BETA merge
authorSangtai Kim <sangtai.kim@samsung.com>
Fri, 3 Feb 2012 07:25:55 +0000 (16:25 +0900)
committerSangtai Kim <sangtai.kim@samsung.com>
Fri, 3 Feb 2012 07:25:55 +0000 (16:25 +0900)
529 files changed:
CMakeLists.txt
debian/changelog
debian/control
src/platform/API/Account/AccountFactory.cpp [new file with mode: 0755]
src/platform/API/Account/AccountFactory.h [new file with mode: 0755]
src/platform/API/Account/AccountFilter.cpp [new file with mode: 0755]
src/platform/API/Account/AccountFilter.h [new file with mode: 0755]
src/platform/API/Account/AccountServiceProviderProperty.cpp [new file with mode: 0755]
src/platform/API/Account/AccountServiceProviderProperty.h [new file with mode: 0755]
src/platform/API/Account/AccountServiceTypeProperty.cpp [new file with mode: 0755]
src/platform/API/Account/AccountServiceTypeProperty.h [new file with mode: 0755]
src/platform/API/Account/AccountServices.cpp [new file with mode: 0755]
src/platform/API/Account/AccountServices.h [new file with mode: 0755]
src/platform/API/Account/EventAccount.cpp [new file with mode: 0755]
src/platform/API/Account/EventAccount.h [new file with mode: 0755]
src/platform/API/Account/IAccountManager.cpp [new file with mode: 0755]
src/platform/API/Account/IAccountManager.h [new file with mode: 0755]
src/platform/API/Account/IAccountService.cpp [new file with mode: 0755]
src/platform/API/Account/IAccountService.h [new file with mode: 0755]
src/platform/API/Account/IEventAddAccount.h [new file with mode: 0755]
src/platform/API/Account/IEventCreateAccount.h [new file with mode: 0755]
src/platform/API/Account/IEventDeleteAccount.h [new file with mode: 0755]
src/platform/API/Account/IEventFindAccounts.h [new file with mode: 0755]
src/platform/API/Account/IEventFindProviders.h [new file with mode: 0644]
src/platform/API/Account/IEventFindServiceTypes.h [new file with mode: 0755]
src/platform/API/Account/IEventGetAccountById.h [new file with mode: 0755]
src/platform/API/Account/IEventGetAccountServices.h [new file with mode: 0755]
src/platform/API/Account/IEventGetProviderById.h [new file with mode: 0755]
src/platform/API/Account/IEventGetServiceTypeById.h [new file with mode: 0755]
src/platform/API/Account/IEventUpdateAccount.h [new file with mode: 0755]
src/platform/API/Account/OnAddEventsChanged.h [new file with mode: 0755]
src/platform/API/Account/OnDeleteEventsChanged.h [new file with mode: 0755]
src/platform/API/Account/OnUpdateEventsChanged.h [new file with mode: 0755]
src/platform/API/Account/config.cmake [new file with mode: 0755]
src/platform/API/Account/log.h [new file with mode: 0755]
src/platform/API/Application/ApplicationEvent.h
src/platform/API/Application/ApplicationInformation.h
src/platform/API/Application/ApplicationServiceExtraData.h
src/platform/API/Application/ApplicationServiceReply.h
src/platform/API/Application/ApplicationServiceRequest.h
src/platform/API/Bluetooth/BluetoothFactory.cpp [changed mode: 0755->0644]
src/platform/API/Bluetooth/BluetoothFactory.h [changed mode: 0755->0644]
src/platform/API/Bluetooth/EventBTConnectToServiceByUUID.h [changed mode: 0755->0644]
src/platform/API/Bluetooth/EventBTCreateDestroyBonding.h [changed mode: 0755->0644]
src/platform/API/Bluetooth/EventBTGetAdapter.h [changed mode: 0755->0644]
src/platform/API/Bluetooth/EventBTGetDevice.cpp [changed mode: 0755->0644]
src/platform/API/Bluetooth/EventBTGetDevice.h [changed mode: 0755->0644]
src/platform/API/Bluetooth/EventBTGetKnownDevices.cpp [changed mode: 0755->0644]
src/platform/API/Bluetooth/EventBTGetKnownDevices.h [changed mode: 0755->0644]
src/platform/API/Bluetooth/EventBTOnDiscoveryDevices.cpp [changed mode: 0755->0644]
src/platform/API/Bluetooth/EventBTOnDiscoveryDevices.h [changed mode: 0755->0644]
src/platform/API/Bluetooth/EventBTRegisterRFCOMM.h [changed mode: 0755->0644]
src/platform/API/Bluetooth/EventBTServiceOnConnect.cpp [new file with mode: 0644]
src/platform/API/Bluetooth/EventBTServiceOnConnect.h [new file with mode: 0644]
src/platform/API/Bluetooth/EventBTSetPowered.h [changed mode: 0755->0644]
src/platform/API/Bluetooth/EventBTSetVisible.h [changed mode: 0755->0644]
src/platform/API/Bluetooth/EventBTUnregisterRFCOMM.h
src/platform/API/Bluetooth/IBluetoothAdapterManager.cpp [moved from src/platform/API/Bluetooth/IBluetoothManager.cpp with 93% similarity, mode: 0644]
src/platform/API/Bluetooth/IBluetoothAdapterManager.h [changed mode: 0755->0644]
src/platform/API/Bluetooth/IBluetoothServiceHandlerManager.cpp [moved from src/platform/API/Bluetooth/EventBTRegisterRFCOMM.cpp with 67% similarity, mode: 0644]
src/platform/API/Bluetooth/IBluetoothServiceHandlerManager.h [new file with mode: 0644]
src/platform/API/Bluetooth/IBluetoothSocketManager.h
src/platform/API/Bluetooth/config.cmake
src/platform/API/Calendar/CalendarEvent.cpp
src/platform/API/Calendar/CalendarEvent.h
src/platform/API/Calendar/CalendarItemGeo.cpp [new file with mode: 0755]
src/platform/API/Calendar/CalendarItemGeo.h [new file with mode: 0755]
src/platform/API/Calendar/EventAlarm.cpp
src/platform/API/Calendar/EventAlarm.h
src/platform/API/Calendar/EventAttendee.cpp
src/platform/API/Calendar/EventFilter.cpp
src/platform/API/Calendar/EventId.cpp
src/platform/API/Calendar/EventRecurrenceRule.cpp
src/platform/API/Calendar/ICalendar.h
src/platform/API/Calendar/config.cmake
src/platform/API/Contact/Contact.h
src/platform/API/Contact/ContactProperties.h
src/platform/API/Contact/IAddressBook.h
src/platform/API/Filesystem/Enums.h [new file with mode: 0755]
src/platform/API/Filesystem/EventCopy.cpp [new file with mode: 0755]
src/platform/API/Filesystem/EventCopy.h [new file with mode: 0755]
src/platform/API/Filesystem/EventCreate.cpp [new file with mode: 0755]
src/platform/API/Filesystem/EventCreate.h [new file with mode: 0755]
src/platform/API/Filesystem/EventFind.cpp [new file with mode: 0755]
src/platform/API/Filesystem/EventFind.h [new file with mode: 0755]
src/platform/API/Filesystem/EventGetStorage.cpp [new file with mode: 0755]
src/platform/API/Filesystem/EventGetStorage.h [new file with mode: 0755]
src/platform/API/Filesystem/EventListNodes.cpp [new file with mode: 0755]
src/platform/API/Filesystem/EventListNodes.h [new file with mode: 0755]
src/platform/API/Filesystem/EventListStorages.cpp [new file with mode: 0755]
src/platform/API/Filesystem/EventListStorages.h [new file with mode: 0755]
src/platform/API/Filesystem/EventMove.cpp [new file with mode: 0755]
src/platform/API/Filesystem/EventMove.h [new file with mode: 0755]
src/platform/API/Filesystem/EventOpen.cpp [new file with mode: 0755]
src/platform/API/Filesystem/EventOpen.h [new file with mode: 0755]
src/platform/API/Filesystem/EventReadText.cpp [new file with mode: 0755]
src/platform/API/Filesystem/EventReadText.h [new file with mode: 0755]
src/platform/API/Filesystem/EventRemove.cpp [new file with mode: 0755]
src/platform/API/Filesystem/EventRemove.h [new file with mode: 0755]
src/platform/API/Filesystem/EventResolve.cpp [new file with mode: 0755]
src/platform/API/Filesystem/EventResolve.h [new file with mode: 0755]
src/platform/API/Filesystem/EventStorageStateChanged.h [new file with mode: 0755]
src/platform/API/Filesystem/EventStoragestateChanged.cpp [new file with mode: 0755]
src/platform/API/Filesystem/IManager.cpp [new file with mode: 0755]
src/platform/API/Filesystem/IManager.h [new file with mode: 0755]
src/platform/API/Filesystem/INode.cpp [new file with mode: 0755]
src/platform/API/Filesystem/INode.h [new file with mode: 0755]
src/platform/API/Filesystem/INodeTypes.h [new file with mode: 0755]
src/platform/API/Filesystem/IPath.cpp [new file with mode: 0755]
src/platform/API/Filesystem/IPath.h [new file with mode: 0755]
src/platform/API/Filesystem/IStream.cpp [new file with mode: 0755]
src/platform/API/Filesystem/IStream.h [new file with mode: 0755]
src/platform/API/Filesystem/NodeFilter.cpp [new file with mode: 0755]
src/platform/API/Filesystem/NodeFilter.h [new file with mode: 0755]
src/platform/API/Filesystem/PathUtils.cpp [new file with mode: 0755]
src/platform/API/Filesystem/PathUtils.h [new file with mode: 0755]
src/platform/API/Filesystem/StorageProperties.cpp [new file with mode: 0755]
src/platform/API/Filesystem/StorageProperties.h [new file with mode: 0755]
src/platform/API/Filesystem/config.cmake [new file with mode: 0755]
src/platform/API/Filter/AnyType.cpp [changed mode: 0755->0644]
src/platform/API/Filter/AnyType.h [changed mode: 0755->0644]
src/platform/API/Filter/AttributeFilter.cpp [changed mode: 0755->0644]
src/platform/API/Filter/AttributeFilter.h [changed mode: 0755->0644]
src/platform/API/Filter/AttributeRangeFilter.cpp [changed mode: 0755->0644]
src/platform/API/Filter/AttributeRangeFilter.h [changed mode: 0755->0644]
src/platform/API/Filter/CompositeFilter.cpp [changed mode: 0755->0644]
src/platform/API/Filter/CompositeFilter.h [changed mode: 0755->0644]
src/platform/API/Filter/FilterFactory.cpp [changed mode: 0755->0644]
src/platform/API/Filter/FilterFactory.h [changed mode: 0755->0644]
src/platform/API/Filter/FilterTypes.h [changed mode: 0755->0644]
src/platform/API/Filter/FilterValidator.cpp [changed mode: 0755->0644]
src/platform/API/Filter/FilterValidator.h [changed mode: 0755->0644]
src/platform/API/Filter/IFilter.cpp [changed mode: 0755->0644]
src/platform/API/Filter/IFilter.h [changed mode: 0755->0644]
src/platform/API/Filter/IFilterVisitor.cpp [changed mode: 0755->0644]
src/platform/API/Filter/IFilterVisitor.h [changed mode: 0755->0644]
src/platform/API/Filter/SortMode.cpp [changed mode: 0755->0644]
src/platform/API/Filter/SortMode.h [changed mode: 0755->0644]
src/platform/API/Messaging/AttachmentFactory.cpp
src/platform/API/Messaging/Attachments.cpp
src/platform/API/Messaging/CallbackNumber.cpp
src/platform/API/Messaging/ConversationFilterValidator.cpp
src/platform/API/Messaging/EmailAccountInfo.cpp
src/platform/API/Messaging/EventAddDraftMessage.h [new file with mode: 0644]
src/platform/API/Messaging/EventDeleteConversations.h
src/platform/API/Messaging/EventGetConversationId.h
src/platform/API/Messaging/EventGetMessagingService.h
src/platform/API/Messaging/EventMessagingService.h
src/platform/API/Messaging/EventQueryConversations.h
src/platform/API/Messaging/EventQueryFolders.h
src/platform/API/Messaging/FolderFilterValidator.cpp
src/platform/API/Messaging/FolderFilterValidatorFactory.cpp
src/platform/API/Messaging/IAttachment.cpp
src/platform/API/Messaging/IBinarySms.cpp
src/platform/API/Messaging/IConversation.h
src/platform/API/Messaging/IEmail.cpp
src/platform/API/Messaging/IEmail.h
src/platform/API/Messaging/IMessage.cpp
src/platform/API/Messaging/IMessage.h
src/platform/API/Messaging/IMessageFolder.h
src/platform/API/Messaging/IMessagingService.h
src/platform/API/Messaging/IMessagingServiceManager.h
src/platform/API/Messaging/IMms.cpp
src/platform/API/Messaging/IMms.h
src/platform/API/Messaging/ISms.cpp
src/platform/API/Messaging/MessageFactory.cpp
src/platform/API/Messaging/MessageFilterValidator.cpp
src/platform/API/Messaging/Recipient.cpp
src/platform/API/Messaging/ReqReceiverMessage.cpp
src/platform/API/Messaging/ReqReceiverMessage.h
src/platform/API/Messaging/SourceAddress.cpp
src/platform/API/Messaging/StorageChangesConversationFilterValidator.cpp
src/platform/API/Messaging/StorageChangesConversationFilterValidatorFactory.cpp
src/platform/API/Messaging/StorageChangesConversationGenerator.cpp
src/platform/API/Messaging/StorageChangesFolderFilterValidator.cpp
src/platform/API/Messaging/StorageChangesFolderFilterValidatorFactory.cpp
src/platform/API/Messaging/StorageChangesFolderGenerator.cpp
src/platform/API/Messaging/StorageChangesMessageFilterValidator.cpp
src/platform/API/Messaging/StorageChangesMessageGenerator.cpp
src/platform/API/Messaging/ToRecipient.cpp
src/platform/API/Messaging/VirtualMessage.cpp
src/platform/API/Messaging/VirtualMessage.h
src/platform/API/Messaging/config.cmake
src/platform/API/Systeminfo/BaseProperties.h [changed mode: 0755->0644]
src/platform/API/Systeminfo/EventWatchSysteminfo.cpp [changed mode: 0755->0644]
src/platform/API/Systeminfo/EventWatchSysteminfo.h [changed mode: 0755->0644]
src/platform/API/Systeminfo/ISysteminfo.h [changed mode: 0755->0644]
src/platform/API/Systeminfo/SysteminfoListener.h
src/platform/API/TimeUtil/DurationProperties.h
src/platform/API/TimeUtil/TimeUtilFactory.cpp
src/platform/API/TimeUtil/TimeUtilFactory.h
src/platform/API/config.cmake
src/platform/Tizen/Account/AccountManager.cpp [new file with mode: 0755]
src/platform/Tizen/Account/AccountManager.h [new file with mode: 0755]
src/platform/Tizen/Account/AccountService.cpp [new file with mode: 0755]
src/platform/Tizen/Account/AccountService.h [new file with mode: 0755]
src/platform/Tizen/Account/AccountWrapper.cpp [new file with mode: 0755]
src/platform/Tizen/Account/AccountWrapper.h [new file with mode: 0755]
src/platform/Tizen/Account/config.cmake [new file with mode: 0755]
src/platform/Tizen/Bluetooth/BluetoothAdapterManager.cpp [changed mode: 0755->0644]
src/platform/Tizen/Bluetooth/BluetoothAdapterManager.h [changed mode: 0755->0644]
src/platform/Tizen/Bluetooth/BluetoothDeviceManager.cpp [changed mode: 0755->0644]
src/platform/Tizen/Bluetooth/BluetoothDeviceManager.h
src/platform/Tizen/Bluetooth/BluetoothManager.cpp [deleted file]
src/platform/Tizen/Bluetooth/BluetoothServiceHandlerManager.cpp [new file with mode: 0644]
src/platform/Tizen/Bluetooth/BluetoothServiceHandlerManager.h [new file with mode: 0644]
src/platform/Tizen/Bluetooth/BluetoothSocketManager.cpp [changed mode: 0755->0644]
src/platform/Tizen/Bluetooth/BluetoothSocketManager.h
src/platform/Tizen/Bluetooth/config.cmake [changed mode: 0755->0644]
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 [new file with mode: 0755]
src/platform/Tizen/Calendar/CalendarFilterValidator.h [new file with mode: 0755]
src/platform/Tizen/Calendar/CalendarManager.cpp
src/platform/Tizen/Calendar/CalendarManager.h
src/platform/Tizen/Calendar/CalendarQuery.c
src/platform/Tizen/Calendar/CalendarQuery.h
src/platform/Tizen/Calendar/EventWrapper.cpp
src/platform/Tizen/Calendar/EventWrapper.h
src/platform/Tizen/Calendar/config.cmake
src/platform/Tizen/Call/CallHistory.cpp
src/platform/Tizen/Call/CallHistoryFilter.cpp
src/platform/Tizen/Contact/AddressBook.cpp
src/platform/Tizen/Contact/ContactManager.cpp
src/platform/Tizen/Contact/ContactWrapper.cpp
src/platform/Tizen/Contact/query-svc/query-svc.c
src/platform/Tizen/Contact/query-svc/query-type.h
src/platform/Tizen/Contact/query-svc/query-utility.c
src/platform/Tizen/Contact/query-svc/query-utility.h
src/platform/Tizen/DBus/Connection.cpp
src/platform/Tizen/DBus/Connection.h
src/platform/Tizen/Filesystem/Command.cpp [new file with mode: 0755]
src/platform/Tizen/Filesystem/Command.h [new file with mode: 0755]
src/platform/Tizen/Filesystem/CopyCommand.cpp [new file with mode: 0755]
src/platform/Tizen/Filesystem/CopyCommand.h [new file with mode: 0755]
src/platform/Tizen/Filesystem/Manager.cpp [new file with mode: 0755]
src/platform/Tizen/Filesystem/Manager.h [new file with mode: 0755]
src/platform/Tizen/Filesystem/MoveCommand.cpp [new file with mode: 0755]
src/platform/Tizen/Filesystem/MoveCommand.h [new file with mode: 0755]
src/platform/Tizen/Filesystem/Node.cpp [new file with mode: 0755]
src/platform/Tizen/Filesystem/Node.h [new file with mode: 0755]
src/platform/Tizen/Filesystem/NodeFilterMatcher.cpp [new file with mode: 0755]
src/platform/Tizen/Filesystem/NodeFilterMatcher.h [new file with mode: 0755]
src/platform/Tizen/Filesystem/Path.cpp [new file with mode: 0755]
src/platform/Tizen/Filesystem/Path.h [new file with mode: 0755]
src/platform/Tizen/Filesystem/RemoveCommand.cpp [new file with mode: 0755]
src/platform/Tizen/Filesystem/RemoveCommand.h [new file with mode: 0755]
src/platform/Tizen/Filesystem/Stream.cpp [new file with mode: 0755]
src/platform/Tizen/Filesystem/Stream.h [new file with mode: 0755]
src/platform/Tizen/Filesystem/System.cpp [new file with mode: 0755]
src/platform/Tizen/Filesystem/System.h [new file with mode: 0755]
src/platform/Tizen/Filesystem/Utils.cpp [new file with mode: 0755]
src/platform/Tizen/Filesystem/Utils.h [new file with mode: 0755]
src/platform/Tizen/Filesystem/config.cmake [new file with mode: 0755]
src/platform/Tizen/Messaging/Attachment.cpp
src/platform/Tizen/Messaging/BinarySms.cpp
src/platform/Tizen/Messaging/BinarySms.h
src/platform/Tizen/Messaging/CallbackMgr.cpp
src/platform/Tizen/Messaging/Conversation.cpp
src/platform/Tizen/Messaging/Conversation.h
src/platform/Tizen/Messaging/ConversationQueryGenerator.cpp
src/platform/Tizen/Messaging/Email.cpp
src/platform/Tizen/Messaging/Email.h
src/platform/Tizen/Messaging/EmailConverter.cpp
src/platform/Tizen/Messaging/FolderQueryGenerator.cpp
src/platform/Tizen/Messaging/MailSender.cpp
src/platform/Tizen/Messaging/MailSender.h
src/platform/Tizen/Messaging/MailSync.cpp
src/platform/Tizen/Messaging/MailSync.h
src/platform/Tizen/Messaging/MessageFolder.cpp
src/platform/Tizen/Messaging/MessageFolder.h
src/platform/Tizen/Messaging/MessageQueryGenerator.cpp
src/platform/Tizen/Messaging/Messaging.cpp
src/platform/Tizen/Messaging/Messaging.h
src/platform/Tizen/Messaging/MessagingServiceManager.cpp
src/platform/Tizen/Messaging/Mms.cpp
src/platform/Tizen/Messaging/Mms.h
src/platform/Tizen/Messaging/MsgServiceHandleMgr.h
src/platform/Tizen/Messaging/ScopedMail.h
src/platform/Tizen/Messaging/ScopedMailbox.h
src/platform/Tizen/Messaging/Sms.cpp
src/platform/Tizen/Messaging/Sms.h
src/platform/Tizen/Messaging/SyncNetworkStatus.cpp
src/platform/Tizen/Messaging/config.cmake
src/platform/Tizen/Messaging/messageDB/MessageStorageReader.cpp
src/platform/Tizen/Messaging/messageDB/MsgSqliteWrapper.cpp
src/platform/Tizen/NFC/NFCManager.cpp
src/platform/Tizen/NFC/NFCTag.cpp
src/platform/Tizen/NFC/NFCTagMifareClassic.cpp
src/platform/Tizen/NFC/NFCTagMifareUltra.cpp
src/platform/Tizen/NFC/NFCTarget.cpp
src/platform/Tizen/NFC/NFCUtil.cpp
src/platform/Tizen/NFC/NdefMessage.cpp
src/platform/Tizen/NFC/NdefRecord.cpp
src/platform/Tizen/Systeminfo/Systeminfo.cpp [changed mode: 0755->0644]
src/platform/Tizen/Systeminfo/Systeminfo.h [changed mode: 0755->0644]
src/platform/Tizen/TimeUtil/TZDate.cpp
src/platform/Tizen/TimeUtil/TZDate.h
src/platform/Tizen/TimeUtil/TimeUtil.cpp
src/platform/Tizen/TimeUtil/TimeUtilTools.cpp
src/platform/Tizen/config.cmake
src/standards/Tizen/Account/AccountConverter.cpp [new file with mode: 0755]
src/standards/Tizen/Account/AccountConverter.h [new file with mode: 0755]
src/standards/Tizen/Account/AccountManagerController.cpp [new file with mode: 0755]
src/standards/Tizen/Account/CMakeLists.txt [new file with mode: 0755]
src/standards/Tizen/Account/JSAccount.cpp [new file with mode: 0755]
src/standards/Tizen/Account/JSAccount.h [new file with mode: 0755]
src/standards/Tizen/Account/JSAccountManager.cpp [new file with mode: 0755]
src/standards/Tizen/Account/JSAccountManager.h [new file with mode: 0755]
src/standards/Tizen/Account/JSAccountService.cpp [new file with mode: 0755]
src/standards/Tizen/Account/JSAccountService.h [new file with mode: 0755]
src/standards/Tizen/Account/JSAccountServiceProvider.cpp [new file with mode: 0755]
src/standards/Tizen/Account/JSAccountServiceProvider.h [new file with mode: 0755]
src/standards/Tizen/Account/JSAccountServiceType.cpp [new file with mode: 0755]
src/standards/Tizen/Account/JSAccountServiceType.h [new file with mode: 0755]
src/standards/Tizen/Account/JSAccountServices.cpp [new file with mode: 0755]
src/standards/Tizen/Account/JSAccountServices.h [new file with mode: 0755]
src/standards/Tizen/Account/JSFeatureArray.cpp [moved from src/standards/Tizen/Calendar/JSCategoryArray.cpp with 66% similarity]
src/standards/Tizen/Account/JSFeatureArray.h [moved from src/standards/Tizen/Calendar/JSCategoryArray.h with 90% similarity]
src/standards/Tizen/Account/ResponseDispatcher.cpp [new file with mode: 0755]
src/standards/Tizen/Account/ResponseDispatcher.h [new file with mode: 0755]
src/standards/Tizen/Account/config.xml [new file with mode: 0755]
src/standards/Tizen/Account/plugin_config.cpp [new file with mode: 0755]
src/standards/Tizen/Account/plugin_config.h [new file with mode: 0755]
src/standards/Tizen/Account/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/JSApplication.cpp
src/standards/Tizen/Application/JSApplicationEvent.cpp
src/standards/Tizen/Application/JSApplicationInformation.cpp
src/standards/Tizen/Application/JSApplicationInformationArray.cpp
src/standards/Tizen/Application/JSApplicationServiceExtraData.cpp
src/standards/Tizen/Application/JSApplicationServiceExtraDataArray.cpp
src/standards/Tizen/Application/JSApplicationServiceReply.cpp
src/standards/Tizen/Application/JSApplicationServiceRequest.cpp
src/standards/Tizen/Application/plugin_initializer.cpp
src/standards/Tizen/Bluetooth/BluetoothAdapterListener.cpp [changed mode: 0755->0644]
src/standards/Tizen/Bluetooth/BluetoothAdapterListener.h [changed mode: 0755->0644]
src/standards/Tizen/Bluetooth/BluetoothConverter.cpp
src/standards/Tizen/Bluetooth/BluetoothConverter.h [changed mode: 0755->0644]
src/standards/Tizen/Bluetooth/BluetoothDeviceManagerListener.cpp [changed mode: 0755->0644]
src/standards/Tizen/Bluetooth/BluetoothMultiCallback.cpp
src/standards/Tizen/Bluetooth/BluetoothMultiCallback.h
src/standards/Tizen/Bluetooth/BluetoothSocketListener.cpp
src/standards/Tizen/Bluetooth/CMakeLists.txt [changed mode: 0755->0644]
src/standards/Tizen/Bluetooth/JSBluetoothAdapter.cpp
src/standards/Tizen/Bluetooth/JSBluetoothAdapter.h [changed mode: 0755->0644]
src/standards/Tizen/Bluetooth/JSBluetoothClassDeviceMinor.h
src/standards/Tizen/Bluetooth/JSBluetoothDevice.cpp [changed mode: 0755->0644]
src/standards/Tizen/Bluetooth/JSBluetoothManager.cpp [changed mode: 0755->0644]
src/standards/Tizen/Bluetooth/JSBluetoothServiceHandler.cpp [new file with mode: 0644]
src/standards/Tizen/Bluetooth/JSBluetoothServiceHandler.h [new file with mode: 0644]
src/standards/Tizen/Bluetooth/JSBluetoothSocket.cpp [changed mode: 0755->0644]
src/standards/Tizen/Bluetooth/JSBluetoothSocket.h
src/standards/Tizen/Bluetooth/plugin_config.cpp [changed mode: 0755->0644]
src/standards/Tizen/Bluetooth/plugin_config.h [changed mode: 0755->0644]
src/standards/Tizen/Bluetooth/plugin_initializer.cpp
src/standards/Tizen/CMakeLists.txt
src/standards/Tizen/Calendar/CMakeLists.txt
src/standards/Tizen/Calendar/CalendarConverter.cpp
src/standards/Tizen/Calendar/CalendarConverter.h
src/standards/Tizen/Calendar/CalendarResponseDispatcher.cpp
src/standards/Tizen/Calendar/JSAttendee.cpp
src/standards/Tizen/Calendar/JSAttendee.h
src/standards/Tizen/Calendar/JSCalendar.cpp
src/standards/Tizen/Calendar/JSCalendar.h
src/standards/Tizen/Calendar/JSCalendarEvent.cpp
src/standards/Tizen/Calendar/JSCalendarEvent.h
src/standards/Tizen/Calendar/JSCalendarItem.cpp
src/standards/Tizen/Calendar/JSCalendarItem.h
src/standards/Tizen/Calendar/JSCalendarItemGeo.cpp [new file with mode: 0755]
src/standards/Tizen/Calendar/JSCalendarItemGeo.h [new file with mode: 0755]
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/JSCalendarTask.cpp
src/standards/Tizen/Calendar/JSCalendarTask.h
src/standards/Tizen/Calendar/JSEventAlarm.cpp
src/standards/Tizen/Calendar/JSEventAlarm.h
src/standards/Tizen/Calendar/JSEventId.cpp
src/standards/Tizen/Calendar/JSEventId.h
src/standards/Tizen/Calendar/JSRecurrenceRule.cpp
src/standards/Tizen/Calendar/JSRecurrenceRule.h
src/standards/Tizen/Calendar/plugin_initializer.cpp
src/standards/Tizen/Call/Converter.cpp
src/standards/Tizen/Call/JSCallApi.cpp
src/standards/Tizen/Call/JSCallHistory.cpp
src/standards/Tizen/Call/JSCallHistoryEntry.cpp
src/standards/Tizen/Call/ResponseDispatcher.cpp
src/standards/Tizen/Call/plugin_initializer.cpp
src/standards/Tizen/Common/JSTizenException.cpp
src/standards/Tizen/Common/JSTizenExceptionFactory.cpp
src/standards/Tizen/Contact/AddressBookController.h
src/standards/Tizen/Contact/ContactConverter.cpp
src/standards/Tizen/Contact/ContactManagerController.h
src/standards/Tizen/Contact/JSAddressBook.cpp
src/standards/Tizen/Contact/JSAddressBookArray.cpp
src/standards/Tizen/Contact/JSAddressBookChangeCallbackManager.cpp
src/standards/Tizen/Contact/JSAttributesOfInterestArray.cpp
src/standards/Tizen/Contact/JSContact.cpp
src/standards/Tizen/Contact/JSContactAddressArray.cpp
src/standards/Tizen/Contact/JSContactAddressTypeArray.cpp
src/standards/Tizen/Contact/JSContactAnniversaryArray.cpp
src/standards/Tizen/Contact/JSContactArray.cpp
src/standards/Tizen/Contact/JSContactEmailAddressArray.cpp
src/standards/Tizen/Contact/JSContactEmailAddressTypeArray.cpp
src/standards/Tizen/Contact/JSContactManager.cpp
src/standards/Tizen/Contact/JSContactName.cpp
src/standards/Tizen/Contact/JSContactOrganizationArray.cpp
src/standards/Tizen/Contact/JSContactPhoneNumber.cpp
src/standards/Tizen/Contact/JSContactPhoneNumberArray.cpp
src/standards/Tizen/Contact/JSContactPhoneNumberTypeArray.cpp
src/standards/Tizen/Contact/JSContactProperties.cpp
src/standards/Tizen/Contact/JSContactWebSiteArray.cpp
src/standards/Tizen/Contact/JSStringArray.cpp
src/standards/Tizen/Contact/plugin_initializer.cpp
src/standards/Tizen/Filesystem/CMakeLists.txt [new file with mode: 0755]
src/standards/Tizen/Filesystem/Converter.cpp [new file with mode: 0755]
src/standards/Tizen/Filesystem/Converter.h [new file with mode: 0755]
src/standards/Tizen/Filesystem/Encodings.cpp [new file with mode: 0755]
src/standards/Tizen/Filesystem/Encodings.h [new file with mode: 0755]
src/standards/Tizen/Filesystem/EventGetNodeData.cpp [new file with mode: 0755]
src/standards/Tizen/Filesystem/EventGetNodeData.h [new file with mode: 0755]
src/standards/Tizen/Filesystem/FilesystemUtils.cpp [new file with mode: 0755]
src/standards/Tizen/Filesystem/FilesystemUtils.h [new file with mode: 0755]
src/standards/Tizen/Filesystem/JSFile.cpp [new file with mode: 0755]
src/standards/Tizen/Filesystem/JSFile.h [new file with mode: 0755]
src/standards/Tizen/Filesystem/JSFilestream.cpp [new file with mode: 0755]
src/standards/Tizen/Filesystem/JSFilestream.h [new file with mode: 0755]
src/standards/Tizen/Filesystem/JSFilesystemManager.cpp [new file with mode: 0755]
src/standards/Tizen/Filesystem/JSFilesystemManager.h [new file with mode: 0755]
src/standards/Tizen/Filesystem/JSStorage.cpp [new file with mode: 0755]
src/standards/Tizen/Filesystem/JSStorage.h [new file with mode: 0755]
src/standards/Tizen/Filesystem/ResponseDispatcher.cpp [new file with mode: 0755]
src/standards/Tizen/Filesystem/ResponseDispatcher.h [new file with mode: 0755]
src/standards/Tizen/Filesystem/StorageStaticController.cpp [new file with mode: 0755]
src/standards/Tizen/Filesystem/StorageStaticController.h [new file with mode: 0755]
src/standards/Tizen/Filesystem/config.xml [new file with mode: 0755]
src/standards/Tizen/Filesystem/plugin_config.cpp [new file with mode: 0755]
src/standards/Tizen/Filesystem/plugin_config.h [new file with mode: 0755]
src/standards/Tizen/Filesystem/plugin_initializer.cpp [moved from src/standards/Tizen/Log/plugin_initializer.cpp with 50% similarity, mode: 0755]
src/standards/Tizen/Geocoder/GeocoderController.h
src/standards/Tizen/Geocoder/JSAddress.cpp
src/standards/Tizen/Geocoder/JSCoordinates.cpp
src/standards/Tizen/Geocoder/JSGeocoder.cpp
src/standards/Tizen/Geocoder/plugin_initializer.cpp
src/standards/Tizen/Log/CMakeLists.txt [deleted file]
src/standards/Tizen/Log/JSTizenLog.cpp [deleted file]
src/standards/Tizen/Log/JSTizenLog.h [deleted file]
src/standards/Tizen/Log/config.xml [deleted file]
src/standards/Tizen/Messaging/CMakeLists.txt
src/standards/Tizen/Messaging/ConverterMessage.cpp
src/standards/Tizen/Messaging/ConverterMessage.h
src/standards/Tizen/Messaging/JSConversation.cpp
src/standards/Tizen/Messaging/JSConversation.h
src/standards/Tizen/Messaging/JSMessage.cpp
src/standards/Tizen/Messaging/JSMessage.h
src/standards/Tizen/Messaging/JSMessageAttachment.cpp
src/standards/Tizen/Messaging/JSMessageBody.cpp
src/standards/Tizen/Messaging/JSMessageFolder.cpp
src/standards/Tizen/Messaging/JSMessageFolder.h
src/standards/Tizen/Messaging/JSMessagingListener.cpp
src/standards/Tizen/Messaging/JSMessagingListener.h
src/standards/Tizen/Messaging/JSMessagingService.cpp
src/standards/Tizen/Messaging/JSMessagingService.h
src/standards/Tizen/Messaging/JSMessagingServiceManager.cpp
src/standards/Tizen/Messaging/JSMessagingStorage.cpp
src/standards/Tizen/Messaging/JSMessagingStorage.h
src/standards/Tizen/Messaging/JSRecipientArray.cpp
src/standards/Tizen/Messaging/MessagingController.h
src/standards/Tizen/Messaging/config.xml
src/standards/Tizen/Messaging/plugin_config.cpp [changed mode: 0644->0755]
src/standards/Tizen/Messaging/plugin_config.h [changed mode: 0644->0755]
src/standards/Tizen/Messaging/plugin_initializer.cpp
src/standards/Tizen/NFC/JSNFCManager.cpp
src/standards/Tizen/NFC/JSNFCTag.cpp
src/standards/Tizen/NFC/JSNFCTagMifareClassic.cpp
src/standards/Tizen/NFC/JSNFCTagMifareUltra.cpp
src/standards/Tizen/NFC/JSNFCTarget.cpp
src/standards/Tizen/NFC/JSNdefMessage.cpp
src/standards/Tizen/NFC/JSNdefRecord.cpp
src/standards/Tizen/NFC/NFCConverter.cpp
src/standards/Tizen/NFC/NFCStaticController.cpp
src/standards/Tizen/NFC/ResponseDispatcher.cpp
src/standards/Tizen/NFC/plugin_initializer.cpp
src/standards/Tizen/Sensors/CMakeLists.txt
src/standards/Tizen/Sensors/JSSensorConnection.cpp
src/standards/Tizen/Sensors/JSSensorData.cpp [deleted file]
src/standards/Tizen/Sensors/JSSensorData.h [deleted file]
src/standards/Tizen/Sensors/JSSensorDataEvent.cpp
src/standards/Tizen/Sensors/JSSensorDataEvent.h
src/standards/Tizen/Sensors/JSSensorError.h [changed mode: 0755->0644]
src/standards/Tizen/Sensors/plugin_initializer.cpp
src/standards/Tizen/Systeminfo/JSCellularNetworkInfo.cpp
src/standards/Tizen/Systeminfo/JSCpuInfo.cpp
src/standards/Tizen/Systeminfo/JSDeviceInfo.cpp
src/standards/Tizen/Systeminfo/JSDisplayInfo.cpp
src/standards/Tizen/Systeminfo/JSPowerInfo.cpp
src/standards/Tizen/Systeminfo/JSStorageInfo.cpp
src/standards/Tizen/Systeminfo/JSSysteminfo.cpp [changed mode: 0755->0644]
src/standards/Tizen/Systeminfo/JSSysteminfo.h
src/standards/Tizen/Systeminfo/JSWifiNetworkInfo.cpp
src/standards/Tizen/Systeminfo/config.xml
src/standards/Tizen/Systeminfo/plugin_config.cpp
src/standards/Tizen/Systeminfo/plugin_config.h
src/standards/Tizen/Systeminfo/plugin_initializer.cpp
src/standards/Tizen/TimeUtil/CMakeLists.txt
src/standards/Tizen/TimeUtil/JSTZDate.cpp
src/standards/Tizen/TimeUtil/JSTZDate.h
src/standards/Tizen/TimeUtil/JSTimeDuration.cpp [new file with mode: 0755]
src/standards/Tizen/TimeUtil/JSTimeDuration.h [new file with mode: 0755]
src/standards/Tizen/TimeUtil/JSTimeUtil.cpp
src/standards/Tizen/TimeUtil/JSTimeUtil.h
src/standards/Tizen/TimeUtil/TimeUtilConverter.cpp
src/standards/Tizen/TimeUtil/TimeUtilConverter.h
src/standards/Tizen/TimeUtil/plugin_initializer.cpp
src/standards/Tizen/Tizen/CMakeLists.txt
src/standards/Tizen/Tizen/FilterConverter.cpp
src/standards/Tizen/Tizen/JSFeature.cpp
src/standards/Tizen/Tizen/JSFeature.h
src/standards/Tizen/Tizen/JSFeatureParam.cpp
src/standards/Tizen/Tizen/JSTizen.cpp
src/standards/Tizen/Tizen/PluginOnDemandPriv.cpp
src/standards/Tizen/Tizen/PluginOnDemandPriv.h
src/standards/Tizen/Tizen/plugin_initializer.cpp

index d511be3..8795534 100755 (executable)
@@ -11,9 +11,10 @@ include(FindPkgConfig)
 
 pkg_search_module(webkit REQUIRED ewebkit>=0.1.0)
 pkg_search_module(dpl REQUIRED dpl-efl>=1.0.0)
-pkg_search_module(wrt-plugin-api REQUIRED wrt-plugin-api>=1.1.1)
-pkg_search_module(wrt-deviceapis-commons REQUIRED wrt-deviceapis-commons)
-pkg_search_module(wrt-deviceapis-commons-javascript REQUIRED wrt-deviceapis-commons-javascript)
+pkg_search_module(dpl-event REQUIRED dpl-event-efl)
+pkg_search_module(wrt-plugin-api REQUIRED wrt-plugin-api>=0.7.0)
+pkg_search_module(wrt-deviceapis-commons REQUIRED wrt-plugins-commons)
+pkg_search_module(wrt-deviceapis-commons-javascript REQUIRED wrt-plugins-commons-javascript)
 
 include_directories(
   ${webkit_INCLUDE_DIRS}
@@ -70,6 +71,7 @@ set(CONFIG_FILE_NAME "config.cmake")
 set(DIR_COMMONS ${CMAKE_SOURCE_DIR}/src/commons)
 set(LIBS_COMMON
     ${dpl_LDFLAGS}
+    ${dpl-event_LDFLAGS}
     ${webkit_LDFLAGS}
     ${wrt-deviceapis-commons_LDFLAGS}
     ${wrt-deviceapis-commons-javascript_LDFLAGS}
@@ -117,7 +119,7 @@ add_subdirectory(src)
 # Cache
 
 set(PLATFORM "${PLATFORM}" CACHE STRING "Target platform" FORCE)
-set(CMAKE_CONFIG_FILE_NAME "${CMAKE_CONFIG_FILE_NAME}" CACHE 
+set(CMAKE_CONFIG_FILE_NAME "${CMAKE_CONFIG_FILE_NAME}" CACHE
     STRING "CMake configuration file name." FORCE)
 
 
index 721c226..b33beac 100644 (file)
@@ -1,3 +1,11 @@
+wrt-plugins-tizen (0.2.0-0) unstable; urgency=low
+
+  * beta merge
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.0-0
+
+ -- Sangtai Kim <sangtai.kim@samsung.com>  Fri, 03 Feb 2012 16:24:08 +0900
+
 wrt-plugins-tizen (0.1.2-10) unstable; urgency=low
 
   * Application, Contact bug fix. UnitTest update
index b0f7db8..6959f64 100755 (executable)
@@ -2,13 +2,13 @@ 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, wrt-commons-dev, 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, 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
 Uploaders: Sangtai Kim <sangtai.kim@samsung.com>
 
 Package: wrt-plugins-tizen
 Architecture: any
 Section: libs
-Depends: ${shlibs:Depends}, ${misc:Depends}, wrt
+Depends: ${shlibs:Depends}, ${misc:Depends}, wrt (>=0.8.5), wrt-commons (>=0.2.6), wrt-plugins-common (>=0.3.7)
 Description: JavaScript plugins for WebRuntime
 
 Package: wrt-plugins-tizen-dbg
diff --git a/src/platform/API/Account/AccountFactory.cpp b/src/platform/API/Account/AccountFactory.cpp
new file mode 100755 (executable)
index 0000000..feaf310
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include "AccountFactory.h"
+#include "IAccountManager.h"
+#include "IAccountService.h"
+#include <Account/AccountManager.h>
+
+using namespace TizenApis::Platform::Account;
+namespace TizenApis {
+namespace Api {
+namespace Account{
+
+IAccountManagerPtr AccountFactory::createAccountManagerObject()
+{
+    LogDebug("entered");
+    IAccountManagerPtr result(new AccountManager());
+    return result;
+}
+
+//TODO: which is right, account or accountservice?
+IAccountServicePtr AccountFactory::createAccountObject()
+{
+    LogDebug("entered");
+    IAccountServicePtr result(new AccountService());
+    return result;
+}
+
+AccountFactory& AccountFactory::getInstance()
+{
+    LogDebug("entered");
+    static AccountFactory theInstance;
+    return theInstance;
+}
+
+
+}
+}
+}
diff --git a/src/platform/API/Account/AccountFactory.h b/src/platform/API/Account/AccountFactory.h
new file mode 100755 (executable)
index 0000000..78665fc
--- /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. 
+ */
+
+
+/**
+ * @file        ICalendarFactory.h
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef _ABSTRACT_LAYER_ACCOUNT_FACTORY_H_
+#define _ABSTRACT_LAYER_ACCOUNT_FACTORY_H_
+
+#include "IAccountManager.h"
+#include "IAccountService.h"
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+
+       
+class AccountFactory : private DPL::Noncopyable
+{
+  private:
+    AccountFactory()
+    {
+    }
+  public:
+    static AccountFactory& getInstance();
+    IAccountManagerPtr    createAccountManagerObject();
+    IAccountServicePtr           createAccountObject();
+};
+}
+}
+}
+
+#endif /* WRTPLUGINSCAMERAFACTORY_H_ */
\ No newline at end of file
diff --git a/src/platform/API/Account/AccountFilter.cpp b/src/platform/API/Account/AccountFilter.cpp
new file mode 100755 (executable)
index 0000000..2198f84
--- /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 "AccountFilter.h"
+#include <dpl/log/log.h>
+
+/**
+ * @file        AccountFilter.cpp
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ */
+
+namespace TizenApis {
+namespace Api {
+namespace Account {
+
+AccountFilter::AccountFilter()
+{
+}
+
+AccountFilter::~AccountFilter()
+{
+}
+
+std::string AccountFilter::getIdFilter() const
+{
+    return *m_id;
+}
+
+void AccountFilter::setIdFilter(const std::string &value)
+{
+    m_id = value;
+}
+
+bool AccountFilter::getIdIsSet() const
+{
+    return !m_id.IsNull();
+}
+}
+}
+}
+
diff --git a/src/platform/API/Account/AccountFilter.h b/src/platform/API/Account/AccountFilter.h
new file mode 100755 (executable)
index 0000000..a3dff2f
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef _ABSTRACT_LAYER_IACCOUNT_FILTER_H_
+#define _ABSTRACT_LAYER_IACCOUNT_FILTER_H_
+
+#include <ctime>
+#include <string>
+#include <vector>
+#include <dpl/shared_ptr.h>
+#include <dpl/optional.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Account {
+
+class AccountFilter
+{
+  public:
+
+    AccountFilter();
+    virtual ~AccountFilter();
+
+    std::string getIdFilter() const;
+    void setIdFilter(const std::string &value);
+
+    bool getIdIsSet() const;
+
+  protected:
+    DPL::Optional<std::string> m_id;
+};
+
+typedef DPL::SharedPtr<AccountFilter> AccountFilterPtr;
+
+}
+}
+}
+
+#endif /* _ABSTRACT_LAYER_IACCOUNT_FILTER_H_ */
+
diff --git a/src/platform/API/Account/AccountServiceProviderProperty.cpp b/src/platform/API/Account/AccountServiceProviderProperty.cpp
new file mode 100755 (executable)
index 0000000..e494dfb
--- /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.
+ */
+
+
+
+/*
+ * AccountServiceProviderProperty.cpp
+ *
+ *  Created on: 2012. 2. 1.
+ *      Author: sangtai
+ */
+
+#include "AccountServiceProviderProperty.h"
+
+namespace TizenApis {
+       namespace Api {
+               namespace Account {
+
+                       AccountServiceProviderProperty::AccountServiceProviderProperty() {
+                       }
+
+                       AccountServiceProviderProperty::~AccountServiceProviderProperty() {
+                       }
+
+                       std::string AccountServiceProviderProperty::getId() const{
+                               return m_id;
+                       }
+                       void AccountServiceProviderProperty::setId(const std::string &value){
+                               m_id = value;
+                       }
+
+                       std::string AccountServiceProviderProperty::getDisplayName() const{
+                               return m_displayName;
+                       }
+                       void AccountServiceProviderProperty::setDisplayName(const std::string &value){
+                               m_displayName = value;
+                       }
+
+                       std::string AccountServiceProviderProperty::getIconPath() const{
+                               return m_icon;
+                       }
+                       void AccountServiceProviderProperty::setIconPath(const std::string &value){
+                               m_icon = value;
+                       }
+
+               } /* namespace Account */
+       } /* namespace Api */
+} /* namespace TizenApis */
diff --git a/src/platform/API/Account/AccountServiceProviderProperty.h b/src/platform/API/Account/AccountServiceProviderProperty.h
new file mode 100755 (executable)
index 0000000..6fda807
--- /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.
+ */
+
+
+
+
+
+/*
+ * AccountServiceProviderProperty.h
+ *
+ *  Created on: 2012. 2. 1.
+ *      Author: sangtai
+ */
+
+#ifndef ACCOUNTSERVICEPROVIDERPROPERTY_H_
+#define ACCOUNTSERVICEPROVIDERPROPERTY_H_
+
+#include <string>
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+       namespace Api {
+               namespace Account {
+
+
+
+                       class AccountServiceProviderProperty {
+                               public:
+                                       AccountServiceProviderProperty();
+                                       virtual ~AccountServiceProviderProperty();
+
+                                       std::string getId() const;
+                                       void setId(const std::string &value);
+
+                                       std::string getDisplayName() const;
+                                       void setDisplayName(const std::string &value);
+
+                                       std::string getIconPath() const;
+                                       void setIconPath(const std::string &value);
+
+
+                               private:
+                                       std::string m_id;
+                                       std::string m_displayName;
+                                       std::string m_icon;
+                       };
+
+                       typedef DPL::SharedPtr<AccountServiceProviderProperty> AccountServiceProviderPropertyPtr;
+               } /* namespace Account */
+       } /* namespace Api */
+} /* namespace TizenApis */
+#endif /* ACCOUNTSERVICEPROVIDERPROPERTY_H_ */
diff --git a/src/platform/API/Account/AccountServiceTypeProperty.cpp b/src/platform/API/Account/AccountServiceTypeProperty.cpp
new file mode 100755 (executable)
index 0000000..b3d1cce
--- /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.
+ */
+
+
+/*
+ * AccountServiceTypeProperty.cpp
+ *
+ *  Created on: 2012. 1. 30.
+ *      Author: sangtai
+ */
+
+#include "AccountServiceTypeProperty.h"
+
+namespace TizenApis {
+       namespace Api {
+               namespace Account {
+
+                       AccountServiceTypeProperty::AccountServiceTypeProperty() {
+                       }
+
+                       AccountServiceTypeProperty::~AccountServiceTypeProperty() {
+                       }
+
+                       std::string AccountServiceTypeProperty::getId() const{
+                               return m_id;
+                       }
+                       void AccountServiceTypeProperty::setId(const std::string &value){
+                               m_id = value;
+                       }
+
+                       std::string AccountServiceTypeProperty::getDisplayName() const{
+                               return m_displayName;
+                       }
+                       void AccountServiceTypeProperty::setDisplayName(const std::string &value){
+                               m_displayName = value;
+                       }
+
+                       std::string AccountServiceTypeProperty::getIconPath() const{
+                               return m_icon;
+                       }
+                       void AccountServiceTypeProperty::setIconPath(const std::string &value){
+                               m_icon = value;
+                       }
+
+                       std::vector<std::string > AccountServiceTypeProperty::getTags() const{
+                               return m_tags;
+                       }
+                       void AccountServiceTypeProperty::setTags(const std::vector<std::string >& value){
+                               m_tags =value;
+                       }
+
+               } // namespace Account
+       }
+}
diff --git a/src/platform/API/Account/AccountServiceTypeProperty.h b/src/platform/API/Account/AccountServiceTypeProperty.h
new file mode 100755 (executable)
index 0000000..3892134
--- /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.
+ */
+
+/*
+ * AccountServiceTypeProperty.h
+ *
+ *  Created on: 2012. 1. 30.
+ *      Author: sangtai
+ */
+
+#ifndef ACCOUNTSERVICETYPEPROPERTY_H_
+#define ACCOUNTSERVICETYPEPROPERTY_H_
+
+#include <string>
+#include <dpl/shared_ptr.h>
+#include <vector>
+
+namespace TizenApis {
+       namespace Api {
+               namespace Account {
+
+                       class AccountServiceTypeProperty;
+
+                       typedef DPL::SharedPtr<AccountServiceTypeProperty> AccountServiceTypePropertyPtr;
+                       typedef std::vector<AccountServiceTypePropertyPtr> AccountServiceTypePropertyArray;
+                       typedef DPL::SharedPtr<AccountServiceTypePropertyArray> AccountServiceTypePropertyArrayPtr;
+
+                       class AccountServiceTypeProperty {
+                               public:
+                                       AccountServiceTypeProperty();
+                                       virtual ~AccountServiceTypeProperty();
+
+                                       std::string getId() const;
+                                       void setId(const std::string &value);
+
+                                       std::string getDisplayName() const;
+                                       void setDisplayName(const std::string &value);
+
+                                       std::string getIconPath() const;
+                                       void setIconPath(const std::string &value);
+
+                                       std::vector<std::string > getTags() const;
+                                       void setTags(const std::vector<std::string >& value);
+
+                               private :
+                                       std::string m_id;
+                                       std::string m_displayName;
+                                       std::string m_icon;
+
+                                       std::vector<std::string > m_tags;
+                       };
+               }               // namespace Account
+       }
+}
+
+#endif /* ACCOUNTSERVICETYPEPROPERTY_H_ */
diff --git a/src/platform/API/Account/AccountServices.cpp b/src/platform/API/Account/AccountServices.cpp
new file mode 100755 (executable)
index 0000000..1a15272
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file        AccountServices.cpp
+ * @author      Jihwa Park (jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ * @brief
+ */
+
+#include "AccountServices.h"
+
+namespace TizenApis {
+       namespace Api {
+               namespace Account {
+
+                       AccountServices::AccountServices() {
+                       }
+
+                       AccountServices::~AccountServices() {
+                       }
+
+                       std::string AccountServices::getId() const{
+                               return m_id;
+                       }
+                       void AccountServices::setId(const std::string &value){
+                                m_id = value;
+                       }
+
+                       std::string AccountServices::getName() const{
+                               return m_name;
+                       }
+                       void AccountServices::setName(const std::string &value){
+                               m_name = value;
+                       }
+
+                       std::string AccountServices::getApplicationId() const{
+                               return m_applicationId;
+                       }
+                       void AccountServices::setApplicationId(const std::string &value){
+                               m_applicationId = value;;
+                       }
+
+                       std::string AccountServices::getDisplayName() const{
+                               return m_displayName;
+                       }
+                       void AccountServices::setDisplayName(const std::string &value){
+                               m_displayName = value;
+                       }
+
+                       std::string AccountServices::getIcon() const{
+                               return m_icon;
+                       }
+                       void AccountServices::setIcon(const std::string &value){
+                               m_icon = value;
+                       }
+
+                       std::string AccountServices::getAccountId() const{
+                               return m_accountId;
+                       }
+                       void AccountServices::setAccountId(const std::string &value){
+                                m_accountId = value;
+                       }
+
+                       std::string AccountServices::getServiceTypeId() const{
+                               return m_serviceTypeId;
+                       }
+                       void AccountServices::setServiceTypeId(const std::string &value){
+                               m_serviceTypeId = value;
+                       }
+
+                       std::string AccountServices::getProviderId() const{
+                               return m_providerId;
+                       }
+                       void AccountServices::setProviderId(const std::string &value){
+                               m_providerId = value;
+                       }
+
+                       std::vector<std::string> AccountServices::getTags() const{
+                               return m_tags;
+                       }
+                       void AccountServices::setTags(const std::vector<std::string> &value){
+                               m_tags = value;
+                       }
+
+                       std::string AccountServices::getSettings() const{
+                               return m_setttings;
+                       }
+                       void AccountServices::setSettings(const std::string &value){
+                               m_setttings = value;
+                       }
+
+               } // Account
+       } // Api
+}
+
diff --git a/src/platform/API/Account/AccountServices.h b/src/platform/API/Account/AccountServices.h
new file mode 100755 (executable)
index 0000000..37465be
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file        AccountServices.h
+ * @author      Jihwa park(jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _API_ACCOUNT_SERVICE_H_
+#define _API_ACCOUNT_SERVICE_H_
+
+#include <vector>
+#include <string>
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Account {
+
+class AccountServices;
+typedef DPL::SharedPtr<AccountServices> AccountServicesPtr;
+typedef std::vector<AccountServicesPtr> AccountServicesArray;
+typedef DPL::SharedPtr<AccountServicesArray> AccountServicesArrayPtr;
+
+class AccountServices
+{
+public:
+       AccountServices();
+       ~AccountServices();
+
+       std::string getId() const;
+       void setId(const std::string &value);
+
+       std::string getName() const;
+       void setName(const std::string &value);
+
+       std::string getApplicationId() const;
+       void setApplicationId(const std::string &value);
+
+       std::string getDisplayName() const;
+       void setDisplayName(const std::string &value);
+
+       std::string getIcon() const;
+       void setIcon(const std::string &value);
+
+       std::string getAccountId() const;
+       void setAccountId(const std::string &value);
+
+       std::string getServiceTypeId() const;
+       void setServiceTypeId(const std::string &value);
+
+       std::string getProviderId() const;
+       void setProviderId(const std::string &value);
+
+       std::vector<std::string> getTags() const;
+       void setTags(const std::vector<std::string> &value);
+
+       std::string getSettings() const;
+       void setSettings(const std::string &value);
+
+private:
+       std::string m_id;
+       std::string m_name;
+       std::string m_applicationId;
+       std::string m_displayName;
+       std::string m_icon;
+       std::string m_accountId;
+       std::string m_serviceTypeId;
+       std::string m_providerId;
+       std::vector<std::string> m_tags;
+       std::string m_setttings;
+};
+
+} // Account
+} // Api
+} // TizenApis
+
+#endif // _API_ACCOUNT_SERVICE_H_
+
diff --git a/src/platform/API/Account/EventAccount.cpp b/src/platform/API/Account/EventAccount.cpp
new file mode 100755 (executable)
index 0000000..005b66c
--- /dev/null
@@ -0,0 +1,245 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "EventAccount.h"
+#include <dpl/log/log.h>
+
+/**
+ * @file        EventAccount.cpp
+ *
+ * @version     0.1
+ */
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+EventAccount::EventAccount():
+             m_accountid(UNDEFINED_ACCOUNT_ID)
+{
+}
+
+EventAccount::~EventAccount()
+{
+}
+
+
+bool EventAccount::validate() const
+{
+//TODO: is this necessary?
+/*
+    if (m_status == INVALID_STATUS) {
+        LogError("Incorrect status value detected");
+        return false;
+    }*/
+    return true;
+}
+
+
+int EventAccount::getID() const
+{
+    LogDebug("entered");
+    return m_accountid;
+}
+
+void EventAccount::setID(const int &value)
+{
+    m_accountid = value;
+}
+
+std::string EventAccount::getAccountId() const
+{
+    LogDebug("entered");
+    return m_AccountId;
+}
+
+void EventAccount::setAccountId(const std::string &value)
+{
+    LogDebug("entered ");
+    m_AccountId = value;
+}
+
+std::string EventAccount::getDisplayName() const
+{
+    LogDebug("entered");
+    return m_displayname;
+}
+
+void EventAccount::setDisplayName(const std::string &value)
+{
+    LogDebug("entered");
+    m_displayname = value;
+}
+
+std::string EventAccount::getIconPath() const
+{
+    LogDebug("entered");
+    return m_iconPath;
+}
+
+void EventAccount::setIconPath(const std::string &value)
+{
+    LogDebug("entered");
+    m_iconPath = value;
+}
+
+std::string EventAccount::getProviderName() const
+{
+    LogDebug("entered");
+    return m_providername;
+}
+
+void EventAccount::setProviderName(const std::string &value)
+{
+    LogDebug("entered");
+    m_providername = value;
+}
+
+bool EventAccount::getEnabled() const
+{
+    LogDebug("entered");
+    return m_enabled;
+}
+
+void EventAccount::setEnabled(bool &value)
+{
+    LogDebug("entered");
+    m_enabled = value;
+}
+
+unsigned long EventAccount::getCredentailId() const
+{
+    LogDebug("entered");
+    return m_credentialId;
+}
+
+void EventAccount::setCredentailId(unsigned long &value)
+{
+    LogDebug("entered");
+    m_credentialId = value;
+}
+
+std::string EventAccount::getSettings() const
+{
+    LogDebug("entered");
+    return m_settings;
+}
+
+void EventAccount::setSettings(const std::string &value)
+{
+    LogDebug("entered");
+    m_settings = value;
+}
+
+std::string EventAccount::getServiceTypeId() const
+{
+    LogDebug("entered");
+    return m_serviceTypeId;
+}
+
+void EventAccount::setServiceTypeId(const std::string &value)
+{
+    LogDebug("entered");
+    m_serviceTypeId = value;
+}
+
+std::string EventAccount::getProviderId() const
+{
+    LogDebug("entered");
+    return m_providerId;
+}
+
+void EventAccount::setProviderId(const std::string &value)
+{
+    LogDebug("entered");
+    m_providerId = value;
+}
+
+std::string EventAccount::getprefix() const
+{
+    LogDebug("entered");
+    return m_prefix;
+}
+
+void EventAccount::setprefix(const std::string &value)
+{
+    LogDebug("entered");
+    m_prefix = value;
+}
+
+std::string EventAccount::getUserName() const
+{
+    LogDebug("entered");
+    return m_username;
+}
+
+void EventAccount::setUserName(const std::string &value)
+{
+    LogDebug("entered");
+    m_username = value;
+}
+
+std::string EventAccount::getPackageName() const
+{
+    LogDebug("entered");
+    return m_packagename;
+}
+
+void EventAccount::setPackageName(const std::string &value)
+{
+    LogDebug("entered");
+    m_packagename = value;
+}
+
+std::string EventAccount::getEmailAddress() const
+{
+    LogDebug("entered");
+    return m_emailaddress;
+}
+
+void EventAccount::setEmailAddress(const std::string &value)
+{
+    LogDebug("entered");
+    m_emailaddress = value;
+}
+
+std::string EventAccount::getDomainName() const
+{
+    LogDebug("entered");
+    return m_domainname;
+}
+
+void EventAccount::setDomainName(const std::string &value)
+{
+    LogDebug("entered");
+    m_domainname = value;
+}
+
+AccountServicesArrayPtr EventAccount::getService() const
+{
+    LogDebug("<<<");
+    return m_service;
+}
+
+void EventAccount::setService(const AccountServicesArrayPtr &value)
+{
+    LogDebug("entered");
+       m_service = value;
+}
+
+}
+}
+}
diff --git a/src/platform/API/Account/EventAccount.h b/src/platform/API/Account/EventAccount.h
new file mode 100755 (executable)
index 0000000..968ed2d
--- /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        EventAccount.h
+ *
+ * @version     0.1
+ */
+
+#ifndef _ABSTRACT_LAYER_EVENT_ATTENDEE_H_
+#define _ABSTRACT_LAYER_EVENT_ATTENDEE_H_
+
+#include <string>
+#include <vector>
+#include <dpl/shared_ptr.h>
+#include "AccountServices.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+
+typedef std::vector<std::string> FeatureList;
+typedef DPL::SharedPtr<FeatureList> FeatureListPtr;
+
+class EventAccount
+{
+  public:
+
+       static const int UNDEFINED_ACCOUNT_ID = -1;
+       EventAccount();
+       virtual ~EventAccount();
+
+       bool validate() const;
+
+       int getID() const;
+       void setID(const int &value);
+
+       std::string getAccountId() const;
+       void setAccountId(const std::string &value);
+
+       std::string getDisplayName() const;
+       void setDisplayName(const std::string &value);
+
+       std::string getIconPath() const;
+       void setIconPath(const std::string &value);
+
+       std::string getProviderName() const;
+       void setProviderName(const std::string &value);
+
+       bool getEnabled() const;
+       void setEnabled(bool &value);
+
+       unsigned long getCredentailId() const;
+       void setCredentailId(unsigned long &value);
+
+       std::string getSettings() const;
+       void setSettings(const std::string &value);
+
+       std::string getServiceTypeId() const;
+       void setServiceTypeId(const std::string &value);
+
+       std::string getProviderId() const;
+       void setProviderId(const std::string &value);
+
+       std::string getprefix() const;
+       void setprefix(const std::string &value);
+
+       std::string getUserName() const;
+       void setUserName(const std::string &value);
+
+       std::string getPackageName() const;
+       void setPackageName(const std::string &value);
+
+       std::string getEmailAddress() const;
+       void setEmailAddress(const std::string &value);
+
+       std::string getDomainName() const;
+       void setDomainName(const std::string &value);
+
+       AccountServicesArrayPtr getService() const;
+       void setService(const AccountServicesArrayPtr &value);
+
+  protected:
+       int m_accountid;
+       std::string m_AccountId;
+       std::string m_displayname;
+       std::string m_iconPath;
+       std::string m_providername;
+       bool m_enabled;
+       unsigned long m_credentialId;
+       std::string m_settings;
+
+       std::string m_serviceTypeId;
+       std::string m_providerId;
+       std::string m_prefix;
+
+       std::string m_username;
+       std::string m_packagename;
+       std::string m_emailaddress;
+       std::string m_domainname;
+
+       AccountServicesArrayPtr                         m_service;
+
+};
+
+typedef DPL::SharedPtr<EventAccount> EventAccountPtr;
+typedef std::vector<EventAccountPtr> EventAccountList;
+typedef DPL::SharedPtr<EventAccountList> EventAccountListPtr;
+
+}
+}
+}
+
+#endif /* _ABSTRACT_LAYER_EVENT_ATTENDEE_H_ */
diff --git a/src/platform/API/Account/IAccountManager.cpp b/src/platform/API/Account/IAccountManager.cpp
new file mode 100755 (executable)
index 0000000..7b9febe
--- /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.
+ */
+
+
+/**
+ * @file        IAccountManager.cpp
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ */
+
+#include "IAccountManager.h"
+#include <Commons/ThreadPool.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+IAccountManager::IAccountManager() :
+    WrtDeviceApis::Commons::EventRequestReceiver< IEventGetAccountServices >(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver< IEventAddAccount >(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver< IEventDeleteAccount >(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindAccounts>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateAccount>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetAccountById>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetServiceTypeById>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetProviderById>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindProviders>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
+         WrtDeviceApis::Commons::EventRequestReceiver< IEventFindServiceTypes>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD)
+{
+    LogDebug("entered");
+}
+
+IAccountManager::~IAccountManager()
+{
+    LogDebug("entered");
+}
+
+
+void IAccountManager::getAccountServices(const IEventGetAccountServicesPtr &event)
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetAccountServices>::PostRequest(event);
+}
+
+void IAccountManager::addAccount(const IEventAddAccountPtr &event)
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventAddAccount>::PostRequest(event);
+}
+
+void IAccountManager::deleteAccount(const IEventDeleteAccountPtr &event)
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventDeleteAccount>::PostRequest(event);
+}
+
+void IAccountManager::findAccounts(const IEventFindAccountsPtr &event)
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindAccounts>::PostRequest(event);
+}
+
+void IAccountManager::findServiceTypes(const IEventFindServiceTypesPtr &event){
+       LogDebug("<<<");
+       WrtDeviceApis::Commons::EventRequestReceiver<IEventFindServiceTypes>::PostRequest(event);
+}
+
+
+void IAccountManager::updateAccount(const IEventUpdateAccountPtr &event)
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateAccount>::PostRequest(event);
+}
+
+void IAccountManager::getAccountById(const IEventGetAccountByIdPtr &event)
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetAccountById>::PostRequest(event);
+}
+
+void IAccountManager::getServiceTypeById(const IEventGetServiceTypeByIdPtr &event)
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetServiceTypeById>::PostRequest(event);
+}
+
+void IAccountManager::getProviderById(const IEventGetProviderByIdPtr &event)
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetProviderById>::PostRequest(event);
+}
+
+void IAccountManager::FindProviders(const IEventFindProvidersPtr &event)
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindProviders>::PostRequest(event);
+}
+
+}
+}
+}
diff --git a/src/platform/API/Account/IAccountManager.h b/src/platform/API/Account/IAccountManager.h
new file mode 100755 (executable)
index 0000000..f35a9df
--- /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.
+ */
+
+
+/**
+ * @file        IAccountManager.h
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef _ABSTRACT_LAYER_IACCOUNT_MANAGER_H_
+#define _ABSTRACT_LAYER_IACCOUNT_MANAGER_H_
+
+#include "IAccountService.h"
+#include "IEventGetAccountServices.h"
+#include "IEventFindServiceTypes.h"
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+
+class IAccountManager : public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetAccountServices >,
+       public WrtDeviceApis::Commons::EventRequestReceiver< IEventAddAccount > ,
+       public WrtDeviceApis::Commons::EventRequestReceiver< IEventDeleteAccount >,
+       public WrtDeviceApis::Commons::EventRequestReceiver< IEventFindAccounts >,
+       public WrtDeviceApis::Commons::EventRequestReceiver< IEventUpdateAccount >,
+       public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetAccountById >,
+       public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetServiceTypeById >,
+       public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetProviderById >,
+       public WrtDeviceApis::Commons::EventRequestReceiver< IEventFindProviders >,
+       public WrtDeviceApis::Commons::EventRequestReceiver< IEventFindServiceTypes >
+{
+  public:
+       IAccountManager();
+
+       virtual ~IAccountManager();
+
+       virtual void getAccountServices(const IEventGetAccountServicesPtr &event);
+
+       virtual void addAccount(const IEventAddAccountPtr &event);
+
+       virtual void deleteAccount(const IEventDeleteAccountPtr &event);
+
+       virtual void findAccounts(const IEventFindAccountsPtr &event);
+
+       virtual void findServiceTypes(const IEventFindServiceTypesPtr &event);
+
+       virtual void updateAccount(const IEventUpdateAccountPtr &event);
+
+       virtual void getAccountById(const IEventGetAccountByIdPtr &event);
+
+       virtual void getServiceTypeById(const IEventGetServiceTypeByIdPtr &event);
+
+       virtual void getProviderById(const IEventGetProviderByIdPtr &event);
+
+       virtual void FindProviders(const IEventFindProvidersPtr &event);
+
+
+  protected:
+       virtual void OnRequestReceived(const IEventGetAccountServicesPtr &event) = 0;
+
+       virtual void OnRequestReceived(const IEventAddAccountPtr &event) = 0;
+
+       virtual void OnRequestReceived(const IEventDeleteAccountPtr &event) = 0;
+
+       virtual void OnRequestReceived(const IEventFindAccountsPtr &event) = 0;
+
+       virtual void OnRequestReceived(const IEventUpdateAccountPtr &event) = 0;
+
+       virtual void OnRequestReceived(const IEventGetAccountByIdPtr &event) = 0;
+
+       virtual void OnRequestReceived(const IEventGetServiceTypeByIdPtr &event) = 0;
+
+       virtual void OnRequestReceived(const IEventGetProviderByIdPtr &event) = 0;
+
+       virtual void OnRequestReceived(const IEventFindProvidersPtr &event) = 0;
+
+       virtual void OnRequestReceived(const IEventFindServiceTypesPtr &event) = 0;
+
+};
+
+typedef DPL::SharedPtr<IAccountManager> IAccountManagerPtr;
+
+}
+}
+}
+
+#endif /* _ABSTRACT_LAYER_IACCOUNT_MANAGER_H_ */
diff --git a/src/platform/API/Account/IAccountService.cpp b/src/platform/API/Account/IAccountService.cpp
new file mode 100755 (executable)
index 0000000..e953d60
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+
+/**
+ * @file        IAccount.cpp
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ */
+
+#include "IAccountService.h"
+#include <Commons/ThreadPool.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+IAccountService::IAccountService() :
+   
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventDeleteAccount>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateAccount>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindAccounts>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventCreateAccount>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventAddAccount>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
+    m_id(0),
+    m_type(TYPE_INTERNET)
+{
+}
+
+IAccountService::~IAccountService()
+{
+}
+
+void IAccountService::createAccount(IEventCreateAccountPtr &event)
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventCreateAccount>::PostRequest(event);
+}
+
+void IAccountService::addAccount(IEventAddAccountPtr &event)
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventAddAccount>::PostRequest(event);
+}
+
+
+void IAccountService::updateAccount(IEventUpdateAccountPtr &event)
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateAccount>::PostRequest(event);
+}
+
+void IAccountService::deleteAccount(IEventDeleteAccountPtr &event)
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventDeleteAccount>::PostRequest(event);
+}
+
+void IAccountService::findAccounts(IEventFindAccountsPtr &event)
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindAccounts>::PostRequest(event);
+}
+
+
+}
+}
+}
diff --git a/src/platform/API/Account/IAccountService.h b/src/platform/API/Account/IAccountService.h
new file mode 100755 (executable)
index 0000000..1c0afc5
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * @file        IAccount.h
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef _ABSTRACT_LAYER_IACCOUNT_H_
+#define _ABSTRACT_LAYER_IACCOUNT_H_
+
+#include <string>
+#include <dpl/log/log.h>
+#include <dpl/shared_ptr.h>
+//#include "CalendarEvent.h"
+//#include "EventFilter.h"
+#include "IEventCreateAccount.h"
+#include "IEventAddAccount.h"
+#include "IEventDeleteAccount.h"
+#include "IEventFindAccounts.h"
+#include "IEventUpdateAccount.h"
+#include "IEventGetAccountById.h"
+#include "IEventGetServiceTypeById.h"
+#include "IEventGetProviderById.h"
+#include "IEventFindProviders.h"
+
+#include "OnAddEventsChanged.h"
+#include "OnUpdateEventsChanged.h"
+#include "OnDeleteEventsChanged.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+class IAccountService :
+    public WrtDeviceApis::Commons::EventRequestReceiver< IEventDeleteAccount >,
+    public WrtDeviceApis::Commons::EventRequestReceiver< IEventUpdateAccount >,
+    public WrtDeviceApis::Commons::EventRequestReceiver< IEventFindAccounts >,
+    public WrtDeviceApis::Commons::EventRequestReceiver< IEventCreateAccount >,
+    public WrtDeviceApis::Commons::EventRequestReceiver< IEventAddAccount >
+{
+  public:
+
+    typedef enum
+    {
+        TYPE_NONE,
+     //   TYPE_SIM,
+     //   TYPE_TOKEN,
+     //   TYPE_HW,
+        TYPE_INTERNET
+     //   TYPE_LOCAL,
+     //   TYPE_OTHER
+    } AccountType;
+
+    IAccountService();
+    virtual ~IAccountService();
+    virtual void                createAccount(IEventCreateAccountPtr &event);
+    virtual void                addAccount(IEventAddAccountPtr &event);
+    virtual void                updateAccount(IEventUpdateAccountPtr &event);
+    virtual void                deleteAccount(IEventDeleteAccountPtr &event);
+    virtual void                findAccounts(IEventFindAccountsPtr &event);
+
+
+    virtual std::string         getName() const
+    {
+        return m_name;
+    }
+    virtual void                setName(const std::string &value)
+    {
+        m_name = value;
+    }
+    virtual AccountType        getType() const
+    {
+        return m_type;
+    }
+    virtual void                setType(const AccountType value)
+    {
+        m_type = value;
+    }
+    virtual int                 getId() const
+    {
+        return m_id;
+    }
+    virtual void                setId(const int value)
+    {
+        m_id = value;
+    }
+
+   //TODO: check the meaning of emitters as below.
+    virtual OnAddEventsChangedEmitterPtr getAddEmitter() const
+    {
+        return m_addEmitter;
+    }
+    virtual void                setAddEmitter(OnAddEventsChangedEmitterPtr value)
+    {
+        m_addEmitter = value;
+    }
+    virtual OnUpdateEventsChangedEmitterPtr getUpdateEmitter() const
+    {
+        return m_updateEmitter;
+    }
+    virtual void                setUpdateEmitter(OnUpdateEventsChangedEmitterPtr value)
+    {
+        m_updateEmitter = value;
+    }
+        virtual OnDeleteEventsChangedEmitterPtr getDeleteEmitter() const
+    {
+        return m_deleteEmitter;
+    }
+    virtual void                setDeleteEmitter(OnDeleteEventsChangedEmitterPtr value)
+    {
+        m_deleteEmitter = value;
+    }
+  protected:
+    int m_id;
+    std::string m_name;
+    AccountType m_type;
+    OnAddEventsChangedEmitterPtr m_addEmitter;
+    OnUpdateEventsChangedEmitterPtr m_updateEmitter;
+    OnDeleteEventsChangedEmitterPtr m_deleteEmitter;
+
+    virtual void OnRequestReceived(const IEventDeleteAccountPtr &event) = 0;
+    virtual void OnRequestReceived(const IEventUpdateAccountPtr &event) = 0;
+    virtual void OnRequestReceived(const IEventFindAccountsPtr &event) = 0;
+    virtual void OnRequestReceived(const IEventCreateAccountPtr &event) = 0;
+    virtual void OnRequestReceived(const IEventAddAccountPtr &event) = 0;
+};
+
+typedef DPL::SharedPtr<IAccountService> IAccountServicePtr;
+}
+}
+}
+
+#endif /* _ABSTRACT_LAYER_IACCOUNT_H_ */
diff --git a/src/platform/API/Account/IEventAddAccount.h b/src/platform/API/Account/IEventAddAccount.h
new file mode 100755 (executable)
index 0000000..ced1b11
--- /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.
+ */
+
+
+/*
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _ABSTRACT_LAYER_IEVENT_ADD_ACCOUNT_H_
+#define _ABSTRACT_LAYER_IEVENT_ADD_ACCOUNT_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "EventAccount.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+class IEventAddAccount : public WrtDeviceApis::Commons::IEvent<IEventAddAccount>
+{
+    EventAccountPtr m_event;
+    bool m_result;
+  public:
+    void             setResult(bool value)
+    {
+        m_result = value;
+    }
+    bool             getResult() const
+    {
+        return m_result;
+    }
+    void             setEvent(EventAccountPtr value)
+    {
+        m_event = value;
+    }
+    EventAccountPtr getEvent() const
+    {
+        return m_event;
+    }
+    IEventAddAccount() : m_event(NULL),
+        m_result(false)
+    {
+    }
+    ~IEventAddAccount()
+    {
+    }
+    virtual void clearOnCancel()
+    {
+    }
+};
+
+typedef DPL::SharedPtr<IEventAddAccount> IEventAddAccountPtr;
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_ADD_ACCOUNT_H_ */
diff --git a/src/platform/API/Account/IEventCreateAccount.h b/src/platform/API/Account/IEventCreateAccount.h
new file mode 100755 (executable)
index 0000000..cd1bae1
--- /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.
+ */
+
+
+/*
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _ABSTRACT_LAYER_IEVENT_CREATE_ACCOUNT_H_
+#define _ABSTRACT_LAYER_IEVENT_CREATE_ACCOUNT_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "EventAccount.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+class IEventCreateAccount : public WrtDeviceApis::Commons::IEvent<IEventCreateAccount>
+{
+    EventAccountPtr m_event;
+    bool m_result;
+  public:
+    void             setResult(bool value)
+    {
+        m_result = value;
+    }
+    bool             getResult() const
+    {
+        return m_result;
+    }
+    void             setEvent(EventAccountPtr value)
+    {
+        m_event = value;
+    }
+    EventAccountPtr getEvent() const
+    {
+        return m_event;
+    }
+    IEventCreateAccount() : m_event(NULL),
+        m_result(false)
+    {
+    }
+    ~IEventCreateAccount()
+    {
+    }
+    virtual void clearOnCancel()
+    {
+    }
+};
+
+typedef DPL::SharedPtr<IEventCreateAccount> IEventCreateAccountPtr;
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_CREATE_ACCOUNT_H_ */
diff --git a/src/platform/API/Account/IEventDeleteAccount.h b/src/platform/API/Account/IEventDeleteAccount.h
new file mode 100755 (executable)
index 0000000..73f159f
--- /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.
+ */
+
+
+/*
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _ABSTRACT_LAYER_IEVENT_DELETE_ACCOUNT_H_
+#define _ABSTRACT_LAYER_IEVENT_DELETE_ACCOUNT_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "EventAccount.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+class IEventDeleteAccount : public WrtDeviceApis::Commons::IEvent<IEventDeleteAccount>
+{
+    EventAccountPtr m_event;
+    bool m_result;
+  public:
+    void             setResult(bool value)
+    {
+        m_result = value;
+    }
+    bool             getResult() const
+    {
+        return m_result;
+    }
+    void             setEvent(EventAccountPtr value)
+    {
+        m_event = value;
+    }
+    EventAccountPtr getEvent() const
+    {
+        return m_event;
+    }
+    IEventDeleteAccount() : m_event(NULL),
+        m_result(false)
+    {
+    }
+    ~IEventDeleteAccount()
+    {
+    }
+    virtual void clearOnCancel()
+    {
+    }
+};
+
+typedef DPL::SharedPtr<IEventDeleteAccount> IEventDeleteAccountPtr;
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_DELETE_ACCOUNT_H_ */
diff --git a/src/platform/API/Account/IEventFindAccounts.h b/src/platform/API/Account/IEventFindAccounts.h
new file mode 100755 (executable)
index 0000000..d4ac491
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/*
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _ABSTRACT_LAYER_IEVENT_FIND_ACCOUNTS_H_
+#define _ABSTRACT_LAYER_IEVENT_FIND_ACCOUNTS_H_
+
+#include <vector>
+#include <Commons/IEvent.h>
+#include "EventAccount.h"
+#include "AccountFilter.h"
+#include <dpl/shared_ptr.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;
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_FIND_ACCOUNTS_H_ */
diff --git a/src/platform/API/Account/IEventFindProviders.h b/src/platform/API/Account/IEventFindProviders.h
new file mode 100644 (file)
index 0000000..581f6bc
--- /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.
+ */
+
+
+/*
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _ABSTRACT_LAYER_IEVENT_FIND_PROVIDER_H_
+#define _ABSTRACT_LAYER_IEVENT_FIND_PROVIDER_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()
+    {
+    }
+};
+
+typedef DPL::SharedPtr<IEventFindProviders> IEventFindProvidersPtr;
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_FIND_PROVIDER_H_ */
+
diff --git a/src/platform/API/Account/IEventFindServiceTypes.h b/src/platform/API/Account/IEventFindServiceTypes.h
new file mode 100755 (executable)
index 0000000..74cf326
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/*
+ * IEventFindServiceTypes.h
+ *
+ *  Created on: 2012. 1. 30.
+ *      Author: sangtai
+ */
+
+#ifndef IEVENTFINDSERVICETYPES_H_
+#define IEVENTFINDSERVICETYPES_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+
+#include "AccountServiceTypeProperty.h"
+
+namespace TizenApis {
+       namespace Api {
+               namespace Account {
+
+                       class IEventFindServiceTypes : public WrtDeviceApis::Commons::IEvent<IEventFindServiceTypes>{
+                               public:
+                                       IEventFindServiceTypes(): m_prefix(""), m_result(false){
+                                       }
+                                       virtual ~IEventFindServiceTypes(){
+                                       }
+
+                                       void setPrefix(const std::string& value){
+                                               m_prefix = value;
+                                       }
+                                       std::string getPrefix(){
+                                               return m_prefix;
+                                       }
+
+                                       void setResult(bool value){
+                                               m_result = value;
+                                       }
+
+                                       bool getResult(){
+                                               return m_result;
+                                       }
+
+                                       AccountServiceTypePropertyArrayPtr getAccountServiceTypeProperties(){
+                                               return m_accountServiceTypeProperties;
+                                       }
+                                       void setServiceTypeProperties(const AccountServiceTypePropertyArrayPtr &value){
+                                               m_accountServiceTypeProperties = value;
+                                       }
+
+                                       virtual void clearOnCancel() {
+                                       }
+
+                               private:
+                                       std::string m_prefix;
+                                       bool m_result;
+
+                                       AccountServiceTypePropertyArrayPtr m_accountServiceTypeProperties;
+                       };
+
+                       typedef DPL::SharedPtr<IEventFindServiceTypes> IEventFindServiceTypesPtr;
+               }       // namespace Account
+       }
+}
+
+#endif /* IEVENTFINDSERVICETYPES_H_ */
diff --git a/src/platform/API/Account/IEventGetAccountById.h b/src/platform/API/Account/IEventGetAccountById.h
new file mode 100755 (executable)
index 0000000..fd41c00
--- /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.
+ */
+
+
+/*
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _ABSTRACT_LAYER_IEVENT_GET_ACCOUNT_BY_ID_H_
+#define _ABSTRACT_LAYER_IEVENT_GET_ACCOUNT_BY_ID_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "EventAccount.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+class IEventGetAccountById : public WrtDeviceApis::Commons::IEvent<IEventGetAccountById>
+{
+    EventAccountPtr m_event;
+    bool m_result;
+  public:
+    void             setResult(bool value)
+    {
+        m_result = value;
+    }
+    bool             getResult() const
+    {
+        return m_result;
+    }
+    void             setEvent(EventAccountPtr value)
+    {
+        m_event = value;
+    }
+    EventAccountPtr getEvent() const
+    {
+        return m_event;
+    }
+    IEventGetAccountById() : m_event(NULL),
+        m_result(false)
+    {
+    }
+    ~IEventGetAccountById()
+    {
+    }
+    virtual void clearOnCancel()
+    {
+    }
+};
+
+typedef DPL::SharedPtr<IEventGetAccountById> IEventGetAccountByIdPtr;
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_GET_ACCOUNT_BY_ID_H_ */
diff --git a/src/platform/API/Account/IEventGetAccountServices.h b/src/platform/API/Account/IEventGetAccountServices.h
new file mode 100755 (executable)
index 0000000..27ea7dc
--- /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.
+ */
+
+
+/*
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _ABSTRACT_LAYER_IEVENT_GET_ACCOUNT_SERVICE_H_
+#define _ABSTRACT_LAYER_IEVENT_GET_ACCOUNT_SERVICE_H_
+
+#include <vector>
+#include <Commons/IEvent.h>
+#include "IAccountService.h"
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+class IEventGetAccountServices : public WrtDeviceApis::Commons::IEvent<
+        IEventGetAccountServices>
+{
+    std::vector<IAccountServicePtr>     m_accountservices;
+    bool m_result;
+  public:
+    void                        setResult(bool value)
+    {
+        m_result = value;
+    }
+    bool                        getResult() const
+    {
+        return m_result;
+    }
+       //TODO: need to confirm this.
+    void                        addAccountService(IAccountServicePtr value)
+    {
+        m_accountservices.push_back(value);
+    }
+       //TODO: need to confirm this.
+    std::vector<IAccountServicePtr>     getAccountServices() const
+    {
+        return m_accountservices;
+    }
+    IEventGetAccountServices() : m_result(false)
+    {
+    }
+    ~IEventGetAccountServices()
+    {
+    }
+    virtual void clearOnCancel()
+    {
+    }
+};
+
+typedef DPL::SharedPtr<IEventGetAccountServices> IEventGetAccountServicesPtr;
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_GET_ACCOUNT_SERVICE_H_ */
diff --git a/src/platform/API/Account/IEventGetProviderById.h b/src/platform/API/Account/IEventGetProviderById.h
new file mode 100755 (executable)
index 0000000..1bce836
--- /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      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _ABSTRACT_LAYER_IEVENT_GET_PROVIDER_BY_ID_H_
+#define _ABSTRACT_LAYER_IEVENT_GET_PROVIDER_BY_ID_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "EventAccount.h"
+
+#include "AccountServiceProviderProperty.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+class IEventGetProviderById : public WrtDeviceApis::Commons::IEvent<IEventGetProviderById>
+{
+       EventAccountPtr m_event;
+               bool m_result;
+
+       private :
+               AccountServiceProviderPropertyPtr m_accountServiceProviderPropertyPtr;
+
+       public:
+               void setResult(bool value) {
+                       m_result = value;
+               }
+
+               bool getResult() const {
+                       return m_result;
+               }
+
+               void setEvent(EventAccountPtr value) {
+                       m_event = value;
+               }
+
+               EventAccountPtr getEvent() const {
+                       return m_event;
+               }
+
+               void setAccountServiceProviderProperty(AccountServiceProviderPropertyPtr value){
+                       m_accountServiceProviderPropertyPtr = value;
+               }
+
+               AccountServiceProviderPropertyPtr getAccountServiceProviderProperty(){
+                       return m_accountServiceProviderPropertyPtr;
+               }
+
+               IEventGetProviderById() :
+                               m_event(NULL), m_result(false) {
+               }
+
+               ~IEventGetProviderById() {
+               }
+
+               virtual void clearOnCancel() {
+               }
+};
+
+typedef DPL::SharedPtr<IEventGetProviderById> IEventGetProviderByIdPtr;
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_GET_PROVIDER_BY_ID_H_ */
+
diff --git a/src/platform/API/Account/IEventGetServiceTypeById.h b/src/platform/API/Account/IEventGetServiceTypeById.h
new file mode 100755 (executable)
index 0000000..517839e
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @author      jihwa park (jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _ABSTRACT_LAYER_IEVENT_GET_SERVICETYPE_BY_ID_H_
+#define _ABSTRACT_LAYER_IEVENT_GET_SERVICETYPE_BY_ID_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "EventAccount.h"
+#include "AccountServiceTypeProperty.h"
+
+namespace TizenApis {
+       namespace Api {
+               namespace Account {
+                       class IEventGetServiceTypeById: public WrtDeviceApis::Commons::IEvent<IEventGetServiceTypeById> {
+                                       EventAccountPtr m_event;
+
+                                       AccountServiceTypePropertyPtr m_accountServiceTypePropertyPtr;
+
+                                       bool m_result;
+                               public:
+                                       void setResult(bool value) {
+                                               m_result = value;
+                                       }
+                                       bool getResult() const {
+                                               return m_result;
+                                       }
+                                       void setEvent(EventAccountPtr value) {
+                                               m_event = value;
+                                       }
+                                       EventAccountPtr getEvent() const {
+                                               return m_event;
+                                       }
+
+                                       AccountServiceTypePropertyPtr getAccountServiceTypeProperty(){
+                                               return m_accountServiceTypePropertyPtr;
+                                       }
+
+                                       void setAccountServiceTypeProperty(AccountServiceTypePropertyPtr value){
+                                               m_accountServiceTypePropertyPtr = value;
+                                       }
+
+                                       IEventGetServiceTypeById() :
+                                                       m_event(NULL), m_result(false) {
+                                       }
+                                       ~IEventGetServiceTypeById() {
+                                       }
+                                       virtual void clearOnCancel() {
+                                       }
+                       };
+
+                       typedef DPL::SharedPtr<IEventGetServiceTypeById> IEventGetServiceTypeByIdPtr;
+               }
+       }
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_GET_SERVICETYPE_BY_ID_H_ */
diff --git a/src/platform/API/Account/IEventUpdateAccount.h b/src/platform/API/Account/IEventUpdateAccount.h
new file mode 100755 (executable)
index 0000000..bea4285
--- /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.
+ */
+
+
+/*
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _ABSTRACT_LAYER_IEVENT_UPDATE_ACCOUNT_H_
+#define _ABSTRACT_LAYER_IEVENT_UPDATE_ACCOUNT_H_
+
+#include <Commons/IEvent.h>
+#include "EventAccount.h"
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+class IEventUpdateAccount : public WrtDeviceApis::Commons::IEvent<IEventUpdateAccount>
+{
+    EventAccountPtr m_event;
+    bool m_result;
+  public:
+    void             setResult(bool value)
+    {
+        m_result = value;
+    }
+    bool             getResult() const
+    {
+        return m_result;
+    }
+    void             setEvent(EventAccountPtr value)
+    {
+        m_event = value;
+    }
+    EventAccountPtr getEvent() const
+    {
+        return m_event;
+    }
+
+    IEventUpdateAccount() : m_event(NULL),
+        m_result(false)
+    {
+    }
+    ~IEventUpdateAccount()
+    {
+    }
+    virtual void clearOnCancel()
+    {
+    }
+};
+
+typedef DPL::SharedPtr<IEventUpdateAccount> IEventUpdateAccountPtr;
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_UPDATE_ACCOUNT_H_ */
diff --git a/src/platform/API/Account/OnAddEventsChanged.h b/src/platform/API/Account/OnAddEventsChanged.h
new file mode 100755 (executable)
index 0000000..e012dfa
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+
+/*
+ * @file          OnAddEventsChanged.h
+ * @author
+ * @version     0.1
+ * @brief  
+ */
+
+#ifndef _ON_ADD_EVENTS_CHANGED_H_
+#define _ON_ADD_EVENTS_CHANGED_H_
+
+#include <vector>
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include <Commons/ListenerEvent.h>
+#include <Commons/ListenerEventEmitter.h>
+
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+
+class OnAddEventsChanged : public WrtDeviceApis::Commons::ListenerEvent<OnAddEventsChanged>
+{
+    public:
+    typedef enum
+    {
+               SUCCESS_ALL,
+               FAIL_ALL,
+               EVENT_ADD_SUCCESS,
+               EVENT_ADD_FAIL
+    } EventAddStatus;
+
+    void setResult (bool value) {
+        m_result = value;
+    }  
+    bool getResult() const {
+        return m_result;
+    }
+
+    void setEvent(EventAccountPtr value) {
+        m_event = value;
+    }
+    EventAccountPtr getEvent() const {
+        return m_event;
+    }
+
+    void setStatus(EventAddStatus value) {
+        m_status = value;
+    }
+    EventAddStatus getStatus() const {
+        return m_status;
+    }
+
+    OnAddEventsChanged() : m_result(false) {
+    }
+    ~OnAddEventsChanged() {
+    }
+
+    private:
+    EventAccountPtr m_event;
+    EventAddStatus m_status;
+    bool m_result;
+};
+
+typedef DPL::SharedPtr<OnAddEventsChanged> OnAddEventsChangedPtr;
+typedef WrtDeviceApis::Commons::ListenerEventEmitter<OnAddEventsChanged> OnAddEventsChangedEmitter;
+typedef DPL::SharedPtr<OnAddEventsChangedEmitter> OnAddEventsChangedEmitterPtr;
+
+} // Api
+} // WrtPlugins
+}
+
+#endif //_ON_ADD_EVENTS_CHANGED_H_
\ No newline at end of file
diff --git a/src/platform/API/Account/OnDeleteEventsChanged.h b/src/platform/API/Account/OnDeleteEventsChanged.h
new file mode 100755 (executable)
index 0000000..18bee40
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+
+/*
+ * @file          OnDeleteEventsChanged.h
+ * @author
+ * @version     0.1
+ * @brief  
+ */
+
+#ifndef _ON_DELETE_EVENTS_CHANGED_H_
+#define _ON_DELETE_EVENTS_CHANGED_H_
+
+#include <vector>
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include <Commons/ListenerEvent.h>
+#include <Commons/ListenerEventEmitter.h>
+
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+
+class OnDeleteEventsChanged : public WrtDeviceApis::Commons::ListenerEvent<OnDeleteEventsChanged>
+{
+    public:
+    typedef enum
+    {
+               SUCCESS_ALL,
+               FAIL_ALL,
+               EVENT_DELETE_SUCCESS,
+               EVENT_DELETE_FAIL
+    } EventDeleteStatus;
+
+    void setResult (bool value) {
+        m_result = value;
+    }  
+    bool getResult() const {
+        return m_result;
+    }
+
+    void setEvent(EventAccountPtr value) {
+        m_event = value;
+    }
+    EventAccountPtr getEvent() const {
+        return m_event;
+    }
+
+    void setStatus(EventDeleteStatus value) {
+        m_status = value;
+    }
+    EventDeleteStatus getStatus() const {
+        return m_status;
+    }
+
+    OnDeleteEventsChanged() : m_result(false) {
+    }
+    ~OnDeleteEventsChanged() {
+    }
+
+    private:
+    EventAccountPtr m_event;
+    EventDeleteStatus m_status;
+    bool m_result;
+};
+
+typedef DPL::SharedPtr<OnDeleteEventsChanged> OnDeleteEventsChangedPtr;
+typedef WrtDeviceApis::Commons::ListenerEventEmitter<OnDeleteEventsChanged> OnDeleteEventsChangedEmitter;
+typedef DPL::SharedPtr<OnDeleteEventsChangedEmitter> OnDeleteEventsChangedEmitterPtr;
+
+} // Api
+} // WrtPlugins
+}
+
+#endif //_ON_DELETE_EVENTS_CHANGED_H_
\ No newline at end of file
diff --git a/src/platform/API/Account/OnUpdateEventsChanged.h b/src/platform/API/Account/OnUpdateEventsChanged.h
new file mode 100755 (executable)
index 0000000..ab47daf
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+
+/*
+ * @file          OnUpdateEventsChanged.h
+ * @author
+ * @version     0.1
+ * @brief  
+ */
+
+#ifndef _ON_UPDATE_EVENTS_CHANGED_H_
+#define _ON_UPDATE_EVENTS_CHANGED_H_
+
+#include <vector>
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include <Commons/ListenerEvent.h>
+#include <Commons/ListenerEventEmitter.h>
+
+
+namespace TizenApis {
+namespace Api {
+namespace Account{
+
+class OnUpdateEventsChanged : public WrtDeviceApis::Commons::ListenerEvent<OnUpdateEventsChanged>
+{
+    public:
+    typedef enum
+    {
+               SUCCESS_ALL,
+               FAIL_ALL,
+               EVENT_UPDATE_SUCCESS,
+               EVENT_UPDATE_FAIL
+    } EventUpdateStatus;
+
+    void setResult (bool value) {
+        m_result = value;
+    }  
+    bool getResult() const {
+        return m_result;
+    }
+
+    void setEvent(EventAccountPtr value) {
+        m_event = value;
+    }
+    EventAccountPtr getEvent() const {
+        return m_event;
+    }
+
+    void setStatus(EventUpdateStatus value) {
+        m_status = value;
+    }
+    EventUpdateStatus getStatus() const {
+        return m_status;
+    }
+
+    OnUpdateEventsChanged() : m_result(false) {
+    }
+    ~OnUpdateEventsChanged() {
+    }
+
+    private:
+    EventAccountPtr m_event;
+    EventUpdateStatus m_status;
+    bool m_result;
+};
+
+typedef DPL::SharedPtr<OnUpdateEventsChanged> OnUpdateEventsChangedPtr;
+typedef WrtDeviceApis::Commons::ListenerEventEmitter<OnUpdateEventsChanged> OnUpdateEventsChangedEmitter;
+typedef DPL::SharedPtr<OnUpdateEventsChangedEmitter> OnUpdateEventsChangedEmitterPtr;
+
+} // Api
+} // WrtPlugins
+}
+
+#endif //_ON_UPDATE_EVENTS_CHANGED_H_
\ No newline at end of file
diff --git a/src/platform/API/Account/config.cmake b/src/platform/API/Account/config.cmake
new file mode 100755 (executable)
index 0000000..bbc0820
--- /dev/null
@@ -0,0 +1,13 @@
+get_current_path()
+set(SRCS_PLATFORM_API_ACCOUNT
+  ${CURRENT_PATH}/IAccountService.cpp
+  ${CURRENT_PATH}/IAccountManager.cpp
+  ${CURRENT_PATH}/AccountFactory.cpp
+  ${CURRENT_PATH}/EventAccount.cpp
+  ${CURRENT_PATH}/AccountFilter.cpp
+  ${CURRENT_PATH}/AccountServices.cpp
+  ${CURRENT_PATH}/AccountServiceTypeProperty.cpp
+  ${CURRENT_PATH}/AccountServiceProviderProperty.cpp
+  
+  PARENT_SCOPE
+)
diff --git a/src/platform/API/Account/log.h b/src/platform/API/Account/log.h
new file mode 100755 (executable)
index 0000000..5804619
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. 
+*/
+/*
+ * log.h
+ *
+ *  Created on: 2011. 11. 25.
+ *      Author: sangtai
+ */
+
+#ifndef LOG_H_
+#define LOG_H_
+
+#include <dpl/log/log.h>
+
+#define AccountLogError(ARG)   LogError("\u001B[0;31m" << ARG << "\u001B[0;39m")
+#define AccountLogWarning(ARG) LogWarning("\u001B[1;33m" << ARG << "\u001B[0;39m")
+
+#endif /* LOG_H_ */
index c76c69b..b58d6bb 100755 (executable)
@@ -20,7 +20,7 @@
 
 #include <string>
 #include <vector>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include "ApplicationInformation.h"
 
index 03b31e2..94f5a5b 100755 (executable)
@@ -19,7 +19,7 @@
 
 #include <string>
 #include <vector>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 
 namespace TizenApis {
index 14b4364..673ed85 100755 (executable)
@@ -19,7 +19,7 @@
 
 #include <string>
 #include <vector>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 
 namespace TizenApis {
index a1cf029..9a4c047 100755 (executable)
@@ -17,7 +17,7 @@
 #ifndef TIZENAPIS_API_APPLICATION_SERVICE_REPLY_H_
 #define TIZENAPIS_API_APPLICATION_SERVICE_REPLY_H_
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include "ApplicationServiceExtraData.h"
 
index 10e6eaa..730839c 100755 (executable)
@@ -19,7 +19,7 @@
 
 #include <string>
 #include <vector>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include <app_service.h>
 #include "ApplicationServiceExtraData.h"
old mode 100755 (executable)
new mode 100644 (file)
index 5e868b5..36f66f9
@@ -20,6 +20,7 @@
 #include <Bluetooth/BluetoothAdapterManager.h>
 #include <Bluetooth/BluetoothDeviceManager.h>
 #include <Bluetooth/BluetoothSocketManager.h>
+#include <Bluetooth/BluetoothServiceHandlerManager.h>
 #include "BluetoothFactory.h"
 
 namespace TizenApis {
@@ -42,6 +43,11 @@ IBluetoothSocketManagerPtr BluetoothFactory::getBluetoothSocketManager()
        return IBluetoothSocketManagerPtr( new Platform::Bluetooth::BluetoothSocketManager() );
 }              
 
+IBluetoothServiceHandlerManagerPtr BluetoothFactory::getBluetoothServiceHandlerManager()
+{
+       return IBluetoothServiceHandlerManagerPtr( new Platform::Bluetooth::BluetoothServiceHandlerManager() );
+}
+
 
 BluetoothFactory& BluetoothFactory::getInstance() 
 {
old mode 100755 (executable)
new mode 100644 (file)
index 511cb3c..15c24cf
@@ -23,7 +23,7 @@
 #include "IBluetoothAdapterManager.h"
 #include "IBluetoothDeviceManager.h"
 #include "IBluetoothSocketManager.h"
-
+#include "IBluetoothServiceHandlerManager.h"
 
 namespace TizenApis {
 namespace Api {
@@ -35,6 +35,8 @@ public:
        IBluetoothAdapterManagerPtr getBluetoothAdapterManager();
        IBluetoothDeviceManagerPtr getBluetoothDeviceManager();
        IBluetoothSocketManagerPtr getBluetoothSocketManager();
+       IBluetoothServiceHandlerManagerPtr getBluetoothServiceHandlerManager();
+
        static BluetoothFactory& getInstance();
 
 protected:
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 465ae40..28fb235
 
 #include <Commons/IEvent.h>
 #include <dpl/shared_ptr.h>
-#include <Commons/ListenerEvent.h>
-#include <Commons/ListenerEventEmitter.h>
 #include "BTDevice.h"
 
 namespace TizenApis {
 namespace Api {
 namespace Bluetooth {
 
-class EventBTRegisterRFCOMM : public WrtDeviceApis::Commons::ListenerEvent<EventBTRegisterRFCOMM>
+class EventBTRegisterRFCOMM :
+    public WrtDeviceApis::Commons::IEvent<EventBTRegisterRFCOMM>
 {
-public :
-       typedef enum 
-       {
-               REGISTER_SUCCESS,
-               REGISTER_CONNECTED,
-               REGISTER_DISCONNECTED
-       } EventBTRegisterConnectionState;
-
 private:
-       EventBTRegisterConnectionState m_State;
-       BluetoothSocketData m_socket;
+       std::string m_uuid;
+       std::string m_name;
+       int m_registerSocket;
+       int m_securityLevel;
 public:
-       EventBTRegisterRFCOMM();
-       ~EventBTRegisterRFCOMM();
-       void setSocketData(BluetoothSocketData socket);
-       BluetoothSocketData getSocketData();
-       void setConnectionState(EventBTRegisterConnectionState state) {m_State = state;}
-       EventBTRegisterConnectionState getConnectionState() { return m_State;}
-
+       EventBTRegisterRFCOMM() { m_uuid = ""; m_registerSocket = -1;}
+       ~EventBTRegisterRFCOMM() {}
+       void setUuid(std::string uuid) { m_uuid = uuid;}
+       void setSocketFd(int registerSocketFd) { m_registerSocket = registerSocketFd;}
+       void setSecurityLevel(int securityLevel) { m_securityLevel = securityLevel;}
+       void setName(std::string name) { m_name = name;}
+       std::string getName() { return m_name;}
+       int getSecurityLevel() { return m_securityLevel; }
+       std::string getUuid() { return m_uuid;}
+       int getSocketFd() { return m_registerSocket;}
 };
 
 typedef DPL::SharedPtr<EventBTRegisterRFCOMM> EventBTRegisterRFCOMMPtr;
-typedef WrtDeviceApis::Commons::ListenerEventEmitter<EventBTRegisterRFCOMM> EventBTRegisterRFCOMMEmitter;
-typedef DPL::SharedPtr<EventBTRegisterRFCOMMEmitter> EventBTRegisterRFCOMMEmitterPtr;
 
 }
 }
diff --git a/src/platform/API/Bluetooth/EventBTServiceOnConnect.cpp b/src/platform/API/Bluetooth/EventBTServiceOnConnect.cpp
new file mode 100644 (file)
index 0000000..38aa984
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+
+
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include "EventBTServiceOnConnect.h"
+#include "BTDevice.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Bluetooth {
+
+EventBTServiceOnConnect::EventBTServiceOnConnect()
+{
+       
+}
+
+EventBTServiceOnConnect::~EventBTServiceOnConnect()
+{
+}
+
+void EventBTServiceOnConnect::setSocketData(BluetoothSocketData socketData) 
+{ 
+       m_socketData = socketData;
+}
+
+BluetoothSocketData EventBTServiceOnConnect::getSocketData() 
+{ 
+       return m_socketData;
+}
+
+
+
+}
+}
+}
+
diff --git a/src/platform/API/Bluetooth/EventBTServiceOnConnect.h b/src/platform/API/Bluetooth/EventBTServiceOnConnect.h
new file mode 100644 (file)
index 0000000..d9a2254
--- /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_BLUETOOTH_SERVICE_ON_CONNECT_H_
+#define TIZENAPIS_API_BLUETOOTH_SERVICE_ON_CONNECT_H_
+
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include <Commons/ListenerEvent.h>
+#include <Commons/ListenerEventEmitter.h>
+#include "BTDevice.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Bluetooth {
+
+class EventBTServiceOnConnect : public WrtDeviceApis::Commons::ListenerEvent<EventBTServiceOnConnect>
+{
+private:
+       BluetoothSocketData m_socketData;
+public:
+       EventBTServiceOnConnect() {}
+       ~EventBTServiceOnConnect() {} 
+
+       void setSocketData(BluetoothSocketData socketData)
+       { 
+               m_socketData = socketData;
+       }
+       
+       BluetoothSocketData getSocketData()
+       {
+               return m_socketData;
+       }
+
+};
+
+typedef DPL::SharedPtr<EventBTServiceOnConnect> EventBTServiceOnConnectPtr;
+typedef WrtDeviceApis::Commons::ListenerEventEmitter<EventBTServiceOnConnect> EventBTServiceOnConnectEmitter;
+typedef DPL::SharedPtr<EventBTServiceOnConnectEmitter> EventBTServiceOnConnectEmitterPtr;
+
+}
+}
+}
+
+#endif 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 1963d09..cef2737 100644 (file)
@@ -29,13 +29,8 @@ namespace Bluetooth {
 class EventBTUnregisterRFCOMMService : public WrtDeviceApis::Commons::IEvent<EventBTUnregisterRFCOMMService>
 {
 public:
-       EventBTUnregisterRFCOMMService() { m_serviceSocket = -1;}
+       EventBTUnregisterRFCOMMService() { }
        ~EventBTUnregisterRFCOMMService() { }
-       void setUnregisterSocket(int socket) { m_serviceSocket = socket;}
-       int getUnregisterSocket() { return m_serviceSocket;}
-private:
-       int m_serviceSocket;
-       
 };
 
 typedef DPL::SharedPtr<EventBTUnregisterRFCOMMService> EventBTUnregisterRFCOMMServicePtr;
old mode 100755 (executable)
new mode 100644 (file)
similarity index 93%
rename from src/platform/API/Bluetooth/IBluetoothManager.cpp
rename to src/platform/API/Bluetooth/IBluetoothAdapterManager.cpp
index cc6852e..803d849
@@ -32,8 +32,9 @@ IBluetoothAdapterManager::IBluetoothAdapterManager() :
        EventRequestReceiver<EventBTSetPowered>(ThreadEnum::BLUETOOTH_THREAD),
        EventRequestReceiver<EventBTSetVisible>(ThreadEnum::BLUETOOTH_THREAD),
        EventRequestReceiver<EventBTSetName>(ThreadEnum::BLUETOOTH_THREAD),
-       EventRequestReceiver<EventBTUnregisterRFCOMMService>(ThreadEnum::BLUETOOTH_THREAD),
-       EventRequestReceiver<EventBTStopDiscovery>(ThreadEnum::BLUETOOTH_THREAD)
+       EventRequestReceiver<EventBTStopDiscovery>(ThreadEnum::BLUETOOTH_THREAD),
+       EventRequestReceiver<EventBTRegisterRFCOMM>(ThreadEnum::BLUETOOTH_THREAD)
+       
        
 {
 }
old mode 100755 (executable)
new mode 100644 (file)
index f90a221..883668a
@@ -25,7 +25,6 @@
 #include <API/Bluetooth/EventBTGetDevice.h>
 #include <API/Bluetooth/EventBTSetPowered.h>
 #include <API/Bluetooth/EventBTRegisterRFCOMM.h>
-#include <API/Bluetooth/EventBTUnregisterRFCOMM.h>
 #include <API/Bluetooth/EventBTSetVisible.h>
 #include <API/Bluetooth/EventBTOnDiscoveryDevices.h>
 #include <API/Bluetooth/EventBTSetName.h>
@@ -45,8 +44,8 @@ class IBluetoothAdapterManager :
        public WrtDeviceApis::Commons::EventRequestReceiver<EventBTSetPowered>,
        public WrtDeviceApis::Commons::EventRequestReceiver<EventBTSetVisible>,
        public WrtDeviceApis::Commons::EventRequestReceiver<EventBTSetName>,
-       public WrtDeviceApis::Commons::EventRequestReceiver<EventBTUnregisterRFCOMMService>,
-       public WrtDeviceApis::Commons::EventRequestReceiver<EventBTStopDiscovery>
+       public WrtDeviceApis::Commons::EventRequestReceiver<EventBTStopDiscovery>,
+       public WrtDeviceApis::Commons::EventRequestReceiver<EventBTRegisterRFCOMM>
        
 {
 public:
@@ -58,9 +57,7 @@ public:
        virtual void getDevice(const EventBTGetDevicePtr& event) = 0;
        virtual void createBonding(const EventBTCreateDestroyBondingPtr& event) = 0;
        virtual void destroyBonding(const EventBTCreateDestroyBondingPtr& event) = 0;
-       virtual long registerRFCOMMServiceByUUID(const EventBTRegisterRFCOMMEmitterPtr& emitter,
-                       std::string uuid, std::string name, unsigned short int security) = 0;
-       virtual void unregisterRFCOMMService(const EventBTUnregisterRFCOMMServicePtr& event) = 0;
+       virtual void registerRFCOMMServiceByUUID(const EventBTRegisterRFCOMMPtr& event) = 0;
        virtual void stopDiscovery(const EventBTStopDiscoveryPtr& event) = 0;
        virtual void setAdapterName(const EventBTSetNamePtr& event) = 0;
        virtual std::string getName() = 0;
@@ -71,13 +68,14 @@ public:
 protected:
        IBluetoothAdapterManager();
 
-       virtual void OnRequestReceived(const EventBTSetPoweredPtr& event) = 0;
-       virtual void OnRequestReceived(const EventBTSetVisiblePtr& event) = 0;
+       virtual void OnRequestReceived(const EventBTCreateDestroyBondingPtr& event) = 0;
        virtual void OnRequestReceived(const EventBTGetKnownDevicesPtr& event) = 0;
        virtual void OnRequestReceived(const EventBTGetDevicePtr& event) = 0;
-       virtual void OnRequestReceived(const EventBTCreateDestroyBondingPtr& event) = 0;
+       virtual void OnRequestReceived(const EventBTSetPoweredPtr& event) = 0;
+       virtual void OnRequestReceived(const EventBTSetVisiblePtr& event) = 0;
        virtual void OnRequestReceived(const EventBTSetNamePtr& event) = 0;
-
+       virtual void OnRequestReceived(const EventBTStopDiscoveryPtr& event) = 0;       
+       virtual void OnRequestReceived(const EventBTRegisterRFCOMMPtr& event) = 0;      
 };
 
 typedef DPL::SharedPtr<IBluetoothAdapterManager> IBluetoothAdapterManagerPtr;
old mode 100755 (executable)
new mode 100644 (file)
similarity index 67%
rename from src/platform/API/Bluetooth/EventBTRegisterRFCOMM.cpp
rename to src/platform/API/Bluetooth/IBluetoothServiceHandlerManager.cpp
index b079a4f..3a31444
  * limitations under the License. 
  */
 
-#include "EventBTRegisterRFCOMM.h"
+
+#include "IBluetoothServiceHandlerManager.h"
+
+using namespace WrtDeviceApis::Commons;
 
 namespace TizenApis {
 namespace Api {
 namespace Bluetooth {
 
 
-EventBTRegisterRFCOMM::EventBTRegisterRFCOMM() 
-{ 
-       LogDebug("entered"); 
-}
-EventBTRegisterRFCOMM::~EventBTRegisterRFCOMM() 
-{ 
-}
-
-       
-void EventBTRegisterRFCOMM::setSocketData(BluetoothSocketData socket) 
+IBluetoothServiceHandlerManager::IBluetoothServiceHandlerManager() :
+       EventRequestReceiver<EventBTUnregisterRFCOMMService>(ThreadEnum::BLUETOOTH_THREAD)
 {
-       m_socket = socket;
 }
 
-BluetoothSocketData EventBTRegisterRFCOMM::getSocketData() 
-{ 
-       return m_socket;
+IBluetoothServiceHandlerManager::~IBluetoothServiceHandlerManager() {
 }
-
 }
+
 }
 }
 
-
diff --git a/src/platform/API/Bluetooth/IBluetoothServiceHandlerManager.h b/src/platform/API/Bluetooth/IBluetoothServiceHandlerManager.h
new file mode 100644 (file)
index 0000000..da8b940
--- /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 TIZENAPIS_API_IBLUETOOTH_SERVICE_HANDLER_MANAGER_H_
+#define TIZENAPIS_API_IBLUETOOTH_SERVICE_HANDLER_MANAGER_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/ThreadPool.h>
+#include <API/Bluetooth/EventBTUnregisterRFCOMM.h>
+#include <API/Bluetooth/EventBTServiceOnConnect.h>
+
+using namespace TizenApis::Api;
+
+namespace TizenApis {
+namespace Api {
+namespace Bluetooth {
+
+
+class IBluetoothServiceHandlerManager :
+       public WrtDeviceApis::Commons::EventRequestReceiver<EventBTUnregisterRFCOMMService>
+{
+public:
+       virtual ~IBluetoothServiceHandlerManager();
+       virtual void unRegister(const EventBTUnregisterRFCOMMServicePtr &event) = 0;
+       virtual int setServiceHandlerListener(const EventBTServiceOnConnectEmitterPtr& emitter) = 0;
+       virtual void setUUID(std::string uuid) = 0;
+       virtual std::string getUUID() = 0;
+       virtual void setRegisterSocket(int socket) = 0;
+       virtual void setName(std::string name) = 0;
+       virtual void setIsConnected(bool connected) = 0;
+       virtual std::string getName() = 0;
+       virtual bool getIsConnected() = 0;
+protected:
+       IBluetoothServiceHandlerManager();
+       virtual void OnRequestReceived(const EventBTUnregisterRFCOMMServicePtr& event) = 0;     
+};
+
+typedef DPL::SharedPtr<IBluetoothServiceHandlerManager> IBluetoothServiceHandlerManagerPtr;
+
+}
+}
+}
+#endif
index 857bcd1..b1f6ac2 100644 (file)
@@ -41,6 +41,7 @@ public:
        virtual unsigned int getState() = 0;
        virtual BluetoothDeviceData getPeer() = 0;
        virtual int setSocketNotifier(EventBTSocketNotificationEmitterPtr emitter) = 0;
+       virtual EventBTSocketNotificationEmitterPtr getSocketNotifier() = 0;
        virtual int writeData(const char *data, const unsigned int length) = 0;
        virtual EventBTReadDataType readData() = 0;
        virtual int close() = 0;
index e50e0bb..57b17a6 100644 (file)
@@ -4,11 +4,12 @@ set(SRCS_PLATFORM_API_BLUETOOTH
   ${CURRENT_PATH}/BluetoothFactory.cpp
   ${CURRENT_PATH}/EventBTGetKnownDevices.cpp
   ${CURRENT_PATH}/EventBTGetDevice.cpp
-  ${CURRENT_PATH}/EventBTRegisterRFCOMM.cpp
   ${CURRENT_PATH}/EventBTOnDiscoveryDevices.cpp
   ${CURRENT_PATH}/EventBTSocketNotification.cpp
-  ${CURRENT_PATH}/IBluetoothManager.cpp
+  ${CURRENT_PATH}/IBluetoothAdapterManager.cpp
   ${CURRENT_PATH}/IBluetoothDeviceManager.cpp
   ${CURRENT_PATH}/IBluetoothSocketManager.cpp
+  ${CURRENT_PATH}/IBluetoothServiceHandlerManager.cpp
+  ${CURRENT_PATH}/IBluetoothSocketManager.cpp
   PARENT_SCOPE
 )
index 4442b5f..16a043c 100755 (executable)
@@ -15,7 +15,7 @@
  */
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/Exception.h>
 #include "CalendarEvent.h"
 
@@ -27,8 +27,10 @@ CalendarEvent::CalendarEvent() :
     m_calendarId(UNDEFINED_CALENDAR_ID),
     m_status(UNDEFINED_STATUS),
     m_categories(new CategoryList()),
+    m_isAllDay(false),
     m_recurrenceId(0),
     m_isDetached(false),
+    m_geolocation(new CalendarItemGeo()),
     m_calendarType(EVENT_TYPE)
 {
 }
@@ -170,6 +172,7 @@ void CalendarEvent::display() const
 {
     LogDebug("m_id " << m_id);
     LogDebug("m_calendarId " << m_calendarId);
+    LogDebug("m_calendarType " << m_calendarType);
     LogDebug("m_description " << m_description);
     LogDebug("m_subject " << m_subject);
     LogDebug("m_startTime " << m_startTime);
@@ -293,24 +296,14 @@ void CalendarEvent::setAttributesOfInterest(AttributeListPtr value)
     m_attributesOfInterest = value;
 }
 
-double CalendarEvent::getLatitude() const
+CalendarItemGeoPtr CalendarEvent::getGeolocation() const
 {
-    return m_latitude;
+    return m_geolocation;
 }
 
-void CalendarEvent::setLatitude(double value)
+void CalendarEvent::setGeolocation(CalendarItemGeoPtr value)
 {
-    m_latitude = value;
-}
-
-double CalendarEvent::getLongitude() const
-{
-    return m_longitude;
-}
-
-void CalendarEvent::setLongitude(double value)
-{
-    m_longitude = value;
+    m_geolocation = value;
 }
 
 std::string CalendarEvent::getTimeZone() const
index 61804a8..59fb856 100755 (executable)
@@ -24,6 +24,7 @@
 #include <dpl/optional.h>
 #include <dpl/shared_ptr.h>
 
+#include "CalendarItemGeo.h"
 #include "EventAttendee.h"
 #include "EventRecurrenceRule.h"
 
@@ -182,11 +183,8 @@ class CalendarEvent
     void setAttributesOfInterest(AttributeListPtr value);
     AttributeListPtr getAttributesOfInterest() const;
 
-    void setLatitude(double value);
-    double getLatitude() const;
-
-    void setLongitude(double value);
-    double getLongitude() const;
+    void setGeolocation(CalendarItemGeoPtr value);
+    CalendarItemGeoPtr getGeolocation() const;
 
     void setTimeZone(std::string value);
     std::string getTimeZone() const;
@@ -229,8 +227,7 @@ class CalendarEvent
     EventAttendeeListPtr m_attendees;
     bool m_isDetached;
     AttributeListPtr m_attributesOfInterest;
-    double m_latitude;
-    double m_longitude;
+    CalendarItemGeoPtr m_geolocation;
     std::string m_timeZone;
     TaskPriority m_priority;
     std::time_t m_createdDate;
diff --git a/src/platform/API/Calendar/CalendarItemGeo.cpp b/src/platform/API/Calendar/CalendarItemGeo.cpp
new file mode 100755 (executable)
index 0000000..e05e69b
--- /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 "CalendarItemGeo.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Calendar {
+
+CalendarItemGeo::CalendarItemGeo()
+{
+    m_latitude = GEO_UNDEFINED;
+    m_longitude = GEO_UNDEFINED;
+}
+
+CalendarItemGeo::~CalendarItemGeo()
+{
+}
+
+double CalendarItemGeo::getLatitude() const
+{
+    return m_latitude;
+}
+
+void CalendarItemGeo::setLatitude(const double &value)
+{
+    m_latitude = value;
+}
+
+double CalendarItemGeo::getLongitude() const
+{
+    return m_longitude;
+}
+
+void CalendarItemGeo::setLongitude(const double &value)
+{
+    m_longitude = value;
+}
+
+}
+}
+}
diff --git a/src/platform/API/Calendar/CalendarItemGeo.h b/src/platform/API/Calendar/CalendarItemGeo.h
new file mode 100755 (executable)
index 0000000..d5afc27
--- /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 _CALENDAR_ITEM_GEO_H_
+#define _CALENDAR_ITEM_GEO_H_
+
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Calendar {
+
+class CalendarItemGeo
+{
+  public:
+
+       enum GeoValue{
+               GEO_LATITUDE_MIN = -90,
+               GEO_LATITUDE_MAX = 90,
+               GEO_LONGITUDE_MIN = -180,
+               GEO_LONGITUDE_MAX = 180,
+               GEO_UNDEFINED = -999
+       };
+
+    CalendarItemGeo();
+    virtual ~CalendarItemGeo();
+
+    double getLatitude() const;
+    void setLatitude(const double &value);
+
+    double getLongitude() const;
+    void setLongitude(const double &value);
+
+  protected:
+    double m_latitude;
+    double m_longitude;
+};
+
+typedef DPL::SharedPtr<CalendarItemGeo> CalendarItemGeoPtr;
+
+}
+}
+}
+
+#endif /* _CALENDAR_ITEM_GEO_H_ */
index 9f58bb0..ee0f089 100755 (executable)
@@ -16,7 +16,7 @@
 
 
 #include "EventAlarm.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 namespace TizenApis {
 namespace Api {
@@ -25,8 +25,6 @@ namespace Calendar {
 EventAlarm::EventAlarm()
 {
     m_absoluteDate = 0;
-    m_minutes = 0;
-    m_days = 0;
 }
 EventAlarm::~EventAlarm()
 {
@@ -41,40 +39,31 @@ void EventAlarm::setAbsoluteDate(const std::time_t &value)
     m_absoluteDate = value;
 }
 
-std::string EventAlarm::getTimeZone() const
-{
-    return m_timeZone;
-}
-void EventAlarm::setTimeZone(const std::string &value)
-{
-    m_timeZone = value;
-}
-
-long EventAlarm::getMinutes() const
+TizenApis::Api::TimeUtil::DurationProperties EventAlarm::getDuration() const
 {
-    return m_minutes;
+    return m_duration;
 }
-void EventAlarm::setMinutes(const long &value)
+void EventAlarm::setDuration(TizenApis::Api::TimeUtil::DurationProperties value)
 {
-    m_minutes = value;
+    m_duration = value;
 }
 
-long EventAlarm::getDays() const
+std::vector<CalendarEvent::EventAlarmType> EventAlarm::getMethods() const
 {
-    return m_days;
+    return m_methods;
 }
-void EventAlarm::setDays(const long &value)
+void EventAlarm::setMethods(const std::vector<CalendarEvent::EventAlarmType> &value)
 {
-    m_days = value;
+    m_methods = value;
 }
 
-std::vector<int> EventAlarm::getMethods() const
+std::string EventAlarm::getTimeZone() const
 {
-    return m_methods;
+    return m_timeZone;
 }
-void EventAlarm::setMethods(const std::vector<int> &value)
+void EventAlarm::setTimeZone(const std::string &value)
 {
-    m_methods = value;
+    m_timeZone = value;
 }
 
 }
index 4e3062c..89b7962 100755 (executable)
@@ -22,6 +22,8 @@
 #include <ctime>
 #include <string>
 #include <dpl/shared_ptr.h>
+#include "CalendarEvent.h"
+#include "API/TimeUtil/DurationProperties.h"
 
 namespace TizenApis {
 namespace Api {
@@ -36,24 +38,20 @@ class EventAlarm
     std::time_t getAbsoluteDate() const;
     void setAbsoluteDate(const std::time_t &value);
 
-    std::string getTimeZone() const;
-    void setTimeZone(const std::string &value);
-
-    long getMinutes() const;
-    void setMinutes(const long &value);
+    TizenApis::Api::TimeUtil::DurationProperties getDuration() const;
+    void setDuration(TizenApis::Api::TimeUtil::DurationProperties value);
 
-    long getDays() const;
-    void setDays(const long &value);
+    std::vector<CalendarEvent::EventAlarmType> getMethods() const;
+    void setMethods(const std::vector<CalendarEvent::EventAlarmType> &value);
 
-    std::vector<int> getMethods() const;
-    void setMethods(const std::vector<int> &value);
+    std::string getTimeZone() const;
+    void setTimeZone(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_timeZone;
-    long m_minutes;
-    long m_days;
-    std::vector<int> m_methods;
 };
 
 typedef DPL::SharedPtr<EventAlarm> EventAlarmPtr;
index 604379a..8f129c7 100755 (executable)
@@ -16,7 +16,7 @@
 
 
 #include "EventAttendee.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 /**
  * @file        EventAttendee.cpp
index c44a9d9..495fb0c 100755 (executable)
@@ -16,7 +16,7 @@
 
 
 #include "EventFilter.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 /**
  * @file        EventFilter.cpp
index 73ff075..8c6ffd7 100755 (executable)
 
 
 #include "EventId.h"
-#include <dpl/log.h>
-
-/**
- * @file        EventId.cpp
- *
- * @version     0.1
- */
 
 namespace TizenApis {
 namespace Api {
index d35c1e1..49b968b 100755 (executable)
@@ -17,7 +17,7 @@
 
 #include "EventRecurrenceRule.h"
 #include <Commons/Exception.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 /**
  * @file        EventRecurrenceRule.cpp
index 1f79e6b..d78a018 100755 (executable)
@@ -19,7 +19,8 @@
 #define _ABSTRACT_LAYER_ICALENDAR_H_
 
 #include <string>
-#include <dpl/log.h>
+#include <sstream>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include "CalendarEvent.h"
 #include "EventFilter.h"
@@ -98,9 +99,11 @@ class ICalendar : public WrtDeviceApis::Commons::EventRequestReceiver< IEventAdd
     {
         return m_id;
     }
-    virtual void                setId(const std::string &value)
+    virtual void                setId(const int value)
     {
-        m_id = value;
+        std::stringstream ss;
+        ss<<value;
+        m_id = ss.str();
     }
 
     virtual int                 getAccountId() const
index f6c6bb3..9227227 100755 (executable)
@@ -9,5 +9,6 @@ set(SRCS_PLATFORM_API_CALENDAR
   ${CURRENT_PATH}/EventRecurrenceRule.cpp
   ${CURRENT_PATH}/EventId.cpp
   ${CURRENT_PATH}/EventAlarm.cpp
+  ${CURRENT_PATH}/CalendarItemGeo.cpp
   PARENT_SCOPE
-)
\ No newline at end of file
+)
index 3c2bcbe..ff1f6eb 100755 (executable)
@@ -27,7 +27,7 @@
 #include <ctime>
 #include <string>
 #include <vector>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include "ContactProperties.h"
 
index e98cb0f..a0ca03c 100755 (executable)
@@ -27,7 +27,7 @@
 #include <ctime>
 #include <string>
 #include <vector>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include "ContactTypes.h"
 #include "ContactName.h"
index 7eb72d2..42c823a 100755 (executable)
@@ -26,7 +26,7 @@
 
 #include <vector>
 #include <string>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include <Commons/EventReceiver.h>
 #include "EventAddressBookAddBatch.h"
diff --git a/src/platform/API/Filesystem/Enums.h b/src/platform/API/Filesystem/Enums.h
new file mode 100755 (executable)
index 0000000..95003dc
--- /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. 
+ */
+
+#ifndef TIZENAPIS_FILESYSTEM_ENUMS_H_
+#define TIZENAPIS_FILESYSTEM_ENUMS_H_
+
+#include <string>
+#include <map>
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+enum LocationType
+{
+    LT_APPS,
+    LT_DOCUMENTS,
+    LT_DOWNLOADS,
+    LT_GAMES,
+    LT_IMAGES,
+    LT_OTHERS,
+    LT_ROOT,
+    LT_SDCARD,
+    LT_SOUNDS,
+    LT_TEMP,
+    LT_VIDEOS
+};
+
+enum NodeType
+{
+    NT_DIRECTORY,
+    NT_FILE
+};
+
+enum AccessMode
+{
+    AM_READ     = 0x0001,
+    AM_WRITE    = 0x0002,
+    AM_APPEND   = 0x0004
+};
+
+/**
+ * Used in @see IManager::access().
+ */
+enum AccessType
+{
+    AT_EXISTS   = 0x0000, //!< AT_EXISTS - checks for existence
+    AT_READ     = 0x0001, //!< AT_READ   - checks for read access
+    AT_WRITE    = 0x0002, //!< AT_WRITE  - checks for write access
+    AT_EXEC     = 0x0004 //!< AT_EXEC   - checks for execution access
+};
+
+enum Permissions
+{
+    PERM_NONE   = 0x0000,
+    PERM_READ   = 0x0001,
+    PERM_WRITE  = 0x0002
+};
+
+enum PlatformMode
+{
+    PM_USER_READ    = 0x0100,
+    PM_USER_WRITE   = 0x0080,
+    PM_USER_EXEC    = 0x0040,
+    PM_GROUP_READ   = 0x0020,
+    PM_GROUP_WRITE  = 0x0010,
+    PM_GROUP_EXEC   = 0x0008,
+    PM_OTHER_READ   = 0x0004,
+    PM_OTHER_WRITE  = 0x0002,
+    PM_OTHER_EXEC   = 0x0001,
+    PM_NONE         = 0x0000
+};
+
+enum Options
+{
+    OPT_NONE        = 0x0000,
+    OPT_OVERWRITE   = 0x0001,
+    OPT_RECURSIVE   = 0x0002
+};
+
+enum FindFilter
+{
+    FF_NAME,
+    FF_CREATED,
+    FF_MODIFIED,
+    FF_SIZE
+};
+typedef std::map<FindFilter, std::string> FiltersMap;
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif /* TIZENAPIS_FILESYSTEM_ENUMS_H_ */
diff --git a/src/platform/API/Filesystem/EventCopy.cpp b/src/platform/API/Filesystem/EventCopy.cpp
new file mode 100755 (executable)
index 0000000..acd3df3
--- /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 "EventCopy.h"
+#include <dpl/assert.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+EventCopy::EventCopy(const IPathPtr& src,
+        const IPathPtr& dest) :
+    m_src(src),
+    m_dest(dest),
+    m_options(OPT_NONE)
+{
+    Assert(src && "Source path not set.");
+    Assert(dest && "Destination path not set.");
+}
+
+IPathPtr EventCopy::getDestination() const
+{
+    return m_dest;
+}
+
+IPathPtr EventCopy::getSource() const
+{
+    return m_src;
+}
+
+INodePtr EventCopy::getResult() const
+{
+    return m_result;
+}
+
+void EventCopy::setResult(const INodePtr& node)
+{
+    m_result = node;
+}
+
+int EventCopy::getOptions() const
+{
+    return m_options;
+}
+
+void EventCopy::setOptions(int options)
+{
+    m_options = options;
+}
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventCopy.h b/src/platform/API/Filesystem/EventCopy.h
new file mode 100755 (executable)
index 0000000..af5dc5a
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef TIZENAPIS_FILESYSTEM_EVENTCOPY_H_
+#define TIZENAPIS_FILESYSTEM_EVENTCOPY_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "IPath.h"
+#include "INode.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class EventCopy : public WrtDeviceApis::Commons::IEvent<EventCopy>
+{
+  public:
+    /**
+     * Creates new event object.
+     * @param src Path to source node.
+     * @param dest Path to destination node.
+     * @return New object.
+     */
+    EventCopy(const IPathPtr& src,
+            const IPathPtr& dest);
+
+    /**
+     * Gets destination path.
+     * @return Destination path.
+     */
+    IPathPtr getDestination() const;
+
+    /**
+     * Gets source path.
+     * @return Source path.
+     */
+    IPathPtr getSource() const;
+
+    /**
+     * Gets result node.
+     * @return Result node.
+     */
+    INodePtr getResult() const;
+
+    /**
+     * Sets result node.
+     * @param node Result node.
+     */
+    void setResult(const INodePtr& node);
+
+    /**
+     * Gets options.
+     * @return Options.
+     */
+    int getOptions() const;
+
+    /**
+     * Sets options.
+     * @param options Options.
+     */
+    void setOptions(int options);
+
+  private:
+    IPathPtr m_src;   ///< Source path.
+    IPathPtr m_dest;  ///< Destination path.
+    INodePtr m_result; ///< Result node.
+    int m_options;    ///< Options for copy action @see WrtPlugins::Api::Filesystem::Options.
+};
+
+typedef DPL::SharedPtr<EventCopy> EventCopyPtr;
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif // TIZENAPIS_FILESYSTEM_EVENTCOPY_H_
diff --git a/src/platform/API/Filesystem/EventCreate.cpp b/src/platform/API/Filesystem/EventCreate.cpp
new file mode 100755 (executable)
index 0000000..ed51ef6
--- /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. 
+ */
+
+#include "EventCreate.h"
+
+#include <dpl/assert.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+EventCreate::EventCreate(const IPathPtr& path,
+        NodeType type) :
+    m_path(path),
+    m_type(type),
+    m_options(OPT_NONE)
+{
+    Assert(path && "Path is not set.");
+}
+
+IPathPtr EventCreate::getPath() const
+{
+    return m_path;
+}
+
+NodeType EventCreate::getType() const
+{
+    return m_type;
+}
+
+int EventCreate::getOptions() const
+{
+    return m_options;
+}
+
+void EventCreate::setOptions(int options)
+{
+    m_options = options;
+}
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventCreate.h b/src/platform/API/Filesystem/EventCreate.h
new file mode 100755 (executable)
index 0000000..a01122a
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef TIZENAPIS_FILESYSTEM_EVENTCREATE_H_
+#define TIZENAPIS_FILESYSTEM_EVENTCREATE_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "IPath.h"
+#include "Enums.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class EventCreate : public WrtDeviceApis::Commons::IEvent<EventCreate>
+{
+  public:
+    /**
+     * Creates new event object.
+     * @param path Path to node to create.
+     * @param type Type of node to create.
+     * @return New object.
+     */
+    EventCreate(const IPathPtr& path,
+            NodeType type);
+
+    /**
+     * Gets path to the node.
+     * @return Path to node.
+     */
+    IPathPtr getPath() const;
+
+    /**
+     * Gets type of the node.
+     * @return Type of node.
+     */
+    NodeType getType() const;
+
+    /**
+     * Gets options.
+     * @return Options.
+     */
+    int getOptions() const;
+
+    /**
+     * Sets options.
+     * @param options Options.
+     */
+    void setOptions(int options);
+
+  private:
+    IPathPtr m_path;  ///< Path to node to create.
+    NodeType m_type;  ///< Type of the node.
+    int m_options;    ///< Options for create action @see WrtPlugins::Api::Filesystem::Options.
+};
+
+typedef DPL::SharedPtr<EventCreate> EventCreatePtr;
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif // TIZENAPIS_FILESYSTEM_EVENTCREATE_H_
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventFind.cpp b/src/platform/API/Filesystem/EventFind.cpp
new file mode 100755 (executable)
index 0000000..26b65bc
--- /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. 
+ */
+
+#include "EventFind.h"
+
+#include <Filesystem/Path.h>
+#include "INode.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+EventFind::EventFind(const IPathPtr& path) : m_path(path)
+{
+}
+
+IPathPtr EventFind::getPath() const
+{
+    return m_path;
+}
+
+NodeList EventFind::getResult() const
+{
+    return m_nodes;
+}
+
+void EventFind::addResult(const INodePtr& node)
+{
+    m_nodes.push_back(node);
+}
+
+void EventFind::setResult(const NodeList& nodes)
+{
+    m_nodes = nodes;
+}
+
+void EventFind::addFilter(FindFilter name,
+        const std::string& value)
+{
+    m_filters.insert(std::pair<FindFilter, std::string>(name, value));
+}
+
+FiltersMap EventFind::getFilters() const
+{
+    return m_filters;
+}
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventFind.h b/src/platform/API/Filesystem/EventFind.h
new file mode 100755 (executable)
index 0000000..952e3de
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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_IEVENTFILESYSTEMFIND_H_
+#define TIZENAPIS_IEVENTFILESYSTEMFIND_H_
+
+#include <list>
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "IPath.h"
+#include "INodeTypes.h"
+#include "Enums.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class EventFind : public WrtDeviceApis::Commons::IEvent<EventFind>
+{
+  public:
+    /**
+     * Creates new event object.
+     * @param path Start path.
+     * @return New object.
+     */
+    explicit EventFind(const IPathPtr& path);
+
+    /**
+     * Gets start path.
+     * @return Path to start searching from.
+     */
+    IPathPtr getPath() const;
+
+    /**
+     * Gets found nodes.
+     * @return Nodes.
+     */
+    NodeList getResult() const;
+
+    /**
+     * Adds found node.
+     * @param node Found node.
+     */
+    void addResult(const INodePtr& node);
+
+    /**
+     * Sets found nodes.
+     * @param nodes Nodes.
+     */
+    void setResult(const NodeList& nodes);
+
+    /**
+     * Adds find filter.
+     * @param name Filter name.
+     * @param value Filter value.
+     */
+    void addFilter(FindFilter name,
+            const std::string& value);
+
+    /**
+     * Gets all filters.
+     * @return Filters.
+     */
+    FiltersMap getFilters() const;
+
+  private:
+    IPathPtr m_path;    ///< Start path.
+    NodeList m_nodes;   ///< Resolved nodes.
+    FiltersMap m_filters; ///< Search filters.
+};
+
+typedef DPL::SharedPtr<EventFind> EventFindPtr;
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif /* TIZENAPIS_IEVENTFILESYSTEMFIND_H_ */
diff --git a/src/platform/API/Filesystem/EventGetStorage.cpp b/src/platform/API/Filesystem/EventGetStorage.cpp
new file mode 100755 (executable)
index 0000000..80c50b1
--- /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 "EventGetStorage.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+EventGetStorage::EventGetStorage()
+{
+}
+
+void EventGetStorage::setLabel(const std::string &Label)
+{
+       label = Label;
+}
+
+std::string EventGetStorage::getLabel() const
+{
+       return label;
+}
+
+void EventGetStorage::setResult (const StoragePropertiesPtr &Storages) 
+{ 
+       storages = Storages;
+}
+
+StoragePropertiesPtr EventGetStorage::getResult() const 
+{
+       return storages;
+}
+
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventGetStorage.h b/src/platform/API/Filesystem/EventGetStorage.h
new file mode 100755 (executable)
index 0000000..e45c034
--- /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_FILESYSTEM_EVENT_GET_STORAGE_H_
+#define TIZENAPIS_API_FILESYSTEM_EVENT_GET_STORAGE_H_
+
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include <string>
+#include "StorageProperties.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class EventGetStorage : public WrtDeviceApis::Commons::IEvent<
+        EventGetStorage>
+{
+  private:
+       std::string label;
+       StoragePropertiesPtr storages;
+  public:
+       void setLabel(const std::string &Label);
+       std::string getLabel() const;
+       void setResult (const StoragePropertiesPtr& Storages);
+       StoragePropertiesPtr getResult() const;
+       EventGetStorage();
+};
+
+typedef DPL::SharedPtr<EventGetStorage> EventGetStoragePtr;
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif //TIZENAPIS_API_FILESYSTEM_EVENT_GET_STORAGE_H_
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventListNodes.cpp b/src/platform/API/Filesystem/EventListNodes.cpp
new file mode 100755 (executable)
index 0000000..db09924
--- /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 "EventListNodes.h"
+#include <dpl/assert.h>
+#include "INode.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+EventListNodes::EventListNodes(const INodePtr& node) : m_node(node)
+{
+    Assert(m_node && "Node can't be NULL.");
+}
+
+INodePtr EventListNodes::getNode() const
+{
+    return m_node;
+}
+
+NodeFilterPtr EventListNodes::getFilter() const
+{
+    return m_filter;
+}
+
+void EventListNodes::setFilter(const NodeFilterPtr& filter)
+{
+    m_filter = filter;
+}
+
+NodeList EventListNodes::getResult() const
+{
+    return m_list;
+}
+
+void EventListNodes::setResult(const NodeList& list)
+{
+    m_list = list;
+}
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventListNodes.h b/src/platform/API/Filesystem/EventListNodes.h
new file mode 100755 (executable)
index 0000000..167fbb4
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef TIZENAPIS_FILESYSTEM_EVENTLISTNODES_H_
+#define TIZENAPIS_FILESYSTEM_EVENTLISTNODES_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "INodeTypes.h"
+#include "NodeFilter.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class EventListNodes : public WrtDeviceApis::Commons::IEvent<EventListNodes>
+{
+  public:
+    /**
+     * Creates new event object.
+     * @param path Node to list children for.
+     * @return New object.
+     */
+    explicit EventListNodes(const INodePtr& node);
+
+    /**
+     * Gets parent node.
+     * @return Parent node.
+     */
+    INodePtr getNode() const;
+
+    /**
+     * Gets filter.
+     * @return Filter.
+     */
+    NodeFilterPtr getFilter() const;
+
+    /**
+     * Sets filter.
+     * @param filter Filter to list only specific nodes.
+     */
+    void setFilter(const NodeFilterPtr& filter);
+
+    /**
+     * Gets nodes.
+     * @return Nodes list.
+     */
+    NodeList getResult() const;
+
+    /**
+     * Sets nodes list.
+     * @param list Nodes list.
+     */
+    void setResult(const NodeList& list);
+
+  private:
+    NodeList m_list;      ///< List of child nodes.
+    INodePtr m_node;      ///< Node to list children for.
+    NodeFilterPtr m_filter; ///< Filter.
+};
+
+typedef DPL::SharedPtr<EventListNodes> EventListNodesPtr;
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif // TIZENAPIS_FILESYSTEM_EVENTLISTNODES_H_
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventListStorages.cpp b/src/platform/API/Filesystem/EventListStorages.cpp
new file mode 100755 (executable)
index 0000000..138597b
--- /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 "EventListStorages.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+EventListStorages::EventListStorages()
+{
+}
+
+void EventListStorages::setResult (const std::vector<StoragePropertiesPtr>& Storages) 
+{ 
+       storages = Storages;
+}
+
+std::vector<StoragePropertiesPtr> EventListStorages::getResult() const 
+{
+       return storages;
+}
+
+} // Filesystem
+} // Api
+} // TizenApis
diff --git a/src/platform/API/Filesystem/EventListStorages.h b/src/platform/API/Filesystem/EventListStorages.h
new file mode 100755 (executable)
index 0000000..b3741ec
--- /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_API_FILESYSTEM_EVENT_LIST_STORAGES_H_
+#define TIZENAPIS_API_FILESYSTEM_EVENT_LIST_STORAGES_H_
+
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include <vector>
+#include "StorageProperties.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class EventListStorages : public WrtDeviceApis::Commons::IEvent<
+        EventListStorages>
+{
+  private:
+       std::vector<StoragePropertiesPtr> storages;
+  public:
+       void setResult (const std::vector<StoragePropertiesPtr>& Storages);
+       std::vector<StoragePropertiesPtr> getResult() const;
+       EventListStorages();
+};
+
+typedef DPL::SharedPtr<EventListStorages> EventListStoragesPtr;
+}
+}
+}
+
+#endif
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventMove.cpp b/src/platform/API/Filesystem/EventMove.cpp
new file mode 100755 (executable)
index 0000000..c5d1f76
--- /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 "EventMove.h"
+#include <dpl/assert.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+EventMove::EventMove(const IPathPtr& src,
+        const IPathPtr& dest) :
+    m_src(src),
+    m_dest(dest),
+    m_options(OPT_NONE)
+{
+    Assert(src && "Source path not set.");
+    Assert(dest && "Destination path not set.");
+}
+
+IPathPtr EventMove::getDestination() const
+{
+    return m_dest;
+}
+
+IPathPtr EventMove::getSource() const
+{
+    return m_src;
+}
+
+INodePtr EventMove::getResult() const
+{
+    return m_result;
+}
+
+void EventMove::setResult(const INodePtr& node)
+{
+    m_result = node;
+}
+
+int EventMove::getOptions() const
+{
+    return m_options;
+}
+
+void EventMove::setOptions(int options)
+{
+    m_options = options;
+}
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventMove.h b/src/platform/API/Filesystem/EventMove.h
new file mode 100755 (executable)
index 0000000..d208c98
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef TIZENAPIS_FILESYSTEM_EVENTMOVE_H_
+#define TIZENAPIS_FILESYSTEM_EVENTMOVE_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "IPath.h"
+#include "INode.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class EventMove : public WrtDeviceApis::Commons::IEvent<EventMove>
+{
+  public:
+    /**
+     * Creates new event object.
+     * @param src Source path.
+     * @param dest Destination path.
+     * @return New object.
+     */
+    EventMove(const IPathPtr& src,
+            const IPathPtr& dest);
+
+    /**
+     * Gets destination path.
+     * @return Destination path.
+     */
+    IPathPtr getDestination() const;
+
+    /**
+     * Gets source path.
+     * @return Source path.
+     */
+    IPathPtr getSource() const;
+
+    /**
+     * Gets result node.
+     * @return Result node.
+     */
+    INodePtr getResult() const;
+
+    /**
+     * Sets result node.
+     * @param node Result node.
+     */
+    void setResult(const INodePtr& node);
+
+    /**
+     * Gets options.
+     * @return Options.
+     */
+    int getOptions() const;
+
+    /**
+     * Sets options.
+     * @param options Options.
+     */
+    void setOptions(int options);
+
+  private:
+    IPathPtr m_src;   ///< Source path.
+    IPathPtr m_dest;  ///< Destination path.
+    INodePtr m_result; ///< Result node.
+    int m_options;    ///< Options for copy action @see WrtPlugins::Api::Filesystem::Options.
+};
+
+typedef DPL::SharedPtr<EventMove> EventMovePtr;
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif // TIZENAPIS_FILESYSTEM_EVENTMOVE_H_
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventOpen.cpp b/src/platform/API/Filesystem/EventOpen.cpp
new file mode 100755 (executable)
index 0000000..c1f47ca
--- /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 "EventOpen.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+EventOpen::EventOpen(int mode) : m_mode(mode)
+{
+}
+
+int EventOpen::getMode() const
+{
+    return m_mode;
+}
+
+IStreamPtr EventOpen::getResult() const
+{
+    return m_stream;
+}
+
+void EventOpen::setResult(const IStreamPtr& stream)
+{
+    m_stream = stream;
+}
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventOpen.h b/src/platform/API/Filesystem/EventOpen.h
new file mode 100755 (executable)
index 0000000..9112dd7
--- /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_FILESYSTEM_EVENTOPEN_H_
+#define TIZENAPIS_FILESYSTEM_EVENTOPEN_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "IStream.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class EventOpen : public WrtDeviceApis::Commons::IEvent<EventOpen>
+{
+  public:
+    /**
+     * Creates new event object.
+     * @param mode Mode to open the node in.
+     * @return New object.
+     */
+    explicit EventOpen(int mode);
+
+    /**
+     * Gets mode.
+     * @return Mode.
+     */
+    int getMode() const;
+
+    /**
+     * Gets result stream.
+     * @return Result stream.
+     */
+    IStreamPtr getResult() const;
+
+    /**
+     * Sets result stream.
+     * @param stream Result stream.
+     */
+    void setResult(const IStreamPtr& stream);
+
+  private:
+    int m_mode;         ///< Mode.
+    IStreamPtr m_stream; ///< Opened stream.
+};
+
+typedef DPL::SharedPtr<EventOpen> EventOpenPtr;
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif // TIZENAPIS_FILESYSTEM_EVENTOPEN_H_
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventReadText.cpp b/src/platform/API/Filesystem/EventReadText.cpp
new file mode 100755 (executable)
index 0000000..80c01da
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "EventReadText.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+std::string EventReadText::getResult() const
+{
+    return m_result;
+}
+
+void EventReadText::setResult(const std::string& result)
+{
+    m_result = result;
+}
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventReadText.h b/src/platform/API/Filesystem/EventReadText.h
new file mode 100755 (executable)
index 0000000..a5ba108
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef TIZENAPIS_FILESYSTEM_EVENTREADTEXT_H_
+#define TIZENAPIS_FILESYSTEM_EVENTREADTEXT_H_
+
+#include <string>
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "IPath.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class EventReadText : public WrtDeviceApis::Commons::IEvent<EventReadText>
+{
+  public:
+    /**
+     * Gets read text.
+     * @return Text.
+     */
+    std::string getResult() const;
+
+    /**
+     * Sets read text.
+     * @param result Text.
+     */
+    void setResult(const std::string& result);
+
+  private:
+    std::string m_result; ///< Read text.
+};
+
+typedef DPL::SharedPtr<EventReadText> EventReadTextPtr;
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif // TIZENAPIS_FILESYSTEM_EVENTREADTEXT_H_
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventRemove.cpp b/src/platform/API/Filesystem/EventRemove.cpp
new file mode 100755 (executable)
index 0000000..16da2cf
--- /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 "EventRemove.h"
+#include <dpl/assert.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+EventRemove::EventRemove(const IPathPtr& path) :
+    m_path(path),
+    m_options(OPT_NONE)
+{
+    Assert(m_path && "Path is not set.");
+}
+
+IPathPtr EventRemove::getPath() const
+{
+    return m_path;
+}
+
+int EventRemove::getOptions() const
+{
+    return m_options;
+}
+
+void EventRemove::setOptions(int options)
+{
+    m_options = options;
+}
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventRemove.h b/src/platform/API/Filesystem/EventRemove.h
new file mode 100755 (executable)
index 0000000..69cc705
--- /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 TIZENAPIS_FILESYSTEM_EVENTREMOVE_H_
+#define TIZENAPIS_FILESYSTEM_EVENTREMOVE_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "INode.h"
+#include "Enums.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class EventRemove : public WrtDeviceApis::Commons::IEvent<EventRemove>
+{
+  public:
+    /**
+     * Creates new event object.
+     * @param path Path to the node to remove.
+     * @return New object.
+     */
+    explicit EventRemove(const IPathPtr& path);
+
+    /**
+     * Gets path to the node to remove.
+     * @return Path.
+     */
+    IPathPtr getPath() const;
+
+    /**
+     * Gets options.
+     * @return Options.
+     */
+    int getOptions() const;
+
+    /**
+     * Sets options.
+     * @param options Options.
+     */
+    void setOptions(int options);
+
+  private:
+    IPathPtr m_path; ///< Source path.
+    int m_options;  ///< Options for remove action @see WrtPlugins::Api::Filesystem::Options.
+};
+
+typedef DPL::SharedPtr<EventRemove> EventRemovePtr;
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif // TIZENAPIS_FILESYSTEM_EVENTREMOVE_H_
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventResolve.cpp b/src/platform/API/Filesystem/EventResolve.cpp
new file mode 100755 (executable)
index 0000000..5839b1e
--- /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 "EventResolve.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+EventResolve::EventResolve(const IPathPtr& path) : m_path(path)
+{
+}
+
+IPathPtr EventResolve::getPath() const
+{
+    return m_path;
+}
+
+INodePtr EventResolve::getResult() const
+{
+    return m_node;
+}
+
+void EventResolve::setResult(const INodePtr& node)
+{
+    m_node = node;
+}
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventResolve.h b/src/platform/API/Filesystem/EventResolve.h
new file mode 100755 (executable)
index 0000000..5691c45
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef TIZENAPIS_FILESYSTEM_EVENTRESOLVE_H_
+#define TIZENAPIS_FILESYSTEM_EVENTRESOLVE_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "IPath.h"
+#include "INode.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class EventResolve : public WrtDeviceApis::Commons::IEvent<EventResolve>
+{
+  public:
+    /**
+     * Creates new event object.
+     * @param path Path to the node to resolve.
+     * @return New object.
+     */
+    explicit EventResolve(const IPathPtr& path);
+
+    /**
+     * Gets path of the node to resolve.
+     * @return Path to resolve.
+     */
+    IPathPtr getPath() const;
+
+    /**
+     * Gets resolved node.
+     * NULL if none found. Check exception code.
+     * @return Resolved node or NULL.
+     */
+    INodePtr getResult() const;
+
+    /**
+     * Sets resolved node.
+     * @param node Resolved node.
+     */
+    void setResult(const INodePtr& node);
+
+  private:
+    IPathPtr m_path; ///< Path to the requested node.
+    INodePtr m_node; ///< Resolved node.
+};
+
+typedef DPL::SharedPtr<EventResolve> EventResolvePtr;
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif // WRTPLUGINS_FILESYSTEM_EVENTRESOLVE_H_
diff --git a/src/platform/API/Filesystem/EventStorageStateChanged.h b/src/platform/API/Filesystem/EventStorageStateChanged.h
new file mode 100755 (executable)
index 0000000..04b46ed
--- /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_FILESYSTEM_EVENT_STORAGESTATE_CHANGED_H_
+#define TIZENAPIS_API_FILESYSTEM_EVENT_STORAGESTATE_CHANGED_H_
+
+#include <vector>
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include <Commons/ListenerEvent.h>
+#include <Commons/ListenerEventEmitter.h>
+#include "StorageProperties.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+
+class EventStorageStateChanged : public WrtDeviceApis::Commons::ListenerEvent<EventStorageStateChanged>
+{
+private:
+       StoragePropertiesPtr storages;
+
+public:
+       void setResult (const StoragePropertiesPtr& Storages);
+       StoragePropertiesPtr getResult() const;
+
+       EventStorageStateChanged();
+};
+
+typedef DPL::SharedPtr<EventStorageStateChanged> EventStorageStateChangedPtr;
+typedef WrtDeviceApis::Commons::ListenerEventEmitter<EventStorageStateChanged> EventStorageStateChangedEmitter;
+typedef DPL::SharedPtr<EventStorageStateChangedEmitter> EventStorageStateChangedEmitterPtr;
+
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif //TIZENAPIS_API_FILESYSTEM_EVENT_STORAGESTATE_CHANGED_H_
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/EventStoragestateChanged.cpp b/src/platform/API/Filesystem/EventStoragestateChanged.cpp
new file mode 100755 (executable)
index 0000000..93426b3
--- /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 "EventStorageStateChanged.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+EventStorageStateChanged::EventStorageStateChanged()
+{
+}
+
+void EventStorageStateChanged::setResult (const StoragePropertiesPtr &Storages) 
+{ 
+       storages = Storages;
+}
+
+StoragePropertiesPtr EventStorageStateChanged::getResult() const 
+{
+       return storages;
+}
+
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/IManager.cpp b/src/platform/API/Filesystem/IManager.cpp
new file mode 100755 (executable)
index 0000000..9a321a9
--- /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 <Filesystem/Manager.h>
+#include <Commons/ThreadPool.h>
+#include "IManager.h"
+
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+IManager& IManager::getInstance()
+{
+    static Platform::Filesystem::Manager instance;
+    return instance;
+}
+
+IManager::IManager() :
+    EventRequestReceiver<EventResolve>(ThreadEnum::FILESYSTEM_THREAD),
+    EventRequestReceiver<EventGetStorage>(ThreadEnum::FILESYSTEM_THREAD),
+    EventRequestReceiver<EventListStorages>(ThreadEnum::FILESYSTEM_THREAD),
+    EventRequestReceiver<EventCopy>(ThreadEnum::FILESYSTEM_THREAD),
+    EventRequestReceiver<EventMove>(ThreadEnum::FILESYSTEM_THREAD),
+    EventRequestReceiver<EventCreate>(ThreadEnum::FILESYSTEM_THREAD),
+    EventRequestReceiver<EventRemove>(ThreadEnum::FILESYSTEM_THREAD),
+    EventRequestReceiver<EventFind>(ThreadEnum::FILESYSTEM_THREAD)
+{
+}
+
+IManager::~IManager()
+{
+}
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/IManager.h b/src/platform/API/Filesystem/IManager.h
new file mode 100755 (executable)
index 0000000..526028f
--- /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_FILESYSTEM_IMANAGER_H_
+#define TIZENAPIS_FILESYSTEM_IMANAGER_H_
+
+#include <map>
+#include <vector>
+#include <string>
+#include <cstddef>
+#include <dpl/noncopyable.h>
+#include <Commons/EventReceiver.h>
+#include "EventResolve.h"
+#include "EventGetStorage.h"
+#include "EventListStorages.h"
+#include "EventStorageStateChanged.h"
+#include "EventCopy.h"
+#include "EventMove.h"
+#include "EventRemove.h"
+#include "EventCreate.h"
+#include "EventFind.h"
+#include "Enums.h"
+#include "INode.h"
+#include "IPath.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+typedef std::vector<IPathPtr> LocationPaths;
+
+typedef std::vector<LocationType> LocationTypes;
+
+typedef std::map<std::string, Api::Filesystem::IPathPtr> StorageList;
+
+class IManager : public WrtDeviceApis::Commons::EventRequestReceiver<EventResolve>,
+    public WrtDeviceApis::Commons::EventRequestReceiver<EventGetStorage>,
+    public WrtDeviceApis::Commons::EventRequestReceiver<EventListStorages>,
+    public WrtDeviceApis::Commons::EventRequestReceiver<EventCopy>,
+    public WrtDeviceApis::Commons::EventRequestReceiver<EventMove>,
+    public WrtDeviceApis::Commons::EventRequestReceiver<EventCreate>,
+    public WrtDeviceApis::Commons::EventRequestReceiver<EventRemove>,
+    public WrtDeviceApis::Commons::EventRequestReceiver<EventFind>
+{
+  public:
+    static IManager& getInstance();
+
+    virtual ~IManager() = 0;
+
+    /**
+     * Gets base path.
+     * @return Valid path or empty shared pointer.
+     */
+    virtual IPathPtr getBasePath() const = 0;
+
+    virtual StorageList getStorageList() const = 0;
+
+    /**
+     * Gets path for specified location type.
+     * @param type Location type @see WrtPlugins::Api::Filesystem::LocationType.
+     * @return Valid path or empty shared pointer.
+     */
+    virtual IPathPtr getLocationPath(LocationType type) const = 0;
+
+    /**
+     * Gets paths to default locations.
+     * @return Paths to predefined virtual locations.
+     */
+    virtual LocationPaths getLocationPaths() const = 0;
+
+    /**
+     * Gets locations supported by platform.
+     * @return Supported locations.
+     */
+    virtual LocationTypes getLocations() const = 0;
+
+    /**
+     * Gets filesystem node.
+     * @param event Get node event @see Api::Filesystem::EventGetNode.
+     * @remarks Asynchronous.
+     */
+    virtual void getNode(const EventResolvePtr& event) = 0;
+
+    /**
+     * Gets maximum length of filesystem path.
+     * @return Maximum path length.
+     */
+    virtual std::size_t getMaxPathLength() const = 0;
+
+    /**
+     * Copies node to specified destination.
+     * @param event Copy node event @see Api::Filesystem::EventCopy.
+     * @remarks Asynchronous.
+     */
+    virtual void copy(const EventCopyPtr& event) = 0;
+
+    /**
+     * Moves node to specified destination.
+     * @param event Move node event @see Api::Filesystem::EventMove.
+     * @remarks Asynchronous.
+     */
+    virtual void move(const EventMovePtr& event) = 0;
+
+    /**
+     * Creates a node.
+     * @param event Create node event @see Api::Filesystem::EventCreate.
+     * @remarks Asynchronous.
+     */
+    virtual void create(const EventCreatePtr& event) = 0;
+
+    /**
+     * Removes node.
+     * @param event Remove node event @see Api::Filesystem::EventRemove.
+     * @remarks Asynchronous.
+     */
+    virtual void remove(const EventRemovePtr& event) = 0;
+
+    /**
+     * Finds nodes.
+     * @param event Find nodes event @see Api::Filesystem::EventFind.
+     * @remarks Asynchronous.
+     */
+    virtual void find(const EventFindPtr& event) = 0;
+
+    /**
+     * Checks if node at specified path has supplied access rights.
+     * @param path Path to the node.
+     * @param accessType Access right(s) to check @see AccessType. Multiple values
+     *                   can be passed using OR operator.
+     * @return True if specified node has supplied access rights, false otherwise.
+     */
+    virtual bool access(const IPathPtr& path,
+            int accessType) const = 0;
+
+    virtual void addOpenedNode(const Api::Filesystem::INodePtr& node) = 0;
+    virtual void removeOpenedNode(const Api::Filesystem::INodePtr& node) = 0;
+    virtual bool checkIfOpened(const Api::Filesystem::IPathPtr& path) const = 0;
+
+    virtual void getStorage(const EventGetStoragePtr& event) = 0;
+    virtual void listStorages(const EventListStoragesPtr& event) = 0;
+
+    virtual long addStorageStateChangeListener(const EventStorageStateChangedEmitterPtr& emitter) = 0;
+    virtual void removeStorageStateChangeListener(EventStorageStateChangedEmitter::IdType id) = 0;
+
+  protected:
+    IManager();
+
+    virtual void OnRequestReceived(const EventResolvePtr& event) = 0;
+    virtual void OnRequestReceived(const EventGetStoragePtr& event) = 0;
+    virtual void OnRequestReceived(const EventListStoragesPtr& event) = 0;
+    virtual void OnRequestReceived(const EventCopyPtr& event) = 0;
+    virtual void OnRequestReceived(const EventMovePtr& event) = 0;
+    virtual void OnRequestReceived(const EventCreatePtr& event) = 0;
+    virtual void OnRequestReceived(const EventRemovePtr& event) = 0;
+    virtual void OnRequestReceived(const EventFindPtr& event) = 0;
+}; // IManager
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif // TIZENAPIS_FILESYSTEM_IMANAGER_H_
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/INode.cpp b/src/platform/API/Filesystem/INode.cpp
new file mode 100755 (executable)
index 0000000..4f364e4
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "INode.h"
+#include <Commons/ThreadPool.h>
+
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+INode::INode() :
+    EventRequestReceiver<EventListNodes>(ThreadEnum::FILESYSTEM_THREAD),
+    EventRequestReceiver<EventOpen>(ThreadEnum::FILESYSTEM_THREAD),
+    EventRequestReceiver<EventReadText>(ThreadEnum::FILESYSTEM_THREAD)
+{
+}
+
+INode::~INode()
+{
+}
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/INode.h b/src/platform/API/Filesystem/INode.h
new file mode 100755 (executable)
index 0000000..a09a0bf
--- /dev/null
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef TIZENAPIS_FILESYSTEM_INODE_H_
+#define TIZENAPIS_FILESYSTEM_INODE_H_
+
+#include <string>
+#include <vector>
+#include <ctime>
+#include <dpl/noncopyable.h>
+#include <dpl/shared_ptr.h>
+#include <Commons/Deprecated.h>
+#include <Commons/EventReceiver.h>
+#include "EventListNodes.h"
+#include "EventOpen.h"
+#include "EventReadText.h"
+#include "Enums.h"
+#include "IPath.h"
+#include "IStream.h"
+#include "INodeTypes.h"
+#include "NodeFilter.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class INode : public WrtDeviceApis::Commons::EventRequestReceiver<EventListNodes>,
+    public WrtDeviceApis::Commons::EventRequestReceiver<EventOpen>,
+    public WrtDeviceApis::Commons::EventRequestReceiver<EventReadText>
+{
+  public:
+    typedef std::vector<std::string> NameList;
+    typedef NameList::iterator NodeListIterator;
+
+  public:
+    virtual ~INode() = 0;
+
+    /**
+     * Gets direct child of this node.
+     * @param path Path to the child node.
+     * @return Ptr to the child node.
+     * @remarks Ownership passed to the caller.
+     */
+    virtual INodePtr getChild(const IPathPtr& path) = 0;
+
+    /**
+     * Gets path of current node.
+     * @return Node's path.
+     */
+    virtual IPathPtr getPath() const = 0;
+
+    /**
+     * Gets type of current node.
+     * @return Node's type.
+     */
+    virtual NodeType getType() const = 0;
+
+    /**
+     * Gets permissions of the virtual node (not real filesystem node).
+     * @return Node's permissions.
+     */
+    virtual int getPermissions() const = 0;
+
+    /**
+     * Sets permissions on the virtual node (not real filesystem node).
+     * @param perms Node's permissions @see Api::Filesystem::Permissions.
+     */
+    virtual void setPermissions(int perms) = 0;
+
+    /**
+     * Gets list of names of direct child nodes.
+     * @return Names of child nodes.
+     */
+    virtual NameList getChildNames() const = 0;
+
+    /**
+     * Gets list of direct child nodes.
+     * @return Child nodes.
+     * @remarks Ownership passed to the caller.
+     * @deprecated
+     */
+    virtual NodeList getChildNodes(const NodeFilterPtr& filter =
+                NodeFilterPtr()) const /* WRT_PLUGINS_DEPRECATED */ = 0;
+
+    /**
+     * Gets list of direct descendant nodes.
+     * @param event Get child nodes event.
+     */
+    virtual void getChildNodes(const EventListNodesPtr& event) = 0;
+
+    /**
+     * Gets stream for this node.
+     * @param mode @see Api::Filesystem::AccessMode.
+     * @return Stream connected with current node.
+     * @deprecated Use async version of thi method instead.
+     */
+    virtual IStreamPtr open(int mode) = 0;
+
+    /**
+     * Gets stream for this node.
+     * @param mode @see Api::Filesystem::AccessMode.
+     * @return Stream connected with current node.
+     */
+    virtual void open(const EventOpenPtr& event) = 0;
+
+    /**
+     * Removes underlying filesystem node.
+     * @param options Removal options (by default removal is recursive).
+     * @remarks Synchronous.
+     * Valid options:
+     * - OPT_RECURSIVE - remove node recursively.
+     */
+    virtual void remove(int options = OPT_RECURSIVE) = 0;
+
+    /**
+     * Creates child of current node.
+     * @param path Path to the node to create.
+     * @param type Type of the node @see Api::Filesystem::NodeType.
+     * @param options Additional options see remarks (no options by default).
+     * @return Ptr to newly created node.
+     * @remarks
+     * Valid options:
+     * - OPT_RECURSIVE - attempt to create all necessary sub-directories
+     */
+    virtual INodePtr createChild(const IPathPtr& path,
+            NodeType type,
+            int options = OPT_NONE) = 0;
+
+    /**
+     * Gets size of this node.
+     * @return Size.
+     */
+    virtual std::size_t getSize() const = 0;
+
+    /**
+     * Gets creation date of this node.
+     * @return Date.
+     */
+    virtual std::time_t getCreated() const = 0;
+
+    /**
+     * Gets last modification date of this node.
+     * @return Date.
+     */
+    virtual std::time_t getModified() const = 0;
+
+    /**
+     * Gets parent of this node.
+     * @return Parent node or NULL if no parent (e.g. in case of a root node).
+     */
+    virtual INodePtr getParent() const = 0;
+
+    /**
+     * Gets platform permissions.
+     * @return Platform permissions (set of flags from @see Permissions enum).
+     */
+    virtual int getMode() const = 0;
+
+    /**
+     * Reads whole file as text.
+     * @param event Read file event.
+     */
+    virtual void read(const EventReadTextPtr& event) = 0;
+
+    virtual std::string toUri(int widgetId) const = 0;
+
+  protected:
+    INode();
+};
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif /* TIZENAPIS_FILESYSTEM_INODE_H_ */
diff --git a/src/platform/API/Filesystem/INodeTypes.h b/src/platform/API/Filesystem/INodeTypes.h
new file mode 100755 (executable)
index 0000000..b4ec4bd
--- /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_FILESYSTEM_INODETYPES_H_
+#define TIZENAPIS_FILESYSTEM_INODETYPES_H_
+
+#include <vector>
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class INode;
+
+typedef DPL::SharedPtr<INode> INodePtr;
+
+typedef std::vector<INodePtr> NodeList;
+typedef NodeList::iterator NodeListIterator;
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif // TIZENAPIS_FILESYSTEM_INODETYPES_H_
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/IPath.cpp b/src/platform/API/Filesystem/IPath.cpp
new file mode 100755 (executable)
index 0000000..8fbd66d
--- /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 <Filesystem/Path.h>
+#include "IPath.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+IPathPtr IPath::create(const std::string& str)
+{
+    return Platform::Filesystem::Path::create(str);
+}
+
+IPath::SeparatorType IPath::getSeparator()
+{
+    return Platform::Filesystem::Path::getSeparator();
+}
+
+IPath::~IPath()
+{
+}
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/IPath.h b/src/platform/API/Filesystem/IPath.h
new file mode 100755 (executable)
index 0000000..64d4220
--- /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 TIZENAPIS_FILESYSTEM_IPATH_H_
+#define TIZENAPIS_FILESYSTEM_IPATH_H_
+
+#include <string>
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class IPath;
+typedef DPL::SharedPtr<IPath> IPathPtr;
+
+class IPath
+{
+  public:
+    typedef char SeparatorType;
+
+  public:
+    /**
+     * Creates path object from specified string.
+     * @param str Path string.
+     * @return Path.
+     * @throw InvalidArgumentException If supplied string is not a valid path.
+     * @throw PlatformException If error in platform occurs.
+     * @remarks Ownership passed to the caller.
+     */
+    static IPathPtr create(const std::string& str);
+
+    /**
+     * Gets separator used by current platform.
+     * @return Path separator.
+     */
+    static SeparatorType getSeparator();
+
+  public:
+    virtual ~IPath() = 0;
+
+    /**
+     * Gets full path.
+     * @return Full path.
+     */
+    virtual std::string getFullPath() const = 0;
+
+    /**
+     * Gets base path (full path w/o name).
+     * @return Base path
+     */
+    virtual std::string getPath() const = 0;
+
+    /**
+     * Gets the last part of path.
+     * @return Path's name.
+     * @return Last part is typically name of a directory or file.
+     */
+    virtual std::string getName() const = 0;
+
+    /**
+     * Appends path specified as string to current path.
+     * @param path Path to append.
+     * @return Current path object.
+     */
+    virtual IPathPtr append(const std::string& path) = 0;
+
+    /**
+     * Appends path specified as path object to current path.
+     * @param path Path to append.
+     * @return Current path object.
+     */
+    virtual IPathPtr append(const IPathPtr& path) = 0;
+
+    /**
+     * Checks if path is abolute.
+     * @return True if absolute, false if relative.
+     */
+    virtual bool isAbsolute() const = 0;
+
+    /**
+     * Clones this object.
+     * @return Independent copy.
+     */
+    virtual IPathPtr clone() const = 0;
+};
+
+inline const IPathPtr operator+(const IPath& lhs,
+        const IPath& rhs)
+{
+    return IPath::create(lhs.getFullPath())->append(rhs.getFullPath());
+}
+
+inline const IPathPtr operator+(const IPath& lhs,
+        const std::string& rhs)
+{
+    return IPath::create(lhs.getFullPath())->append(rhs);
+}
+
+inline const IPathPtr operator+(const std::string& lhs,
+        const IPath& rhs)
+{
+    return IPath::create(lhs)->append(rhs.getFullPath());
+}
+
+inline const bool operator==(const IPath& lhs,
+        const IPath& rhs)
+{
+    return (lhs.getFullPath() == rhs.getFullPath());
+}
+
+inline const bool operator==(const IPath& lhs,
+        const std::string& rhs)
+{
+    return (lhs.getFullPath() == rhs);
+}
+
+inline const bool operator==(const std::string& lhs,
+        const IPath& rhs)
+{
+    return (lhs == rhs.getFullPath());
+}
+
+inline const bool operator!=(const IPath& lhs,
+        const IPath& rhs)
+{
+    return (lhs.getFullPath() != rhs.getFullPath());
+}
+
+inline const bool operator!=(const IPath& lhs,
+        const std::string& rhs)
+{
+    return (lhs.getFullPath() != rhs);
+}
+
+inline const bool operator!=(const std::string& lhs,
+        const IPath& rhs)
+{
+    return (lhs != rhs.getFullPath());
+}
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif // TIZENAPIS_FILESYSTEM_IPATH_H_
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/IStream.cpp b/src/platform/API/Filesystem/IStream.cpp
new file mode 100755 (executable)
index 0000000..ae6a705
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "IStream.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+IStream::~IStream()
+{
+}
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/IStream.h b/src/platform/API/Filesystem/IStream.h
new file mode 100755 (executable)
index 0000000..6e140a5
--- /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. 
+ */
+
+#ifndef TIZENAPIS_FILESYSTEM_ISTREAM_H_
+#define TIZENAPIS_FILESYSTEM_ISTREAM_H_
+
+#include <cstddef>
+#include <string>
+#include <dpl/noncopyable.h>
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class IStream;
+typedef DPL::SharedPtr<IStream> IStreamPtr;
+
+class IStream : private DPL::Noncopyable
+{
+  public:
+    virtual ~IStream() = 0;
+
+    virtual IStreamPtr write(bool arg) = 0;
+    virtual IStreamPtr write(unsigned char arg) = 0;
+    virtual IStreamPtr write(char arg) = 0;
+    virtual IStreamPtr write(int arg) = 0;
+    virtual IStreamPtr write(double arg) = 0;
+    virtual IStreamPtr write(const std::string& arg) = 0;
+
+    virtual IStreamPtr read(bool& arg) = 0;
+    virtual IStreamPtr read(unsigned char& arg) = 0;
+    virtual IStreamPtr read(char& arg) = 0;
+    virtual IStreamPtr read(int& arg) = 0;
+    virtual IStreamPtr read(double& arg) = 0;
+    virtual IStreamPtr read(std::string& arg) = 0;
+
+    /**
+     * Gets characters from stream.
+     * @param num Number of characters to read.
+     * @return Pointer to read buffer.
+     * @throw PlatformException if stream is closed, EOF is set or write-only.
+     * @remarks Passes ownership to the caller.
+     */
+    virtual char* getChars(std::size_t num) = 0;
+
+    /**
+     * Gets bytes from stream.
+     * @param num Number of bytes to read.
+     * @return Pointer to read buffer.
+     * @remarks Passes ownership to the caller.
+     * @throw PlatformException if stream is closed, EOF is set or write-only.
+     */
+    virtual unsigned char* getBytes(std::size_t num) = 0;
+
+    /**
+     * Gets number of bytes read by last getBytes() or getChars() operation.
+     * @return Number of read bytes.
+     * @throw PlatformException if stream is closed or write-only.
+     */
+    virtual std::size_t getCount() const = 0;
+
+    /**
+     * Reads line of characters from stream (till '\n' character).
+     * @return Read line.
+     */
+    virtual std::string getLine() = 0;
+
+    /**
+     * Checks whether stream is open.
+     * @return True if stream is open, false otherwsie.
+     */
+    virtual bool isOpen() const = 0;
+
+    /**
+     * Checks whether End-Of-Line character occured.
+     * @return True if EOF flag was set, false otherwise.
+     */
+    virtual bool isEof() const = 0;
+
+    /**
+     * Closes stream.
+     */
+    virtual void close() = 0;
+
+    /**
+     * Gets current position in stream.
+     * @return Position or -1 if fails.
+     */
+    virtual long getPosition() const = 0;
+
+    /**
+     * Sets current position in stream.
+     * @param position Position to set.
+     */
+    virtual void setPosition(long position) = 0;
+
+    /**
+     * Gets mode stream was opened in.
+     * @return Mode @see Api::Filesystem::AccessMode.
+     */
+    virtual int getMode() const = 0;
+
+    /**
+     * Gets stream's size.
+     * @return Size or -1 if unavailable (e.g. stream is write-only).
+     */
+    virtual long getSize() const = 0;
+};
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif /* TIZENAPIS_FILESYSTEM_ISTREAM_H_ */
diff --git a/src/platform/API/Filesystem/NodeFilter.cpp b/src/platform/API/Filesystem/NodeFilter.cpp
new file mode 100755 (executable)
index 0000000..b0f542f
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+
+#include "NodeFilter.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+OptionalString NodeFilter::getName() const
+{
+    return m_name;
+}
+
+void NodeFilter::setName(const OptionalString& name)
+{
+    m_name = name;
+}
+
+OptionalDate NodeFilter::getMinCreated() const
+{
+    return m_created.min;
+}
+
+void NodeFilter::setMinCreated(const OptionalDate& date)
+{
+    m_created.min = date;
+}
+
+OptionalDate NodeFilter::getMaxCreated() const
+{
+    return m_created.max;
+}
+
+void NodeFilter::setMaxCreated(const OptionalDate& date)
+{
+    m_created.max = date;
+}
+
+void NodeFilter::setCreated(const OptionalDate& date)
+{
+    m_created.min = m_created.max = date;
+}
+
+OptionalDate NodeFilter::getMinModified() const
+{
+    return m_modified.min;
+}
+
+void NodeFilter::setMinModified(const OptionalDate& date)
+{
+    m_modified.min = date;
+}
+
+OptionalDate NodeFilter::getMaxModified() const
+{
+    return m_modified.max;
+}
+
+void NodeFilter::setMaxModified(const OptionalDate& date)
+{
+    m_modified.max = date;
+}
+
+void NodeFilter::setModified(const OptionalDate& date)
+{
+    m_modified.min = m_modified.max = date;
+}
+
+OptionalSize NodeFilter::getMinSize() const
+{
+    return m_size.min;
+}
+
+void NodeFilter::setMinSize(const OptionalSize& size)
+{
+    m_size.min = size;
+}
+
+OptionalSize NodeFilter::getMaxSize() const
+{
+    return m_size.max;
+}
+
+void NodeFilter::setMaxSize(const OptionalSize& size)
+{
+    m_size.max = size;
+}
+
+void NodeFilter::setSize(const OptionalSize& size)
+{
+    m_size.min = m_size.max = size;
+}
+} // Filesystem
+} // Api
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/NodeFilter.h b/src/platform/API/Filesystem/NodeFilter.h
new file mode 100755 (executable)
index 0000000..725dbf4
--- /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 TIZENAPIS_FILESYSTEM_NODEFILTER_H_
+#define TIZENAPIS_FILESYSTEM_NODEFILTER_H_
+
+#include <ctime>
+#include <cstddef>
+#include <string>
+#include <dpl/optional.h>
+#include <dpl/shared_ptr.h>
+#include <Commons/Range.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+typedef DPL::Optional<std::string> OptionalString;
+typedef DPL::Optional<std::time_t> OptionalDate;
+typedef DPL::Optional<std::size_t> OptionalSize;
+
+class NodeFilter
+{
+  public:
+    OptionalString getName() const;
+    void setName(const OptionalString& name);
+
+    OptionalDate getMinCreated() const;
+    void setMinCreated(const OptionalDate& date);
+
+    OptionalDate getMaxCreated() const;
+    void setMaxCreated(const OptionalDate& date);
+
+    void setCreated(const OptionalDate& date);
+
+    OptionalDate getMinModified() const;
+    void setMinModified(const OptionalDate& date);
+
+    OptionalDate getMaxModified() const;
+    void setMaxModified(const OptionalDate& date);
+
+    void setModified(const OptionalDate& date);
+
+    OptionalSize getMinSize() const;
+    void setMinSize(const OptionalSize& size);
+
+    OptionalSize getMaxSize() const;
+    void setMaxSize(const OptionalSize& size);
+
+    void setSize(const OptionalSize& size);
+
+  private:
+    OptionalString m_name;
+    WrtDeviceApis::Commons::Range<OptionalDate> m_created;
+    WrtDeviceApis::Commons::Range<OptionalDate> m_modified;
+    WrtDeviceApis::Commons::Range<OptionalSize> m_size;
+};
+
+typedef DPL::SharedPtr<NodeFilter> NodeFilterPtr;
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif // TIZENAPIS_FILESYSTEM_NODEFILTER_H_
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/PathUtils.cpp b/src/platform/API/Filesystem/PathUtils.cpp
new file mode 100755 (executable)
index 0000000..7e6aa00
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "PathUtils.h"
+#include <dpl/log/log.h>
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+namespace PathUtils {
+PathList getParts(const IPathPtr& path)
+{
+    PathList result;
+    IPath::SeparatorType separator = path->getSeparator();
+    std::string fullPath = path->getFullPath();
+    std::string::size_type pos = 0;
+    while ((pos = fullPath.find(separator, pos + 1)) != std::string::npos) {
+        result.push_back(IPath::create(fullPath.substr(0, pos)));
+    }
+    return result;
+}
+} // PathUtils
+} // Filesystem
+} // Api
+} // TizenApis
diff --git a/src/platform/API/Filesystem/PathUtils.h b/src/platform/API/Filesystem/PathUtils.h
new file mode 100755 (executable)
index 0000000..97fb425
--- /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_FILESYSTEM_PATHUTILS_H_
+#define TIZENAPIS_FILESYSTEM_PATHUTILS_H_
+
+#include <vector>
+#include "IPath.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+namespace PathUtils {
+typedef std::vector<IPathPtr> PathList;
+typedef PathList::iterator PathListIterator;
+
+/**
+ * Gets sub-paths of supplied path.
+ * The supplied path is not included.
+ * @param path
+ * @return List of paths.
+ */
+PathList getParts(const IPathPtr& path);
+} // PathUtils
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif // TIZENAPIS_FILESYSTEM_PATHUTILS_H_
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/StorageProperties.cpp b/src/platform/API/Filesystem/StorageProperties.cpp
new file mode 100755 (executable)
index 0000000..4a5e08c
--- /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. 
+ */
+
+#include "StorageProperties.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+StorageProperties::StorageProperties() :
+               id(0),
+               label(""),
+               type(0),
+               state(0),
+               fullpath("")
+{
+}
+
+void StorageProperties::setId (const int Id)
+{
+       id = Id;
+}
+
+void StorageProperties::setLabel (const std::string &Label)
+{
+       label = Label;
+}
+
+void StorageProperties::setType (const short Type)
+{
+       type = Type;
+}
+
+void StorageProperties::setState (const short State)
+{
+       state = State;
+}
+
+void StorageProperties::setFullPath (const std::string &FullPath)
+{
+       fullpath = FullPath;
+}
+
+int StorageProperties::getId() const
+{
+       return id;
+}
+
+std::string StorageProperties::getLabel() const
+{
+       return label;
+}
+
+short StorageProperties::getType() const
+{
+       return type;
+}
+
+short StorageProperties::getState() const
+{
+       return state;
+}
+
+std::string StorageProperties::getFullPath() const
+{
+       return fullpath;
+}
+} // Filesystem
+} // Api
+} // TizenApis
diff --git a/src/platform/API/Filesystem/StorageProperties.h b/src/platform/API/Filesystem/StorageProperties.h
new file mode 100755 (executable)
index 0000000..e58eb1c
--- /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. 
+ */
+
+
+#ifndef TIZENAPIS_API_FILESYSTEM_STORAGE_PROPERTIES_H_
+#define TIZENAPIS_API_FILESYSTEM_STORAGE_PROPERTIES_H_
+
+#include <dpl/shared_ptr.h>
+#include <string>
+
+namespace TizenApis {
+namespace Api {
+namespace Filesystem {
+class StorageProperties;
+typedef DPL::SharedPtr<StorageProperties> StoragePropertiesPtr;
+
+class StorageProperties
+{
+private:
+       int id;
+       std::string label;
+       short type;
+       short state;
+       std::string fullpath;
+public:
+       enum StorageType
+       {
+               TYPE_INTERNAL = 0,
+               TYPE_EXTERNAL,
+       };
+
+       enum StorageState
+       {
+               STATE_UNMOUNTABLE = -2,
+               STATE_REMOVED = -1,
+               STATE_MOUNTED = 0,
+       };
+
+       void setId (const int Id);
+       void setLabel (const std::string &Label);
+       void setType (const short Type);
+       void setState (const short State);
+       void setFullPath (const std::string &FullPath);
+
+       int getId() const;
+       std::string getLabel() const;
+       short getType() const;
+       short getState() const;
+       std::string getFullPath() const;
+       
+       StorageProperties();
+};
+} // Filesystem
+} // Api
+} // TizenApis
+
+#endif //TIZENAPIS_API_FILESYSTEM_STORAGE_PROPERTIES_H_
\ No newline at end of file
diff --git a/src/platform/API/Filesystem/config.cmake b/src/platform/API/Filesystem/config.cmake
new file mode 100755 (executable)
index 0000000..8993a7b
--- /dev/null
@@ -0,0 +1,23 @@
+get_current_path()
+
+set(SRCS_PLATFORM_API_FILESYSTEM
+  ${CURRENT_PATH}/IManager.cpp
+  ${CURRENT_PATH}/IPath.cpp
+  ${CURRENT_PATH}/IStream.cpp
+  ${CURRENT_PATH}/EventResolve.cpp
+  ${CURRENT_PATH}/EventGetStorage.cpp
+  ${CURRENT_PATH}/EventListStorages.cpp  
+  ${CURRENT_PATH}/EventCopy.cpp
+  ${CURRENT_PATH}/EventMove.cpp
+  ${CURRENT_PATH}/EventRemove.cpp
+  ${CURRENT_PATH}/EventFind.cpp
+  ${CURRENT_PATH}/EventListNodes.cpp
+  ${CURRENT_PATH}/EventOpen.cpp
+  ${CURRENT_PATH}/EventReadText.cpp
+  ${CURRENT_PATH}/INode.cpp
+  ${CURRENT_PATH}/NodeFilter.cpp
+  ${CURRENT_PATH}/PathUtils.cpp
+  ${CURRENT_PATH}/StorageProperties.cpp
+  ${CURRENT_PATH}/EventStoragestateChanged.cpp
+  PARENT_SCOPE
+)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 7b5216e..2a22c0e
@@ -54,10 +54,13 @@ bool FilterValidator::validateAttribute(std::string& attrName, AnyArrayPtr& valu
 
        PropertyPtr prop = m_properties[attrName];
 
-       AnyArray::iterator arrayIter;
-       for(arrayIter = values->begin(); arrayIter != values->end(); arrayIter++)
-               if(!(prop->type & (*arrayIter)->getType()))
-                       return false;
+       if(values != NULL)
+       {
+               AnyArray::iterator arrayIter;
+               for(arrayIter = values->begin(); arrayIter != values->end(); arrayIter++)
+                       if(!(prop->type & (*arrayIter)->getType()))
+                               return false;
+       }
 
        if(m_matchFlags[matchFlag] == false)
                return false;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 76e42b3..4bfbc68
@@ -22,7 +22,7 @@
  */
 
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/Exception.h>
 #include "IFilterVisitor.h"
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index cac6d9a..7e77789 100755 (executable)
@@ -22,7 +22,7 @@
  * @brief
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/Exception.h>
 #include <Messaging/Attachment.h>
 #include "AttachmentFactory.h"
index 4b4e350..1b8bc08 100755 (executable)
@@ -24,7 +24,7 @@
  * @brief
  */
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/Exception.h>
 #include "Attachments.h"
 #include "AttachmentFactory.h"
index 5e15cbf..196c98a 100755 (executable)
@@ -23,7 +23,7 @@
  * @version    0.1
  * @brief
  */
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "CallbackNumber.h"
 #include "CallbackNumber.h"
 
index 569b384..bb20fe5 100755 (executable)
@@ -25,7 +25,7 @@
 
 #include <API/Messaging/log.h>
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 using namespace TizenApis::Api::Tizen;
 
index 410bb99..cbd7c1b 100755 (executable)
@@ -76,25 +76,6 @@ std::string EmailAccountInfo::getAddress() const
     return m_address;
 }
 
-#if 0
-void EmailAccountInfo::setAccountData(int id, const char* name, const char* address)
-{      
-       std::stringstream stream;
-       stream << id;
-       if (stream.fail()) {
-               ThrowMsg(WrtDeviceApis::Commons::UnknownException,
-                "Couldn't convert e-mail account id");
-       }
-       
-       //m_id = stream.str();
-       //m_name = name;                //name
-       //m_address = address; //address
-       
-       m_id = "1";
-       m_name="Gmail";
-       m_address = "milkelf.choi@gmail.com";
-}
-#endif
 const bool EmailAccountInfo::operator==(const EmailAccountInfo& account) const
 {
     return (m_id == account.m_id &&
diff --git a/src/platform/API/Messaging/EventAddDraftMessage.h b/src/platform/API/Messaging/EventAddDraftMessage.h
new file mode 100644 (file)
index 0000000..7689191
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. 
+*/
+
+
+
+#ifndef EVENTADDDRAFTMESSAGE_H
+#define EVENTADDDRAFTMESSAGE_H
+
+#include <vector>
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "IMessage.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Messaging {
+
+class EventAddDraftMessage;
+
+typedef DPL::SharedPtr<EventAddDraftMessage> EventAddDraftMessagePtr;
+
+class EventAddDraftMessage :
+    public WrtDeviceApis::Commons::IEvent<EventAddDraftMessage>
+{
+  public:
+
+    IMessagePtr msg;
+
+    virtual void clearOnCancel()
+    {
+    }
+};
+}
+}
+}
+#endif
index 0e0ee44..320aec9 100755 (executable)
 * limitations under the License. 
 */
 
-/**
- *
- *
- * @file       EventDeleteConversations.h
- * @author     Kangsoo Lee (wpeter.lee@samsung.com)
- * @version    0.1
- * @brief
- */
-
 
 #ifndef EVENT_DELETE_CONVERSATIONS_H
 #define EVENT_DELETE_CONVERSATIONS_H
index ec31c55..a002b91 100755 (executable)
 * limitations under the License. 
 */
 
-/**
- *
- *
- * @file       EventGetConversationId.h
- * @author     Kangsoo Lee (wpeter.lee@samsung.com)
- * @version    0.1
- * @brief
- */
 
 #ifndef EVENT_GET_CONVERSATION_ID_H
 #define EVENT_GET_CONVERSATION_ID_H
index 45a5c79..4b6b9fd 100755 (executable)
 * limitations under the License. 
 */
 
-
-/*
- * @author    Dongjin Choi (milkelf.choi@samsung.com)
- */
-
 #ifndef WRTPLUGINS_API_GET_MESSAGING_SERVICE_EVENT_MESSAGING_H_
 #define WRTPLUGINS_API_GET_MESSAGING_SERVICE_EVENT_MESSAGING_H_
 
index 057cf2c..b3e2521 100755 (executable)
 * See the License for the specific language governing permissions and
 * limitations under the License. 
 */
-\r
-\r
-/*\r
- * @author    Dongjin Choi (milkelf.choi@samsung.com)\r
- */\r
-\r
-#ifndef WRTPLUGINS_API_MESSAGING_SERVICE_EVENT_H_\r
-#define WRTPLUGINS_API_MESSAGING_SERVICE_EVENT_H_\r
-\r
-#include <Commons/IEvent.h>\r
-#include <dpl/shared_ptr.h>\r
-#include "MessageProperties.h"\r
-\r
-#include "IMessage.h"\r
-#include "IAttachment.h"\r
-#include "IMessagingService.h"\r
-\r
-namespace TizenApis {\r
-namespace Api {\r
-namespace Messaging {\r
-\r
-class EventMessagingService;\r
-\r
-class EventMessagingService: public WrtDeviceApis::Commons::IEvent<EventMessagingService> {\r
-       \r
-public:\r
-       static const int MESSAGING_SERVICE_EVENT_TYPE_SEND_MESSAGE                      = 1;\r
-       static const int MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_BODY         = 2;\r
-       static const int MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_ATTACHMENT = 3;\r
-       static const int MESSAGING_SERVICE_EVENT_TYPE_SYNC                                      = 4;   //now, I have no idea about sync.                                \r
-       static const int MESSAGING_SERVICE_EVENT_TYPE_SYNC_FOLDER                       = 5;\r
-       \r
-private:\r
-       \r
-       MessagingPropertiesPtr m_messagingPropsPtr;\r
-       int m_eventType;\r
-       \r
-                \r
-       //now temporary\r
-       //IMessagePtr m_message;\r
-public:        \r
-       int getEventType() const{\r
-               return m_eventType;\r
-       }       \r
-\r
-       void setEventType(int type) {\r
-               m_eventType = type;\r
-       }\r
-       \r
-       void setMessageProperties(MessagingPropertiesPtr msgProps)\r
-       {\r
-               m_messagingPropsPtr = msgProps;\r
-       }\r
-\r
-       MessagingPropertiesPtr getMessageProperties()\r
-       {\r
-               return m_messagingPropsPtr;\r
-       }\r
-\r
-       IMessagePtr m_message;\r
-\r
-       IAttachmentPtr m_attachment;\r
-\r
-       IMessagingServicePtr m_messagingService;\r
-\r
-       int opId;\r
-\r
-       std::string m_folder_name;\r
-\r
-       int m_sync_account_id;  //account ID\r
-       int m_sync_folder_id;   // folder ID\r
-       int m_sync_limit;       //limit\r
-       \r
-       EventMessagingService()\r
-       {\r
-               m_eventType = MESSAGING_SERVICE_EVENT_TYPE_SEND_MESSAGE;        //default value.\r
-       }\r
-               \r
-};\r
-\r
-typedef DPL::SharedPtr<EventMessagingService> EventMessagingServicePtr;\r
-\r
-} // Api\r
-} // WrtPlugins\r
-}\r
-#endif //WRTPLUGINS_API_MESSAGING_SERVICE_EVENT_H_\r
-\r
+
+#ifndef WRTPLUGINS_API_MESSAGING_SERVICE_EVENT_H_
+#define WRTPLUGINS_API_MESSAGING_SERVICE_EVENT_H_
+
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include "MessageProperties.h"
+
+#include "IMessage.h"
+#include "IAttachment.h"
+#include "IMessagingService.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Messaging {
+
+class EventMessagingService;
+
+class EventMessagingService: public WrtDeviceApis::Commons::IEvent<EventMessagingService> {
+       
+public:
+       static const int MESSAGING_SERVICE_EVENT_TYPE_SEND_MESSAGE                      = 1;
+       static const int MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_BODY         = 2;
+       static const int MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_ATTACHMENT = 3;
+       static const int MESSAGING_SERVICE_EVENT_TYPE_SYNC                                      = 4;   //now, I have no idea about sync.                                
+       static const int MESSAGING_SERVICE_EVENT_TYPE_SYNC_FOLDER                       = 5;
+       
+private:
+       
+       MessagingPropertiesPtr m_messagingPropsPtr;
+       int m_eventType;
+       
+                
+       //now temporary
+       //IMessagePtr m_message;
+public:        
+       int getEventType() const{
+               return m_eventType;
+       }       
+
+       void setEventType(int type) {
+               m_eventType = type;
+       }
+       
+       void setMessageProperties(MessagingPropertiesPtr msgProps)
+       {
+               m_messagingPropsPtr = msgProps;
+       }
+
+       MessagingPropertiesPtr getMessageProperties()
+       {
+               return m_messagingPropsPtr;
+       }
+
+       IMessagePtr m_message;
+
+       IAttachmentPtr m_attachment;
+
+       IMessagingServicePtr m_messagingService;
+
+       int opId;
+
+       std::string m_folder_name;
+
+       int m_sync_account_id;  //account ID
+       int m_sync_folder_id;   // folder ID
+       int m_sync_limit;       //limit
+       
+       EventMessagingService()
+       {
+               m_eventType = MESSAGING_SERVICE_EVENT_TYPE_SEND_MESSAGE;        //default value.
+       }
+               
+};
+
+typedef DPL::SharedPtr<EventMessagingService> EventMessagingServicePtr;
+
+} // Api
+} // WrtPlugins
+}
+#endif //WRTPLUGINS_API_MESSAGING_SERVICE_EVENT_H_
+
index 898dec4..de0c435 100755 (executable)
 * limitations under the License. 
 */
 
-/**
- *
- *
- * @file       EventQueryConversatioin.h
- * @author     Kangsoo Lee (wpeter.lee@samsung.com)
- * @version    0.1
- * @brief
- */
  
 #ifndef EVENT_QUERY_CONVERSATIONS_H
 #define EVENT_QUERY_CONVERSATIONS_H
index 3690132..d086e60 100755 (executable)
 */
 
 
-/**
- *
- *
- * @file       EventQueryFolders.h
- * @author     Oy Kwon (sirot.kwon@samsung.com)
- * @version    0.1
- * @brief
- */
+
 #ifndef EVENTQUERYFOLDERS_H
 #define EVENTQUERYFOLDERS_H
 
index 08d44b6..b7fc3e3 100644 (file)
@@ -23,7 +23,7 @@
 #include "FolderFilterValidator.h"
 #include "FolderFilterValidatorFactory.h"
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "log.h"
 
 using namespace WrtDeviceApis::Commons;
@@ -104,15 +104,18 @@ namespace TizenApis {
                                }
                        }
 
-                       LogDebug("## 001 ##");
+                       if(m_attributeAndMatchFlagsMap.count(attrName) == 0)
+                       {
+                               MsgLogWanning(">>>[Waning] attrName is not supported:[" << attrName << "]");
+                               return false;                   
+                       }
+
                        std::vector<std::string> vec = m_attributeAndMatchFlagsMap.find(attrName)->second;
-                       LogDebug("## 002 ##");
 
                        if(vectorContains(vec, matchFlag)==false){
                                MsgLogWanning(">>>[Waning]MatchFlag check fail unsupported flag:[" << matchFlag << "] for Attribute:[" << attrName << "]");
                                return false;
                        }
-                       LogDebug("## 003 ##");
                        return true;
                }
 
index ec60334..c672310 100644 (file)
@@ -28,7 +28,7 @@ namespace TizenApis {
        namespace Platform {
                namespace Messaging {
 
-               const std::string FolderFilterValidatorFactory::ATTRIBUTE_ACCOUNTID               = "accountid";
+               const std::string FolderFilterValidatorFactory::ATTRIBUTE_ACCOUNTID               = "serviceId";
                const std::string FolderFilterValidatorFactory::ATTRIBUTE_FOLDERPATH             = "path";
 
                 std::string FolderFilterValidatorFactory::MATCH_EXACTLY              = "EXACTLY";
@@ -40,7 +40,7 @@ namespace TizenApis {
                //TODO change to constant
                static PropertyStructArray properties =
                {
-                               {"accountid",        Api::Tizen::PrimitiveType_String},
+                               {"serviceId",        Api::Tizen::PrimitiveType_String},
                                {"path",             Api::Tizen::PrimitiveType_String},
                                {0,                  Api::Tizen::PrimitiveType_Notype}
                };
index 4260ceb..6df400b 100755 (executable)
@@ -24,7 +24,7 @@
  * @brief
  */
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/errno_string.h>
 #include <Commons/Exception.h>
 #include "IAttachment.h"
index b8e284b..f48a686 100755 (executable)
@@ -24,7 +24,7 @@
  * @brief
  */
 #include "IBinarySms.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 namespace TizenApis {
 namespace Api {
index 9c22f25..c520e3c 100755 (executable)
 * limitations under the License. 
 */
  
-/**
-* @file                 Conversation.h
-* @author       Kangsoo Lee (wpeter.lee@samsung.com)
-* @version      0.1
-*/
 
 #ifndef ICONVERSATION_H
 #define ICONVERSATION_H
index 34bddf8..e4259b8 100755 (executable)
@@ -24,7 +24,7 @@
  * @brief
  */
 #include "IEmail.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 using namespace std;
 
index 4b48394..f89aa30 100755 (executable)
@@ -33,9 +33,7 @@
 #include "ToRecipient.h"
 #include "CcRecipient.h"
 #include "BccRecipient.h"
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
 #include "Attachments.h"
-#endif
 
 namespace TizenApis {
 namespace Api {
@@ -43,11 +41,8 @@ namespace Messaging {
 
 class IEmail : virtual public IMessage,
     public CcRecipient,
-    public BccRecipient
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
-    ,
+    public BccRecipient,
     public Attachments
-#endif
 {
   public:
     explicit IEmail(const std::string& id = "");
@@ -73,9 +68,7 @@ class IEmail : virtual public IMessage,
     virtual int downloadBody() = 0;
     virtual void downloadBodyCancel(int handle ) = 0;
 
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
-    virtual void downloadAttachment(const Api::Messaging::IAttachmentPtr& attachment) = 0;
-#endif
+    virtual int downloadAttachment(const Api::Messaging::IAttachmentPtr& attachment) = 0;
 
 #if 0  
     virtual void sync(int account_id);  
index cdfda72..743bae4 100755 (executable)
@@ -24,7 +24,7 @@
  * @brief
  */
 #include <pcrecpp.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/Exception.h>
 #include "IMessage.h"
 #include "EventSendMessage.h"
index a111c9a..2628332 100755 (executable)
@@ -195,6 +195,13 @@ class IMessage :
 
 
     /**
+     * method used to addMessageToDraft
+     * @throw PlatformException Thrown when addMessageToDraft fail
+     */
+    virtual void addMessageToDraft() = 0;
+
+
+    /**
      * method used to read all data from low level message
      * @throw PlatformException Thrown when reading message fail
      */
index f86731e..ccd8a6c 100755 (executable)
 * limitations under the License. 
 */
  
-/**
-* @file                 IMessageFolder.h
-* @author       Oy Kwon (sirot.kwon@samsung.com)
-* @version      0.1
-*/
 
 #ifndef IMESSAGEFOLDER_H
 #define IMESSAGEFOLDER_H
index 9674ed5..83a2a9d 100755 (executable)
 * limitations under the License. 
 */
 
-
-/*
- * @author Dongjin, Choi <milkelf.choi@samsung.com>
- */
-
 #ifndef WRTPLUGINS_API_IMESSAGING_SERVICE_H_
 #define WRTPLUGINS_API_IMESSAGING_SERVICE_H_
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "IMessagingTypes.h"
 #include <string>
 #include <dpl/shared_ptr.h>
index ff84e8b..180c611 100755 (executable)
 * limitations under the License. 
 */
 
-
-/*
- * @author Dongjin, Choi <milkelf.choi@samsung.com>
- */
-
 #ifndef WRTPLUGINS_API_IMESSAGING_SERVICE_MANAGER_H_
 #define WRTPLUGINS_API_IMESSAGING_SERVICE_MANAGER_H_
 
 #include <vector>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include "IMessagingTypes.h"
 #include <dpl/shared_ptr.h>
index c69067c..becf19d 100755 (executable)
@@ -25,7 +25,7 @@
  */
 #include "IMms.h"
 #include "ValidityPeriodHours.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 using namespace std;
 
index 9726f51..dbff801 100755 (executable)
@@ -34,9 +34,7 @@
 #include "ToRecipient.h"
 #include "CcRecipient.h"
 #include "BccRecipient.h"
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
 #include "Attachments.h"
-#endif
 #include "IMmsSlides.h"
 
 namespace TizenApis {
@@ -50,11 +48,8 @@ class IMms :
     virtual public IMessage,
     virtual public IMmsSlides,
     public CcRecipient,
-    public BccRecipient
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
-    ,
+    public BccRecipient,
     public Attachments
-#endif    
 {
   public:   // fields
 
index 68eb6c8..3e21fa7 100755 (executable)
@@ -24,7 +24,7 @@
  * @brief
  */
 #include "ISms.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 using namespace std;
 
index a40af85..921de11 100755 (executable)
@@ -23,7 +23,7 @@
  * @version    0.1
  * @brief
  */
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/Exception.h>
 #include <Messaging/Sms.h>
 #include <Messaging/BinarySms.h>
@@ -120,7 +120,7 @@ IMessagePtr MessageFactory::createEmailMessage(const int mailId, const int accou
        email = new Email(stream.str(), accountId);
 
        IMessagePtr imsg(email);
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
+
        std::vector<IAttachmentPtr> attachments = email->getAttachments();
 
        int idx = 0;
@@ -129,7 +129,6 @@ IMessagePtr MessageFactory::createEmailMessage(const int mailId, const int accou
                LogDebug("set Messsage ID = " << attachments[idx]->getAttachmentID());
                attachments[idx]->setMessage(imsg);
        }
-#endif
 
        return imsg;
        
index fe851ba..ab1cc17 100755 (executable)
@@ -23,7 +23,7 @@
 #include "MessageFilterValidator.h"
 #include "MessageFilterValidatorFactory.h"
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "log.h"
 
 using namespace WrtDeviceApis::Commons;
@@ -154,6 +154,12 @@ namespace TizenApis {
                                }
                        }
 
+                       if(m_attributeAndMatchFlagsMap.count(attrName) == 0)
+                       {
+                               MsgLogWanning(">>>[Waning] attrName is not supported:[" << attrName << "]");
+                               return false;
+                       }
+
                        std::vector<std::string> vec = m_attributeAndMatchFlagsMap.find(attrName)->second;
 
                        if(vectorContains(vec, matchFlag)==false){
index 2a6dcb5..d073739 100755 (executable)
@@ -25,7 +25,7 @@
  */
 #include <algorithm>
 #include <sstream>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/Exception.h>
 #include "Recipient.h"
 
index a3cf2b1..823fae6 100755 (executable)
@@ -41,6 +41,7 @@ namespace Api {
 namespace Messaging {
 
 ReqReceiverMessage::ReqReceiverMessage() :
+    EventAddDraftMessageReqReceiver(ThreadEnum::MESSAGING_THREAD),     
     EventSendMessageReqReceiver(ThreadEnum::MESSAGING_THREAD),
     EventUpdateMessageReqReceiver(ThreadEnum::MESSAGING_THREAD),
     EventDeleteMessageReqReceiver(ThreadEnum::MESSAGING_THREAD),
@@ -60,6 +61,12 @@ ReqReceiverMessage::~ReqReceiverMessage()
 {
 }
 
+void ReqReceiverMessage::addDraftMessage(const EventAddDraftMessagePtr& event)
+{
+    LogDebug("enter");
+    EventAddDraftMessageReqReceiver::PostRequest(event);
+}
+
 void ReqReceiverMessage::sendMessage(const EventSendMessagePtr& event)
 {
     LogDebug("enter");
@@ -127,13 +134,11 @@ void ReqReceiverMessage::loadMessageBody(const EventMessagingServicePtr& event)
        EventMessagingServiceReqReceiver::PostRequest(event);
 }
 
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
 void ReqReceiverMessage::loadMessageAttachment(const EventMessagingServicePtr& event)
 {
        LogDebug("enter");
        EventMessagingServiceReqReceiver::PostRequest(event);
 }
-#endif
 
 void ReqReceiverMessage::sync(const EventMessagingServicePtr& event)
 {
@@ -147,6 +152,26 @@ void ReqReceiverMessage::syncFolder(const EventMessagingServicePtr& event)
        EventMessagingServiceReqReceiver::PostRequest(event);
 }
 
+void ReqReceiverMessage::OnRequestReceived(const EventAddDraftMessagePtr& event)
+{
+    LogDebug("enter");
+
+    Try {
+        IMessagePtr msg = event->msg;
+        if (!event->checkCancelled()) {
+            event->setCancelAllowed(false);
+            msg->addMessageToDraft();
+        } else {
+            event->setCancelAllowed(true);
+        }
+    }
+    Catch(WrtDeviceApis::Commons::PlatformException) {
+        MsgLogError("platform exception");
+        event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::UnknownException);
+    }
+
+}
+
 void ReqReceiverMessage::OnRequestReceived(const EventSendMessagePtr& event)
 {
     LogDebug("enter");
@@ -428,7 +453,7 @@ void ReqReceiverMessage::OnRequestReceived(const EventMessagingServicePtr& event
                                event->setCancelAllowed(true);
                        }
                }
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
+
                else if (MessagingServiceEventType == EventMessagingService::MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_ATTACHMENT)
                {
                        if (!event->checkCancelled()) {
@@ -444,10 +469,16 @@ void ReqReceiverMessage::OnRequestReceived(const EventMessagingServicePtr& event
                                        {
                                                IEmailPtr email = MessageFactory::convertToEmail(msg);
                                                event->switchToManualAnswer();          //switch to manual answer;
-                                               email->downloadAttachment(event->m_attachment);
+                                               int handle = email->downloadAttachment(event->m_attachment);
+                                               LogDebug("Load Message Attachment handle : " << handle);
+                                               if (event->opId && event->m_messagingService)
+                                               {
+                                                       event->m_messagingService->setHandleToOpId(event->opId, handle);
+                                               }
                                        }
                                        else
                                        {
+                                               LogDebug(" invaild message. ");
                                                event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException);
                                        }
                                }
@@ -459,7 +490,6 @@ void ReqReceiverMessage::OnRequestReceived(const EventMessagingServicePtr& event
                        }
 
                }
-#endif
 
                else if (MessagingServiceEventType == EventMessagingService::MESSAGING_SERVICE_EVENT_TYPE_SYNC)
                {
index e6a9fcf..ce23660 100755 (executable)
@@ -28,6 +28,7 @@
 
 #include <dpl/singleton.h>
 
+#include "EventAddDraftMessage.h"
 #include "EventSendMessage.h"
 #include "EventUpdateMessage.h"
 #include "EventDeleteMessage.h"
@@ -46,6 +47,8 @@ namespace TizenApis {
 namespace Api {
 namespace Messaging {
 
+typedef WrtDeviceApis::Commons::EventRequestReceiver<EventAddDraftMessage>
+EventAddDraftMessageReqReceiver;
 typedef WrtDeviceApis::Commons::EventRequestReceiver<EventSendMessage>
 EventSendMessageReqReceiver;
 typedef WrtDeviceApis::Commons::EventRequestReceiver<EventUpdateMessage>
@@ -68,7 +71,8 @@ typedef WrtDeviceApis::Commons::EventRequestReceiver<EventQueryFolders>
 EventQueryFoldersReqReceiver;  
 typedef WrtDeviceApis::Commons::EventRequestReceiver<EventMessagingService>
 EventMessagingServiceReqReceiver;      
-class ReqReceiverMessage : public EventSendMessageReqReceiver,
+class ReqReceiverMessage : public EventAddDraftMessageReqReceiver,
+    public EventSendMessageReqReceiver,        
     public EventUpdateMessageReqReceiver,
     public EventDeleteMessageReqReceiver,
     public EventDeleteMessagesReqReceiver,
@@ -88,6 +92,8 @@ class ReqReceiverMessage : public EventSendMessageReqReceiver,
 
     virtual ~ReqReceiverMessage();
 
+    void addDraftMessage(const EventAddDraftMessagePtr& event);
+
     void sendMessage(const EventSendMessagePtr& event);
 
     void updateMessage(const EventUpdateMessagePtr& event);
@@ -118,6 +124,9 @@ class ReqReceiverMessage : public EventSendMessageReqReceiver,
 
                
   protected:
+
+    void OnRequestReceived(const EventAddDraftMessagePtr& event);
+
     void OnRequestReceived(const EventSendMessagePtr& event);
 
     void OnRequestReceived(const EventUpdateMessagePtr& event);
index a646d65..c1c5a92 100755 (executable)
@@ -23,7 +23,7 @@
  * @version    0.1
  * @brief
  */
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "Commons/Exception.h"
 #include "SourceAddress.h"
 
index 569d145..4e75c6c 100755 (executable)
@@ -23,7 +23,7 @@
 #include "StorageChangesConversationFilterValidator.h"
 #include "StorageChangesConversationFilterValidatorFactory.h"
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
index f0ef126..3f75d6a 100755 (executable)
@@ -33,7 +33,7 @@ namespace TizenApis {
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_MESSAGE_COUNT    = "messageCount";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_UNREAD_MESSAGES  = "unreadMessages";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_PREVIEW          = "preview";
-               const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_IS_READ          = "read";
+               const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_IS_READ          = "isRead";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_FROM             = "from";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_TO               = "to";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_CC               = "cc";
@@ -48,7 +48,7 @@ namespace TizenApis {
                                {"messageCount",         Api::Tizen::PrimitiveType_Number},
                                {"unreadMessages",       Api::Tizen::PrimitiveType_Number},
                                {"preview",                      Api::Tizen::PrimitiveType_String},
-                               {"read",                         Api::Tizen::PrimitiveType_Number},
+                               {"isRead",                       Api::Tizen::PrimitiveType_Number},
                                {"from",             Api::Tizen::PrimitiveType_String},
                                {"to",               Api::Tizen::PrimitiveType_String},
                                {"cc",               Api::Tizen::PrimitiveType_String},
index e869da9..927cb5b 100755 (executable)
@@ -28,7 +28,7 @@
 
 #include <emf-types.h>
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 using namespace std;
 using namespace TizenApis::Api::Tizen;
@@ -337,7 +337,7 @@ namespace TizenApis {
                                }
                                return;
                        }
-                       if(attrName.compare("read")==0){
+                       if(attrName.compare("isRead")==0){
                                LogDebug("<<< value:[" << value << "]");
                                int nType = value->toString().compare("true");
                                if((int)m_read == nType)
@@ -479,11 +479,11 @@ namespace TizenApis {
 
                        int retMessageType = -1;
 
-                       if(stringType.compare("SMS") ==0){
+                       if(stringType.compare("tizen.sms") ==0){
                                retMessageType = Api::Messaging::SMS;
-                       }else if(stringType.compare("MMS") ==0){
+                       }else if(stringType.compare("tizen.mms") ==0){
                                retMessageType = Api::Messaging::MMS;
-                       }else if(stringType.compare("EMAIL") ==0){
+                       }else if(stringType.compare("tizen.email") ==0){
                                retMessageType = Api::Messaging::EMAIL;
                        }else{
                                LogError("invalid type:[" << stringType << "]");
index c9338b3..7982fe6 100755 (executable)
@@ -23,7 +23,7 @@
 #include "StorageChangesFolderFilterValidator.h"
 #include "StorageChangesFolderFilterValidatorFactory.h"
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
index a30ffc1..803efb0 100755 (executable)
@@ -29,8 +29,8 @@ namespace TizenApis {
                namespace Messaging {
 
                const std::string StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_ID              = "id";
-               const std::string StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_PARENT_ID       = "parentid";
-               const std::string StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_ACCOUNT_ID      = "accountid";
+               const std::string StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_PARENT_ID       = "parentId";
+               const std::string StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_ACCOUNT_ID      = "serviceId";
                const std::string StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_CONTENT_TYPE    = "contentType";
                const std::string StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_NAME            = "name";
                const std::string StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_PATH            = "path";
@@ -40,8 +40,8 @@ namespace TizenApis {
                static PropertyStructArray properties =
                {
                                {"id",             Api::Tizen::PrimitiveType_String},
-                               {"parentid",       Api::Tizen::PrimitiveType_String},
-                               {"accountid",      Api::Tizen::PrimitiveType_String},
+                               {"parentId",       Api::Tizen::PrimitiveType_String},
+                               {"serviceId",      Api::Tizen::PrimitiveType_String},
                                {"contentType",    Api::Tizen::PrimitiveType_String},
                                {"name",                   Api::Tizen::PrimitiveType_String},
                                {"path",           Api::Tizen::PrimitiveType_String},
index 4fc812b..8e89d62 100755 (executable)
@@ -27,7 +27,7 @@
 
 #include <emf-types.h>
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 using namespace std;
 using namespace TizenApis::Api::Tizen;
@@ -246,7 +246,7 @@ namespace TizenApis {
                        std::string valueString;
 
 //  Check Folder_type and filter_type
-                       if(attrName.compare("accountid")==0){
+                       if(attrName.compare("serviceId")==0){
                                LogDebug("<<< value:[" << value << "]");
                                int nType = atoi(value->toString().c_str());
                                if((int)m_accountid == nType)
@@ -355,11 +355,11 @@ namespace TizenApis {
 
                        int retMessageType = -1;
 
-                       if(stringType.compare("SMS") ==0){
+                       if(stringType.compare("tizen.sms") ==0){
                                retMessageType = Api::Messaging::SMS;
-                       }else if(stringType.compare("MMS") ==0){
+                       }else if(stringType.compare("tizen.mms") ==0){
                                retMessageType = Api::Messaging::MMS;
-                       }else if(stringType.compare("EMAIL") ==0){
+                       }else if(stringType.compare("tizen.email") ==0){
                                retMessageType = Api::Messaging::EMAIL;
                        }else{
                                LogError("invalid type:[" << stringType << "]");
index e8ca819..e80c406 100755 (executable)
@@ -23,7 +23,7 @@
 #include "StorageChangesMessageFilterValidator.h"
 #include "StorageChangesMessageFilterValidatorFactory.h"
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
index 73f2a61..d99d325 100755 (executable)
@@ -28,7 +28,7 @@
 
 #include <emf-types.h>
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 using namespace std;
 using namespace TizenApis::Api::Tizen;
@@ -576,11 +576,11 @@ namespace TizenApis {
 
                        int retMessageType = -1;
 
-                       if(stringType.compare("SMS") ==0){
+                       if(stringType.compare("tizen.sms") ==0){
                                retMessageType = Api::Messaging::SMS;
-                       }else if(stringType.compare("MMS") ==0){
+                       }else if(stringType.compare("tizen.mms") ==0){
                                retMessageType = Api::Messaging::MMS;
-                       }else if(stringType.compare("EMAIL") ==0){
+                       }else if(stringType.compare("tizen.email") ==0){
                                retMessageType = Api::Messaging::EMAIL;
                        }else{
                                LogError("invalid type:[" << stringType << "]");
index 2eed804..bdf9d21 100755 (executable)
@@ -23,7 +23,7 @@
  * @version    0.1
  * @brief
  */
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "ToRecipient.h"
 
 using namespace std;
index 712eacb..5c943a9 100755 (executable)
@@ -23,7 +23,7 @@
  * @version    0.1
  * @brief
  */
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "Commons/Exception.h"
 #include "IMessage.h"
 #include "VirtualMessage.h"
@@ -84,6 +84,11 @@ void VirtualMessage::updateIsRead()
 {
 }
 
+void VirtualMessage::addMessageToDraft()
+{
+}
+
+
 }
 }
 }
index bab4272..5f9fd43 100755 (executable)
@@ -33,9 +33,7 @@
 #include "Subject.h"
 #include "CcRecipient.h"
 #include "BccRecipient.h"
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
 #include "Attachments.h"
-#endif
 #include "CallbackNumber.h"
 #include "ValidityPeriodHours.h"
 
@@ -51,11 +49,8 @@ typedef DPL::SharedPtr<VirtualMessage> VirtualMessagePtr;
 class VirtualMessage :
     public IMessage,
     public CcRecipient,
-    public BccRecipient
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
-    ,
+    public BccRecipient,
     public Attachments
-#endif
 {
   public:
     VirtualMessage();
@@ -81,6 +76,9 @@ class VirtualMessage :
     void remove();
 
     void updateIsRead();       
+
+    void addMessageToDraft();
+       
 };
 }
 }
index ea40b32..3ead051 100755 (executable)
@@ -4,9 +4,9 @@ set(SRCS_PLATFORM_API_MESSAGING
   ${CURRENT_PATH}/IMessagingService.cpp
   ${CURRENT_PATH}/MessagingFactory.cpp
 
-#    ${CURRENT_PATH}/Attachments.cpp
-#    ${CURRENT_PATH}/IAttachment.cpp
-#    ${CURRENT_PATH}/AttachmentFactory.cpp
+    ${CURRENT_PATH}/Attachments.cpp
+    ${CURRENT_PATH}/IAttachment.cpp
+    ${CURRENT_PATH}/AttachmentFactory.cpp
     ${CURRENT_PATH}/BccRecipient.cpp
     ${CURRENT_PATH}/Body.cpp
     ${CURRENT_PATH}/CcRecipient.cpp
old mode 100755 (executable)
new mode 100644 (file)
index df71153..7e1b6ad
@@ -21,7 +21,7 @@
 
 #include <JavaScriptCore/JavaScript.h>
 #include <dpl/shared_ptr.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/Converter.h>
 #include "standards/Tizen/Systeminfo/JSWifiNetworkInfo.h"
old mode 100755 (executable)
new mode 100644 (file)
index 485af3f..4f8f43a
@@ -29,7 +29,7 @@ using namespace WrtDeviceApis::Commons;
 
 namespace {
 
-static Eina_Bool timer_cb(void* data)
+static Eina_Bool timeout_timer_cb(void* data)
 {
     LogDebug("enter");
     EventWatchSysteminfo *event = static_cast<EventWatchSysteminfo *> (data);
@@ -53,6 +53,7 @@ EventWatchSysteminfo::EventWatchSysteminfo() :
 EventWatchSysteminfo::~EventWatchSysteminfo()
 {
     LogDebug("destroy event data, id=" << m_id);
+    removeTimer();
 }
 
 void EventWatchSysteminfo::setWatchOption(const WatchOption& watchoption) {
@@ -137,17 +138,13 @@ void EventWatchSysteminfo::processGetValue()
                     bool prevIsCharging = JSValueToBoolean(context, propertyCharging);
 
                     if(level != prevLevel || isCharging != prevIsCharging) {
-                        if (m_WatchOption.highThreshold > 0 || m_WatchOption.lowThreshold > 0) {
-                            if (level > m_WatchOption.highThreshold || level < m_WatchOption.lowThreshold) {
+                        if (((m_WatchOption.highThreshold > 0) && (level > m_WatchOption.highThreshold))
+                            || ((m_WatchOption.lowThreshold > 0) && (level < m_WatchOption.lowThreshold))
+                            || ((m_WatchOption.highThreshold == 0) && (m_WatchOption.lowThreshold == 0))) {
                                 m_cbm->callOnSuccess(tmpValue);
                                 m_lastValue = tmpValue;
                                 setTimer();
                             }
-                        } else {
-                            m_cbm->callOnSuccess(tmpValue);
-                            m_lastValue = tmpValue;
-                            setTimer();
-                        }
                     }
                 } else if (m_BaseProperty->getWatchType() == 2) {
                     std::string key = "brightness";
@@ -157,17 +154,13 @@ void EventWatchSysteminfo::processGetValue()
                     double prevBrightness = JSValueToNumber(context, propertyBrightness, exception);
 
                     if(brightness != prevBrightness) {
-                        if (m_WatchOption.highThreshold > 0 || m_WatchOption.lowThreshold > 0) {
-                            if (brightness > m_WatchOption.highThreshold || brightness < m_WatchOption.lowThreshold) {
+                        if (((m_WatchOption.highThreshold > 0) && (brightness > m_WatchOption.highThreshold))
+                            || ((m_WatchOption.lowThreshold > 0) && (brightness < m_WatchOption.lowThreshold))
+                            || ((m_WatchOption.highThreshold == 0) && (m_WatchOption.lowThreshold == 0))) {
                                 m_cbm->callOnSuccess(tmpValue);
                                 m_lastValue = tmpValue;
                                 setTimer();
                             }
-                        } else {
-                            m_cbm->callOnSuccess(tmpValue);
-                            m_lastValue = tmpValue;
-                            setTimer();
-                        }
                     }
                 } else if (m_BaseProperty->getWatchType() == 3) {
                     std::string key = "status";
@@ -189,17 +182,13 @@ void EventWatchSysteminfo::processGetValue()
                     double prevSignalStrength = JSValueToNumber(context, propertySignalStrength, exception);
 
                     if(!JSStringIsEqual(status,prevStatus) || !JSStringIsEqual(ssid,prevSsid) || signalStrength != prevSignalStrength) {
-                        if (m_WatchOption.highThreshold > 0 || m_WatchOption.lowThreshold > 0) {
-                            if (signalStrength > m_WatchOption.highThreshold || signalStrength < m_WatchOption.lowThreshold) {
+                        if (((m_WatchOption.highThreshold > 0) && (signalStrength > m_WatchOption.highThreshold))
+                            || ((m_WatchOption.lowThreshold > 0) && (signalStrength < m_WatchOption.lowThreshold))
+                            || ((m_WatchOption.highThreshold == 0) && (m_WatchOption.lowThreshold == 0))) {
                                 m_cbm->callOnSuccess(tmpValue);
                                 m_lastValue = tmpValue;
                                 setTimer();
                             }
-                        } else {
-                            m_cbm->callOnSuccess(tmpValue);
-                            m_lastValue = tmpValue;
-                            setTimer();
-                        }
                     }
                 } else if (m_BaseProperty->getWatchType() == 4) {
                     std::string key = "status";
@@ -276,7 +265,7 @@ void EventWatchSysteminfo::setTimer()
             m_initTimer = NULL;
         }
         double value = m_WatchOption.timeout/(double)1000;
-        m_initTimer = ecore_timer_add(value, timer_cb, this);
+        m_initTimer = ecore_timer_add(value, timeout_timer_cb, this);
         ecore_timer_thaw(m_initTimer);
     }
 }
@@ -287,7 +276,7 @@ void EventWatchSysteminfo::removeTimer()
         ecore_timer_freeze(m_initTimer);
         ecore_timer_del(m_initTimer);
     }
-    m_initTimer = NULL;
+    m_initTimer = NULL;        
 }
 
 void EventWatchSysteminfo::clearWatch()
old mode 100755 (executable)
new mode 100644 (file)
index 80b50a2..91f6fe9
@@ -47,7 +47,6 @@ class ISysteminfo :
     virtual void watch(const EventWatchSysteminfoPtr& event) = 0;    
        virtual BasePropertyPtr getBasePropertyPtr(JSContextRef context, JSValueRef property) = 0;
        virtual void clearWatch(const int id) = 0;
-       virtual bool isDuplicateWatch(const char * property) = 0;
 
   protected:
     ISysteminfo();
index 7c0f70d..407a462 100755 (executable)
@@ -1,25 +1,24 @@
 /*
  *
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
- * 
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *  
+ *
  */
 
 #ifndef WRTPLUGINS_API_SYSTEMINFO_LISTENER_H_
 #define WRTPLUGINS_API_SYSTEMINFO_LISTENER_H_
 
-#include <dpl/controller.h>
 #include <CommonsJavaScript/JSPendingOperation.h>
 #include "EventGetSysteminfo.h"
 #include "EventWatchSysteminfo.h"
index 8c43e67..dc39335 100755 (executable)
 
 using namespace std;
 
+namespace TizenApis {
+namespace Api {
+namespace TimeUtil {
+
 namespace {
        const short MSECS_UNIT= 0;
        const short SECONDS_UNIT = 1;
@@ -34,11 +38,6 @@ namespace {
 
 }
 
-namespace TizenApis {
-namespace Api {
-namespace TimeUtil {
-       
-
 struct DurationProperties
 {
        long long length;
index 197a985..5a15a8f 100755 (executable)
@@ -27,6 +27,10 @@ ITimeUtilPtr TimeUtilFactory::createTimeUtilObject() {
        return ITimeUtilPtr( new Platform::TimeUtil::TimeUtil() );
 }
 
+ITZDatePtr TimeUtilFactory::createTZDateObject(const std::string &timezone) {
+       return ITZDatePtr( new Platform::TimeUtil::TZDate(timezone) );
+}
+
 ITZDatePtr TimeUtilFactory::createTZDateObject(const bool isNotNull) {
        return ITZDatePtr( new Platform::TimeUtil::TZDate(isNotNull) );
 }
index 9929ec4..e3f7844 100755 (executable)
@@ -37,6 +37,7 @@ private:
     TimeUtilFactory(){;}
 public:
        ITimeUtilPtr createTimeUtilObject();
+       ITZDatePtr createTZDateObject(const std::string &timezone);
        ITZDatePtr createTZDateObject(const bool isNotNull = TRUE);
        ITZDatePtr createTZDateObject(const TZDateProperties &properties);
                
index 03c98e0..fe5bccb 100755 (executable)
@@ -9,12 +9,12 @@ include_config_file(Call)
 include_config_file(TimeUtil)
 include_config_file(Systeminfo)
 include_config_file(NFC)
+include_config_file(Filesystem)
+include_config_file(Account)
 
-#include_config_file(Account)
 #include_config_file(Accelerometer)
 #include_config_file(Orientation)
 #include_config_file(Gyroscope)
-#include_config_file(Filesystem)
 #include_config_file(UI)
 #include_config_file(Haptics)
 #include_config_file(MMPlayer)
diff --git a/src/platform/Tizen/Account/AccountManager.cpp b/src/platform/Tizen/Account/AccountManager.cpp
new file mode 100755 (executable)
index 0000000..a649bcd
--- /dev/null
@@ -0,0 +1,416 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * @file        AccountManager.cpp
+ * @author      Jihwa Park (jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ */
+#include <algorithm>
+#include <vector>
+
+#include <dpl/log/log.h>
+#include <dpl/scoped_ptr.h>
+
+#include "AccountManager.h"
+
+#include "API/Account/OnAddEventsChanged.h"
+#include "API/Account/OnUpdateEventsChanged.h"
+#include "API/Account/OnDeleteEventsChanged.h"
+#include "account.h"
+
+#include <CommonsJavaScript/Converter.h>
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+int id_list[1024] = {0, };
+int count = 0;
+
+bool GetAccountList(account_h handle, void* user_data)
+{
+       int id = 0;
+       account_get_account_id(handle, &id);
+       id_list[count] = id;
+       count++;
+       return true;
+}
+
+namespace TizenApis {
+namespace Platform {
+namespace Account{
+int AccountManager::m_instanceCount = 0;
+
+AccountManager::AccountManager()
+{
+    LogDebug("entered");
+
+    DPL::Mutex::ScopedLock mx(&m_constructorMutex);
+    if (m_instanceCount == 0) {
+        LogDebug("opening account DB");
+        if (ACCOUNT_ERROR_NONE != account_connect()) {
+            ThrowMsg(PlatformException, "Account DB initialization failed");
+        }
+    }
+    m_instanceCount++;
+}
+
+AccountManager::~AccountManager()
+{
+    LogDebug("entered");
+    DPL::Mutex::ScopedLock mx(&m_constructorMutex);
+    m_instanceCount--;
+    if (m_instanceCount == 0) {
+        LogDebug("closing account DB");
+        if (ACCOUNT_ERROR_NONE != account_disconnect()) {
+            LogError("Account database not clearly closed.");
+        }
+    }
+}
+
+void AccountManager::OnRequestReceived(const IEventGetAccountServicesPtr &event)
+{
+    LogDebug("entered");
+    static std::vector<IAccountServicePtr> AccountServices;
+
+    Try
+    {
+               if (AccountServices.empty()) {
+                       IAccountServicePtr newAccountService(new AccountService());
+                       newAccountService->setName("default internet account");
+                       newAccountService->setId(0);
+                       newAccountService->setType(AccountService::TYPE_INTERNET);
+                       AccountServices.push_back(newAccountService);
+               }
+               if (!event->checkCancelled()) {
+                       std::vector<IAccountServicePtr>::const_iterator it = AccountServices.begin();
+                       for (; it != AccountServices.end(); ++it) {
+                               event->addAccountService(*it);
+                       }
+                       event->setResult(true);
+               }
+       }
+    Catch(Exception)
+    {
+        LogError("error occuered during obtaining data");
+        event->setResult(false);
+    }
+    event->setCancelAllowed(true);
+
+}
+
+
+void AccountManager::OnRequestReceived(const IEventDeleteAccountPtr &account)
+{
+    LogDebug("entered");
+
+    Try
+    {
+        if (!account->getEvent()) {
+            ThrowMsg(NullPointerException, "event parameter is NULL");
+        }
+
+        //TODO: check if ID is valid
+        /*
+        if (!account->getEvent()->getIdIsSet()) {
+            ThrowMsg(Commons::InvalidArgumentException,
+                     "Cannot delete non-existing event.");
+        }
+        */
+        DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(account->getEvent()));
+        accountWrapper->convertAbstractAccountToPlatformAccount();
+        if (account->checkCancelled()) {
+            account->setCancelAllowed(true);
+            account->setResult(true);
+            return;
+        }
+        accountWrapper->deleteAccount();
+        account->setResult(true);
+    }
+    catch (const NotFoundException &ex)
+    {
+        LogError("event doesn't exist");
+        account->setResult(false);
+        account->setExceptionCode(ExceptionCodes::NotFoundException);
+    }
+    catch (const Exception &ex)
+    {
+        LogError("Error during deleting event " << ex.DumpToString());
+        account->setResult(false);
+    }
+    account->setCancelAllowed(false);
+}
+
+
+void AccountManager::OnRequestReceived(const IEventAddAccountPtr &account)
+{
+    LogDebug("entered");
+    Try
+    {
+        if (!account->getEvent()) {
+            ThrowMsg(NullPointerException, "event parameter is NULL");
+        }
+       /* if (account->getEvent()->getIdIsSet()) {
+            LogWarning("adding event that is already added");
+            account->getEvent()->resetId();
+        }*/
+        DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(account->getEvent()));
+        accountWrapper->convertAbstractAccountToPlatformAccount();
+        if (account->checkCancelled()) {
+            account->setCancelAllowed(true);
+            account->setResult(true);
+            return;
+        }
+
+        accountWrapper->setDummyServices();
+
+        accountWrapper->saveAccount();
+        account->setResult(true);
+    }
+    catch (const Exception &ex)
+    {
+        LogError("Error during adding event" << ex.DumpToString());
+        account->setResult(false);
+    }
+    account->setCancelAllowed(false);
+}
+
+void AccountManager::OnRequestReceived(const IEventFindAccountsPtr &event)
+{
+    LogDebug("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);
+        }
+       }
+
+    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");
+       }
+
+               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());
+               }
+               event->setResult(true);
+    }
+    catch (const Exception &ex)
+    {
+        LogError("Exception: " << ex.DumpToString());
+        event->setResult(false);
+    }
+    event->setCancelAllowed(true);
+}
+
+
+void AccountManager::OnRequestReceived(const IEventUpdateAccountPtr &account)
+{
+    LogDebug("entered");
+
+    Try
+    {
+        if (!account->getEvent()) {
+            ThrowMsg(NullPointerException, "event parameter is NULL");
+        }
+  /*      if (!account->getEvent()->getIdIsSet()) {
+            ThrowMsg(
+                Commons::InvalidArgumentException,
+                "Cannot update non-existing event. Event needs adding or ID is wrong");
+        }*/
+        DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(account->getEvent()));
+        accountWrapper->convertAbstractAccountToPlatformAccount();
+        if (account->checkCancelled()) {
+            account->setCancelAllowed(true);
+            account->setResult(true);
+            return;
+        }
+        accountWrapper->saveAccount();
+        account->setResult(true);
+    }
+    catch (const Exception &ex)
+    {
+        LogError("Error during updating event " << ex.DumpToString());
+        account->setResult(false);
+    }
+    account->setCancelAllowed(false);
+}
+
+void AccountManager:: OnRequestReceived(const IEventGetAccountByIdPtr &account)
+{
+    LogDebug("entered");
+    Try
+    {
+        if (!account->getEvent()) {
+            ThrowMsg(NullPointerException, "event parameter is NULL");
+        }
+        DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(account->getEvent()));
+        accountWrapper->getAccountbyId();
+        if (account->checkCancelled()) {
+            account->setCancelAllowed(true);
+            account->setResult(true);
+            return;
+        }
+               account->setEvent(accountWrapper->getAbstractAccount());
+        account->setResult(true);
+    }
+    catch (const Exception &ex)
+    {
+        LogError("Error during updating event " << ex.DumpToString());
+        account->setResult(false);
+    }
+    account->setCancelAllowed(false);
+}
+
+void AccountManager:: OnRequestReceived(const IEventGetServiceTypeByIdPtr &eventGetServicetypeById)
+{
+       LogDebug("<<<");
+
+       Try{
+               if (!eventGetServicetypeById->getEvent()) {
+                       ThrowMsg(NullPointerException, "event parameter is NULL");
+               }
+
+               DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(eventGetServicetypeById->getEvent()));
+               accountWrapper->getServiceTypebyId();
+               if (eventGetServicetypeById->checkCancelled()) {
+                       eventGetServicetypeById->setCancelAllowed(true);
+                       eventGetServicetypeById->setResult(true);
+                       return;
+               }
+               eventGetServicetypeById->setEvent(accountWrapper->getAbstractAccount());
+
+               //TODO set real value sangtai.kim
+               eventGetServicetypeById->setAccountServiceTypeProperty(accountWrapper->getDummyAccountServiceType());
+
+               eventGetServicetypeById->setResult(true);
+       } catch (const Exception &ex) {
+               LogError("Error during updating event " << ex.DumpToString());
+               eventGetServicetypeById->setResult(false);
+       }
+       eventGetServicetypeById->setCancelAllowed(false);
+}
+
+void AccountManager:: OnRequestReceived(const IEventGetProviderByIdPtr &event)
+{
+       LogDebug("<<<");
+       Try{
+               if (!event->getEvent()) {
+                       ThrowMsg(NullPointerException, "event parameter is NULL");
+               }
+               DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(event->getEvent()));
+               if (event->checkCancelled()) {
+                       event->setCancelAllowed(true);
+                       event->setResult(true);
+                       return;
+               }
+
+               //TODO set real value sangtai.kim
+               event->setAccountServiceProviderProperty(accountWrapper->getDummyAccountServiceProviderProperty());
+
+               event->setResult(true);
+       }catch (const Exception &ex)    {
+               LogError("Error during updating event " << ex.DumpToString());
+               event->setResult(false);
+       }
+       event->setCancelAllowed(false);
+       LogDebug(">>>");
+}
+
+void AccountManager:: OnRequestReceived(const IEventFindProvidersPtr &account)
+{
+    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);
+}
+
+void AccountManager::OnRequestReceived(const IEventFindServiceTypesPtr &event) {
+       LogDebug("<<< DUMMY IMPLEMENTATION");
+
+       std::string prefix = event->getPrefix();
+       LogDebug("prefix:[" << prefix << "]");
+
+       //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);
+
+       event->setServiceTypeProperties(accountServiceTypeProperties);
+
+       event->setResult(true);
+       LogDebug(">>>");
+}
+
+
+}
+}
+}
diff --git a/src/platform/Tizen/Account/AccountManager.h b/src/platform/Tizen/Account/AccountManager.h
new file mode 100755 (executable)
index 0000000..2be836e
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * @file        AccountManager.h
+ * @author      Jihwa Park (jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ */
+
+#ifndef _TIZEN__ACCOUNTMANAGER_H_
+#define _TIZEN__ACCOUNTMANAGER_H_
+
+#include <vector>
+#include <list>
+#include <dpl/mutex.h>
+#include "AccountService.h"
+#include "API/Account/IAccountManager.h"
+
+//using namespace TizenApis::Api::Account;
+//using namespace WrtDeviceApis::Commons;
+//using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Platform {
+namespace Account{
+class AccountManager : public IAccountManager
+{
+       public:
+               AccountManager();
+               virtual ~AccountManager();
+
+       protected:
+               virtual void OnRequestReceived(const IEventGetAccountServicesPtr &event);
+               virtual void OnRequestReceived(const IEventAddAccountPtr &event);
+               virtual void OnRequestReceived(const IEventDeleteAccountPtr &event);
+               virtual void OnRequestReceived(const IEventFindAccountsPtr &account);
+               virtual void OnRequestReceived(const IEventUpdateAccountPtr &account);
+               virtual void OnRequestReceived(const IEventGetAccountByIdPtr &account);
+               virtual void OnRequestReceived(const IEventGetServiceTypeByIdPtr &account);
+               virtual void OnRequestReceived(const IEventGetProviderByIdPtr &account);
+               virtual void OnRequestReceived(const IEventFindProvidersPtr &account);
+               virtual void OnRequestReceived(const IEventFindServiceTypesPtr &event);
+
+
+       private:
+               static int m_instanceCount;
+               DPL::Mutex m_constructorMutex;
+};
+
+}
+}
+}
+#endif
diff --git a/src/platform/Tizen/Account/AccountService.cpp b/src/platform/Tizen/Account/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/AccountService.h b/src/platform/Tizen/Account/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 
diff --git a/src/platform/Tizen/Account/AccountWrapper.cpp b/src/platform/Tizen/Account/AccountWrapper.cpp
new file mode 100755 (executable)
index 0000000..fae2d5b
--- /dev/null
@@ -0,0 +1,2074 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * @file        AccountWrapper.cpp
+ * @author      Jihwa Park (jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ */
+
+#include <string.h>
+#include <algorithm>
+#include <pcrecpp.h>
+#include <dpl/log/log.h>
+#include <Commons/Exception.h>
+#include "AccountWrapper.h"
+#include "AccountService.h"
+#include "account.h"
+
+#include "db-util.h"
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+//using namespace WrtDeviceApis::CommonsJavaScript;
+
+ // For Test
+
+#define _QUERY_DB_NAME "/opt/dbspace/.test-accounts.db"
+#define _QUERY_SQL_STRING_LEN          4096    //short sql string length
+#define _USER_ACCOUNT_TABLE_NAME "user_account"
+#define _SERVICES_TABLE_NAME "service"
+#define _SERVICETYPE_TABLE_NAME "service_type"
+#define _PROVIDER_LIST_TABLE_NAME "provider_list"
+#define _TAGS_MIME_TABLE_NAME "tags_mime"
+#define _RELATION_TABLE_NAME "relation"
+#define _REL_PROVIDER_TABLE_NAME "provider_to_svctype"
+
+static sqlite3 *test_hDBCt;
+typedef sqlite3_stmt* stmt;
+
+#define __USER_ACCOUNT_SCHEMA  "create table %s \n"\
+"(\n"\
+       "user_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
+       "displayname TEXT, "\
+       "icon TEXT, "\
+       "account_id TEXT, "\
+       "enable INTEGER, "\
+       "credential_id REAL, "\
+       "settings TEXT, "\
+       "provider_id TEXT, "\
+       "login_id TEXT, "\
+       "_list_id INTEGER "\
+");"
+
+#define __SERVICE_SCHEMA  "create table %s \n"\
+"(\n"\
+       "_svc_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
+       "service_id TEXT, "\
+       "service_name TEXT, "\
+       "application_id TEXT, "\
+       "display_name TEXT, "\
+       "icon TEXT, "\
+       "serviceType_id TEXT,  "\
+       "provider_id TEXT,  "\
+       "setting TEXT, "\
+       "enable INTEGER DEFAULT 0"\
+");"
+
+#define __SERVICETYPE_SCHEMA  "create table %s \n"\
+"(\n"\
+       "type_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
+       "serviceType_id TEXT, "\
+       "display_name TEXT, "\
+       "icon TEXT "\
+");"
+
+#define __TAGS_MIMETYPE_SCHEMA  "create table %s \n"\
+"(\n"\
+       "tags_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
+       "tag_name TEXT "\
+");"
+
+#define __RELATION_SCHEMA  "create table %s \n"\
+"(\n"\
+       "relation_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
+       "tags_id INTEGER, "\
+       "_svc_id INTEGER, "\
+       "type_id INTEGER, "\
+       "tag_name TEXT "\
+");"
+
+#define __REL_PROVIDER_SCHEMA  "create table %s \n"\
+"(\n"\
+       "_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
+       "_list_id INTEGER, "\
+       "type_id INTEGER "\
+");"
+
+#define __PROVIDER_LIST_SCHEMA  "create table %s \n"\
+"(\n"\
+       "_list_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
+       "provider_id TEXT, "\
+       "display_name TEXT, "\
+       "icon TEXT "\
+");"
+
+stmt __query_prepare(char *query)
+{
+       int rc = -1;
+       stmt pStmt = NULL;
+
+       printf("!! query : %s \n", query);
+
+       rc = sqlite3_prepare_v2(test_hDBCt, query, strlen(query), &pStmt, NULL);
+
+       if(SQLITE_OK != rc)
+       {
+               return NULL;
+       }
+
+       return pStmt;
+}
+
+int _query_exec(char *query)
+{
+   int rc = -1;
+   char* pszErrorMsg = NULL;
+
+    rc = sqlite3_exec(test_hDBCt, query, NULL, NULL, &pszErrorMsg);
+   if(SQLITE_OK != rc)
+   {
+       sqlite3_free(pszErrorMsg);
+   }
+
+   return rc;
+}
+
+int
+_create_all_tables(void)
+{
+       int rc = -1;
+       int error_code = 0;
+       char    query[_QUERY_SQL_STRING_LEN + 1] = {0, };
+
+       //Create test table
+       {
+               memset(query, 0, sizeof(query));
+               snprintf(query, sizeof(query) - 1,  __USER_ACCOUNT_SCHEMA, _USER_ACCOUNT_TABLE_NAME);
+               rc = _query_exec(query);
+
+               memset(query, 0, sizeof(query));
+               snprintf(query, sizeof(query) - 1,  __SERVICE_SCHEMA, _SERVICES_TABLE_NAME);
+               rc = _query_exec(query);
+
+               memset(query, 0, sizeof(query));
+               snprintf(query, sizeof(query) - 1,  __SERVICETYPE_SCHEMA, _SERVICETYPE_TABLE_NAME);
+               rc = _query_exec(query);
+
+               memset(query, 0, sizeof(query));
+               snprintf(query, sizeof(query) - 1,  __TAGS_MIMETYPE_SCHEMA, _TAGS_MIME_TABLE_NAME);
+               rc = _query_exec(query);
+
+               memset(query, 0, sizeof(query));
+               snprintf(query, sizeof(query) - 1,  __RELATION_SCHEMA, _RELATION_TABLE_NAME);
+               rc = _query_exec(query);
+
+               memset(query, 0, sizeof(query));
+               snprintf(query, sizeof(query) - 1,  __REL_PROVIDER_SCHEMA, _REL_PROVIDER_TABLE_NAME);
+               rc = _query_exec(query);
+
+               memset(query, 0, sizeof(query));
+               snprintf(query, sizeof(query) - 1,  __PROVIDER_LIST_SCHEMA, _PROVIDER_LIST_TABLE_NAME);
+               rc = _query_exec(query);
+
+       }
+
+       return error_code;
+}
+
+int _query_bind_text(stmt pStmt, int pos, char* str)
+{
+       int len = 0;
+       if(str != NULL)
+       {
+               len = strlen(str);
+               return sqlite3_bind_text(pStmt, pos, (const char*)str, len, SQLITE_STATIC);
+       }
+       return -1;
+}
+
+int _query_step(stmt pStmt)
+{
+       return sqlite3_step(pStmt);
+}
+
+void _query_finalize(stmt pStmt)
+{
+       int rc = -1;
+
+       if(!pStmt)
+         return;
+
+       rc = sqlite3_finalize(pStmt);
+       if(rc != SQLITE_OK)
+       {
+
+       }
+}
+
+int _query_bind_int(stmt pStmt, int pos, int num)
+{
+   return sqlite3_bind_int(pStmt, pos, num);
+}
+#if 0
+void insert_dummy_data()
+{
+       int             rc = 0;
+       char    query[_QUERY_SQL_STRING_LEN + 1] = {0, };
+       stmt    hstmt = NULL;
+       int i = 0;
+
+       _create_all_tables();
+
+// insert to tag_name to tag_mime table
+       memset(query, 0x00, sizeof(query));
+       sprintf(query, "insert into %s(tag_name) values (?) ", _TAGS_MIME_TABLE_NAME);
+
+       char* tag_name[] =
+       {
+               "tizen.messaging",
+               "tizen.email",
+               "tizen.sms",
+               "tizen.mms",
+               "tizen.chat",
+               "tizen.call",
+               "tizen.sharing"
+       };
+
+       for(i = 0; i < 7; i++)
+       {
+               hstmt = __query_prepare(query);
+
+               _query_bind_text(hstmt, 1, (char*)tag_name[i]);
+               rc = _query_step(hstmt);
+               if(rc != SQLITE_DONE)
+               {
+                       printf("\n !! rc : %d \n", rc);
+               }
+
+               _query_finalize(hstmt);
+               hstmt = NULL;
+       }
+
+//    rc = sqlite3_exec(test_hDBCt, "BEGIN IMMEDIATE TRANSACTION", NULL, NULL, &pszErrorMsg);
+
+// insert to _USER_ACCOUNT_TABLE_NAME
+       memset(query, 0x00, sizeof(query));
+       sprintf(query, "insert into %s(displayname, icon, account_id, provider_id, login_id) values "
+               "(?, ?, ?, ?, ?) ", _USER_ACCOUNT_TABLE_NAME);
+
+       char* displayname[] =
+       {
+               "Jamie's google account",
+               "William's facebook account",
+               "Craig's twitter account",
+               "Lucille's account"
+       };
+
+       char* icon[] =
+       {
+               "/opt/icon/image1.jpg",
+               "",
+               "/opt/icon/image1.jpg",
+               "/opt/icon/image2.jpg"
+       };
+
+       char* account_id[] =
+       {
+               "com.google:Jamie@gmail.com",
+               "com.facebook:William@facebook.com",
+               "com.twitter:Craig@twitter.com",
+               "com.custom:Lucille@gmail.com"
+       };
+
+       char* provider_id[] =
+       {
+               "com.google",
+               "com.facebook",
+               "com.twitter",
+               "com.custom"
+       };
+
+       char* login_id[] =
+       {
+               "Jamie@gmail.com",
+               "William@facebook.com",
+               "Craig@twitter.com",
+               "Lucille@gmail.com"
+       };
+
+       for(i = 0; i < 4; i++)
+       {
+               hstmt = __query_prepare(query);
+
+               _query_bind_text(hstmt, 1, (char*)displayname[i]);
+               _query_bind_text(hstmt, 2, (char*)icon[i]);
+               _query_bind_text(hstmt, 3, (char*)account_id[i]);
+               _query_bind_text(hstmt, 4, (char*)provider_id[i]);
+               _query_bind_text(hstmt, 5, (char*)login_id[i]);
+
+               rc = _query_step(hstmt);
+               if(rc != SQLITE_DONE)
+               {
+                       printf("\n !! rc : %d \n", rc);
+               }
+
+               _query_finalize(hstmt);
+               hstmt = NULL;
+       }
+
+// insert to _SERVICETYPE_TABLE_NAME
+       memset(query, 0x00, sizeof(query));
+       sprintf(query, "insert into %s(serviceType_id) values (?) ", _SERVICETYPE_TABLE_NAME);
+
+       char* service_type_id[] =
+       {
+               "tizen.sms",
+               "tizen.mms",
+               "tizen.tel"
+       };
+
+       for(i = 0; i < 3; i++)
+       {
+               hstmt = __query_prepare(query);
+               _query_bind_text(hstmt, 1, (char*)service_type_id[i]);
+
+               rc = _query_step(hstmt);
+               if(rc != SQLITE_DONE)
+               {
+                       printf("\n !! rc : %d \n", rc);
+               }
+
+               _query_finalize(hstmt);
+               hstmt = NULL;
+       }
+
+// insert to _SERVICE_TABLE_NAME
+       memset(query, 0x00, sizeof(query));
+       sprintf(query, "insert into %s(service_id, provider_id, serviceType_id) values "
+               "(?, ?, ?) ", _SERVICES_TABLE_NAME);
+
+       char* service_id[] =
+       {
+               "com.google.gmail",
+               "com.google.gtalk",
+               "com.google.picasa",
+               "com.facebook.facebook",
+               "com.twitter.twitter",
+               "com.custom.custom",
+       };
+
+       for(i = 0; i < 6; i++)
+       {
+               hstmt = __query_prepare(query);
+
+               _query_bind_text(hstmt, 1, (char*)service_id[i]);
+
+               if(i < 3)
+               {
+                       _query_bind_text(hstmt, 2, (char*)provider_id[0]);
+                       _query_bind_text(hstmt, 3, (char*)service_type_id[i]);
+               }else
+               {
+                       _query_bind_text(hstmt, 2, (char*)provider_id[i-2]);
+                       _query_bind_text(hstmt, 3, (char*)service_type_id[2]);
+               }
+
+               rc = _query_step(hstmt);
+               if(rc != SQLITE_DONE)
+               {
+                       printf("\n !! rc : %d \n", rc);
+               }
+
+               _query_finalize(hstmt);
+               hstmt = NULL;
+       }
+
+// insert to _PROVIDER_LIST_TABLE_NAME
+       memset(query, 0x00, sizeof(query));
+       sprintf(query, "insert into %s(provider_id, display_name) values (?, ?) ", _PROVIDER_LIST_TABLE_NAME);
+
+       char* provider_display_name[] =
+       {
+               "provider:com.google",
+               "provider:com.facebook",
+               "provider:com.twitter",
+               "provider:com.custom",
+       };
+
+       for(i = 0; i < 4; i++)
+       {
+               hstmt = __query_prepare(query);
+
+               _query_bind_text(hstmt, 1, (char*)provider_id[i]);
+               _query_bind_text(hstmt, 2, (char*)provider_display_name[i]);
+
+               rc = _query_step(hstmt);
+               if(rc != SQLITE_DONE)
+               {
+                       printf("\n !! rc : %d \n", rc);
+               }
+
+               _query_finalize(hstmt);
+               hstmt = NULL;
+       }
+
+// insert to _RELATION_TABLE_NAME
+       memset(query, 0x00, sizeof(query));
+       sprintf(query, "insert into %s(tags_id, _svc_id, type_id, tag_name) values (?, ?, ?, ?) ", _RELATION_TABLE_NAME);
+
+       hstmt = __query_prepare(query);
+
+       _query_bind_int(hstmt, 1, 2);
+       _query_bind_int(hstmt, 2, 1);
+       _query_bind_int(hstmt, 3, 0);
+       _query_bind_text(hstmt, 4, (char*)tag_name[1]);
+
+       rc = _query_step(hstmt);
+       if(rc != SQLITE_DONE)
+               printf("\n !! rc : %d \n", rc);
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+       hstmt = __query_prepare(query);
+       _query_bind_int(hstmt, 1, 5);
+       _query_bind_int(hstmt, 2, 2);
+       _query_bind_int(hstmt, 3, 0);
+       _query_bind_text(hstmt, 4, (char*)tag_name[4]);
+
+       rc = _query_step(hstmt);
+       if(rc != SQLITE_DONE)
+               printf("\n !! rc : %d \n", rc);
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+       hstmt = __query_prepare(query);
+       _query_bind_int(hstmt, 1, 7);
+       _query_bind_int(hstmt, 2, 3);
+       _query_bind_int(hstmt, 3, 0);
+       _query_bind_text(hstmt, 4, (char*)tag_name[6]);
+
+       rc = _query_step(hstmt);
+       if(rc != SQLITE_DONE)
+               printf("\n !! rc : %d \n", rc);
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+       hstmt = __query_prepare(query);
+
+       _query_bind_int(hstmt, 1, 7);
+       _query_bind_int(hstmt, 2, 4);
+       _query_bind_int(hstmt, 3, 0);
+       _query_bind_text(hstmt, 4, (char*)tag_name[6]);
+
+       rc = _query_step(hstmt);
+       if(rc != SQLITE_DONE)
+               printf("\n !! rc : %d \n", rc);
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+       hstmt = __query_prepare(query);
+
+       _query_bind_int(hstmt, 1, 7);
+       _query_bind_int(hstmt, 2, 5);
+       _query_bind_int(hstmt, 3, 0);
+       _query_bind_text(hstmt, 4, (char*)tag_name[6]);
+
+       rc = _query_step(hstmt);
+       if(rc != SQLITE_DONE)
+               printf("\n !! rc : %d \n", rc);
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+       hstmt = __query_prepare(query);
+
+       _query_bind_int(hstmt, 1, 7);
+       _query_bind_int(hstmt, 2, 6);
+       _query_bind_int(hstmt, 3, 0);
+       _query_bind_text(hstmt, 4, (char*)tag_name[6]);
+
+       rc = _query_step(hstmt);
+       if(rc != SQLITE_DONE)
+               printf("\n !! rc : %d \n", rc);
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+       hstmt = __query_prepare(query);
+
+       _query_bind_int(hstmt, 1, 1);
+       _query_bind_int(hstmt, 2, 0);
+       _query_bind_int(hstmt, 3, 1);
+       _query_bind_text(hstmt, 4, (char*)tag_name[0]);
+
+       rc = _query_step(hstmt);
+       if(rc != SQLITE_DONE)
+               printf("\n !! rc : %d \n", rc);
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+       hstmt = __query_prepare(query);
+
+       _query_bind_int(hstmt, 1, 3);
+       _query_bind_int(hstmt, 2, 0);
+       _query_bind_int(hstmt, 3, 1);
+       _query_bind_text(hstmt, 4, (char*)tag_name[2]);
+
+       rc = _query_step(hstmt);
+       if(rc != SQLITE_DONE)
+               printf("\n !! rc : %d \n", rc);
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+       hstmt = __query_prepare(query);
+
+       _query_bind_int(hstmt, 1, 4);
+       _query_bind_int(hstmt, 2, 0);
+       _query_bind_int(hstmt, 3, 1);
+       _query_bind_text(hstmt, 4, (char*)tag_name[3]);
+
+       rc = _query_step(hstmt);
+       if(rc != SQLITE_DONE)
+               printf("\n !! rc : %d \n", rc);
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+       hstmt = __query_prepare(query);
+
+       _query_bind_int(hstmt, 1, 1);
+       _query_bind_int(hstmt, 2, 0);
+       _query_bind_int(hstmt, 3, 2);
+       _query_bind_text(hstmt, 4, (char*)tag_name[0]);
+
+       rc = _query_step(hstmt);
+       if(rc != SQLITE_DONE)
+               printf("\n !! rc : %d \n", rc);
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+       hstmt = __query_prepare(query);
+
+       _query_bind_int(hstmt, 1, 4);
+       _query_bind_int(hstmt, 2, 0);
+       _query_bind_int(hstmt, 3, 2);
+       _query_bind_text(hstmt, 4, (char*)tag_name[3]);
+
+       rc = _query_step(hstmt);
+       if(rc != SQLITE_DONE)
+               printf("\n !! rc : %d \n", rc);
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+       hstmt = __query_prepare(query);
+
+       _query_bind_int(hstmt, 1, 5);
+       _query_bind_int(hstmt, 2, 0);
+       _query_bind_int(hstmt, 3, 3);
+       _query_bind_text(hstmt, 4, (char*)tag_name[4]);
+
+       rc = _query_step(hstmt);
+       if(rc != SQLITE_DONE)
+               printf("\n !! rc : %d \n", rc);
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+       hstmt = __query_prepare(query);
+
+       _query_bind_int(hstmt, 1, 6);
+       _query_bind_int(hstmt, 2, 0);
+       _query_bind_int(hstmt, 3, 3);
+       _query_bind_text(hstmt, 4, (char*)tag_name[5]);
+
+       rc = _query_step(hstmt);
+       if(rc != SQLITE_DONE)
+               printf("\n !! rc : %d \n", rc);
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+// insert to _REL_PROVIDER_TABLE_NAME
+       memset(query, 0x00, sizeof(query));
+       sprintf(query, "insert into %s(_list_id, type_id) values (?, ?) ", _REL_PROVIDER_TABLE_NAME);
+
+       for(i = 0; i < 6; i++)
+       {
+               hstmt = __query_prepare(query);
+
+               if(i<3)
+               {
+                       _query_bind_int(hstmt, 1, 1);
+                       _query_bind_int(hstmt, 2, i+1);
+               }else
+               {
+                       _query_bind_int(hstmt, 1, i-1);
+                       _query_bind_int(hstmt, 2, 3);
+               }
+
+               rc = _query_step(hstmt);
+               if(rc != SQLITE_DONE)
+               {
+                       printf("\n !! rc : %d \n", rc);
+               }
+
+               _query_finalize(hstmt);
+               hstmt = NULL;
+       }
+//    rc = sqlite3_exec(test_hDBCt, "COMMIT TRANSACTION", NULL, NULL, &pszErrorMsg);
+
+}
+#endif
+
+typedef enum
+{
+       SERVICE_TYPE_ID,
+       TAGS,
+       PROVIDER_ID,
+       FILTER_ATTRIBUTE_MAX
+}filter_e;
+
+typedef enum
+{
+       ENABLE,
+       DISABLE,
+       ALL
+}status_e;
+
+typedef 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;
+       bool enabled;
+}tags_info_t;
+
+typedef struct
+{
+       char* AccountServiceTypeId;
+       char* displayName;
+       char* icon;
+       GList* tags_info; // tags_info_t
+}AccountServiceType_t;
+
+typedef struct
+{
+       char* AccountServiceId;
+       char* serviceName;
+       char* applicationId;
+       char* displayName;
+       char* icon;
+       char* AccountId;
+       char* AccountServiceTypeId;
+       char* AccountServiceProviderId;
+       char* setting;
+       GList* tags_info; // tags_info_t
+       bool enabled;
+}AccountService_t;
+
+typedef struct
+{
+       char* AccountServiceProviderId;
+       char* displayName;
+       char* icon;
+}provider_t;
+
+typedef struct
+{
+       char* 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;
+
+UserAccount_t user_account = {0, };
+UserProperties_t property = {0, };
+AccountServiceType_t serviceType = {0, };
+provider_t provider = {0, };
+
+int addAccount(const char* providerId, UserProperties_t* properties, UserAccount_t* account)
+{
+       return 0;
+}
+
+typedef struct
+{
+       GList* filter_list;
+       status_e status;
+       int tags_count;
+}search_list_t;
+
+typedef struct
+{
+       filter_e filter_type;
+       char* value;
+}filter_value_t;
+
+int set_account_filter(search_list_t* search_list, filter_e filter_type, char* value)
+{
+       filter_value_t* object = NULL;
+       object = g_new0(filter_value_t, 1);
+
+       object->filter_type = filter_type;
+       object->value = g_strdup(value);
+       if(filter_type == TAGS)
+               search_list->tags_count++;
+       search_list->filter_list = g_list_append(search_list->filter_list, object);
+
+       return 0;
+}
+
+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);
+}
+
+double _query_column_double(stmt pStmt, int pos)
+{
+   return sqlite3_column_double(pStmt, pos);
+}
+
+#define QUERY_MAX_LEN 4096
+#define SUB_QUERY_LEN 2048
+#define TABLE_LEN 512
+
+void _get_tags(tags_owner owner, int id, GList** tags_list)
+{
+       int rc = 0;
+       char query[QUERY_MAX_LEN + 1] = {0, };
+
+       switch(owner)
+       {
+               case TAG_SERVICE :
+                       snprintf(query, sizeof(query) - 1, "select tag_name from relation where _svc_id = %d", id);
+                       break;
+               case TAG_SERVICE_TYPE :
+                       snprintf(query, sizeof(query) - 1, "select tag_name from relation where type_id = %d", id);
+               default :
+                       break;
+       }
+
+       stmt hstmt = __query_prepare(query);
+
+       rc = _query_step(hstmt);
+       while(rc == SQLITE_ROW)
+       {
+               tags_info_t* tag_info = NULL;
+               tag_info = g_new0(tags_info_t, 1);
+               tag_info->tag_info = g_strdup(_query_column_text(hstmt, 0));
+
+               *tags_list = g_list_append(*tags_list, tag_info);
+               rc = _query_step(hstmt);
+       }
+       _query_finalize(hstmt);
+}
+
+char* _make_condition_part(search_list_t* search_list, query_type_e type)
+{
+       char* query = NULL;
+       char tmp_query[SUB_QUERY_LEN + 1] = {0, };
+       char pre_query[TABLE_LEN + 1] = {0, };
+       char table[TABLE_LEN + 1] = {0, };
+       used_filter_attr use_filter = USE_FILTER_NONE;
+       int filter_count = 0;
+       int tags_count = 0;
+
+       query = g_new0(char, QUERY_MAX_LEN);
+
+       if(type == FIND_ACCOUNT)
+               snprintf(pre_query, sizeof(pre_query) - 1, "where user_account.provider_id in (select a.provider_id from service a ");
+       else
+               snprintf(pre_query, sizeof(pre_query) - 1, "where service._svc_id in (select a._svc_id from service a ");
+
+       GList* tmp_filter_list = search_list->filter_list;
+       while(tmp_filter_list)
+       {
+               filter_value_t* object = (filter_value_t*)tmp_filter_list->data;
+
+               if(object->value != NULL)
+               {
+                       if(object->filter_type == SERVICE_TYPE_ID)
+                       {
+                               use_filter = (used_filter_attr)(use_filter | USE_SERVICE_TYPE_ID);
+
+                               if(tmp_query[0] == '\0')
+                                       sprintf(tmp_query, "a.%s = ? ", filter_attribute[object->filter_type]);
+                               else
+                                       sprintf(tmp_query, "and %s a.%s = ? ", tmp_query, filter_attribute[object->filter_type]);
+
+                       }else if(object->filter_type == TAGS)
+                       {
+                               use_filter = (used_filter_attr)(use_filter | USE_TAGS);
+                               tags_count++;
+
+                               if(tags_count == 1)
+                               {
+                                       if(table[0] == '\0')
+                                               sprintf(table, ", relation b ");
+                                       else
+                                               sprintf(table, "%s, relation b ", table);
+
+                                       if(tmp_query[0] == '\0')
+                                       {
+                                               if(search_list->tags_count > 1)
+                                                       sprintf(tmp_query, "(a._svc_id = b._svc_id) and (b.%s = ? ", filter_attribute[object->filter_type]);
+                                               else
+                                                       sprintf(tmp_query, "(a._svc_id = b._svc_id) and b.%s = ? ", filter_attribute[object->filter_type]);
+                                       }else
+                                       {
+                                               if(search_list->tags_count > 1)
+                                                       sprintf(tmp_query, "%s and (a._svc_id = b._svc_id) and (b.%s = ? ", tmp_query, filter_attribute[object->filter_type]);
+                                               else
+                                                       sprintf(tmp_query, "%s and (a._svc_id = b._svc_id) and b.%s = ? ", tmp_query, filter_attribute[object->filter_type]);
+                                       }
+                               }else
+                               {
+                                       sprintf(tmp_query, "%s or b.%s = ? ", tmp_query, filter_attribute[object->filter_type]);
+                                       if(search_list->tags_count > 1 && search_list->tags_count == tags_count)
+                                               sprintf(tmp_query, "%s) ", tmp_query);
+                               }
+                       }else if(object->filter_type == PROVIDER_ID)
+                       {
+                               use_filter = (used_filter_attr)(use_filter | USE_PROVIDER_ID);
+
+                               if(tmp_query[0] == '\0')
+                                       sprintf(tmp_query, "a.%s = ? ", filter_attribute[object->filter_type]);
+                               else
+                                       sprintf(tmp_query, "%s and a.%s = ? ", tmp_query, filter_attribute[object->filter_type]);
+                       }
+                       filter_count++;
+               }
+               tmp_filter_list = g_list_next(tmp_filter_list);
+       }
+
+       if(table[0] != '\0')
+               snprintf(query, QUERY_MAX_LEN, "%s %s where %s)", pre_query, table, tmp_query);
+       else
+               snprintf(query, QUERY_MAX_LEN, "%s where %s)", pre_query, tmp_query);
+
+       if(type == FIND_ACCOUNT)
+       {
+               if((use_filter | USE_PROVIDER_ID) == USE_PROVIDER_ID && filter_count == 1)
+               {
+                       memset(query, 0x00, QUERY_MAX_LEN);
+                       snprintf(query, QUERY_MAX_LEN, "where user_account.provider_id = ? ");
+               }else if((use_filter | USE_SERVICE_TYPE_ID) == USE_SERVICE_TYPE_ID && filter_count == 1)
+               {
+                       memset(query, 0x00, QUERY_MAX_LEN);
+                       snprintf(query, QUERY_MAX_LEN, ",service where (user_account.provider_id = service.provider_id) and service.serviceType_id = ? ");
+               }
+       }else
+       {
+               if((use_filter | USE_PROVIDER_ID) == USE_PROVIDER_ID && filter_count == 1)
+               {
+                       memset(query, 0x00, QUERY_MAX_LEN);
+                       snprintf(query, QUERY_MAX_LEN, ",service where (user_account.provider_id = service.provider_id) and user_account.provider_id = ? ");
+               }else if((use_filter | USE_SERVICE_TYPE_ID) == USE_SERVICE_TYPE_ID && filter_count == 1)
+               {
+                       memset(query, 0x00, QUERY_MAX_LEN);
+                       snprintf(query, QUERY_MAX_LEN, " where service.serviceType_id = ? ");
+               }
+       }
+
+       if(filter_count == 0)
+               return NULL;
+       else
+               return query;
+}
+
+void _get_service_list_by_account(char* provider_id, GList** service_list)
+{
+       int rc = 0;
+       int id = 0;
+       char query[QUERY_MAX_LEN + 1] = {0, };
+
+       snprintf(query, sizeof(query) - 1, "select service_id, service_name, application_id, display_name, icon, serviceType_id, provider_id, setting, enable, _svc_id "
+               "from %s where provider_id = %s", _SERVICES_TABLE_NAME, provider_id);
+
+       stmt hstmt = __query_prepare(query);
+
+       rc = _query_step(hstmt);
+       while(rc == SQLITE_ROW)
+       {
+               AccountService_t* service_info = NULL;
+               service_info = g_new0(AccountService_t, 1);
+
+               service_info->AccountServiceId = g_strdup(_query_column_text(hstmt, 0));
+               service_info->serviceName = g_strdup(_query_column_text(hstmt, 1));
+               service_info->applicationId = g_strdup(_query_column_text(hstmt, 2));
+               service_info->displayName = g_strdup(_query_column_text(hstmt, 3));
+               service_info->icon = g_strdup(_query_column_text(hstmt, 4));
+               service_info->AccountServiceTypeId = g_strdup(_query_column_text(hstmt, 5));
+               service_info->AccountServiceProviderId = g_strdup(_query_column_text(hstmt, 6));
+               service_info->setting = g_strdup(_query_column_text(hstmt, 7));
+               service_info->enabled = _query_column_int(hstmt, 8);
+               id =  _query_column_int(hstmt, 9);
+
+               _get_tags(TAG_SERVICE, id, &(service_info->tags_info));
+
+               *service_list = g_list_append(*service_list, service_info);
+               rc = _query_step(hstmt);
+       }
+       _query_finalize(hstmt);
+}
+
+void _make_account_info(int user_id, UserAccount_t* account_info)
+{
+       char query[QUERY_MAX_LEN + 1] = {0, };
+       int rc = 0;
+
+// Get user_account
+       snprintf(query, sizeof(query) - 1, "select displayname, icon, account_id, enable, credential_id, settings, provider_id "
+               "from %s where user_id = %d", _USER_ACCOUNT_TABLE_NAME, user_id);
+
+       stmt hstmt = __query_prepare(query);
+
+       rc = _query_step(hstmt);
+       account_info->displayName = g_strdup(_query_column_text(hstmt, 0));
+       account_info->icon = g_strdup(_query_column_text(hstmt, 1));
+       account_info->AccountId = g_strdup(_query_column_text(hstmt, 2));
+       account_info->enabled = _query_column_int(hstmt, 3);
+       account_info->credentialId = _query_column_double(hstmt, 4);
+       account_info->settings = g_strdup(_query_column_text(hstmt, 5));
+       account_info->AccountServiceProviderId = g_strdup(_query_column_text(hstmt, 6));
+
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+// Get 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, };
+       int rc = 0;
+       stmt hstmt = NULL;
+
+// Get user_account
+       snprintf(query, sizeof(query) - 1, "select service_id, service_name, application_id, display_name, icon, serviceType_id, provider_id, setting, enable "
+               "from %s where _svc_id = %d", _SERVICES_TABLE_NAME, id);
+
+       hstmt = __query_prepare(query);
+
+       rc = _query_step(hstmt);
+       service_info->AccountServiceId = g_strdup(_query_column_text(hstmt, 0));
+       service_info->serviceName = g_strdup(_query_column_text(hstmt, 1));
+       service_info->applicationId = g_strdup(_query_column_text(hstmt, 2));
+       service_info->displayName = g_strdup(_query_column_text(hstmt, 3));
+       service_info->icon = g_strdup(_query_column_text(hstmt, 4));
+       service_info->AccountServiceTypeId = g_strdup(_query_column_text(hstmt, 5));
+       service_info->AccountServiceProviderId = g_strdup(_query_column_text(hstmt, 6));
+       service_info->setting = g_strdup(_query_column_text(hstmt, 7));
+       service_info->enabled = _query_column_int(hstmt, 8);
+
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+// Get account_id
+       snprintf(query, sizeof(query) - 1, "select account_id from %s where provider_id = %s", _USER_ACCOUNT_TABLE_NAME, service_info->AccountServiceProviderId);
+
+       hstmt = __query_prepare(query);
+
+       rc = _query_step(hstmt);
+       service_info->AccountId = g_strdup(_query_column_text(hstmt, 0));
+
+       _query_finalize(hstmt);
+       hstmt = NULL;
+
+// Get tags
+       _get_tags(TAG_SERVICE, id, &(service_info->tags_info));
+
+}
+
+int find_accounts(search_list_t* search_list, status_e status, GList** account_list)
+{
+       int error_code = 0;
+       char query[QUERY_MAX_LEN + 1] = {0, };
+       int i = 1;
+       int index_list[SUB_QUERY_LEN + 1] = {0, };
+       int index_count = 0;
+       int rc = 0;
+       stmt    hstmt = NULL;
+
+       char* filter = _make_condition_part(search_list, FIND_ACCOUNT);
+
+       switch(status)
+       {
+               case ENABLE :
+               {
+                       if(filter)
+                               snprintf(query, sizeof(query) - 1, "select 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");
+               }
+                       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);
+                       else
+                               snprintf(query, sizeof(query) - 1, "select 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);
+                       else
+                               snprintf(query, sizeof(query) - 1, "select user_account.user_id from user_account");
+               }
+                       break;
+       }
+
+       hstmt = __query_prepare(query);
+
+       GList* filter_list_val = search_list->filter_list;
+       while(filter_list_val)
+       {
+               filter_value_t* object = (filter_value_t*)filter_list_val->data;
+
+               if(object->value != NULL)
+                       _query_bind_text(hstmt, i++, object->value);
+
+               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)
+       {
+               ret = _query_column_int(hstmt, 0);
+               index_list[index_count++] = ret;
+               rc = _query_step(hstmt);
+       }
+
+       _query_finalize(hstmt);
+
+// make account object by index_list
+       for(i = 0; i< index_count; i++)
+       {
+// Get account info
+               UserAccount_t* account_info = NULL;
+               account_info = g_new0(UserAccount_t, 1);
+               _make_account_info(index_list[i], account_info);
+
+// Generate account list
+               *account_list = g_list_append(*account_list, account_info);
+       }
+
+       if(filter)
+               free(filter);
+
+       return error_code;
+}
+
+int find_services(search_list_t* search_list, status_e status, GList** service_list)
+{
+       int error_code = 0;
+       char query[QUERY_MAX_LEN + 1] = {0, };
+       int i = 1;
+       int index_list[SUB_QUERY_LEN + 1] = {0, };
+       int index_count = 0;
+       int rc = 0;
+
+       char* filter = _make_condition_part(search_list, FIND_SERVICE);
+
+       switch(status)
+       {
+               case ENABLE :
+               {
+                       if(filter)
+                               snprintf(query, sizeof(query) - 1, "select service._id from service %s and service.enable = 1", filter);
+                       else
+                               snprintf(query, sizeof(query) - 1, "select service._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);
+                       else
+                               snprintf(query, sizeof(query) - 1, "select service._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);
+                       else
+                               snprintf(query, sizeof(query) - 1, "select service._id from service");
+               }
+                       break;
+       }
+
+       stmt hstmt = __query_prepare(query);
+
+       GList* filter_list_val = search_list->filter_list;
+       while(filter_list_val)
+       {
+               filter_value_t* object = (filter_value_t*)filter_list_val->data;
+
+               if(object->value != NULL)
+                       _query_bind_text(hstmt, i++, object->value);
+
+               filter_list_val = g_list_next(filter_list_val);
+       }
+
+       rc = _query_step(hstmt);
+       while(rc == SQLITE_ROW)
+       {
+               index_list[index_count++] = _query_column_int(hstmt, 0);
+               rc = _query_step(hstmt);
+       }
+
+       _query_finalize(hstmt);
+
+       for(i = 0; i< index_count; i++)
+       {
+// Get service info
+               AccountService_t* service_info = NULL;
+               service_info = g_new0(AccountService_t, 1);
+               _make_service_info(index_list[i], service_info);
+
+// Generate service list
+               *service_list = g_list_append(*service_list, service_info);
+       }
+
+       if(filter)
+               free(filter);
+
+       return error_code;
+}
+
+int find_providers(const char* serviceTypeId, GList** provider_list)
+{
+       int error_code = 0;
+       int rc = 0;
+       char query[QUERY_MAX_LEN + 1] = {0, };
+       char sub_query[SUB_QUERY_LEN + 1] = {0, };
+
+       if(serviceTypeId == NULL)
+       {
+               snprintf(query, sizeof(query) - 1, "select provider_id, display_name, icon from provider_list");
+       }else
+       {
+               snprintf(sub_query, sizeof(sub_query) - 1, "select type_id from service_type where serviceType_id = ?");
+               snprintf(query, sizeof(query) - 1, "select a.provider_id, a.display_name, a.icon from provider_list a, provider_to_svctype b "
+                       "where (a._list_id = b._list_id) and b.type_id in (%s) ", sub_query);
+       }
+
+       stmt hstmt = __query_prepare(query);
+
+       rc = _query_step(hstmt);
+       while(rc == SQLITE_ROW)
+       {
+               provider_t* provider = NULL;
+               provider = g_new0(provider_t, 1);
+               provider->AccountServiceProviderId = g_strdup(_query_column_text(hstmt, 0));
+               provider->displayName = g_strdup(_query_column_text(hstmt, 1));
+               provider->icon = g_strdup(_query_column_text(hstmt, 2));
+
+               *provider_list = g_list_append(*provider_list, provider);
+               rc = _query_step(hstmt);
+       }
+
+       _query_finalize(hstmt);
+
+       return error_code;
+}
+
+int find_service_types(char* prefix, GList** servicetype_list)
+{
+       int error_code = 0;
+       int rc = 0;
+       int type_id = 0;
+       char query[QUERY_MAX_LEN + 1] = {0, };
+
+       if(prefix == NULL)
+               snprintf(query, sizeof(query) - 1, "select type_id, serviceType_id, display_name, icon from service_type");
+       else
+               snprintf(query, sizeof(query) - 1, "select type_id, serviceType_id, display_name, icon from service_type where serviceType_id like (? || '%%')");
+
+       stmt hstmt = __query_prepare(query);
+
+       if(prefix != NULL)
+               _query_bind_text(hstmt, 1, prefix);
+
+       rc = _query_step(hstmt);
+       while(rc == SQLITE_ROW)
+       {
+               type_id = _query_column_int(hstmt, 0);
+
+               AccountServiceType_t* servicetype = NULL;
+               servicetype = g_new0(AccountServiceType_t, 1);
+               servicetype->AccountServiceTypeId = g_strdup(_query_column_text(hstmt, 1));
+               servicetype->displayName = g_strdup(_query_column_text(hstmt, 2));
+               servicetype->icon = g_strdup(_query_column_text(hstmt, 3));
+
+               _get_tags(TAG_SERVICE_TYPE, type_id, &(servicetype->tags_info));
+
+               *servicetype_list = g_list_append(*servicetype_list, servicetype);
+               rc = _query_step(hstmt);
+       }
+       _query_finalize(hstmt);
+
+       return error_code;
+}
+
+// use mandatory input parameter
+int getAccountById(char* accountId, UserAccount_t* account)
+{
+       int error_code = 0;
+       int rc = 0;
+       int user_id = 0;
+       char query[QUERY_MAX_LEN + 1] = {0, };
+
+       snprintf(query, sizeof(query) - 1, "select user_id from user_account where account_id = ?");
+
+       stmt hstmt = __query_prepare(query);
+       _query_bind_text(hstmt, 1, accountId);
+
+       rc = _query_step(hstmt);
+
+       user_id = _query_column_int(hstmt, 0);
+       _query_finalize(hstmt);
+
+       _make_account_info(user_id, account);
+
+       return error_code;
+}
+
+int getServiceTypeById(char* serviceTypeId, AccountServiceType_t* serviceType)
+{
+       int error_code = 0;
+       int rc = 0;
+       int type_id = 0;
+       char query[QUERY_MAX_LEN + 1] = {0, };
+
+       snprintf(query, sizeof(query) - 1, "select type_id, serviceType_id, display_name, icon from service_type where serviceType_id = ?");
+
+       stmt hstmt = __query_prepare(query);
+       _query_bind_text(hstmt, 1, serviceTypeId);
+
+       rc = _query_step(hstmt);
+
+       type_id = _query_column_int(hstmt, 0);
+
+       serviceType->AccountServiceTypeId = g_strdup(_query_column_text(hstmt, 1));
+       serviceType->displayName = g_strdup(_query_column_text(hstmt, 2));
+       serviceType->icon = g_strdup(_query_column_text(hstmt, 3));
+
+       _get_tags(TAG_SERVICE_TYPE, type_id, &(serviceType->tags_info));
+
+       _query_finalize(hstmt);
+
+       return error_code;
+}
+
+int getProviderById(char* serviceProviderId, provider_t* provider)
+{
+       int error_code = 0;
+       int rc = 0;
+       char query[QUERY_MAX_LEN + 1] = {0, };
+
+       snprintf(query, sizeof(query) - 1, "select provider_id, display_name, icon from provider_list where provider_id = ?");
+
+       stmt hstmt = __query_prepare(query);
+       _query_bind_text(hstmt, 1, serviceProviderId);
+
+       rc = _query_step(hstmt);
+
+       provider->AccountServiceProviderId = g_strdup(_query_column_text(hstmt, 0));
+       provider->displayName = g_strdup(_query_column_text(hstmt, 1));
+       provider->icon = g_strdup(_query_column_text(hstmt, 2));
+
+       _query_finalize(hstmt);
+
+       return error_code;
+}
+
+namespace TizenApis {
+namespace Platform {
+namespace Account{
+AccountWrapper::AccountWrapper() : m_platformAccount(NULL), m_abstractAccount(NULL)
+{
+    LogDebug("entered");
+    m_abstractAccount = EventAccountPtr(new EventAccount());
+    if (!m_abstractAccount) {
+        ThrowMsg(UnknownException, "abstract object is not created");
+    }
+}
+
+AccountWrapper::AccountWrapper(const EventAccountPtr &event) : m_platformAccount(NULL), m_abstractAccount(event)
+{
+    LogDebug("entered");
+}
+
+AccountWrapper::~AccountWrapper()
+{
+    LogDebug("entered");
+    //TODO: After inserting ,It seems like F/W frees handle. I need to review this later.
+    // After inserting and call freePlatformAccount, Segment fault occurs.
+    //freePlatformAccount();
+}
+
+int AccountWrapper::getIDFromPlatformAccount() const
+{
+    LogDebug("Entered");
+    int error_code = -1;
+       int accountid = 0;
+    if (m_platformAccount == NULL) {
+        ThrowMsg(NullPointerException, "m_platformAccount is not set");
+    }
+
+       error_code = account_get_account_id(m_platformAccount, &accountid);
+
+       if(ACCOUNT_ERROR_NONE != error_code)
+       {
+               ThrowMsg(PlatformException, "Can't get a account id");
+       }
+    return accountid;
+}
+
+//TODO: check if it works to dicriminate update/insert with account id.
+void AccountWrapper::saveAccount()
+{
+    LogDebug("entered");
+
+    int accountID = 0;
+    //Check if platform struct is set.
+    //It could be set here, but forcing user to do it manually can help to avoid problems.
+    if (m_platformAccount == NULL) {
+        ThrowMsg(NullPointerException, "m_platformAccount is not set");
+    }
+
+    accountID = m_abstractAccount->getID();
+
+    displayPlatformAccount();
+
+    int returnID;
+
+    //insert new record or update existing one
+    if (accountID < 0) { // insert new account
+           int err = addAccount(m_abstractAccount->getProviderName().c_str(), &property, &user_account);
+               user_account.AccountId = g_strdup("com.google:myaccount1@gmail.com");
+
+//        int err = account_insert_to_db(m_platformAccount, &returnID);
+        if (ACCOUNT_ERROR_NONE != err) {
+            LogError("Can't insert new account, error code: " << returnID);
+            ThrowMsg(PlatformException, "Can't insert new account.");
+        }
+        m_abstractAccount->setID(returnID);
+               m_abstractAccount->setAccountId(user_account.AccountId);
+
+        LogInfo("New event inserted");
+    } else { //update
+
+          //accountID = getIDFromPlatformAccount();
+         LogDebug("accountID: " << accountID);
+        if (ACCOUNT_ERROR_NONE != account_update_to_db_by_id(m_platformAccount, accountID)) {
+            ThrowMsg(PlatformException, "Can't update new account.");
+        }
+        LogDebug("Account updated");
+    }
+
+}
+
+void AccountWrapper::loadAccount(int id)
+{
+       LogDebug("Entered. ID of account to load: " << id);
+
+       freePlatformAccount();
+
+       if (ACCOUNT_ERROR_NONE != account_create(&m_platformAccount)) {
+               ThrowMsg(PlatformException, "Can't create handle");
+       }
+
+       int errorCode = account_query_account_by_account_id(id, &m_platformAccount);
+
+       if (ACCOUNT_ERROR_NONE != errorCode) {
+               LogError("Can't get account with ID = " << id << ", error code: " << errorCode);
+               ThrowMsg(PlatformException, "Can't get account with ID = " << id << ", error code: " << errorCode);
+       }
+       convertPlatformAccountToAbstractAccount();
+       displayAbstractAccount();
+}
+
+void AccountWrapper::deleteAccount()
+{
+    if (m_platformAccount == NULL) {
+        ThrowMsg(NullPointerException, "Failed to delete event (m_platformAccount==NULL)");
+    }
+    int accountID = m_abstractAccount->getID();
+    LogDebug("accountID : " << accountID);
+    if (accountID < 0) {
+        ThrowMsg(InvalidArgumentException, "Failed to delete account from account DB (account is not saved in account DB)");
+    }
+
+    int err = -1;
+    err = account_delete_from_db_by_id(accountID);
+    if (ACCOUNT_ERROR_NONE != err) {
+        ThrowMsg(PlatformException, "Can't delete account. Error code " << err);
+    }
+    //TODO: Is it necessary?
+    //m_abstractAccount->resetId();
+    //setIDToPlatformAccount();
+}
+
+void AccountWrapper::getAccountbyId()
+{
+    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);
+*/
+/*
+       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();
+}
+
+void AccountWrapper::getServiceTypebyId()
+{
+    std::string serviceTypeId = m_abstractAccount->getServiceTypeId();
+    LogDebug("serviceTypeId : " << serviceTypeId);
+
+//     getServiceTypeById(m_abstractAccount->getServiceTypeId().c_str(), &serviceType);
+       m_abstractAccount->setAccountId("com.google:getaccountbyid@gmail.com");
+
+}
+
+void AccountWrapper::getProviderbyId()
+{
+    std::string providerId = m_abstractAccount->getProviderId();
+    LogDebug("providerId : " << providerId);
+
+//     getProviderById(m_abstractAccount->getProviderId().c_str(), &provider);
+       m_abstractAccount->setAccountId("com.google:getaccountbyid@gmail.com");
+
+}
+
+void AccountWrapper::findProviders()
+{
+    std::string serviceTypeId = m_abstractAccount->getServiceTypeId();
+    LogDebug("serviceTypeId : " << serviceTypeId);
+
+       db_util_open(_QUERY_DB_NAME, &test_hDBCt, 0);
+//     insert_dummy_data();
+
+#if 0
+       GList* provider_list = NULL;
+       int i = 0;
+
+       GList* account_list = NULL;
+       UserAccount_t* account = 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\n\n", account_info->AccountServiceProviderId);
+               account_list = g_list_next(account_list);
+       }
+
+       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);
+       }
+
+       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);
+       }
+
+       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);
+       }
+
+       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);
+       }
+
+       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);
+
+// Add service info to Javascript obj
+               account_list = g_list_next(account_list);
+       }
+
+#endif
+       GList* servicetype_list = NULL;
+
+       find_service_types("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);
+       }
+
+       m_abstractAccount->setAccountId("com.google:findProviders@gmail.com");
+
+}
+
+void AccountWrapper::findServiceTypes()
+{
+       std::string prefix = m_abstractAccount->getprefix();
+    LogDebug("prefix : " << prefix);
+//     GList* servicetype_list = NULL;
+
+//     find_service_types(m_abstractAccount->getprefix().c_str(), &servicetype_list);
+
+//     m_abstractAccount->setAccountId("com.google:findServiceTypes@gmail.com");
+
+}
+
+char *AccountWrapper::getPlatformAccount() const
+{
+    LogDebug("entered");
+    return (char*)m_platformAccount;
+}
+
+EventAccountPtr AccountWrapper::getAbstractAccount() const
+{
+    LogDebug("entered");
+    return m_abstractAccount;
+}
+
+void AccountWrapper::freePlatformAccount()
+{
+    LogDebug("entered");
+    if (m_platformAccount != NULL) {
+        if (ACCOUNT_ERROR_NONE != account_destroy(m_platformAccount)) {
+            LogError("Can't free account handle.");
+        }
+        m_platformAccount = NULL;
+    }
+}
+
+char *AccountWrapper::convertAbstractAccountToPlatformAccount()
+{
+       LogDebug("entered");
+       freePlatformAccount();
+
+       if (ACCOUNT_ERROR_NONE != account_create(&m_platformAccount)) {
+               ThrowMsg(PlatformException, "Can't create handle");
+       }
+
+       property.displayName = g_strdup(m_abstractAccount->getDisplayName().c_str());
+       property.icon = g_strdup(m_abstractAccount->getIconPath().c_str());
+
+       setDisplayNameToPlatformAccount();
+       setIconPathToPlatformAccount();
+       setProviderNameToPlatformAccount();
+/*
+       setUserNameToPlatformAccount();
+       setPackageNameToPlatformAccount();
+
+       //TODO: check if we need to have  user be able to set  the ID.
+       //setIDToPlatformAccount();
+       setEmailAddressToPlatformAccount();
+       setDomainNameToPlatformAccount();
+
+       setAccountServices();
+*/
+       return getPlatformAccount();
+}
+
+void AccountWrapper::setIDToPlatformAccount()
+{
+    LogDebug("entered");
+
+//TODO: check if we need to have  user be able to set  the ID.
+
+#if 0
+    if (!m_platformAccount) {
+        ThrowMsg(UnknownException, "Null platform pointer.");
+    }
+    if (m_abstractAccount->getIdIsSet()) {
+        if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
+                                                       CAL_VALUE_INT_INDEX,
+                                                       m_abstractEvent->getId()))
+        {
+            ThrowMsg(PlatformException, "Can't set event ID.");
+        }
+    } else {
+        if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
+                                                       CAL_VALUE_INT_INDEX,
+                                                       NEW_EVENT_ID)) {
+            ThrowMsg(PlatformException, "Can't set event ID.");
+        }
+    }
+       #endif
+}
+
+void AccountWrapper::setDisplayNameToPlatformAccount()
+{
+    LogDebug("entered");
+       if (!m_platformAccount) {
+               ThrowMsg(UnknownException, "Null platform pointer.");
+       }
+
+       if (ACCOUNT_ERROR_NONE != account_set_display_name(m_platformAccount, m_abstractAccount->getDisplayName().c_str()))
+       {
+               ThrowMsg(PlatformException, "Can't set displayname.");
+       }
+
+}
+
+void AccountWrapper::setIconPathToPlatformAccount()
+{
+    LogDebug("entered");
+       if (!m_platformAccount) {
+               ThrowMsg(UnknownException, "Null platform pointer.");
+       }
+
+       if (ACCOUNT_ERROR_NONE != account_set_icon_path(m_platformAccount, m_abstractAccount->getIconPath().c_str()))
+       {
+               ThrowMsg(PlatformException, "Can't set iconPath.");
+       }
+
+}
+
+void AccountWrapper::setProviderNameToPlatformAccount()
+{
+    LogDebug("entered");
+       if (!m_platformAccount) {
+               ThrowMsg(UnknownException, "Null platform pointer.");
+       }
+
+       if (ACCOUNT_ERROR_NONE != account_set_source(m_platformAccount, m_abstractAccount->getProviderName().c_str()))
+       {
+               ThrowMsg(PlatformException, "Can't set providername.");
+       }
+}
+
+void AccountWrapper::setEmailAddressToPlatformAccount()
+{
+       LogDebug("entered");
+       if (!m_platformAccount) {
+               ThrowMsg(UnknownException, "Null platform pointer.");
+       }
+
+       if (ACCOUNT_ERROR_NONE != account_set_email_address(m_platformAccount, m_abstractAccount->getEmailAddress().c_str()))
+       {
+               ThrowMsg(PlatformException, "Can't set packagename.");
+       }
+}
+
+void AccountWrapper::setDomainNameToPlatformAccount()
+{
+       LogDebug("entered");
+       if (!m_platformAccount) {
+               ThrowMsg(UnknownException, "Null platform pointer.");
+       }
+
+       if (ACCOUNT_ERROR_NONE != account_set_domain_name(m_platformAccount, m_abstractAccount->getDomainName().c_str()))
+       {
+               ThrowMsg(PlatformException, "Can't set packagename.");
+       }
+}
+
+/*
+void AccountWrapper::setHasContactFeatureToPlatformAccount()
+{
+    LogDebug("entered");
+    if (!m_platformAccount) {
+        ThrowMsg(UnknownException, "Null platform pointer.");
+    }
+       account_set_capability(m_platformAccount, ACCOUNT_CAPABILITY_CONTACT, ACCOUNT_CAPABILITY_ENABLED);
+}
+*/
+
+void AccountWrapper::setAccountServices()
+{
+    LogDebug("entered");
+    if (!m_platformAccount) {
+        ThrowMsg(UnknownException, "Null platform pointer.");
+    }
+
+       AccountServicesArrayPtr services = m_abstractAccount->getService();
+       if ((services == NULL) || (services->size() == 0))
+               return;
+
+       //add new items
+       for (size_t i = 0; i < services->size(); ++i)
+       {
+           LogDebug("getServiceName : " << services->at(i)->getName().c_str());
+//         LogDebug("getServiceType : " << services->at(i)->getServiceType().c_str());
+       }
+
+}
+
+void AccountWrapper::getAccountServices()
+{
+    LogDebug("entered");
+    if (!m_platformAccount) {
+        ThrowMsg(UnknownException, "Null platform pointer.");
+    }
+
+       AccountServicesArrayPtr services(new AccountServicesArray());
+       for(int i = 0; i < 2; i++)
+       {
+               AccountServicesPtr service(new AccountServices());
+
+               service->setName("gmail");
+//             service->setServiceType("google_service");
+
+               services->push_back(service);
+       }
+       m_abstractAccount->setService(services);
+
+}
+
+AccountServiceTypePropertyPtr AccountWrapper::getDummyAccountServiceType(){
+
+       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);
+
+       return accountServiceTypePropertyPtr;
+}
+
+AccountServiceProviderPropertyPtr AccountWrapper::getDummyAccountServiceProviderProperty(){
+       std::string accountServiceProviderId = m_abstractAccount->getProviderId();
+
+       AccountServiceProviderPropertyPtr accountServiceProviderPropertyPtr(new AccountServiceProviderProperty);
+       accountServiceProviderPropertyPtr->setId(accountServiceProviderId);
+       accountServiceProviderPropertyPtr->setDisplayName("dummyDisplayName");
+       accountServiceProviderPropertyPtr->setIconPath("dummyIconPath");
+
+       return accountServiceProviderPropertyPtr;
+}
+
+void AccountWrapper::setDummyServices(){
+       LogDebug("<<<");
+
+       AccountServicesArrayPtr services(new AccountServicesArray());
+       for (int i = 0; i < 2; i++) {
+               AccountServicesPtr service(new AccountServices());
+
+               service->setId("dummy_id");
+               service->setName("dummy_name");
+               service->setApplicationId("dummy_applicationId");
+               service->setDisplayName("dummy_displayName");
+               service->setIcon("dummy_Icon");
+               service->setAccountId("dummy_accountId");
+               service->setServiceTypeId("dummy_serviceTypeId");
+               service->setProviderId("dummy_ProviderId");
+//             service->setTags("dummy_");
+               service->setSettings("dummy_settings");
+
+               services->push_back(service);
+       }
+
+       m_abstractAccount->setService(services);
+
+       LogDebug(">>>");
+}
+
+
+EventAccountPtr AccountWrapper::convertPlatformAccountToAbstractAccount()
+{
+    LogDebug("entered");
+    setDisplayNameFromPlatformAccount();
+       setIconPathFromPlatformAccount();
+    setProviderNameFromPlatformAccount();
+
+/*
+    setUserNameFromPlatformAccount();
+    setPackageNameFromPlatformAccount();
+    setIDFromPlatformAccount();
+    setEmailAddressFromPlatformAccount();
+    setDomainNameFromPlatformAccount();
+
+       getAccountServices();
+*/
+    displayPlatformAccount();
+    return getAbstractAccount();
+}
+
+EventAccountPtr AccountWrapper::convertPlatformAccountToAbstractAccount(account_h account_info)
+{
+    LogDebug("entered");
+       m_platformAccount = account_info;
+    setDisplayNameFromPlatformAccount();
+       setIconPathFromPlatformAccount();
+    setProviderNameFromPlatformAccount();
+/*
+    setUserNameFromPlatformAccount();
+    setPackageNameFromPlatformAccount();
+    setIDFromPlatformAccount();
+    setEmailAddressFromPlatformAccount();
+    setDomainNameFromPlatformAccount();
+
+       getAccountServices();
+*/
+    displayPlatformAccount();
+    return getAbstractAccount();
+}
+
+void AccountWrapper::setIDFromPlatformAccount()
+{
+    LogDebug("entered");
+    if (!m_platformAccount) {
+        ThrowMsg(UnknownException, "Null platform pointer.");
+    }
+    m_abstractAccount->setID(getIDFromPlatformAccount());
+}
+
+void AccountWrapper::setDisplayNameFromPlatformAccount()
+{
+    LogDebug("entered");
+    if (!m_platformAccount) {
+        ThrowMsg(UnknownException, "Null platform pointer.");
+    }
+
+    char *displayname = NULL;
+       account_get_display_name(m_platformAccount, &displayname);
+    if (displayname) {
+        m_abstractAccount->setDisplayName(displayname);
+    }
+}
+
+void AccountWrapper::setIconPathFromPlatformAccount()
+{
+    LogDebug("entered");
+    if (!m_platformAccount) {
+        ThrowMsg(UnknownException, "Null platform pointer.");
+    }
+
+    char *iconPath = NULL;
+       account_get_icon_path(m_platformAccount, &iconPath);
+    if (iconPath) {
+        m_abstractAccount->setIconPath(iconPath);
+    }
+}
+
+void AccountWrapper::setProviderNameFromPlatformAccount()
+{
+    LogDebug("entered");
+    if (!m_platformAccount) {
+        ThrowMsg(UnknownException, "Null platform pointer.");
+    }
+
+    char *providername = NULL;
+       account_get_source(m_platformAccount, &providername);
+    if (providername) {
+        m_abstractAccount->setProviderName(providername);
+    }
+}
+
+void AccountWrapper::setEmailAddressFromPlatformAccount()
+{
+    LogDebug("entered");
+    if (!m_platformAccount) {
+        ThrowMsg(UnknownException, "Null platform pointer.");
+    }
+
+    char *emailaddress = NULL;
+       account_get_email_address(m_platformAccount, &emailaddress);
+    if (emailaddress) {
+        m_abstractAccount->setEmailAddress(emailaddress);
+    }
+}
+
+void AccountWrapper::setDomainNameFromPlatformAccount()
+{
+    LogDebug("entered");
+    if (!m_platformAccount) {
+        ThrowMsg(UnknownException, "Null platform pointer.");
+    }
+
+    char *domainname = NULL;
+       account_get_domain_name(m_platformAccount, &domainname);
+    if (domainname) {
+        m_abstractAccount->setDomainName(domainname);
+    }
+}
+
+void AccountWrapper::displayAbstractAccount()
+{
+       LogDebug("account id : " << m_abstractAccount->getID());
+       LogDebug("Display name  : " << m_abstractAccount->getDisplayName());
+}
+
+void AccountWrapper::displayPlatformAccount()
+{
+
+}
+
+}
+}
+}
diff --git a/src/platform/Tizen/Account/AccountWrapper.h b/src/platform/Tizen/Account/AccountWrapper.h
new file mode 100755 (executable)
index 0000000..ad47391
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * @file        AccountWrapper.h
+ * @author      Jihwa Park (jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ */
+
+#ifndef _TIZEN_ACCOUNT_WRAPPER_H_
+#define _TIZEN_ACCOUNT_WRAPPER_H_
+
+#include <string>
+#include <dpl/shared_ptr.h>
+#include <API/Account/EventAccount.h>
+#include <API/Account/AccountServiceTypeProperty.h>
+#include <API/Account/AccountServiceProviderProperty.h>
+#include "account.h"
+
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+
+
+namespace TizenApis {
+namespace Platform {
+namespace Account{
+
+class AccountWrapper
+{
+       public:
+               AccountWrapper();
+               explicit AccountWrapper(const EventAccountPtr &event);
+               virtual ~AccountWrapper();
+               char  *convertAbstractAccountToPlatformAccount();
+               EventAccountPtr convertPlatformAccountToAbstractAccount();
+               EventAccountPtr convertPlatformAccountToAbstractAccount(account_h account_info);
+
+               char  *getPlatformAccount() const;
+               EventAccountPtr getAbstractAccount() const;
+               void        freePlatformAccount();
+               void        saveAccount();
+               void        loadAccount(int id);
+               void        deleteAccount();
+               void            getAccountbyId();
+               void            getServiceTypebyId();
+               void            getProviderbyId();
+               void            findProviders();
+void findServiceTypes();
+
+               //dummy method
+               void setDummyServices();
+               AccountServiceTypePropertyPtr     getDummyAccountServiceType();
+               AccountServiceProviderPropertyPtr getDummyAccountServiceProviderProperty();
+
+       protected:
+               int  getIDFromPlatformAccount() const;
+
+               void setIDFromPlatformAccount();
+               void setIDToPlatformAccount();
+
+               void setDisplayNameFromPlatformAccount();
+               void setDisplayNameToPlatformAccount();
+
+               void setIconPathFromPlatformAccount();
+               void setIconPathToPlatformAccount();
+
+               void setProviderNameFromPlatformAccount();
+               void setProviderNameToPlatformAccount();
+
+               void setEmailAddressFromPlatformAccount();
+               void setEmailAddressToPlatformAccount();
+
+               void setDomainNameFromPlatformAccount();
+               void setDomainNameToPlatformAccount();
+
+               void setAccountServices();
+               void getAccountServices();
+
+       private:
+               void displayAbstractAccount();     //only for debugging
+               void displayPlatformAccount();     //only for debugging
+
+               account_h m_platformAccount;
+               EventAccountPtr m_abstractAccount;
+
+//             static std::map<std::string, std::string> attrSvcMap;
+
+};
+
+typedef DPL::SharedPtr<AccountWrapper> AccountWrapperPtr;
+}
+}
+}
+#endif
diff --git a/src/platform/Tizen/Account/config.cmake b/src/platform/Tizen/Account/config.cmake
new file mode 100755 (executable)
index 0000000..7e5b818
--- /dev/null
@@ -0,0 +1,26 @@
+get_current_path()
+
+pkg_search_module(account REQUIRED accounts-svc)
+pkg_search_module(glib REQUIRED glib-2.0)
+pkg_search_module(libpcrecpp REQUIRED libpcrecpp)
+
+set(INCLUDES_PLATFORM_IMPLEMENTATION_ACCOUNT
+  ${account_INCLUDE_DIRS}
+  ${glib_INCLUDE_DIRS}
+  ${libpcrecpp_INCLUDE_DIRS}
+  PARENT_SCOPE
+)
+
+set(LIBS_PLATFORM_IMPLEMENTATION_ACCOUNT
+  ${account_LIBRARIES}
+  ${glib_LIBRARIES}
+  ${libpcrecpp_LIBRARIES}
+  PARENT_SCOPE
+)
+
+set(SRCS_PLATFORM_IMPLEMENTATION_ACCOUNT
+  ${CURRENT_PATH}/AccountService.cpp
+  ${CURRENT_PATH}/AccountManager.cpp
+  ${CURRENT_PATH}/AccountWrapper.cpp
+  PARENT_SCOPE
+)
old mode 100755 (executable)
new mode 100644 (file)
index ace36b3..d03c1a1
@@ -58,6 +58,7 @@ static void capi_callback_bt_state_changed(int result, bt_adapter_state_e adapte
        }
 }
 
+
 static void capi_callback_bt_discovery_state_changed(int result, 
        bt_adapter_device_discovery_state_e discovery_state, bt_adapter_device_discovery_info_s *discovery_info, void *user_data)
 {
@@ -107,13 +108,12 @@ static void capi_callback_bt_device_bond_destroyed(int result, char* remote_addr
        ((BluetoothAdapterManager*)user_data)->destroyBondingManualAnswer(result);
 }
 
-static void capi_callback_bt_socket_connection_state_changed(int result, bt_socket_connection_state_e connection_state, 
-       bt_socket_connection_s *connection, void *user_data)
+static void capi_bt_device_service_searched(int result, bt_device_sdp_info_s* sdp_info, void* user_data)
 {
-       LogDebug("OK");
-
-       ((BluetoothAdapterManager*)user_data)->registerRFCOMMServiceByUUIDCallbackEmit(result, connection_state, connection);
+       ((BluetoothAdapterManager*)user_data)->serviceSearchManualAnswer(result);
 }
+
+
 }
 
 BluetoothAdapterManager::BluetoothAdapterManager() 
@@ -271,6 +271,7 @@ void BluetoothAdapterManager::setVisible(const  EventBTSetVisiblePtr& event)
        EventRequestReceiver<EventBTSetVisible>::PostRequest(event);
 }
 
+
 void BluetoothAdapterManager::discoveryDevicesEmitter(const EventBTOnDiscoveryDevicesEmitterPtr& emitter)
 
 {
@@ -457,6 +458,29 @@ void BluetoothAdapterManager::getDevice(const  EventBTGetDevicePtr& event)
        EventRequestReceiver<EventBTGetDevice>::PostRequest(event);
 }
 
+void BluetoothAdapterManager::serviceSearchManualAnswer(unsigned short error)
+{
+       try 
+       {
+               int ret = 0;
+               m_btGetDeviceEvent = true;
+               if ((bt_adapter_foreach_bonded_device(capi_callback_bt_adapter_bonded_device_find, (void*)this))!= BT_ERROR_NONE)
+               {
+                       ThrowMsg(Commons::UnknownException, "bt_adapter_foreach_bonded_device" << ret);
+               }
+               m_btGetDeviceEvent = false;
+
+               LogDebug("EventBTGetDevicePtr - serviceSearchManualAnswer");            
+               m_EventBTGetDevicePtr->setExceptionCode(Commons::ExceptionCodes::None);
+       }
+       catch (const Commons::Exception& ex) 
+       {
+               LogError("Exception: " << ex.GetMessage());
+               m_EventBTGetDevicePtr->setExceptionCode(ex.getCode());
+       }
+       
+       EventRequestReceiver<EventBTGetDevice>::ManualAnswer(m_EventBTGetDevicePtr);
+}
 
 bool BluetoothAdapterManager::getDeviceManualAnswer(bt_device_info_s *device_info)
 {
@@ -590,131 +614,12 @@ void BluetoothAdapterManager::destroyBondingManualAnswer(unsigned short error)
 }
 
 
-void BluetoothAdapterManager::registerRFCOMMServiceByUUIDCallbackEmit(unsigned short error, 
-       bt_socket_connection_state_e connectionState, bt_socket_connection_s *connection)
-{
-       LogDebug("OK");
-               
-       EventBTRegisterRFCOMMPtr event(new EventBTRegisterRFCOMM());
-       bt_socket_unset_connection_state_changed_cb() ;
-       int ret = 0;
-       
-       if (error == BT_ERROR_NONE)
-       {
-               if (connectionState == BT_SOCKET_CONNECTED)
-               {
-                       BluetoothDeviceData deviceData;
-                       BluetoothSocketData socketData;
-                       std::map<std::string, BluetoothSocketData>::iterator it;
-                       
-                       event->setConnectionState(EventBTRegisterRFCOMM::REGISTER_CONNECTED);
-
-                       m_btGetDeviceEvent = false;
-
-                       if ((ret = bt_adapter_foreach_bonded_device(capi_callback_bt_adapter_bonded_device_find, (void*)this)) == BT_ERROR_NONE)
-                       {
-                               findDevice(connection->remote_address, deviceData);
-                       }                       
-
-                       deviceData.isConnected = true;
-
-                       if (connection->local_role == BT_SOCKET_SERVER)
-                       {
-                               socketData.isServer = true;
-                       }
-                       else
-                       {
-                               socketData.isServer = false;
-                       }
-                       
-                       socketData.protocol = PROTOCOL_TYPE_RFCOMM_VALUE_INT;
-                       
-                       socketData.connectedSocket = connection->socket_fd;
-                       socketData.registeredSocket = m_currentServiceSocket;
-                       socketData.state = SOCKET_STATE_OPEN_VALUE_INT;
-                       socketData.uuid = m_uuid;
-                       socketData.peerDevice = deviceData;
-
-                       if (m_socketMap.find(deviceData.address) != m_socketMap.end())
-                       {
-                               LogDebug("Found same device, remove!");
-                               m_socketMap.erase(it);
-                       }
-                       
-                       m_socketMap[deviceData.address] = socketData;
-                       event->setSocketData(socketData);
-                       event->setExceptionCode(Commons::ExceptionCodes::None);
-               }
-               else
-               {
-                       event->setConnectionState(EventBTRegisterRFCOMM::REGISTER_DISCONNECTED);                        
-               }
-       }
-       else
-       {
-               event->setExceptionCode(Commons::ExceptionCodes::UnknownException);
-       }
-       m_registerRFCOMMEmitter->emit(event);
-
-
-}
-long BluetoothAdapterManager::registerRFCOMMServiceByUUID(const EventBTRegisterRFCOMMEmitterPtr& emitter, 
-       std::string uuid, std::string name, unsigned short int security)
+void BluetoothAdapterManager::registerRFCOMMServiceByUUID(const EventBTRegisterRFCOMMPtr& event)
 {
        LogDebug("EventBTRegisterRFCOMMPtr");
-
-       int ret = 0;
-       m_registerRFCOMMEmitter = emitter;
-       m_uuid = uuid;
-       m_name = name;
-       
-       try 
-       {
-               if (m_btPowered == false)       
-               {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
-               }
-
-               if (getVisibility() == false)
-               {
-                       ThrowMsg(Commons::UnknownException, "please set visivility");
-               }
-               
-               if((ret = bt_socket_create_rfcomm(uuid.data(), &m_currentServiceSocket)) != BT_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "service socket creation error" << ret);
-               }
-
-               if( bt_socket_set_connection_state_changed_cb(capi_callback_bt_socket_connection_state_changed, this) != BT_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "unkown platfrom exception");
-               }
-
-               if( bt_socket_listen_and_accept_rfcomm(m_currentServiceSocket, 1) != BT_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "service socket register error");
-               }
-               EventBTRegisterRFCOMMPtr event(new EventBTRegisterRFCOMM());
-               event->setConnectionState(EventBTRegisterRFCOMM::REGISTER_SUCCESS);
-               event->setExceptionCode(Commons::ExceptionCodes::None);
-               m_registerRFCOMMEmitter->emit(event);
-
-       }
-       catch (const Commons::Exception& ex) 
-       {
-               LogError("Exception: " << ex.GetMessage());
-               EventBTRegisterRFCOMMPtr event(new EventBTRegisterRFCOMM());
-               event->setExceptionCode(ex.getCode());
-               m_registerRFCOMMEmitter->emit(event);
-       }
-       return m_currentServiceSocket;
+       EventRequestReceiver<EventBTRegisterRFCOMM>::PostRequest(event);
 }
 
-void BluetoothAdapterManager::unregisterRFCOMMService(const EventBTUnregisterRFCOMMServicePtr& event)
-{
-       LogDebug("EventBTUnregisterRFCOMMServicePtr");
-       EventRequestReceiver<EventBTUnregisterRFCOMMService>::PostRequest(event);
-}
 
 void BluetoothAdapterManager::setAdapterName(const EventBTSetNamePtr& event)
 {
@@ -843,19 +748,6 @@ void BluetoothAdapterManager::OnRequestReceived(const  EventBTSetVisiblePtr& eve
 
                }
 
-               if (bt_adapter_get_visibility(&current_visibility) != BT_ERROR_NONE)
-               {
-                       ThrowMsg(Commons::UnknownException, "get visibility error" << ret);
-               }       
-
-
-               if (current_visibility == visibility_mode)
-               {
-                       LogDebug("already same visiblity");
-                       event->setExceptionCode(Commons::ExceptionCodes::None);
-                       return;
-               }
-
                LogDebug("bt_adapter_set_visibility " << visibility_mode << "  " << event->getTimeout());
 
                if ((ret = bt_adapter_set_visibility(visibility_mode, event->getTimeout()) != BT_ERROR_NONE))
@@ -868,6 +760,7 @@ void BluetoothAdapterManager::OnRequestReceived(const  EventBTSetVisiblePtr& eve
        {
                LogError("Exception: " << ex.GetMessage());
                event->setExceptionCode(ex.getCode());
+               bt_adapter_unset_visibility_mode_changed_cb();
        }
 }
 
@@ -876,8 +769,6 @@ void BluetoothAdapterManager::OnRequestReceived(const  EventBTGetKnownDevicesPtr
 {
        LogDebug("EventBTGetKnownDevicesPtr Enter");
 
-       int ret = 0;
-
        try 
        {
                m_EventBTGetKnownDevicesPtr = event;
@@ -887,19 +778,19 @@ void BluetoothAdapterManager::OnRequestReceived(const  EventBTGetKnownDevicesPtr
                        ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
                }
 
-               if ((ret = bt_adapter_foreach_bonded_device(capi_callback_bt_adapter_bonded_device, (void*)this))!= BT_ERROR_NONE)
+               if (bt_adapter_foreach_bonded_device(capi_callback_bt_adapter_bonded_device, (void*)this)!= BT_ERROR_NONE)
                {
-                       ThrowMsg(Commons::UnknownException, "bt_adapter_foreach_bonded_device" << ret);
+                       ThrowMsg(Commons::UnknownException, "bt_adapter_foreach_bonded_device");
                }
 
-               LogDebug("Get Konwn device");           
-               
-               event->setExceptionCode(Commons::ExceptionCodes::None);
+               LogDebug("Get Konwn device OK");                
+
        }
        catch (const Commons::Exception& ex) 
        {
                LogError("Exception: " << ex.GetMessage());
                event->setExceptionCode(ex.getCode());
+
        }
 }
 
@@ -907,31 +798,32 @@ void BluetoothAdapterManager::OnRequestReceived(const  EventBTGetDevicePtr& even
 {
        LogDebug("EventBTGetDevicePtr Enter");
 
-       int ret = 0;
-
        try 
        {
                m_EventBTGetDevicePtr = event;
-
+               event->switchToManualAnswer();          
+               
                if (m_btPowered == false)       
                {
                        ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
                }
-               m_btGetDeviceEvent = true;
 
-               if ((ret = bt_adapter_foreach_bonded_device(capi_callback_bt_adapter_bonded_device_find, (void*)this))!= BT_ERROR_NONE)
+               if (bt_device_set_service_searched_cb(capi_bt_device_service_searched, (void*)this) != BT_ERROR_NONE)
                {
-                       ThrowMsg(Commons::UnknownException, "bt_adapter_foreach_bonded_device" << ret);
+                       ThrowMsg(Commons::UnknownException, "service search failed" );
                }
-               m_btGetDeviceEvent = false;
-               
-               LogDebug("EventBTGetDevicePtr");                
-               event->setExceptionCode(Commons::ExceptionCodes::None);
+
+               if (bt_device_start_service_search(event->getAddress().data()) != BT_ERROR_NONE)
+               {
+                       ThrowMsg(Commons::UnknownException, "service search failed" );
+               }
+
        }
        catch (const Commons::Exception& ex) 
        {
                LogError("Exception: " << ex.GetMessage());
                event->setExceptionCode(ex.getCode());
+               EventRequestReceiver<EventBTGetDevice>::ManualAnswer(event);
        }
 }
 
@@ -1046,7 +938,7 @@ void BluetoothAdapterManager::OnRequestReceived(const EventBTSetNamePtr& event)
 
 }
 
-void BluetoothAdapterManager::OnRequestReceived(const EventBTUnregisterRFCOMMServicePtr& event) 
+/*void BluetoothAdapterManager::OnRequestReceived(const EventBTUnregisterRFCOMMServicePtr& event) 
 {
        LogDebug("Enter");
        
@@ -1092,7 +984,7 @@ void BluetoothAdapterManager::OnRequestReceived(const EventBTUnregisterRFCOMMSer
        }       
        bt_adapter_unset_state_changed_cb();
 
-}
+}*/
 
 void BluetoothAdapterManager::OnRequestReceived(const EventBTStopDiscoveryPtr& event)
 {
@@ -1119,6 +1011,46 @@ void BluetoothAdapterManager::OnRequestReceived(const EventBTStopDiscoveryPtr& e
        bt_adapter_unset_device_discovery_state_changed_cb();
 }
 
+
+void BluetoothAdapterManager::OnRequestReceived(const EventBTRegisterRFCOMMPtr& event)
+{
+       try 
+       {
+               std::string uuid = event->getUuid();;
+               int serviceSocket;
+               int ret = 0;
+               
+               if (m_btPowered == false)       
+               {
+                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
+               }
+
+               if (getVisibility() == false)
+               {
+                       ThrowMsg(Commons::UnknownException, "please set visivility");
+               }
+               
+               if((ret = bt_socket_create_rfcomm(uuid.data(), &serviceSocket)) != BT_ERROR_NONE )
+               {
+                       ThrowMsg(Commons::UnknownException, "service socket creation error" << ret);
+               }
+
+               if( bt_socket_listen_and_accept_rfcomm(serviceSocket, 5) != BT_ERROR_NONE )
+               {
+                       ThrowMsg(Commons::UnknownException, "service socket register error");
+               }
+               event->setSocketFd(serviceSocket);
+               event->setExceptionCode(Commons::ExceptionCodes::None);
+
+       }
+       catch (const Commons::Exception& ex) 
+       {
+               LogError("Exception: " << ex.GetMessage());
+
+               event->setExceptionCode(ex.getCode());
+       }
+}
+
 }
 }
 }
old mode 100755 (executable)
new mode 100644 (file)
index b8fdb53..49b730c
@@ -45,9 +45,7 @@ public:
        virtual void getDevice(const EventBTGetDevicePtr& event) ;
        virtual void createBonding(const EventBTCreateDestroyBondingPtr& event) ;
        virtual void destroyBonding(const EventBTCreateDestroyBondingPtr& event) ;
-       virtual long registerRFCOMMServiceByUUID(const EventBTRegisterRFCOMMEmitterPtr& emitter,
-                       std::string uuid, std::string name, unsigned short int security);
-       virtual void unregisterRFCOMMService(const EventBTUnregisterRFCOMMServicePtr& event);
+       virtual void registerRFCOMMServiceByUUID(const EventBTRegisterRFCOMMPtr& event);
        virtual void discoveryDevicesEmitter(const EventBTOnDiscoveryDevicesEmitterPtr& emitter);
        virtual void stopDiscovery(const EventBTStopDiscoveryPtr& event);
                
@@ -65,25 +63,24 @@ public:
        void createBondingManualAnswer(unsigned short error, bt_device_info_s *device_info);
        void destroyBondingManualAnswer(unsigned short error);
        void getKnownDevicesManualAnswer(bt_device_info_s *discovery_info);
+       void serviceSearchManualAnswer(unsigned short error);
        bool getDeviceManualAnswer(bt_device_info_s *device_info);
        void discoveryDevicesCallbackEmit(unsigned short error, unsigned short state, bt_adapter_device_discovery_info_s *discovery_info);
        void updateDevice(BluetoothDeviceData &device);
        int findDevice(std::string address, BluetoothDeviceData &device);
-       void registerRFCOMMServiceByUUIDCallbackEmit(unsigned short error, bt_socket_connection_state_e connectionState, bt_socket_connection_s *connection);
        void setAdapterNameManualAnswer(char* deviceName);
 protected:
        BluetoothAdapterManager();
 
-       virtual void OnRequestReceived(const EventBTSetPoweredPtr& event) ;
-       virtual void OnRequestReceived(const EventBTSetVisiblePtr& event) ;
-       virtual void OnRequestReceived(const EventBTGetKnownDevicesPtr& event) ;
-       virtual void OnRequestReceived(const EventBTGetDevicePtr& event) ;
-       virtual void OnRequestReceived(const EventBTCreateDestroyBondingPtr& event) ;
+       virtual void OnRequestReceived(const EventBTCreateDestroyBondingPtr& event);
+       virtual void OnRequestReceived(const EventBTGetKnownDevicesPtr& event);
+       virtual void OnRequestReceived(const EventBTGetDevicePtr& event);
+       virtual void OnRequestReceived(const EventBTSetPoweredPtr& event);
+       virtual void OnRequestReceived(const EventBTSetVisiblePtr& event);
        virtual void OnRequestReceived(const EventBTSetNamePtr& event);
-       virtual void OnRequestReceived(const EventBTUnregisterRFCOMMServicePtr& event);
-       virtual void OnRequestReceived(const EventBTStopDiscoveryPtr& event);
-
-
+       virtual void OnRequestReceived(const EventBTStopDiscoveryPtr& event);   
+       virtual void OnRequestReceived(const EventBTRegisterRFCOMMPtr& event);  
+       
 private:
        static bool m_btPowered;
        static bool m_btGetDeviceEvent;
@@ -96,7 +93,7 @@ private:
        EventBTGetDevicePtr m_EventBTGetDevicePtr;
        EventBTCreateDestroyBondingPtr m_EventBTCreateDestroyBondingPtr;
        std::vector<BluetoothDeviceData> m_Devices;
-       EventBTRegisterRFCOMMEmitterPtr m_registerRFCOMMEmitter;
+       EventBTRegisterRFCOMMPtr m_EventBTRegisterRFCOMMPtr;
        EventBTOnDiscoveryDevicesEmitterPtr m_discoverDevicesEmitter;
        EventBTSetNamePtr m_EventBTSetNamePtr;
 
old mode 100755 (executable)
new mode 100644 (file)
index 1f9be0f..d9df686
@@ -57,6 +57,10 @@ static bool capi_callback_bt_device_bonded_device_find(bt_device_info_s *device_
        return ret;
 }
 
+static void capi_bt_device_service_searched(int result, bt_device_sdp_info_s* sdp_info, void* user_data)
+{
+       ((BluetoothDeviceManager*)user_data)->serviceSearchManualAnswer(result);
+}
 
 }
 
@@ -191,6 +195,38 @@ void BluetoothDeviceManager::cancelConnectToServiceByUUID()
        m_cancelRequest = true;
 }
 
+void BluetoothDeviceManager::serviceSearchManualAnswer(unsigned short error)
+{
+       BluetoothSocketData socketData = m_EventBTConnectToServiceByUUIDPtr->getSocketData();
+
+       try 
+       {
+               if (bt_socket_set_connection_state_changed_cb(
+                       capi_callback_bt_socket_connection_state_changed, this) != BT_ERROR_NONE)
+               {
+                       error = Commons::ExceptionCodes::UnknownException;
+                       ThrowMsg(Commons::UnknownException, "service call back set error");
+               }
+               
+               if (bt_socket_connect_rfcomm(socketData.peerDevice.address.data(), 
+                       socketData.uuid.data()) != BT_ERROR_NONE)
+               {
+                       error = Commons::ExceptionCodes::UnknownException;
+                       ThrowMsg(Commons::UnknownException, "connect error");
+               }
+               LogDebug("Service search OK, try to connect");
+
+       }
+       catch (const Commons::Exception& ex) 
+       {
+               LogError("Exception: " << ex.GetMessage());
+               m_EventBTConnectToServiceByUUIDPtr->setExceptionCode(ex.getCode());     
+               bt_socket_unset_connection_state_changed_cb();
+               EventRequestReceiver<EventBTConnectToServiceByUUID>::ManualAnswer(m_EventBTConnectToServiceByUUIDPtr);
+       }
+}
+
+
 void BluetoothDeviceManager::connectToServiceByUUIDManualAnswer(unsigned short error, 
        bt_socket_connection_state_e connectionState, bt_socket_connection_s *connection)
 
@@ -260,19 +296,15 @@ void BluetoothDeviceManager::OnRequestReceived(const  EventBTConnectToServiceByU
        
        try 
        {
-               if( bt_socket_set_connection_state_changed_cb(capi_callback_bt_socket_connection_state_changed, this) != BT_ERROR_NONE )
+               if (bt_device_set_service_searched_cb(capi_bt_device_service_searched, (void*)this) != BT_ERROR_NONE)
                {
-                       error = Commons::ExceptionCodes::UnknownException;
-                       ThrowMsg(Commons::UnknownException, "service call back set error");
+                       ThrowMsg(Commons::UnknownException, "service search failed" );
                }
 
-               if( bt_socket_connect_rfcomm(socketData.peerDevice.address.data(), 
-                       socketData.uuid.data()) != BT_ERROR_NONE )
+               if (bt_device_start_service_search(socketData.peerDevice.address.data()) != BT_ERROR_NONE)
                {
-                       error = Commons::ExceptionCodes::UnknownException;
-                       ThrowMsg(Commons::UnknownException, "connect error");
+                       ThrowMsg(Commons::UnknownException, "service search failed" );
                }
-               event->setCancelAllowed(true);
        }
        catch (const Commons::Exception& ex) 
        {
index 1221113..b82bd4d 100644 (file)
@@ -47,6 +47,7 @@ public:
        bool deviceFoundAnswer(bt_device_info_s *device_info);
        void connectToServiceByUUIDManualAnswer(unsigned short error, 
                bt_socket_connection_state_e connectionState, bt_socket_connection_s *connection);
+       void serviceSearchManualAnswer(unsigned short error);
 
        virtual ~BluetoothDeviceManager();
        virtual void connectToServiceByUUID(const EventBTConnectToServiceByUUIDPtr& event) ;
diff --git a/src/platform/Tizen/Bluetooth/BluetoothManager.cpp b/src/platform/Tizen/Bluetooth/BluetoothManager.cpp
deleted file mode 100755 (executable)
index d97e143..0000000
+++ /dev/null
@@ -1,1158 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-#include <cassert>
-#include <Commons/Exception.h>
-#include "BluetoothAdapterManager.h"
-#include <API/Bluetooth/BluetoothProperty.h>
-#include <glib.h>
-
-using namespace TizenApis::Api;
-using namespace WrtDeviceApis;
-using namespace DPL;
-
-namespace TizenApis {
-namespace Platform {
-namespace Bluetooth {
-
-bool BluetoothAdapterManager::m_btPowered = false;
-bool BluetoothAdapterManager::m_btGetDeviceEvent = false;
-int BluetoothAdapterManager::m_currentServiceSocket = -1;
-
-
-namespace {
-
-static void capi_callback_bt_name_changed(char *device_name, void *user_data)
-{
-       ((BluetoothAdapterManager*)user_data)->setAdapterNameManualAnswer(device_name);
-}
-
-
-
-
-static void capi_callback_bt_state_changed(int result, bt_adapter_state_e adapter_state, void* user_data)
-{
-       if( result == BT_ERROR_NONE )
-       {
-               LogDebug("State Changed" << adapter_state);
-               ((BluetoothAdapterManager*)user_data)->setPoweredManualAnswer();
-       }
-       else
-       {
-               LogDebug("Error");
-       }
-}
-
-
-static void capi_callback_bt_visibility_changed(int result, bt_adapter_visibility_mode_e visibility, void *user_data)
-{
-       if (result == BT_ERROR_NONE)
-       {
-               LogDebug("Visibility changed" << visibility);
-               ((BluetoothAdapterManager*)user_data)->setVisibleManualAnswer();
-       }
-       else
-       {
-               LogDebug("Error");
-       }
-}
-
-static void capi_callback_bt_discovery_state_changed(int result, 
-       bt_adapter_device_discovery_state_e discovery_state, bt_adapter_device_discovery_info_s *discovery_info, void *user_data)
-{
-       LogDebug("Discovery state" << discovery_state);
-       if (discovery_state ==  BT_ADAPTER_DEVICE_DISCOVERY_FOUND && discovery_info != NULL)
-       {
-               LogDebug("found device" << discovery_info->remote_name << " " << discovery_info->remote_address);
-       }
-       
-       LogDebug("Discovery state" << discovery_state);
-       ((BluetoothAdapterManager*)user_data)->discoveryDevicesCallbackEmit(result, discovery_state, discovery_info);
-
-}
-
-
-static bool capi_callback_bt_adapter_bonded_device(bt_device_info_s *device_info, void *user_data)
-{
-       if( device_info != NULL )
-       {
-               LogDebug("address " << device_info->remote_address << " " << device_info->remote_name);
-               ((BluetoothAdapterManager*)user_data)->getKnownDevicesManualAnswer      (device_info);
-       }
-
-       return true;
-}
-
-static bool capi_callback_bt_adapter_bonded_device_find(bt_device_info_s *device_info, void *user_data)
-{
-       bool ret = true;
-       if( device_info != NULL )
-       {
-               LogDebug("address " << device_info->remote_address << " " << device_info->remote_name);
-               ret = ((BluetoothAdapterManager*)user_data)->getDeviceManualAnswer      (device_info);
-       }
-
-       return ret;;
-}
-
-       
-static void capi_callback_bt_device_bond_created(int result, bt_device_info_s *device_info, void *user_data)
-{
-       ((BluetoothAdapterManager*)user_data)->createBondingManualAnswer(result, device_info);
-}
-
-static void capi_callback_bt_device_bond_destroyed(int result, char* remote_address, void *user_data)
-{
-       ((BluetoothAdapterManager*)user_data)->destroyBondingManualAnswer(result);
-}
-
-static void capi_callback_bt_socket_connection_state_changed(int result, bt_socket_connection_state_e connection_state, 
-       bt_socket_connection_s *connection, void *user_data)
-{
-       LogDebug("OK");
-
-       ((BluetoothAdapterManager*)user_data)->registerRFCOMMServiceByUUIDCallbackEmit(result, connection_state, connection);
-}
-}
-
-BluetoothAdapterManager::BluetoothAdapterManager() 
-{
-       LogDebug("Enter");
-       Init();
-       m_btPowered = canUseBluetooth();
-}
-
-BluetoothAdapterManager::~BluetoothAdapterManager() 
-{
-       LogDebug("Enter");
-}
-
-void BluetoothAdapterManager::Init()
-{
-       LogDebug("Enter");
-
-       bt_initialize();
-}
-
-bool BluetoothAdapterManager::canUseBluetooth()
-{
-       bt_adapter_state_e state;
-       int ret;                
-
-       ret = bt_adapter_get_state(&state);
-
-       if (ret == BT_ERROR_NONE && state == BT_ADAPTER_ENABLED)
-       {
-               return true;
-       }
-       else
-       {
-               return false;
-       }
-}
-
-
-std::string BluetoothAdapterManager::getName()
-{
-       char* name = NULL; 
-       std::string str = "";
-
-       if (bt_adapter_get_name(&name) == BT_ERROR_NONE)
-       {
-               LogDebug("OK");
-
-               if (name != NULL)
-               {
-                       LogDebug("Set");
-                       str = name;
-                       free(name);
-               }
-       }
-       return str;
-}
-
-std::string BluetoothAdapterManager::getAddress()
-{
-       char* address = NULL; 
-       std::string str = "";
-
-       if (bt_adapter_get_address(&address) == BT_ERROR_NONE)
-       {
-               LogDebug("OK");
-               if (address != NULL)
-               {
-                       LogDebug("Set");
-                       str = address;
-                       free(address);
-               }
-       }
-       return str;
-
-}
-
-bool BluetoothAdapterManager::getPowered()
-{
-       bt_adapter_state_e state;
-
-       if (bt_adapter_get_state(&state) == BT_ERROR_NONE)
-       {
-               if (state == BT_ADAPTER_ENABLED)
-               {
-               return true;
-               }
-       }
-
-       return false;
-}
-
-bool BluetoothAdapterManager::getVisibility()
-{
-       bt_adapter_visibility_mode_e mode;
-
-       if (bt_adapter_get_visibility(&mode) == BT_ERROR_NONE)
-       {
-               if (mode != BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE)
-               {
-                       return true;
-               }
-       }       
-       return false;
-}
-       
-void BluetoothAdapterManager::setPowered(const  EventBTSetPoweredPtr& event) 
-{
-       LogDebug("Enter");
-
-       if (event->isEnableRequested())
-       {       
-               Init();
-       }
-
-       EventRequestReceiver<EventBTSetPowered>::PostRequest(event);
-}
-
-void BluetoothAdapterManager::setPoweredManualAnswer() 
-{
-       LogDebug("Enter");
-
-       m_btPowered = canUseBluetooth();
-       bt_adapter_unset_state_changed_cb();
-
-       if (m_EventBTSetPoweredPtr->isEnableRequested())
-       {
-               if (m_btPowered == true)
-               {
-                       m_EventBTSetPoweredPtr->setExceptionCode(Commons::ExceptionCodes::None);
-               }
-               else
-               {
-                       m_EventBTSetPoweredPtr->setExceptionCode(Commons::ExceptionCodes::PlatformException);
-               }
-       }
-       else
-       {
-               if (m_btPowered == false)
-               {
-                       m_EventBTSetPoweredPtr->setExceptionCode(Commons::ExceptionCodes::None);                        
-               }
-               else
-               {
-                       m_EventBTSetPoweredPtr->setExceptionCode(Commons::ExceptionCodes::PlatformException);
-
-               }
-       }
-       EventRequestReceiver<EventBTSetPowered>::ManualAnswer(m_EventBTSetPoweredPtr);
-}
-
-void BluetoothAdapterManager::setVisible(const  EventBTSetVisiblePtr& event) 
-{
-       LogDebug("Enter");
-       EventRequestReceiver<EventBTSetVisible>::PostRequest(event);
-}
-
-void BluetoothAdapterManager::setVisibleManualAnswer() 
-{
-       LogDebug("Enter");
-
-       bt_adapter_unset_visibility_mode_changed_cb();
-       LogDebug("bt_adapter_unset_visibility_mode_changed_cb");
-
-       m_EventBTSetVisiblePtr->setExceptionCode(Commons::ExceptionCodes::None);
-       EventRequestReceiver<EventBTSetVisible>::ManualAnswer(m_EventBTSetVisiblePtr);
-}
-
-void BluetoothAdapterManager::discoveryDevicesEmitter(const EventBTOnDiscoveryDevicesEmitterPtr& emitter)
-
-{
-       LogDebug("Enter");
-
-       int ret = 0;
-
-       m_discoverDevicesEmitter = emitter;
-       
-       try 
-       {
-               if (m_btPowered == false)       
-               {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
-               }
-
-               if ((ret = bt_adapter_set_device_discovery_state_changed_cb(capi_callback_bt_discovery_state_changed, 
-                       (void*)this))!= BT_ERROR_NONE)
-               {
-                       ThrowMsg(Commons::UnknownException, "platform exception error" << ret);
-               }
-
-               if ((ret = bt_adapter_start_device_discovery() != BT_ERROR_NONE))
-               {
-                       ThrowMsg(Commons::UnknownException, "device discovery fail" << ret);                    
-               }
-               LogDebug("OK Discovery Start");         
-       }
-       catch (const Commons::Exception& ex) 
-       {
-               LogError("Exception: " << ex.GetMessage());
-               bt_adapter_unset_device_discovery_state_changed_cb();
-
-               EventBTOnDiscoveryDevicesPtr event(new EventBTOnDiscoveryDevices());
-               event->setExceptionCode(ex.getCode());
-               m_discoverDevicesEmitter->emit(event);
-       }
-}
-
-
-void BluetoothAdapterManager::discoveryDevicesCallbackEmit(unsigned short error, unsigned short state, 
-       bt_adapter_device_discovery_info_s *discovery_info)
-
-{
-       BluetoothDeviceData device;
-       EventBTOnDiscoveryDevicesPtr event(new EventBTOnDiscoveryDevices());
-       unsigned int index = 0;
-       
-       try 
-       {
-               if (discovery_info != NULL)
-               {
-                       device.address = discovery_info->remote_address;
-                       device.name = discovery_info->remote_name;
-                       device.btClass.major = discovery_info->bt_class.major_device_class;
-                       device.btClass.minor = discovery_info->bt_class.minor_device_class;
-                       device.btClass.majorServiceMask = discovery_info->bt_class.major_service_class_mask;
-               }
-
-               switch(state)
-               {
-               case BT_ADAPTER_DEVICE_DISCOVERY_STARTED:
-                       event->setDiscoveryState(EventBTOnDiscoveryDevices::STARTED);
-                       break;
-               case BT_ADAPTER_DEVICE_DISCOVERY_FOUND:
-                       event->setDiscoveryState(EventBTOnDiscoveryDevices::DISCOVERYING);
-                       event->addDevice(device);
-                       m_Devices.push_back(device);
-                       break;
-               case BT_ADAPTER_DEVICE_DISCOVERY_FINISHED:
-                       event->setDiscoveryState(EventBTOnDiscoveryDevices::FINISHED);                  
-
-                       for (index = 0; index < m_Devices.size(); index++)
-                       {
-                               event->addDevice(m_Devices[index]);
-                       }
-                       bt_adapter_unset_device_discovery_state_changed_cb();                   
-                       break;
-               default:
-                       ThrowMsg(Commons::UnknownException, "device discovery fail");                                           
-               }
-               event->setExceptionCode(Commons::ExceptionCodes::None);
-               m_discoverDevicesEmitter->emit(event);
-       }
-       catch (const Commons::Exception& ex) 
-       {
-               LogError("Exception: " << ex.GetMessage());
-               event->setExceptionCode(ex.getCode());
-               bt_adapter_unset_device_discovery_state_changed_cb();
-               m_discoverDevicesEmitter->emit(event);
-       }
-}
-
-void BluetoothAdapterManager::getKownDevices(const  EventBTGetKnownDevicesPtr& event) 
-{
-       LogDebug("Enter");
-       EventRequestReceiver<EventBTGetKnownDevices>::PostRequest(event);
-}
-
-void BluetoothAdapterManager::updateDevice(BluetoothDeviceData &device)
-{
-       unsigned int i = 0;
-       LogDebug("Enter");
-
-       for (i = 0; i < m_Devices.size(); i++)
-       {
-               if (device.address == m_Devices[i].address &&
-                       device.name ==  m_Devices[i].name)
-               {
-                       m_Devices[i].isBonded = device.isBonded;
-                       m_Devices[i].isConnected = device.isConnected;  
-                       m_Devices[i].isTrusted = device.isTrusted;
-                       m_Devices[i].btClass = device.btClass;
-                       m_Devices[i].uuids = device.uuids;
-                                       
-               }
-       }
-
-       if (i == m_Devices.size())
-       {
-               m_Devices.push_back(device);
-       }
-}
-
-int BluetoothAdapterManager::findDevice(std::string address, BluetoothDeviceData& device)
-{
-       unsigned int i = 0;
-       
-       for (i = 0; i < m_Devices.size(); i++)
-       {
-               if (address == m_Devices[i].address)
-               {
-                       device = m_Devices[i];
-                       return BT_ERROR_NONE;
-               }
-       }
-       return BT_ERROR_OPERATION_FAILED;
-}
-
-void BluetoothAdapterManager::getKnownDevicesManualAnswer(bt_device_info_s *device_info)
-{
-       LogDebug("Enter");
-
-       BluetoothDeviceData device;
-       int index = 0;
-
-       if (device_info != NULL)
-       {
-
-               device.address = device_info->remote_address;
-               device.name = device_info->remote_name;
-
-               device.btClass.major = device_info->bt_class.major_device_class;
-               device.btClass.minor = device_info->bt_class.minor_device_class;
-               device.btClass.majorServiceMask = device_info->bt_class.major_service_class_mask;
-
-               device.isBonded = device_info->is_bonded;
-               device.isConnected = device_info->is_connected;
-               device.isTrusted = device_info->is_authorized;
-
-               if (device_info->service_uuid != NULL)
-               {
-                       for (index = 0; index < device_info->service_count; index++)
-                       {
-                               if (device_info->service_uuid[index] != NULL)
-                               {
-                                       device.uuids.push_back(device_info->service_uuid[index]);
-                               }
-                       }
-               }
-               else
-               {
-                       LogDebug("uuid is null");
-               }
-               updateDevice(device);
-               m_EventBTGetKnownDevicesPtr->addDevice(device);
-       }
-
-}
-
-void BluetoothAdapterManager::getDevice(const  EventBTGetDevicePtr& event) 
-{
-       LogDebug("Enter");
-       EventRequestReceiver<EventBTGetDevice>::PostRequest(event);
-}
-
-
-bool BluetoothAdapterManager::getDeviceManualAnswer(bt_device_info_s *device_info)
-{
-       std::string address = "";
-
-       if (device_info != NULL)
-       {
-               address = device_info->remote_address;
-       }
-       
-       BluetoothDeviceData device;
-       int index = 0;
-
-       device.address = device_info->remote_address;
-       device.name = device_info->remote_name;
-
-       device.btClass.major = device_info->bt_class.major_device_class;
-       device.btClass.minor = device_info->bt_class.minor_device_class;
-       device.btClass.majorServiceMask = device_info->bt_class.major_service_class_mask;
-
-
-       device.isBonded = device_info->is_bonded;
-       device.isConnected = device_info->is_connected;
-       device.isTrusted = device_info->is_authorized;
-
-       LogDebug("Enter Found " << device.address << " " << device.name << " " << device.btClass.major << " " << device.btClass.minor);
-
-       if (device_info->service_uuid != NULL)
-       {
-
-               for (index = 0; index < device_info->service_count; index++)
-               {
-                       if (device_info->service_uuid[index] != NULL)
-                       {
-                               device.uuids.push_back(device_info->service_uuid[index]);
-                       }
-               }
-       }
-       else
-       {
-               LogDebug("service uuid null");
-       }
-
-       if (m_btGetDeviceEvent)
-       {
-               LogDebug("Enter - getDeviceManualAnswer" << address << ":" << m_EventBTGetDevicePtr->getAddress());
-               
-               if (address == m_EventBTGetDevicePtr->getAddress())
-               {
-                       updateDevice(device);
-                       m_EventBTGetDevicePtr->setDevice(device);
-                       return false;
-               }
-       }
-       else
-       {
-               updateDevice(device);
-       }
-       
-       return true;
-}
-
-
-
-void BluetoothAdapterManager::createBonding(const  EventBTCreateDestroyBondingPtr& event) 
-{
-       LogDebug("Post Event EventBTCreateDestroyBonding");
-       EventRequestReceiver<EventBTCreateDestroyBonding>::PostRequest(event);
-}
-
-void BluetoothAdapterManager::createBondingManualAnswer(unsigned short error, bt_device_info_s *device_info)
-{
-       int index = 0;
-
-       if (error == BT_ERROR_NONE)
-       {
-               LogDebug("createBondingManualAnswer");
-               
-               BluetoothDeviceData device;
-               device.address = device_info->remote_address;
-               device.name = device_info->remote_name;
-               device.isBonded = device_info->is_bonded;
-               device.isConnected = device_info->is_connected;
-               device.isTrusted = device_info->is_authorized;
-
-               if (device_info->service_uuid != NULL)
-               {
-                       for (index = 0; index < device_info->service_count; index++)
-                       {
-                               if (device_info->service_uuid[index] != NULL)
-                               {
-                                       device.uuids.push_back(device_info->service_uuid[index]);
-                               }
-                       }
-               }
-               else
-               {
-                       LogDebug("service uuid null");
-               }
-               m_EventBTCreateDestroyBondingPtr->setExceptionCode(Commons::ExceptionCodes::None);
-               m_EventBTCreateDestroyBondingPtr->setDevice(device);
-       }
-       else
-       {
-               m_EventBTCreateDestroyBondingPtr->setExceptionCode(Commons::ExceptionCodes::UnknownException);
-       }
-       bt_device_unset_bond_created_cb();
-       EventRequestReceiver<EventBTCreateDestroyBonding>::ManualAnswer(m_EventBTCreateDestroyBondingPtr);
-}
-
-
-
-void BluetoothAdapterManager::destroyBonding(const  EventBTCreateDestroyBondingPtr& event) 
-{
-       LogDebug("Post Event EventBTCreateDestroyBonding");
-       EventRequestReceiver<EventBTCreateDestroyBonding>::PostRequest(event);
-}
-
-void BluetoothAdapterManager::destroyBondingManualAnswer(unsigned short error)
-{
-       if (error == BT_ERROR_NONE)
-       {
-               m_EventBTCreateDestroyBondingPtr->setExceptionCode(Commons::ExceptionCodes::None);
-       }
-       else
-       {
-               m_EventBTCreateDestroyBondingPtr->setExceptionCode(Commons::ExceptionCodes::UnknownException);
-       }
-       bt_device_unset_bond_destroyed_cb();
-       EventRequestReceiver<EventBTCreateDestroyBonding>::ManualAnswer(m_EventBTCreateDestroyBondingPtr);
-}
-
-
-void BluetoothAdapterManager::registerRFCOMMServiceByUUIDCallbackEmit(unsigned short error, 
-       bt_socket_connection_state_e connectionState, bt_socket_connection_s *connection)
-{
-       LogDebug("OK");
-               
-       EventBTRegisterRFCOMMPtr event(new EventBTRegisterRFCOMM());
-       bt_socket_unset_connection_state_changed_cb() ;
-       int ret = 0;
-       
-       if (error == BT_ERROR_NONE)
-       {
-               if (connectionState == BT_SOCKET_CONNECTED)
-               {
-                       BluetoothDeviceData deviceData;
-                       BluetoothSocketData socketData;
-                       std::map<std::string, BluetoothSocketData>::iterator it;
-                       
-                       event->setConnectionState(EventBTRegisterRFCOMM::REGISTER_CONNECTED);
-
-                       m_btGetDeviceEvent = false;
-
-                       if ((ret = bt_adapter_foreach_bonded_device(capi_callback_bt_adapter_bonded_device_find, (void*)this)) == BT_ERROR_NONE)
-                       {
-                               findDevice(connection->remote_address, deviceData);
-                       }                       
-
-                       deviceData.isConnected = true;
-
-                       if (connection->local_role == BT_SOCKET_SERVER)
-                       {
-                               socketData.isServer = true;
-                       }
-                       else
-                       {
-                               socketData.isServer = false;
-                       }
-                       
-                       socketData.protocol = PROTOCOL_TYPE_RFCOMM_VALUE_INT;
-                       
-                       socketData.connectedSocket = connection->socket_fd;
-                       socketData.registeredSocket = m_currentServiceSocket;
-                       socketData.state = SOCKET_STATE_OPEN_VALUE_INT;
-                       socketData.uuid = m_uuid;
-                       socketData.peerDevice = deviceData;
-
-                       if (m_socketMap.find(deviceData.address) != m_socketMap.end())
-                       {
-                               LogDebug("Found same device, remove!");
-                               m_socketMap.erase(it);
-                       }
-                       
-                       m_socketMap[deviceData.address] = socketData;
-                       event->setSocketData(socketData);
-                       event->setExceptionCode(Commons::ExceptionCodes::None);
-               }
-               else
-               {
-                       event->setConnectionState(EventBTRegisterRFCOMM::REGISTER_DISCONNECTED);                        
-               }
-       }
-       else
-       {
-               event->setExceptionCode(Commons::ExceptionCodes::UnknownException);
-       }
-       m_registerRFCOMMEmitter->emit(event);
-
-
-}
-long BluetoothAdapterManager::registerRFCOMMServiceByUUID(const EventBTRegisterRFCOMMEmitterPtr& emitter, 
-       std::string uuid, std::string name, unsigned short int security)
-{
-       LogDebug("EventBTRegisterRFCOMMPtr");
-
-       int ret = 0;
-       m_registerRFCOMMEmitter = emitter;
-       m_uuid = uuid;
-       m_name = name;
-       
-       try 
-       {
-               if (m_btPowered == false)       
-               {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
-               }
-
-               if (getVisibility() == false)
-               {
-                       ThrowMsg(Commons::UnknownException, "please set visivility");
-               }
-               
-               if((ret = bt_socket_create_rfcomm(uuid.data(), &m_currentServiceSocket)) != BT_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "service socket creation error" << ret);
-               }
-
-               if( bt_socket_set_connection_state_changed_cb(capi_callback_bt_socket_connection_state_changed, this) != BT_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "unkown platfrom exception");
-               }
-
-               if( bt_socket_listen_and_accept_rfcomm(m_currentServiceSocket, 1) != BT_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "service socket register error");
-               }
-               EventBTRegisterRFCOMMPtr event(new EventBTRegisterRFCOMM());
-               event->setConnectionState(EventBTRegisterRFCOMM::REGISTER_SUCCESS);
-               event->setExceptionCode(Commons::ExceptionCodes::None);
-               m_registerRFCOMMEmitter->emit(event);
-
-       }
-       catch (const Commons::Exception& ex) 
-       {
-               LogError("Exception: " << ex.GetMessage());
-               EventBTRegisterRFCOMMPtr event(new EventBTRegisterRFCOMM());
-               event->setExceptionCode(ex.getCode());
-               m_registerRFCOMMEmitter->emit(event);
-       }
-       return m_currentServiceSocket;
-}
-
-void BluetoothAdapterManager::unregisterRFCOMMService(const EventBTUnregisterRFCOMMServicePtr& event)
-{
-       LogDebug("EventBTUnregisterRFCOMMServicePtr");
-       EventRequestReceiver<EventBTUnregisterRFCOMMService>::PostRequest(event);
-}
-
-void BluetoothAdapterManager::setAdapterName(const EventBTSetNamePtr& event)
-{
-       LogDebug("EventBTSetNamePtr");
-       EventRequestReceiver<EventBTSetName>::PostRequest(event);
-}
-
-void BluetoothAdapterManager::setAdapterNameManualAnswer(char* deviceName) 
-{
-       LogDebug("Enter");
-
-       if (deviceName != NULL)
-       {
-               if (strcmp(deviceName,  m_EventBTSetNamePtr->getName().c_str()) != 0)
-               {
-                       m_EventBTSetNamePtr->setExceptionCode(Commons::ExceptionCodes::UnknownException);
-               }
-               else
-               {
-                       m_EventBTSetNamePtr->setExceptionCode(Commons::ExceptionCodes::None);
-               }
-       }
-       else
-       {
-               m_EventBTSetNamePtr->setExceptionCode(Commons::ExceptionCodes::UnknownException);
-       }
-       
-       EventRequestReceiver<EventBTSetName>::ManualAnswer(m_EventBTSetNamePtr);
-}
-
-
-
-void BluetoothAdapterManager::stopDiscovery(const EventBTStopDiscoveryPtr& event)
-{
-       LogDebug("EventBTStopDiscoveryPtr");
-       EventRequestReceiver<EventBTStopDiscovery>::PostRequest(event);
-
-}
-
-void BluetoothAdapterManager::OnRequestReceived(const  EventBTSetPoweredPtr& event) 
-{
-       int ret = 0;            
-
-       try 
-       {
-               event->switchToManualAnswer();
-               m_EventBTSetPoweredPtr = event; 
-
-               if( bt_adapter_set_state_changed_cb(capi_callback_bt_state_changed, (void*)this) != BT_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
-               }
-
-               if (event->isEnableRequested())
-               {
-                       ret = bt_adapter_enable();
-
-                       switch(ret) 
-                       {
-                       case BT_ERROR_NONE:
-                               return;
-                       case BT_ERROR_ALREADY_DONE:
-                               event->setExceptionCode(Commons::ExceptionCodes::None);
-                               m_btPowered = canUseBluetooth();
-                               bt_adapter_unset_state_changed_cb();
-                               EventRequestReceiver<EventBTSetPowered>::ManualAnswer(event);
-                               break;
-                       case BT_ERROR_NOT_INITIALIZED:
-                               ThrowMsg(Commons::UnknownException, "bt is not initialized");
-                               break;
-                       case BT_ERROR_RESOURCE_BUSY:
-                               default:
-                               ThrowMsg(Commons::SecurityException, "bt is busy");
-                               break;
-                       }
-               }
-               else
-               {
-                       LogDebug("Disable");
-                       ret = bt_adapter_disable();
-
-                       if (ret == BT_ERROR_NONE)
-                       {
-                               return;
-                       }
-                       ThrowMsg(Commons::UnknownException, "can not disable bt");
-               }
-       }
-       catch (const Commons::Exception& ex) 
-       {
-               LogError("Exception: " << ex.GetMessage());
-               event->setExceptionCode(ex.getCode());
-               bt_adapter_unset_state_changed_cb();
-               EventRequestReceiver<EventBTSetPowered>::ManualAnswer(event);
-       }
-}
-
-void BluetoothAdapterManager::OnRequestReceived(const  EventBTSetVisiblePtr& event) 
-{
-       LogDebug("Enter");
-       int ret = 0;
-       bt_adapter_visibility_mode_e visibility_mode = BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE;
-       bt_adapter_visibility_mode_e current_visibility = BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE;
-
-       try 
-       {
-               m_EventBTSetVisiblePtr = event;
-               event->switchToManualAnswer();          
-
-               if (m_btPowered == false)
-               {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
-               }
-               
-               if (event->isVisibleRequested())
-               {
-                       if (event->getTimeout() == 0) 
-                       {
-                               visibility_mode = BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE;
-                       }
-                       else
-                       {
-                               visibility_mode = BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE;
-                       }
-               }
-               else
-               {
-                       visibility_mode = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE;
-
-               }
-
-               if (bt_adapter_get_visibility(&current_visibility) != BT_ERROR_NONE)
-               {
-                       ThrowMsg(Commons::UnknownException, "get visibility error" << ret);
-               }       
-
-
-               if (current_visibility == visibility_mode)
-               {
-                       LogDebug("already same visiblity");
-                       event->setExceptionCode(Commons::ExceptionCodes::None);
-                       EventRequestReceiver<EventBTSetVisible>::ManualAnswer(event);
-                       return;
-               }
-
-               if((ret = bt_adapter_set_visibility_mode_changed_cb(capi_callback_bt_visibility_changed, (void*)this)) != BT_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error" << ret);
-               }
-
-               LogDebug("bt_adapter_set_visibility " << visibility_mode << "  " << event->getTimeout());
-
-               if ((ret = bt_adapter_set_visibility(visibility_mode, event->getTimeout()) != BT_ERROR_NONE))
-               {
-                       ThrowMsg(Commons::UnknownException, "set visibility error" << ret);
-               }
-       }
-       catch (const Commons::Exception& ex) 
-       {
-               LogError("Exception: " << ex.GetMessage());
-               event->setExceptionCode(ex.getCode());
-               bt_adapter_unset_visibility_mode_changed_cb();
-               EventRequestReceiver<EventBTSetVisible>::ManualAnswer(event);
-       }
-}
-
-       
-void BluetoothAdapterManager::OnRequestReceived(const  EventBTGetKnownDevicesPtr& event) 
-{
-       LogDebug("EventBTGetKnownDevicesPtr Enter");
-
-       int ret = 0;
-
-       try 
-       {
-               m_EventBTGetKnownDevicesPtr = event;
-
-               if (m_btPowered == false)       
-               {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
-               }
-
-               if ((ret = bt_adapter_foreach_bonded_device(capi_callback_bt_adapter_bonded_device, (void*)this))!= BT_ERROR_NONE)
-               {
-                       ThrowMsg(Commons::UnknownException, "bt_adapter_foreach_bonded_device" << ret);
-               }
-
-               LogDebug("Get Konwn device");           
-               
-               event->setExceptionCode(Commons::ExceptionCodes::None);
-       }
-       catch (const Commons::Exception& ex) 
-       {
-               LogError("Exception: " << ex.GetMessage());
-               event->setExceptionCode(ex.getCode());
-       }
-}
-
-void BluetoothAdapterManager::OnRequestReceived(const  EventBTGetDevicePtr& event) 
-{
-       LogDebug("EventBTGetDevicePtr Enter");
-
-       int ret = 0;
-
-       try 
-       {
-               m_EventBTGetDevicePtr = event;
-
-               if (m_btPowered == false)       
-               {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
-               }
-               m_btGetDeviceEvent = true;
-
-               if ((ret = bt_adapter_foreach_bonded_device(capi_callback_bt_adapter_bonded_device_find, (void*)this))!= BT_ERROR_NONE)
-               {
-                       ThrowMsg(Commons::UnknownException, "bt_adapter_foreach_bonded_device" << ret);
-               }
-               m_btGetDeviceEvent = false;
-               
-               LogDebug("EventBTGetDevicePtr");                
-               event->setExceptionCode(Commons::ExceptionCodes::None);
-       }
-       catch (const Commons::Exception& ex) 
-       {
-               LogError("Exception: " << ex.GetMessage());
-               event->setExceptionCode(ex.getCode());
-       }
-}
-
-void BluetoothAdapterManager::OnRequestReceived(const  EventBTCreateDestroyBondingPtr& event) 
-{
-       LogDebug("Enter");
-
-       int ret = 0;
-       const char *device_addr = (event->getAddress()).data();
-
-       try 
-       {
-               m_EventBTCreateDestroyBondingPtr = event;
-               event->switchToManualAnswer();
-
-               if (m_btPowered == false)       
-               {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
-               }
-
-
-               if ((event->getAddress()).length() == 0)
-               {
-                       ThrowMsg(Commons::PlatformException, "address error" << ret);
-               }
-
-
-               if (event->isCreateBonding())
-               {
-
-                       if ((ret = bt_device_set_bond_created_cb(capi_callback_bt_device_bond_created, (void*)this)) != BT_ERROR_NONE )
-                       {
-                               ThrowMsg(Commons::PlatformException, "bt_device_set_bond_created_cb set error" << ret);
-                       }
-
-                       if ((ret = bt_device_create_bond(device_addr) != BT_ERROR_NONE ))
-                       {
-                               ThrowMsg(Commons::PlatformException, "bt_device_create_bond error" << ret);
-                       }
-               }
-               else
-               {
-                       if ((ret = bt_device_set_bond_destroyed_cb (capi_callback_bt_device_bond_destroyed, (void*)this)) != BT_ERROR_NONE )
-                       {
-                               ThrowMsg(Commons::PlatformException, "bt_device_set_bond_created_cb set error" << ret);
-                       }
-
-                       if ((ret = bt_device_destroy_bond (device_addr) != BT_ERROR_NONE ))
-                       {
-                               ThrowMsg(Commons::PlatformException, "bt_device_create_bond error" << ret);
-                       }
-
-               }
-       }
-       catch (const Commons::Exception& ex) 
-       {
-               LogError("Exception: " << ex.GetMessage());
-               bt_device_unset_bond_destroyed_cb ();
-               event->setExceptionCode(ex.getCode());
-
-
-               if (event->isCreateBonding())
-               {
-                       bt_device_unset_bond_created_cb();
-               }
-               else
-               {
-                       bt_device_unset_bond_destroyed_cb();
-               }
-
-               EventRequestReceiver<EventBTCreateDestroyBonding>::ManualAnswer(event);
-       }
-}
-
-void BluetoothAdapterManager::OnRequestReceived(const EventBTSetNamePtr& event) 
-{
-       LogDebug("Enter");
-       try 
-       {
-               std::string adapterName = event->getName();
-
-
-               if (m_btPowered == false)       
-               {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
-               }
-               
-               if (adapterName.length() == 0)
-               {
-                       ThrowMsg(Commons::PlatformException, "set name parameter error");
-               }
-
-               if (bt_adapter_set_name_changed_cb(capi_callback_bt_name_changed, this) != BT_ERROR_NONE)
-               {
-                       ThrowMsg(Commons::PlatformException, "callback set error");             
-               }
-
-               if (bt_adapter_set_name(adapterName.c_str()) != BT_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::PlatformException, "set name error");                 
-               }
-               
-               m_EventBTSetNamePtr = event;            
-               event->switchToManualAnswer();
-
-       }
-       catch (const Commons::Exception& ex) 
-       {
-               LogError("Exception: " << ex.GetMessage());
-               event->setExceptionCode(ex.getCode());
-       }
-
-}
-
-void BluetoothAdapterManager::OnRequestReceived(const EventBTUnregisterRFCOMMServicePtr& event) 
-{
-       LogDebug("Enter");
-       
-       try 
-       {
-               std::map<std::string, BluetoothSocketData>::iterator it;
-               int socketFd = event->getUnregisterSocket();
-               
-               if (m_btPowered == false)       
-               {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
-               }
-
-               
-               if (socketFd < 0)
-               {
-                       ThrowMsg(Commons::UnsupportedException, "no service socket");
-               }
-
-               if (m_socketMap.size() != 0)
-               {
-                       LogDebug("try to disconnect connected socket");
-                       for (it = m_socketMap.begin(); it != m_socketMap.end(); ++it)
-                       {
-                               bt_socket_disconnect_rfcomm((*it).second.connectedSocket);
-                       }
-               }
-               else
-               {
-                       LogDebug("there is no connected socket");
-               }
-
-               if (bt_socket_destroy_rfcomm(socketFd) != BT_ERROR_NONE)
-               {
-                       ThrowMsg(Commons::UnsupportedException, "socket destroy error");
-               }
-               event->setExceptionCode(Commons::ExceptionCodes::None);
-       }
-       catch (const Commons::Exception& ex) 
-       {
-               LogError("Exception: " << ex.GetMessage());
-        event->setExceptionCode(ex.getCode());
-       }       
-       bt_adapter_unset_state_changed_cb();
-
-}
-
-void BluetoothAdapterManager::OnRequestReceived(const EventBTStopDiscoveryPtr& event)
-{
-       LogDebug("Enter");
-       
-       try 
-       {
-               if (m_btPowered == false)       
-               {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
-               }
-
-               if (bt_adapter_stop_device_discovery() != BT_ERROR_NONE)                
-               {
-                       ThrowMsg(Commons::PlatformException, "device discovery stop fail");
-               }
-               bt_adapter_unset_device_discovery_state_changed_cb();
-               event->setExceptionCode(Commons::ExceptionCodes::None);
-       }
-       catch (const Commons::Exception &ex)
-       {
-               LogError("Exception: " << ex.GetMessage());
-        event->setExceptionCode(ex.getCode());
-       }
-}
-
-}
-}
-}
-
diff --git a/src/platform/Tizen/Bluetooth/BluetoothServiceHandlerManager.cpp b/src/platform/Tizen/Bluetooth/BluetoothServiceHandlerManager.cpp
new file mode 100644 (file)
index 0000000..0b20609
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "BluetoothServiceHandlerManager.h"
+#include <dpl/assert.h>
+#include <API/Bluetooth/BluetoothProperty.h>
+#include <API/Bluetooth/BTDevice.h>
+
+
+namespace TizenApis {
+namespace Platform {
+namespace Bluetooth {
+
+using namespace Platform;
+
+BluetoothServiceHandlerManager::BluetoothServiceHandlerManager()
+{
+       LogDebug("Enter");
+}
+
+BluetoothServiceHandlerManager::~BluetoothServiceHandlerManager() 
+{
+       LogDebug("Enter");
+}
+
+
+namespace {
+
+static void capi_callback_bt_connection_state_changed(int result, bt_socket_connection_state_e connection_state, 
+       bt_socket_connection_s *connection, void *user_data)
+{
+       LogDebug("OK");
+       ((BluetoothServiceHandlerManager*)(user_data))->connectionStateChangedEmit(result, connection_state, connection);
+}
+
+
+}
+
+void BluetoothServiceHandlerManager::connectionStateChangedEmit(int result, 
+       bt_socket_connection_state_e connection_state,  bt_socket_connection_s *connection)
+{
+       LogDebug("OK");
+
+       Api::Bluetooth::EventBTServiceOnConnectPtr event(new Api::Bluetooth::EventBTServiceOnConnect());
+
+       if (result == BT_ERROR_NONE)
+       {
+               Api::Bluetooth::BluetoothSocketData socketdata;
+               socketdata.uuid = m_Uuid;
+               socketdata.isServer = true;
+               socketdata.protocol = PROTOCOL_TYPE_RFCOMM_VALUE_INT;
+               socketdata.state = SOCKET_STATE_OPEN_VALUE_INT;
+               socketdata.connectedSocket = connection->socket_fd;
+               socketdata.registeredSocket = connection->socket_fd;
+               socketdata.peerDevice.address = connection->remote_address;
+               socketdata.peerDevice.isConnected = true;
+               m_Connected = true;
+               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
+               event->setSocketData(socketdata);
+       }
+       else
+       {
+               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::UnknownException);
+       }
+       m_emitter->emit(event);
+}
+
+void BluetoothServiceHandlerManager::setRegisterSocket(int socket)
+{
+       m_registerSocket = socket;
+}
+
+void BluetoothServiceHandlerManager::setName(std::string name)
+{
+       m_Name = name;
+}
+
+void BluetoothServiceHandlerManager::setIsConnected(bool connected)
+{
+       m_Connected =  connected;
+
+}
+
+std::string BluetoothServiceHandlerManager::getName()
+{
+       return m_Name;
+}
+
+bool BluetoothServiceHandlerManager::getIsConnected()
+{
+       return m_Connected;
+}
+
+int BluetoothServiceHandlerManager::setServiceHandlerListener(
+       const Api::Bluetooth::EventBTServiceOnConnectEmitterPtr& emitter)
+{
+       if (bt_socket_set_connection_state_changed_cb(capi_callback_bt_connection_state_changed, this) 
+               != BT_ERROR_NONE)
+       {
+               LogDebug("callback set error");
+               return BT_ERROR_NOT_INITIALIZED;
+       }
+       LogDebug("setServiceHandlerListener - OK");
+
+       m_emitter = emitter;
+       return BT_ERROR_NONE;
+}
+
+
+std::string BluetoothServiceHandlerManager::getUUID()
+{
+       return m_Uuid;
+}
+
+void BluetoothServiceHandlerManager::setUUID(std::string uuid)
+{
+       m_Uuid = uuid;
+}
+
+void BluetoothServiceHandlerManager::unRegister(const Api::Bluetooth::EventBTUnregisterRFCOMMServicePtr &event)
+{
+       LogDebug("Enter");
+       WrtDeviceApis::Commons::EventRequestReceiver<Api::Bluetooth::EventBTUnregisterRFCOMMService>::PostRequest(event);
+}
+
+void BluetoothServiceHandlerManager::OnRequestReceived(const Api::Bluetooth::EventBTUnregisterRFCOMMServicePtr& event) 
+{
+       LogDebug("Enter");
+       
+       try 
+       {
+               std::map<std::string, Api::Bluetooth::BluetoothSocketData>::iterator it;
+               
+               if (m_registerSocket < 0)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::UnsupportedException, "no service socket");
+               }
+
+               if (bt_socket_destroy_rfcomm(m_registerSocket) != BT_ERROR_NONE)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::UnsupportedException, "socket destroy error");
+               }
+               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
+       }
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               LogError("Exception: " << ex.GetMessage());
+        event->setExceptionCode(ex.getCode());
+       }       
+       bt_adapter_unset_state_changed_cb();
+
+}
+
+}
+}
+}
diff --git a/src/platform/Tizen/Bluetooth/BluetoothServiceHandlerManager.h b/src/platform/Tizen/Bluetooth/BluetoothServiceHandlerManager.h
new file mode 100644 (file)
index 0000000..20de4cb
--- /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_PLATFROM_BLUETOOTH_SERVICE_HANDLER_MANAGER_H_
+#define TIZENAPIS_PLATFROM_BLUETOOTH_SERVICE_HANDLER_MANAGER_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/ThreadPool.h>
+#include <API/Bluetooth/IBluetoothServiceHandlerManager.h>
+#include <API/Bluetooth/BluetoothFactory.h>
+#include <bluetooth.h>
+#include <dpl/mutex.h>
+#include <vector>
+#include <bluetooth.h>
+
+namespace TizenApis {
+namespace Platform {
+namespace Bluetooth {
+
+class BluetoothServiceHandlerManager : public Api::Bluetooth::IBluetoothServiceHandlerManager
+{
+       friend class TizenApis::Api::Bluetooth::BluetoothFactory;
+public:
+       virtual ~BluetoothServiceHandlerManager();
+       virtual void unRegister(const Api::Bluetooth::EventBTUnregisterRFCOMMServicePtr &event);
+       virtual int setServiceHandlerListener(const Api::Bluetooth::EventBTServiceOnConnectEmitterPtr& emitter);
+       virtual void setUUID(std::string uuid);
+       virtual std::string getUUID();
+       virtual void setRegisterSocket(int socket);
+       virtual void setName(std::string name);
+       virtual void setIsConnected(bool connected);
+       virtual std::string getName();
+       virtual bool getIsConnected();
+       void connectionStateChangedEmit(int result, 
+               bt_socket_connection_state_e connection_state,  bt_socket_connection_s *connection);
+private:
+       std::string m_Uuid;
+       std::string m_Name;
+       bool m_Connected;
+       int m_registerSocket;
+       Api::Bluetooth::EventBTServiceOnConnectEmitterPtr m_emitter;
+protected:
+       BluetoothServiceHandlerManager();
+       virtual void OnRequestReceived(const Api::Bluetooth::EventBTUnregisterRFCOMMServicePtr& event) ;
+};
+
+}
+}
+}
+
+#endif
+
old mode 100755 (executable)
new mode 100644 (file)
index ae77c9c..6491686
@@ -122,6 +122,12 @@ int BluetoothSocketManager::setSocketNotifier(EventBTSocketNotificationEmitterPt
        return BT_ERROR_NONE;
        
 }
+
+EventBTSocketNotificationEmitterPtr BluetoothSocketManager::getSocketNotifier()
+{
+       return m_EventBTSocketNotificationEmitterPtr;
+}
+
 int BluetoothSocketManager::writeData(const char *data, const unsigned int length)
 {
        LogDebug(length);
index 343a623..ada1b10 100644 (file)
@@ -43,6 +43,7 @@ public:
        virtual unsigned int getState();
        virtual BluetoothDeviceData getPeer();
        virtual int setSocketNotifier(EventBTSocketNotificationEmitterPtr emitter);
+       virtual EventBTSocketNotificationEmitterPtr getSocketNotifier();
        virtual int writeData(const char *data, const unsigned int length);
        virtual EventBTReadDataType readData();
        virtual int close();
old mode 100755 (executable)
new mode 100644 (file)
index 30ed4b4..e815958
@@ -16,5 +16,6 @@ set(SRCS_PLATFORM_IMPLEMENTATION_BLUETOOTH
   ${CURRENT_PATH}/BluetoothAdapterManager.cpp
   ${CURRENT_PATH}/BluetoothDeviceManager.cpp
   ${CURRENT_PATH}/BluetoothSocketManager.cpp
+  ${CURRENT_PATH}/BluetoothServiceHandlerManager.cpp
   PARENT_SCOPE
 )
index 6f16ae1..a02be8f 100755 (executable)
 
 
 #include <calendar-svc-provider.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/scoped_ptr.h>
 #include "Calendar.h"
 #include "CalendarManager.h"
 #include "CalendarQuery.h"
 #include "CalendarFilter.h"
+#include "CalendarFilterValidator.h"
 #include "API/Calendar/OnAddEventsChanged.h"
 #include "API/Calendar/OnUpdateEventsChanged.h"
 #include "API/Calendar/OnDeleteEventsChanged.h"
@@ -62,8 +63,7 @@ void Calendar::OnRequestReceived(const IEventAddEventPtr &event)
             LogWarning("adding event that is already added");
             event->getEvent()->resetId();
         }
-        DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(
-                                                      event->getEvent(), getType()));
+        DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(event->getEvent(), getType()));
         event->getEvent()->setCalendarType(getType());
         eventWrapper->convertAbstractEventToPlatformEvent();
         if (event->checkCancelled()) {
@@ -71,6 +71,10 @@ void Calendar::OnRequestReceived(const IEventAddEventPtr &event)
             event->setResult(true);
             return;
         }
+
+        // Set the account and calendar id before saving the item.
+        eventWrapper->setCalendarId(getId());
+        eventWrapper->setCalendarAccountId(getAccountId());
         eventWrapper->saveEvent();
         event->setResult(true);
     }
@@ -78,6 +82,7 @@ void Calendar::OnRequestReceived(const IEventAddEventPtr &event)
     {
         LogError("Error during adding event" << ex.DumpToString());
         event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::UnknownException);
     }
     event->setCancelAllowed(false);
 }
@@ -109,6 +114,9 @@ void Calendar::OnRequestReceived(const IEventAddEventsPtr &events)
             }
 
             try {
+                // Set the account and calendar id before saving the item.
+                eventWrapper->setCalendarId(getId());
+                eventWrapper->setCalendarAccountId(getAccountId());
                 eventWrapper->saveEvent();
             } catch (const Exception &saveException) {
                 LogInfo("Error during saving an event " << saveException.DumpToString());
@@ -127,6 +135,7 @@ void Calendar::OnRequestReceived(const IEventAddEventsPtr &events)
     {
         LogError("Error during adding events" << ex.DumpToString());
         events->setResult(false);
+        events->setExceptionCode(ExceptionCodes::UnknownException);
     }
     events->setCancelAllowed(false);
 }
@@ -155,6 +164,9 @@ void Calendar::OnRequestReceived(const IEventUpdateEventPtr &event)
 
         if ( event->getUpdateAllInstances() || NULL==event->getEvent()->getRecurrenceRule())
         {
+            // Set the account and calendar id before saving the item.
+            eventWrapper->setCalendarId(getId());
+            eventWrapper->setCalendarAccountId(getAccountId());
             eventWrapper->saveEvent();
         }
         else
@@ -201,6 +213,7 @@ void Calendar::OnRequestReceived(const IEventUpdateEventPtr &event)
     {
         LogError("Error during updating event " << ex.DumpToString());
         event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::UnknownException);
     }
     event->setCancelAllowed(false);
 }
@@ -235,6 +248,9 @@ void Calendar::OnRequestReceived(const IEventUpdateEventsPtr &events)
             try {
                 if (events->getUpdateAllInstances() || NULL==thisEvent->getRecurrenceRule())
                 {
+                    // Set the account and calendar id before saving the item.
+                    eventWrapper->setCalendarId(getId());
+                    eventWrapper->setCalendarAccountId(getAccountId());
                     eventWrapper->saveEvent();
                 }
                 else
@@ -290,6 +306,7 @@ void Calendar::OnRequestReceived(const IEventUpdateEventsPtr &events)
     {
         LogError("Error during updating events " << ex.DumpToString());
         events->setResult(false);
+        events->setExceptionCode(ExceptionCodes::UnknownException);
     }
     events->setCancelAllowed(false);
 }
@@ -332,6 +349,7 @@ void Calendar::OnRequestReceived(const IEventDeleteEventPtr &event)
     {
         LogError("Error during deleting event " << ex.DumpToString());
         event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::UnknownException);
     }
     event->setCancelAllowed(false);
 }
@@ -393,6 +411,7 @@ void Calendar::OnRequestReceived(const IEventDeleteEventsPtr &events)
     {
         LogError("Error during deleting event " << ex.DumpToString());
         events->setResult(false);
+        events->setExceptionCode(ExceptionCodes::UnknownException);
     }
     events->setCancelAllowed(false);
 }
@@ -400,30 +419,42 @@ void Calendar::OnRequestReceived(const IEventDeleteEventsPtr &events)
 void Calendar::OnRequestReceived(const IEventFindEventsPtr &event)
 {
     LogDebug("entered");
-    const EventFilterPtr filter = event->getFilter();
-    cal_struct *platformEvent = NULL;
-    cal_iter *iter = NULL;
+    bool useGenericFilter = true;
     event->setResult(true);
-    bool isStartDateSet = false;
 
-    try
+    // Tizen Generic filter
+    if ( useGenericFilter )
     {
-        // Tizen Generic filter
-        if ( event->getGenericFilterIsSet() )
+        try
         {
+            _db_init();
+
             CalendarFilterPtr calendarFilter( new CalendarFilter() );
-               std::string query ("SELECT rowid, * FROM schedule_table");
+
+            // Set the attributesOfInterest here if needed.
+            //std::string query ("SELECT " + calendarFilter.concatenateFilterAttributes() + " FROM schedule_table");
+            std::string query (std::string("SELECT ") + CAL_VALUE_INT_INDEX + " FROM schedule_table");
+            LogInfo("Default query statement: "<<query);
 
                TizenApis::Api::Tizen::IFilterVisitorPtr filterTraversal = DPL::StaticPointerCast<TizenApis::Api::Tizen::IFilterVisitor>(calendarFilter);
 
                if (event->getGenericFilterIsSet()) {
                 TizenApis::Api::Tizen::FilterPtr genericFilter = event->getGenericFilter();
+
+                TizenApis::Api::Tizen::FilterValidatorPtr validator = CalendarFilterValidatorFactory::getCalendarFilterValidator();
+                bool success = genericFilter->validate(validator);
+                if(!success) {
+                    ThrowMsg(InvalidArgumentException, "Invalid filter arguments.");
+                } else {
+                    LogInfo("Filter validation has passed.");
+                }
+
                        genericFilter->travel(filterTraversal, 0);
                        LogDebug("Traverse string [" << calendarFilter->getResult() << "]");
                        query.append(calendarFilter->getResult());
-                       query.append(" AND is_deleted = 0");
+                query.append(" AND is_deleted = 0;");
                } else {
-                       query.append(" WHERE is_deleted = 0");
+                query.append(" WHERE is_deleted = 0;");
                }
 
                if (event->getSortModesIsSet()) {
@@ -434,11 +465,46 @@ void Calendar::OnRequestReceived(const IEventFindEventsPtr &event)
 
                calendarFilter->executeQuery(query, event->getEvents());
 
-               LogDebug("Result counter [" << event->getEvents()->size() << "]");
+            LogDebug("Result count [" << event->getEvents()->size() << "]");
+
+            _db_finish();
+
+            // Now load the full calendar item using the retrieved id.
+            for( unsigned int i=0; i<event->getEvents()->size(); i++) {
+                // platformEvent is freed when the wrapper destructor is called.
+                DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(event->getEvents()->at(i), getType()));
+                eventWrapper->loadEvent(event->getEvents()->at(i)->getId());
+            }
         }
-        // Tizen filter
-        else
+        catch (const InvalidArgumentException &ex)
+        {
+            LogError("Exception: " << ex.DumpToString());
+            event->setResult(false);
+            event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
+        }
+        catch (const NotFoundException &ex)
+        {
+            LogError("Exception: " << ex.DumpToString());
+            event->setResult(false);
+            event->setExceptionCode(ExceptionCodes::NotFoundException);
+        }
+        catch (const Exception &ex)
+        {
+            LogError("Exception: " << ex.DumpToString());
+            event->setResult(false);
+            event->setExceptionCode(ExceptionCodes::UnknownException);
+        }
+    }
+    // WAC style filter
+    else
+    {
+        cal_iter *iter = NULL;
+        try
         {
+            const EventFilterPtr filter = event->getFilter();
+            cal_struct *platformEvent = NULL;
+            bool isStartDateSet = false;
+
             if (NULL==filter)
             {
                 LogInfo("Filter is not set.");
@@ -448,11 +514,13 @@ void Calendar::OnRequestReceived(const IEventFindEventsPtr &event)
                 } else {
                     dataType = CAL_STRUCT_SCHEDULE;
                 }
-                
-                if (CAL_SUCCESS != calendar_svc_get_all(0, 0, dataType, &iter)) {
+
+                std::istringstream stream(getId());
+                int calendarId = -1;
+                stream>>calendarId;
+                if (CAL_SUCCESS != calendar_svc_get_all(getAccountId(), calendarId, dataType, &iter)) {
                         ThrowMsg(PlatformException, "Can't get all records");
                 }
-
             }
             else
             // Use the new calendar service search function with multiple type/value pairs.
@@ -591,20 +659,21 @@ void Calendar::OnRequestReceived(const IEventFindEventsPtr &event)
                 }
             }
         }
-    }
-    catch (const NotFoundException &ex)
-    {
-        event->setResult(false);
-        event->setExceptionCode(ExceptionCodes::NotFoundException);
-    }
-    catch (const Exception &ex)
-    {
-        LogError("Exception: " << ex.DumpToString());
-        event->setResult(false);
-    }
+        catch (const NotFoundException &ex)
+        {
+            LogError("Exception: " << ex.DumpToString());
+            event->setResult(false);
+            event->setExceptionCode(ExceptionCodes::NotFoundException);
+        }
+        catch (const Exception &ex)
+        {
+            LogError("Exception: " << ex.DumpToString());
+            event->setResult(false);
+            event->setExceptionCode(ExceptionCodes::UnknownException);
+        }
 
-    calendar_svc_iter_remove(&iter);
-    event->setCancelAllowed(true);
+        calendar_svc_iter_remove(&iter);
+    }
 }
 
 void Calendar::OnRequestReceived(const IEventCreateEventPtr &event)
@@ -620,6 +689,7 @@ void Calendar::OnRequestReceived(const IEventCreateEventPtr &event)
     {
         LogError("Error during creating an event " << ex.DumpToString());
         event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::UnknownException);
     }
 }
 
@@ -645,6 +715,7 @@ void Calendar::OnRequestReceived(const IEventCreateEventFromStringPtr &event)
         LogError("Error during creating event from string" << ex.DumpToString());
         LogInfo("eventString: " + event->getEventString());
         event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::UnknownException);
     }
     event->setCancelAllowed(false);
 }
@@ -674,6 +745,7 @@ void Calendar::OnRequestReceived(const IEventExportEventToStringPtr &event)
     {
         LogError("Error during creating string from event" << ex.DumpToString());
         event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::UnknownException);
     }
     event->setCancelAllowed(false);
 }
@@ -762,8 +834,6 @@ void Calendar::OnRequestReceived(const IEventWatchChangesPtr &event)
         {
             if( CAL_SUCCESS!=calendar_svc_subscribe_change(eventChangedCb, this) ) {
                 ThrowMsg(PlatformException, "Can't subscribe the db change noti.");
-                event->setResult(false);
-                return;
             } else {
                 // Save the last change fetch time to start watching.
                 std::time_t localTime = time(NULL);
@@ -780,6 +850,7 @@ void Calendar::OnRequestReceived(const IEventWatchChangesPtr &event)
     {
         LogError("Error during creating a watch " << ex.DumpToString());
         event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::UnknownException);
     }
 }
 
@@ -793,8 +864,6 @@ void Calendar::OnRequestReceived(const IEventClearWatchPtr &event)
         if( m_changeEmitters.size()==0 ) {
             if( CAL_SUCCESS!=calendar_svc_unsubscribe_change(eventChangedCb) ) {
                 ThrowMsg(PlatformException, "Can't unsubscribe the db change noti.");
-                event->setResult(false);
-                return;
             } else {
                 LogDebug("Platform watch cleared successfully.");
             }
@@ -805,6 +874,7 @@ void Calendar::OnRequestReceived(const IEventClearWatchPtr &event)
     {
         LogError("Error during clearing the watch " << ex.DumpToString());
         event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::UnknownException);
     }
 }
 
@@ -845,6 +915,7 @@ void Calendar::OnRequestReceived(const IEventExpandEventRecurrencePtr &event)
     {
         LogError("Exception: " << ex.DumpToString());
         event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::UnknownException);
     }
 
     event->setCancelAllowed(true);
index f338da1..a2eba33 100755 (executable)
@@ -18,7 +18,6 @@
 #ifndef _CALENDAR_H_
 #define _CALENDAR_H_
 
-#include <list>
 #include "API/Calendar/ICalendar.h"
 #include "EventWrapper.h"
 
index 9e9a076..e9f2db2 100755 (executable)
  */
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "CalendarFilter.h"
 #include "CalendarQuery.h"
-#include <API/Filter/SortMode.h>
+#include <calendar-svc-provider.h>
+#include <map>
+#include <sstream>
+#include <time.h>
 
 using namespace TizenApis::Api::Calendar;
+using namespace WrtDeviceApis::Commons;
 
 namespace TizenApis {
 namespace Platform {
 namespace Calendar {
 
-CalendarFilter::CalendarFilter() : m_query("")
+// The selected fields for the generic filter support.
+std::map<std::string, std::string> CalendarFilter::m_attributeMap = {
+    {CALENDAR_FILTER_ATTRIBUTE_ID_UID,                              CAL_VALUE_INT_INDEX},
+    {CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE,              CAL_VALUE_GMT_LAST_MODIFIED_TIME},
+    {CALENDAR_FILTER_ATTRIBUTE_DESCRIPTION,                     CAL_VALUE_TXT_DESCRIPTION},
+    {CALENDAR_FILTER_ATTRIBUTE_SUMMARY,                         CAL_VALUE_TXT_SUMMARY},
+    {CALENDAR_FILTER_ATTRIBUTE_START_DATE,                       CAL_VALUE_GMT_START_DATE_TIME},
+    {CALENDAR_FILTER_ATTRIBUTE_LOCATION,                        CAL_VALUE_TXT_LOCATION},
+    {CALENDAR_FILTER_ATTRIBUTE_LATITUDE,                        CAL_VALUE_DBL_LATITUDE},
+    {CALENDAR_FILTER_ATTRIBUTE_LONGITUDE,                       CAL_VALUE_DBL_LONGITUDE},
+    {CALENDAR_FILTER_ATTRIBUTE_ORGANIZER,                       CAL_VALUE_TXT_ORGANIZER_NAME},
+    {CALENDAR_FILTER_ATTRIBUTE_VISIBILITY,                      CAL_VALUE_INT_SENSITIVITY},
+    {CALENDAR_FILTER_ATTRIBUTE_STATUS,                          CAL_VALUE_INT_TASK_STATUS},
+    //{"alarms",                          CAL_VALUE_INT_ALARMS_TICK}, // object interface
+    //{"alarmsType",                      CAL_VALUE_INT_ALARMS_TYPE}, // dependent on the alarm tick
+    {CALENDAR_FILTER_ATTRIBUTE_CATEGORIES,                      CAL_VALUE_LST_MEETING_CATEGORY}, // string array
+    {CALENDAR_FILTER_ATTRIBUTE_PRIORITY,                        CAL_VALUE_INT_PRIORITY},
+    {CALENDAR_FILTER_ATTRIBUTE_DUE_DATE,                        CAL_VALUE_GMT_END_DATE_TIME},
+    //{"completedDate",                   CAL_VALUE_GMT_COMPLETED_DATE_TIME}, // not yet supported in platform
+    //{"progress",                        CAL_VALUE_INT_PROGRESS}, // not yet supported in platform
+    //{"isDetached",                      CAL_VALUE_INT_PRIORITY}, // needs special manipulation
+    {CALENDAR_FILTER_ATTRIBUTE_IS_ALL_DAY,                      CAL_VALUE_INT_ALL_DAY_EVENT},
+    //{CALENDAR_FILTER_ATTRIBUTE_DURATION,                        CAL_VALUE_GMT_END_DATE_TIME}, // needs end date calculation
+    //{"attendees",                       CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME}, // object array interface
+    {CALENDAR_FILTER_ATTRIBUTE_END_DATE,                       CAL_VALUE_GMT_END_DATE_TIME},
+    {CALENDAR_FILTER_ATTRIBUTE_AVAILABILITY,                    CAL_VALUE_INT_AVAILABILITY},
+    //{"recurrenceRule",                  CAL_VALUE_INT_REPEAT_TERM} // object interface
+};
+
+CalendarFilter::CalendarFilter()
 {
        LogDebug("entered");
-       init();
+       m_query.clear();
+       m_query.append(" WHERE");
 }
 
 CalendarFilter::~CalendarFilter()
@@ -39,65 +73,119 @@ CalendarFilter::~CalendarFilter()
 void CalendarFilter::visitPreComposite(TizenApis::Api::Tizen::FilterType& type, int depth)
 {
        LogDebug("entered");
-       m_query = m_query + " (";
+       m_query.append(" (");
 }
 
 void CalendarFilter::visitInComposite(TizenApis::Api::Tizen::FilterType& type, int depth)
 {
        LogDebug("entered");
        if(type == TizenApis::Api::Tizen::UNION_FILTER)
-               m_query = m_query + " OR ";
+               m_query.append(" OR ");
        else if(type == TizenApis::Api::Tizen::INTERSECTION_FILTER)
-               m_query = m_query + " AND ";
+               m_query.append(" AND ");
 }
 
 void CalendarFilter::visitPostComposite(TizenApis::Api::Tizen::FilterType& type, int depth)
 {
        LogDebug("entered");
-       m_query = m_query + " )";
+       m_query.append(" )");
 }
 
 void CalendarFilter::visitAttribute(std::string& attrName, TizenApis::Api::Tizen::AnyArrayPtr& matchValues, std::string& matchFlag, bool caseSensitive, int depth)
 {
-       LogDebug("attrName [" << attrName << "] value length[" << matchValues->size() << "] matchFlag [" << matchFlag << "] caseSensitive [" <<caseSensitive<< "] depth[" << depth << "]");
-       std::string str;
-
-       str.append(convertAttribute(attrName, matchValues));
-
-       m_query = m_query + str;
+       LogDebug("attrName: "<<attrName<<", value length: "<<matchValues->size()<<", matchFlag: "<<matchFlag<<", caseSensitive: "<<caseSensitive<< ", depth:"<<depth);
+
+       std::string conditionQuery;
+       std::string matchString;
+    std::string valueString;
+
+    conditionQuery.append("(");
+    TizenApis::Api::Tizen::AnyArray::iterator iter;
+    for(iter = matchValues->begin(); iter != matchValues->end(); iter++)
+    {
+        TizenApis::Api::Tizen::AnyPtr matchValue = *iter;
+        if(iter != matchValues->begin())
+            conditionQuery.append("OR");
+
+        if(matchValue->getType() == TizenApis::Api::Tizen::PrimitiveType_Time)
+        {
+            tm date = DPL::DynamicPointerCast< TizenApis::Api::Tizen::Any_T<tm> >(matchValue)->getValue();
+            std::stringstream time;
+            time << mktime(&date);
+            valueString = time.str();
+        }
+        else
+        {
+            valueString = matchValue->toString();
+        }
+
+        if(attrName=="visibility" || attrName=="status" || attrName=="priority" || attrName=="availability") {
+            valueString = convertStringToValue(attrName, valueString);
+        }
+
+        if( matchFlag=="EXACTLY" ) {
+            matchString = " like \'" + valueString + "\'";
+        } else if( matchFlag=="CONTAINS") {
+            matchString = " like \'%" + valueString + "%\'";
+        } else if( matchFlag=="STARTSWITH") {
+            matchString = " like \'%" + valueString + "\'";
+        } else if( matchFlag=="ENDSWITH") {
+            matchString = " like \'" + valueString + "%\'";
+        }else if( matchFlag=="EXISTS") {
+            matchString = " is not null";
+        } else {
+            LogError("Invalid matchFlag!");
+            matchString = " is not null";
+        }
+
+        // If the attrName is not directly mapped, branch here.
+        conditionQuery.append(" (" + m_attributeMap[attrName] + matchString + ") ");
+    }
+    conditionQuery.append(")");
+
+       LogInfo("Generated condition query: [" << conditionQuery << "]");
+
+       m_query.append(conditionQuery);
 }
 
 void CalendarFilter::visitAttributeRange(std::string& attrName, TizenApis::Api::Tizen::AnyPtr& initialValue, TizenApis::Api::Tizen::AnyPtr& endValue, int depth)
 {
-       std::string str;
-       str = " " + attrName + ">" + initialValue->toString() + " AND " + attrName + "<" + endValue->toString()+ " ";
-       m_query = m_query + str;
-}
-
-void CalendarFilter::visitID(TizenApis::Api::Tizen::AnyArrayPtr &value, int depth)
-{
-
-}
-
-void CalendarFilter::init()
-{
-       LogDebug("entered");
-       m_query.clear();
-       m_query.append(" WHERE");
-}
-
-std::string CalendarFilter::convertAttribute(std::string &name, TizenApis::Api::Tizen::AnyArrayPtr& matchValues)
-{
-       std::string query("");
-
-       if (name.compare("id") == 0) {
-               query = " (" + name + "= " + matchValues->at(0)->toString() + ")";
-       } else if (name.compare("summary") == 0) {
-               query = " (" + name + "= " + matchValues->at(0)->toString() + ")";
+    LogDebug("attrName: " <<attrName<<", initialValue: "<<initialValue->toString()<<", endValue: " <<endValue->toString()<<", depth: "<<depth);
+       std::string conditionQuery;
+    std::string initialValueStr;
+    std::string endValueStr;
+
+       if (initialValue != NULL) {
+        if( TizenApis::Api::Tizen::PrimitiveType_Time==initialValue->getType() ) {
+            tm date = DPL::DynamicPointerCast< TizenApis::Api::Tizen::Any_T<tm> >(initialValue)->getValue();
+            std::stringstream time;
+            time << mktime(&date);
+            initialValueStr = time.str();
+        } else {
+            initialValueStr = initialValue->toString();
+        }
        }
 
-       LogDebug("query-filter :[" << query << "]");
-       return query;
+       if (endValue != NULL) {
+        if( TizenApis::Api::Tizen::PrimitiveType_Time==endValue->getType() ) {
+            tm date = DPL::DynamicPointerCast< TizenApis::Api::Tizen::Any_T<tm> >(endValue)->getValue();
+            std::stringstream time;
+            time << mktime(&date);
+            endValueStr = time.str();
+        } else {
+            endValueStr = endValue->toString();
+        }
+    }
+
+    if (initialValue!=NULL && endValue==NULL ) {
+        conditionQuery = " " + m_attributeMap[attrName] + ">" + initialValueStr + " ";
+    } else if (initialValue==NULL && endValue!=NULL ) {
+        conditionQuery = " " + m_attributeMap[attrName] + "<" + endValueStr + " ";
+    } else if (initialValue!=NULL && endValue!=NULL ) {
+        conditionQuery = " " + m_attributeMap[attrName] + ">" + initialValueStr + " AND " + m_attributeMap[attrName] + "<" + endValueStr + " ";
+    }
+
+       m_query.append(conditionQuery);
 }
 
 std::string CalendarFilter::getResult() const
@@ -106,23 +194,21 @@ std::string CalendarFilter::getResult() const
        return m_query;
 }
 
-bool CalendarFilter::convertCalendar(calendar_query_s *query_log, CalendarEventListPtr calendarListPtr)
+bool CalendarFilter::convertToCalendar(calendar_query_s *queryData, CalendarEventListPtr calendarListPtr)
 {
-       LogDebug("entered");
-
-       if (query_log == NULL)
-               return false;
+    LogDebug("entered");
 
-       CalendarEventPtr calendarEvent(new CalendarEvent());
+    if (queryData == NULL)
+       return false;
 
-    // convert query results to the event struct.
+    CalendarEventPtr calendarEvent(new CalendarEvent());
 
-       calendarEvent->setId(query_log->rowid);
-       calendarEvent->setSubject(query_log->summary);
+    // Convert query results to the event struct.
+    calendarEvent->setId(queryData->id);
 
-       calendarListPtr->push_back(calendarEvent);
+    calendarListPtr->push_back(calendarEvent);
 
-       return true;
+    return true;
 }
 
 bool CalendarFilter::executeQuery(std::string &query, CalendarEventListPtr calendarListPtr)
@@ -135,16 +221,18 @@ bool CalendarFilter::executeQuery(std::string &query, CalendarEventListPtr calen
        int ret = 0;
 
        hstmt = _query_prepare((char *)(query.c_str()));
+    if( NULL==hstmt) {
+        ThrowMsg(PlatformException, "Can't prepare query!");
+    }
 
        do {
                ret = _query_step(hstmt);
                LogDebug("Query result : [" << ret << "]");
-               if (ret == SQLITE_ROW) {
-                       query_data.rowid = _query_column_int(hstmt, 0);
-                       query_data.summary = _query_column_text(hstmt, 1);
+               if (ret == SQLITE_ROW) { // 100
+                       query_data.id = _query_column_int(hstmt, 0);
 
-                       convertCalendar(&query_data, calendarListPtr);
-               } else if (ret == SQLITE_DONE) {
+                       convertToCalendar(&query_data, calendarListPtr);
+               } else if (ret == SQLITE_DONE) { // 101
                        LogDebug("Query done [" << ret << "]");
                        break;
                } else { //if (ret == SQLITE_DONE || ret == SQLITE_IOERR || ret == SQLITE_BUSY || ret == SQLITE_ERROR || ret == SQLITE_MISUSE)
@@ -154,6 +242,7 @@ bool CalendarFilter::executeQuery(std::string &query, CalendarEventListPtr calen
        } while (1);
 
        _query_finalize(hstmt);
+
        return true;
 }
 
@@ -176,7 +265,7 @@ std::string CalendarFilter::makeQuerySortMode(TizenApis::Api::Tizen::SortModeArr
                        }
                        query.append(attriName);
 
-                       if ((*it)->getOrder() ==        TizenApis::Api::Tizen::ASCENDING_SORT_ORDER) {
+                       if ((*it)->getOrder()==TizenApis::Api::Tizen::ASCENDING_SORT_ORDER) {
                                query.append(" ASC");
                        } else {
                                query.append(" DESC");
@@ -188,6 +277,104 @@ std::string CalendarFilter::makeQuerySortMode(TizenApis::Api::Tizen::SortModeArr
        return query;
 }
 
+std::string CalendarFilter::convertStringToValue(const std::string attrName, const std::string valueString)
+{
+       LogDebug("entered");
+
+    std::stringstream ss;
+
+    if(attrName=="visibility")
+    {
+        if(valueString=="PUBLIC") {
+            ss<<PUBLIC_VISIBILITY;
+            return ss.str();
+        } else if(valueString=="PRIVATE") {
+            ss<<PRIVATE_VISIBILITY;
+            return ss.str();
+        } else if(valueString=="CONFIDENTIAL") {
+            ss<<CONFIDENTIAL_VISIBILITY;
+            return ss.str();
+        } else {
+            return valueString;
+        }
+    }
+    else if(attrName=="status")
+    {
+        if(valueString=="TENTATIVE") {
+            ss<<CALS_EVENT_STATUS_TENTATIVE;
+            return ss.str();
+        } else if(valueString=="CONFIRMED") {
+            ss<<CALS_EVENT_STATUS_CONFIRMED;
+            return ss.str();
+        } else if(valueString=="CANCELLED") {
+            ss<<CALS_EVENT_STATUS_CANCELLED;
+            return ss.str();
+        } else if(valueString=="NEEDS_ACTION") {
+            ss<<CALS_TODO_STATUS_NEEDS_ACTION;
+            return ss.str();
+        } else if(valueString=="IN_PROCESS") {
+            ss<<CALS_TODO_STATUS_IN_PROCESS;
+
+        } else if(valueString=="COMPLETED") {
+            ss<<CALS_TODO_STATUS_COMPLETED;
+            return ss.str();
+        } else {
+            return valueString;
+        }
+    }
+    else if(attrName=="priority")
+    {
+        if(valueString=="HIGH") {
+            ss<<EVENT_PRIORITY_HIGH;
+            return ss.str();
+        } else if(valueString=="MEDIUM") {
+            ss<<EVENT_PRIORITY_NORMAL;
+            return ss.str();
+        } else if(valueString=="LOW") {
+            ss<<EVENT_PRIORITY_LOW;
+            return ss.str();
+        } else {
+            return valueString;
+        }
+    }
+    else if(attrName=="availability")
+    {
+        if(valueString=="BUSY") {
+            ss<<EVENT_BUSY_FB;
+            return ss.str();
+        } else if(valueString=="FREE") {
+            ss<<EVENT_FREE_FB;
+            return ss.str();
+        } else {
+            return valueString;
+        }
+    }
+    else
+    {
+        LogWarning("Invalid attrName");
+    }
+
+    return valueString;
+}
+
+std::string CalendarFilter::concatenateFilterAttributes()
+{
+       LogDebug("entered");
+
+    std::string attributes;
+    std::map<std::string, std::string>::iterator iter;
+    unsigned int i = 0;
+    for( iter=m_attributeMap.begin(); iter!=m_attributeMap.end(); iter++) {
+        attributes.append((*iter).second);
+        if( i+1<m_attributeMap.size() ) {
+            attributes.append(", ");
+        }
+        i++;
+    }
+
+    return attributes;
+}
+
 }
 }
 }
index 4b22f1b..e03fd33 100755 (executable)
@@ -24,6 +24,7 @@
 #include <API/Filter/SortMode.h>
 #include "API/Calendar/CalendarEvent.h"
 #include "CalendarQuery.h"
+#include <calendar-svc-provider.h>
 
 using namespace TizenApis::Api::Calendar;
 
@@ -31,10 +32,37 @@ namespace TizenApis {
 namespace Platform {
 namespace Calendar {
 
+// List of attributes that can be used as the filter argument.
+#define CALENDAR_FILTER_ATTRIBUTE_ID_UID "id.uid"
+#define CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE "lastModificationDate"
+#define CALENDAR_FILTER_ATTRIBUTE_DESCRIPTION "description"
+#define CALENDAR_FILTER_ATTRIBUTE_SUMMARY "summary"
+#define CALENDAR_FILTER_ATTRIBUTE_IS_ALL_DAY "isAllDay"
+#define CALENDAR_FILTER_ATTRIBUTE_START_DATE "startDate"
+//#define CALENDAR_FILTER_ATTRIBUTE_DURATION "duration"
+#define CALENDAR_FILTER_ATTRIBUTE_LOCATION "location"
+#define CALENDAR_FILTER_ATTRIBUTE_LATITUDE "geolocation.latitude"
+#define CALENDAR_FILTER_ATTRIBUTE_LONGITUDE "geolocation.longitude"
+#define CALENDAR_FILTER_ATTRIBUTE_ORGANIZER "organizer"
+#define CALENDAR_FILTER_ATTRIBUTE_VISIBILITY "visibility"
+#define CALENDAR_FILTER_ATTRIBUTE_STATUS "status"
+#define CALENDAR_FILTER_ATTRIBUTE_PRIORITY "priority"
+//#define CALENDAR_FILTER_ATTRIBUTE_ALARMS "alarms"
+#define CALENDAR_FILTER_ATTRIBUTE_CATEGORIES "categories"
+//#define CALENDAR_FILTER_ATTRIBUTE_ATTENDEES "attendees"
+#define CALENDAR_FILTER_ATTRIBUTE_DUE_DATE "dueDate"
+//#define CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE "completedDate"
+#define CALENDAR_FILTER_ATTRIBUTE_PROGRESS "progress"
+//#define CALENDAR_FILTER_ATTRIBUTE_IS_DETACHED "isDetached"
+#define CALENDAR_FILTER_ATTRIBUTE_END_DATE "endDate"
+#define CALENDAR_FILTER_ATTRIBUTE_AVAILABILITY "availability"
+//#define CALENDAR_FILTER_ATTRIBUTE_RECURRENCE_RULE "recurrenceRule"
+
 class CalendarFilter: public TizenApis::Api::Tizen::IFilterVisitor
 {
 private:
        std::string m_query;
+       static std::map<std::string, std::string> m_attributeMap;
 
 public:
        CalendarFilter();
@@ -57,18 +85,16 @@ public:
                        TizenApis::Api::Tizen::AnyPtr& endValue,
                        int depth);
 
-       virtual void visitID(TizenApis::Api::Tizen::AnyArrayPtr &value, int depth);
-
-       void init();
        std::string getResult() const;
-       std::string convertAttribute(std::string &name, TizenApis::Api::Tizen::AnyArrayPtr& matchValues);
-
-       bool convertCalendar(calendar_query_s *query_log, CalendarEventListPtr calendarListPtr);
 
        bool executeQuery(std::string &query, CalendarEventListPtr calendarListPtr);
 
        std::string makeQuerySortMode(TizenApis::Api::Tizen::SortModeArrayPtr attr);
 
+private:
+       bool convertToCalendar(calendar_query_s *query_log, CalendarEventListPtr calendarListPtr);
+       std::string convertStringToValue(const std::string attrName, const std::string valueString);
+       std::string concatenateFilterAttributes();
 };
 
 typedef DPL::SharedPtr<CalendarFilter> CalendarFilterPtr;
diff --git a/src/platform/Tizen/Calendar/CalendarFilterValidator.cpp b/src/platform/Tizen/Calendar/CalendarFilterValidator.cpp
new file mode 100755 (executable)
index 0000000..2be178c
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "CalendarFilterValidator.h"
+#include "CalendarFilter.h"
+
+namespace TizenApis {
+namespace Platform {
+namespace Calendar {
+
+using namespace TizenApis::Api::Tizen;
+
+static PropertyStructArray properties =
+{
+    {CALENDAR_FILTER_ATTRIBUTE_ID_UID,              PrimitiveType_String},
+    {CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE,  PrimitiveType_Time},
+    {CALENDAR_FILTER_ATTRIBUTE_DESCRIPTION,         PrimitiveType_String},
+    {CALENDAR_FILTER_ATTRIBUTE_SUMMARY,             PrimitiveType_String},
+    {CALENDAR_FILTER_ATTRIBUTE_START_DATE,          PrimitiveType_Time},
+    {CALENDAR_FILTER_ATTRIBUTE_LOCATION,            PrimitiveType_String},
+    {CALENDAR_FILTER_ATTRIBUTE_LATITUDE,            PrimitiveType_Double},
+    {CALENDAR_FILTER_ATTRIBUTE_LONGITUDE,           PrimitiveType_Double},
+    {CALENDAR_FILTER_ATTRIBUTE_ORGANIZER,           PrimitiveType_String},
+    {CALENDAR_FILTER_ATTRIBUTE_VISIBILITY,          PrimitiveType_String},
+    {CALENDAR_FILTER_ATTRIBUTE_STATUS,              PrimitiveType_String},
+    {CALENDAR_FILTER_ATTRIBUTE_CATEGORIES,          PrimitiveType_String},
+    {CALENDAR_FILTER_ATTRIBUTE_PRIORITY,            PrimitiveType_String},
+    {CALENDAR_FILTER_ATTRIBUTE_DUE_DATE,            PrimitiveType_Time},
+    {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
+};
+
+FilterValidatorPtr CalendarFilterValidatorFactory::getCalendarFilterValidator()
+{
+    static FilterValidatorPtr theInstance =
+               FilterValidatorPtr(new FilterValidator(properties, matchFlag));
+    return theInstance;
+}
+
+} // Calendar
+} // Platform
+} // TizenApis
diff --git a/src/platform/Tizen/Calendar/CalendarFilterValidator.h b/src/platform/Tizen/Calendar/CalendarFilterValidator.h
new file mode 100755 (executable)
index 0000000..a7905d2
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef _PLATFORM_CALENDAR_FILTER_VALIDATOR_H_
+#define _PLATFORM_CALENDAR_FILTER_VALIDATOR_H_
+
+#include <API/Filter/FilterValidator.h>
+
+namespace TizenApis {
+namespace Platform {
+namespace Calendar {
+
+class CalendarFilterValidatorFactory : private DPL::Noncopyable
+{
+private:
+       CalendarFilterValidatorFactory()
+       {
+       }
+
+public:
+       static TizenApis::Api::Tizen::FilterValidatorPtr        getCalendarFilterValidator();
+};
+
+} // Calendar
+} // Platform
+} // TizenApis
+
+#endif // _PLATFORM_CALENDAR_FILTER_VALIDATOR_H_
\ No newline at end of file
index d703fea..9592542 100755 (executable)
 
 
 #include "CalendarManager.h"
-#include <algorithm>
-#include <dpl/log.h>
-#include <calendar-svc-provider.h>
-#include <calendar-svc-errors.h>
-#include <CommonsJavaScript/Converter.h>
 #include <vector>
-
-namespace {
-const char* SERVICE_PROVIDER_NAME = "phone";
-}
+#include <dpl/log/log.h>
+#include <calendar-svc-provider.h>
 
 using namespace TizenApis::Api::Calendar;
 using namespace WrtDeviceApis::Commons;
@@ -67,20 +60,16 @@ CalendarManager::~CalendarManager()
     }
 }
 
-const char *CalendarManager::getServiceProviderName()
-{
-    return SERVICE_PROVIDER_NAME;
-}
-
 void CalendarManager::OnRequestReceived(const IEventGetCalendarsPtr &event)
 {
+    LogDebug("entered");
     static std::vector<ICalendarPtr> calendars;
     Try
     {
         if (calendars.empty()) {
             cal_iter *iter = NULL;
             if (CAL_SUCCESS !=
-                calendar_svc_get_all(ALL_ACCOUNT_ID, 0, CAL_STRUCT_CALENDAR,
+                calendar_svc_get_all(ALL_ACCOUNT_ID, ALL_CALENDAR_ID, CAL_STRUCT_CALENDAR,
                                      &iter)) {
                 event->setResult(false);
                 return;
@@ -95,13 +84,13 @@ void CalendarManager::OnRequestReceived(const IEventGetCalendarsPtr &event)
                     const char* name = calendar_svc_struct_get_str(
                             calendar,
                             CAL_TABLE_TXT_NAME);
-                    const char* id = calendar_svc_struct_get_str(
+                    const int id = calendar_svc_struct_get_int(
                             calendar,
-                            CAL_TABLE_TXT_CALENDAR_ID);
+                            CAL_TABLE_INT_INDEX);
                     const int accountId = calendar_svc_struct_get_int(
                             calendar,
                             CAL_TABLE_INT_ACCOUNT_ID);
-                    if (name != NULL && id != NULL) {
+                    if (name != NULL) {
                         LogDebug(
                             "Got calendar, id: " << id << ", name: " << name <<
                             ", account id: " << accountId);
@@ -141,12 +130,14 @@ void CalendarManager::OnRequestReceived(const IEventGetCalendarsPtr &event)
 
 void CalendarManager::OnRequestReceived(const IEventGetDefaultCalendarPtr &event)
 {
+    LogDebug("entered");
     ICalendarPtr newCalendar(new Calendar());
     Try
     {
         cal_iter *iter = NULL;
+        // Default calendar means the first of local calendars.
         if (CAL_SUCCESS !=
-            calendar_svc_get_all(ALL_ACCOUNT_ID, DEFAULT_CALENDAR_ID, CAL_STRUCT_CALENDAR,
+            calendar_svc_get_all(LOCAL_ACCOUNT_ID, DEFAULT_CALENDAR_ID, CAL_STRUCT_CALENDAR,
                                  &iter)) {
             event->setResult(false);
             return;
@@ -161,13 +152,13 @@ void CalendarManager::OnRequestReceived(const IEventGetDefaultCalendarPtr &event
                 const char* name = calendar_svc_struct_get_str(
                         calendar,
                         CAL_TABLE_TXT_NAME);
-                const char* id = calendar_svc_struct_get_str(
+                const int id = calendar_svc_struct_get_int(
                         calendar,
-                        CAL_TABLE_TXT_CALENDAR_ID);
+                        CAL_TABLE_INT_INDEX);
                 const int accountId = calendar_svc_struct_get_int(
                         calendar,
                         CAL_TABLE_INT_ACCOUNT_ID);
-                if (name != NULL && id != NULL) {
+                if (name != NULL) {
                     LogDebug(
                     "Got default calendar, id: " << id << ", name: " << name <<
                     ", account id: " << accountId);
index 6c1f6da..03a7bfc 100755 (executable)
 #ifndef _CALENDARMANAGER_H_
 #define _CALENDARMANAGER_H_
 
-#include <vector>
-#include <list>
-#include <dpl/mutex.h>
 #include <API/Calendar/ICalendarManager.h>
 #include "Calendar.h"
+#include <dpl/mutex.h>
 
 namespace TizenApis {
 namespace Platform {
@@ -33,7 +31,7 @@ class CalendarManager : public Api::Calendar::ICalendarManager
   public:
     CalendarManager();
     virtual ~CalendarManager();
-    static const char*           getServiceProviderName();
+
   protected:
     virtual void OnRequestReceived(const IEventGetCalendarsPtr &event);
     virtual void OnRequestReceived(const IEventGetDefaultCalendarPtr &event);
index d6fda66..4c5e8af 100755 (executable)
@@ -79,19 +79,6 @@ int _query_step(stmt pStmt)
        return sqlite3_step(pStmt);
 }
 
-void _contact_query_finalize(stmt pStmt)
-{
-       int rc = -1;
-
-       if(!pStmt)
-         return;
-
-       rc = sqlite3_finalize(pStmt);
-       if(rc != SQLITE_OK)
-       {
-       }
-}
-
 int _calendar_query_column_int(stmt pStmt, int pos)
 {
        return (int)sqlite3_column_int(pStmt, pos);
@@ -163,7 +150,7 @@ stmt _query_prepare(char *query)
        int rc = -1;
        stmt pStmt = NULL;
 
-       printf("\nquery : %s !!!!\n", query);
+       printf("\nquery : %s !!!!\n\n", query);
 
        rc = sqlite3_prepare_v2(hDBCt, query, strlen(query), &pStmt, NULL);
 
index 7c6453d..36777a1 100755 (executable)
@@ -19,7 +19,6 @@
 #define _CALENDAR_QUERY_H_
 
 #include <db-util.h>
-//#include <calendar-svc-provider.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -32,8 +31,7 @@ typedef sqlite3_stmt* stmt;
 // Query results struct
 typedef struct
 {
-    int                rowid;         /**< Calendar id in database */
-    char*      summary;
+    int                id;         /**< Calendar id in database */
 } calendar_query_s;
 
 typedef enum
index 189d383..ae17a04 100755 (executable)
@@ -19,7 +19,7 @@
 #include <string.h>
 #include <algorithm>
 #include <pcrecpp.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/Exception.h>
 #include "EventWrapper.h"
 #include "Calendar.h"
@@ -84,6 +84,33 @@ int EventWrapper::getIDFromPlatformEvent() const
     return calendar_svc_struct_get_int(m_platformEvent, CAL_VALUE_INT_INDEX);
 }
 
+void EventWrapper::setCalendarId(const std::string &value)
+{
+    LogInfo("calendar id "<<value);
+    m_calendarId = value;
+    std::istringstream stream(m_calendarId);
+    int calendarId = -1;
+    stream>>calendarId;
+    if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
+                                                   CAL_VALUE_INT_CALENDAR_ID,
+                                                   calendarId))
+    {
+        ThrowMsg(PlatformException, "Can't set calendar id.");
+    }
+}
+
+void EventWrapper::setCalendarAccountId(const int value)
+{
+    LogInfo("account id "<<value);
+    m_calendarAccountId = value;
+    if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
+                                                   CAL_VALUE_INT_ACCOUNT_ID,
+                                                   m_calendarAccountId))
+    {
+        ThrowMsg(PlatformException, "Can't set calendar account id.");
+    }
+}
+
 void EventWrapper::saveEvent()
 {
     LogDebug("entered");
@@ -97,7 +124,7 @@ void EventWrapper::saveEvent()
     displayPlatformEvent();
 
     //insert new record or update existing one
-    if (eventID < 0) { //insert new event
+    if (eventID < 0) {
         int returnValue = calendar_svc_insert(m_platformEvent);
         if (CAL_SUCCESS > returnValue) {
             LogError("Can't insert new event, error code: " << returnValue);
@@ -110,7 +137,7 @@ void EventWrapper::saveEvent()
         ss<<returnValue;
         m_abstractEvent->setUId(ss.str());
         LogInfo("New calendar event inserted with id "<<returnValue);
-    } else { //update
+    } else {
         int errorCode = calendar_svc_update(m_platformEvent);
         if (CAL_SUCCESS != errorCode) {
             ThrowMsg(PlatformException, "Can't update new event with error code: "<<errorCode);
@@ -149,6 +176,7 @@ void EventWrapper::loadEvent(int id)
     }
 
     convertPlatformEventToAbstractEvent();
+    m_abstractEvent->setCalendarType(m_calendarType);
     displayAbstractEvent();
 }
 
@@ -1201,13 +1229,13 @@ void EventWrapper::setPositionToPlatformEvent()
 
     if (CAL_SUCCESS != calendar_svc_struct_set_double(m_platformEvent,
                                                    CAL_VALUE_DBL_LATITUDE,
-                                                   m_abstractEvent->getLatitude())) {
+                                                   m_abstractEvent->getGeolocation()->getLatitude())) {
         ThrowMsg(PlatformException, "Can't set latitude.");
     }
 
     if (CAL_SUCCESS != calendar_svc_struct_set_double(m_platformEvent,
                                                    CAL_VALUE_DBL_LONGITUDE,
-                                                   m_abstractEvent->getLongitude())) {
+                                                   m_abstractEvent->getGeolocation()->getLongitude())) {
         ThrowMsg(PlatformException, "Can't set longitude.");
     }
 }
@@ -1941,15 +1969,19 @@ void EventWrapper::setPositionFromPlatformEvent()
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
 
+    CalendarItemGeoPtr geoInfo(new CalendarItemGeo());
+
     double value = calendar_svc_struct_get_double(
             m_platformEvent,
             CAL_VALUE_DBL_LATITUDE);
-    m_abstractEvent->setLatitude(value);
+    geoInfo->setLatitude(value);
 
     value = calendar_svc_struct_get_double(
             m_platformEvent,
             CAL_VALUE_DBL_LONGITUDE);
-    m_abstractEvent->setLongitude(value);
+    geoInfo->setLongitude(value);
+
+    m_abstractEvent->setGeolocation(geoInfo);
 }
 
 void EventWrapper::setPriorityFromPlatformEvent()
index a3b7cd7..baaea6a 100755 (executable)
@@ -25,6 +25,7 @@
 #include <API/Calendar/EventFilter.h>
 #include <API/Calendar/EventAttendee.h>
 #include <API/Calendar/EventRecurrenceRule.h>
+#include <API/Calendar/CalendarItemGeo.h>
 
 namespace TizenApis {
 namespace Platform {
@@ -48,6 +49,9 @@ class EventWrapper
     void        createEventFromString(std::string value);
     std::string exportEventToString();    
 
+       void setCalendarId(const std::string &value);
+       void setCalendarAccountId(const int value);
+
   protected:
     int  getIDFromPlatformEvent() const;
     void setDescriptionToPlatformEvent();
@@ -105,6 +109,8 @@ class EventWrapper
     cal_struct             *m_platformEvent;
     Api::Calendar::CalendarEventPtr m_abstractEvent;
     Api::Calendar::CalendarEvent::CalendarType    m_calendarType;
+    std::string m_calendarId;
+    int m_calendarAccountId;
 };
 
 typedef DPL::SharedPtr<EventWrapper> EventWrapperPtr;
index 78e5686..459fde0 100755 (executable)
@@ -21,5 +21,6 @@ set(SRCS_PLATFORM_IMPLEMENTATION_CALENDAR
   ${CURRENT_PATH}/EventWrapper.cpp
   ${CURRENT_PATH}/CalendarFilter.cpp
   ${CURRENT_PATH}/CalendarQuery.c
+  ${CURRENT_PATH}/CalendarFilterValidator.cpp
   PARENT_SCOPE
 )
index d51efd1..b7065c7 100755 (executable)
@@ -23,7 +23,7 @@
 #include <cassert>
 #include <Commons/Exception.h>
 #include <dpl/shared_ptr.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <API/Filter/IFilter.h>
 #include <API/Filter/IFilterVisitor.h>
 #include <calllog.h>
index 49766e0..bc4ea2d 100755 (executable)
@@ -15,7 +15,7 @@
  */
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <iomanip>
 
 #include "CallHistoryFilter.h"
index 878275a..d34db95 100755 (executable)
@@ -27,7 +27,7 @@
 #include <fstream>
 #include <sstream>
 #include <pcrecpp.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/exception.h>
 #include <Commons/Exception.h>
 #include <Commons/Regex.h>
index bf323d0..b67d96a 100755 (executable)
@@ -21,7 +21,7 @@
  * @brief
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <contacts-svc.h>
 #include <API/Contact/ContactFactory.h>
 #include <API/Contact/IAddressBook.h>
index 7ed4fce..b9dfd65 100755 (executable)
@@ -24,7 +24,7 @@
 
 #include <vector>
 #include <pcrecpp.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/Exception.h>
 #include "ContactWrapper.h"
 #include "AddressBook.h"
index 0162eee..ef315e6 100755 (executable)
@@ -844,6 +844,9 @@ query_error _make_contact_info(advanced_handle_t* q_handle, projection_type type
                                }else if(strcmp(field_key[FIELD_UID], projection) == 0)
                                {
                                        count = _value_to_projection(q_handle->hstmt, &(q_handle->result_set[q_handle->pos].contact_info->raw_contact_info->uid), count);
+                               }else if(strcmp(field_key[FIELD_PHOTO_URI], projection) == 0)
+                               {
+                                       count = _value_to_projection(q_handle->hstmt, &(q_handle->result_set[q_handle->pos].contact_info->raw_contact_info->photo_uri), count);
                                }
                        }
                }
@@ -929,22 +932,14 @@ query_error _check_extra_contact_info(advanced_handle_t* q_handle, extra_info_ty
 
        if(type == EXTRA_INFO_TYPE_FIELD)
        {
-               if(attribute == CONTACT_PHOTO_URI)
-               {
-                       q_handle->extra_info = q_handle->extra_info | CONTACT_PHOTO;
-                       error_code = QUERY_SUCCESS;
-               }else if(attribute == CATEGORY_INFO)
+               if(attribute == CATEGORY_INFO)
                {
                        q_handle->extra_info = q_handle->extra_info | CATEGORIES;
                        error_code = QUERY_SUCCESS;
                }
        }else if(type == EXTRA_INFO_TYPE_CONDITION)
        {
-               if(attribute == CONTACT_PHOTO_URI)
-               {
-                       q_handle->condition_extra_info = q_handle->condition_extra_info | CONTACT_PHOTO;
-                       error_code = QUERY_SUCCESS;
-               }else if(attribute == CATEGORY_INFO)
+               if(attribute == CATEGORY_INFO)
                {
                        q_handle->condition_extra_info = q_handle->condition_extra_info | CATEGORIES;
                        error_code = QUERY_SUCCESS;
@@ -1953,7 +1948,6 @@ query_error _construct_optimize_query(advanced_handle_t* q_handle, GString* quer
                while(tmp_datatype_list)
                {
                        datatype_t* datatype_info = (datatype_t*)tmp_datatype_list->data;
-
                        if(is_first)
                        {
                                if(q_handle->use_normal_field_key->str[0] != '\0' && is_sub_query == false)
@@ -1976,7 +1970,7 @@ query_error _construct_optimize_query(advanced_handle_t* q_handle, GString* quer
                case ONLY_DATA:
                {
                        if(type == ONLY_CONTACT_ID_FIELD)
-                               g_string_append_printf(query, "select %s from %s", q_handle->query_string, table_key[TABLE_DATA]);
+                               g_string_append_printf(query, "select distinct(%s) from %s", q_handle->query_string, table_key[TABLE_DATA]);
                        else
                                g_string_append_printf(query, "select %s, %s from %s", field_key[FIELD_DATA_DATATYPE_ID], q_handle->query_string, table_key[TABLE_DATA]);
 
@@ -1992,7 +1986,7 @@ query_error _construct_optimize_query(advanced_handle_t* q_handle, GString* quer
                case ONLY_DATA_FROM_PERSON_QUERY:
                {
                        if(type == ONLY_CONTACT_ID_FIELD)
-                               g_string_append_printf(query, "select %s from %s", q_handle->query_string, table_key[TABLE_DATA]);
+                               g_string_append_printf(query, "select distinct(%s) from %s", q_handle->query_string, table_key[TABLE_DATA]);
                        else
                                g_string_append_printf(query, "select %s, %s from %s", field_key[FIELD_DATA_DATATYPE_ID], q_handle->query_string, table_key[TABLE_DATA]);
 
@@ -2333,6 +2327,7 @@ API query_error query_set_condition(ADVANCED_HANDLE handle, contact_attribute_e
        ADVANCED_RETURN_VAL((handle != NULL), {}, QUERY_HANDLE_NONE, ("HANDLE IS NULL"));
        ADVANCED_RETURN_VAL((attribute < ATTRIBUTE_MAX), {}, QUERY_INVALID_ATTRIBUTE, ("INVALID CONTACT ATTRIBUTE"));
        ADVANCED_RETURN_VAL((attr < CONDITION_MAX), {}, QUERY_INVALID_TYPE, ("INVALID CONTACT CONDITION"));
+       ADVANCED_RETURN_VAL((attribute != CONTACT_PHOTO_URI), {}, QUERY_INVALID_ATTRIBUTE, ("INVALID CONTACT ATTRIBUTE"));
 
        if(attr == EXISTS)
        {
@@ -2876,40 +2871,6 @@ CATCH:
        return value;
 }
 
-#define CTS_IMAGE_LOCATION "/opt/data/contacts-svc/img"
-void _get_contact_image(int img_type, char* contact_id, char** img_path)
-{
-       DIR *dp;
-       struct dirent *file_info;
-       char tmp_path[1024];
-       char dir[1024];
-       int index = 0;
-
-       index = atoi(contact_id);
-
-       snprintf(dir, sizeof(dir), "%s/%d", CTS_IMAGE_LOCATION, index);
-       snprintf(tmp_path, sizeof(tmp_path), "%d.", img_type);
-
-       dp = opendir(dir);
-       if(NULL == dp)
-               return;
-
-       *img_path = NULL;
-       while((file_info = readdir(dp)) != NULL)
-       {
-               if(0 == strncmp(tmp_path, file_info->d_name, strlen(tmp_path))) {
-                       snprintf(tmp_path, sizeof(tmp_path), "%s/%s", dir, file_info->d_name);
-                       *img_path = strdup(tmp_path);
-                       if(NULL == *img_path) {
-                               closedir(dp);
-                               return;
-                       }
-                       break;
-               }
-       }
-       closedir(dp);
-}
-
 char* _get_x_attribute_value(advanced_handle_t* q_handle, contact_x_attribute_e attribute, query_error* error_code)
 {
        char* value = NULL;
@@ -3018,14 +2979,7 @@ char* _get_attribute_value(advanced_handle_t* q_handle, contact_attribute_e attr
                        break;
                case CONTACT_PHOTO_URI:
                        ADVANCED_CATCH_SET_ERROR_POINTER((q_handle->result_set[q_handle->return_array_pos].contact_info->raw_contact_info != NULL), {}, QUERY_NO_RECORD, ("no data"));
-                       if((q_handle->extra_info & CONTACT_PHOTO) != 0)
-                       {
-                               OBJ_FREE(q_handle->result_set[q_handle->return_array_pos].contact_info->photo_uri);
-                               q_handle->result_set[q_handle->return_array_pos].contact_info->photo_uri = NULL;
-                               _get_contact_image(0, q_handle->result_set[q_handle->return_array_pos].contact_info->raw_contact_info->contact_id,
-                                       &(q_handle->result_set[q_handle->return_array_pos].contact_info->photo_uri));
-                               value = q_handle->result_set[q_handle->return_array_pos].contact_info->photo_uri;
-                       }
+                       value = q_handle->result_set[q_handle->return_array_pos].contact_info->raw_contact_info->photo_uri;
                        break;
                case CONTACT_LAST_UPDATED_TIME_STAMP:
                        ADVANCED_CATCH_SET_ERROR_POINTER((q_handle->result_set[q_handle->return_array_pos].contact_info->raw_contact_info != NULL), {}, QUERY_NO_RECORD, ("no data"));
index 34bbc21..1b6915a 100755 (executable)
@@ -443,8 +443,6 @@ typedef struct
        raw_contact_t* raw_contact_info;
        name_t* name_info;
 
-       char* photo_uri;
-
        GList* nickname_list;
        GList* number_list;
        GList* email_list;
@@ -537,8 +535,7 @@ typedef struct
 typedef enum
 {
        INVALID_FIELDS = 0x00000000,
-       CONTACT_PHOTO  = 0x00000001,
-       CATEGORIES = 0x00000002
+       CATEGORIES = 0x00000001
 }extra_contact_info;
 
 typedef sqlite3_stmt* stmt;
index add93d5..ca5fea4 100755 (executable)
@@ -381,9 +381,9 @@ char* _convert_person_attribute_to_condition_column_name(contact_attribute_e att
                case CONTACT_RINGTONE :
                        field_name = condition_field_key[FIELD_PERSON_RINGTONE];
                        break;
-//             case CONTACT_PHOTO_URI :
-//                     field_name = condition_field_key[FIELD_PERSON_PHOTO_URI];
-//                     break;
+               case CONTACT_PHOTO_URI :
+                       field_name = condition_field_key[FIELD_PERSON_PHOTO_URI];
+                       break;
 //             case CONTACT_SEND_TO_VOICE_MAIL :
 //                     field_name = condition_field_key[FIELD_PERSON_SEND_TO_VOICEMAIL];
 //                     break;
@@ -426,9 +426,9 @@ char* _convert_person_attribute_to_column_name(contact_attribute_e attribute)
                case CONTACT_RINGTONE :
                        field_name = field_key[FIELD_PERSON_RINGTONE];
                        break;
-//             case CONTACT_PHOTO_URI :
-//                     field_name = field_key[FIELD_PERSON_PHOTO_URI];
-//                     break;
+               case CONTACT_PHOTO_URI :
+                       field_name = field_key[FIELD_PERSON_PHOTO_URI];
+                       break;
 //             case CONTACT_SEND_TO_VOICE_MAIL :
 //                     field_name = field_key[FIELD_PERSON_SEND_TO_VOICEMAIL];
 //                     break;
@@ -510,9 +510,9 @@ char* _convert_attribute_to_condition_column_name(contact_attribute_e attribute)
                case CONTACT_IS_FAVORITE :
                        field_name = condition_field_key[FIELD_IS_FAVORITE];
                        break;
-//             case CONTACT_PHOTO_URI :
-//                     field_name = condition_field_key[FIELD_PHOTO_URI];
-//                     break;
+               case CONTACT_PHOTO_URI :
+                       field_name = condition_field_key[FIELD_PHOTO_URI];
+                       break;
                case CONTACT_LAST_UPDATED_TIME_STAMP :
                        field_name = condition_field_key[FIELD_CHANGED_TIME];
                        break;
@@ -655,7 +655,7 @@ primitive_type _convert_check_attribute_primitive_type(contact_attribute_e attri
                case CONTACT_UID :
                case CONTACT_RINGTONE :
                case CONTACT_NOTE :
-//             case CONTACT_PHOTO_URI :
+               case CONTACT_PHOTO_URI :
                case NAME_FIRST :
                case NAME_LAST:
                case NAME_MIDDLE:
@@ -760,9 +760,9 @@ char* _convert_attribute_to_column_name(contact_attribute_e attribute)
                case CONTACT_IS_FAVORITE :
                        field_name = field_key[FIELD_IS_FAVORITE];
                        break;
-//             case CONTACT_PHOTO_URI :
-//                     field_name = field_key[FIELD_PHOTO_URI];
-//                     break;
+               case CONTACT_PHOTO_URI :
+                       field_name = field_key[FIELD_PHOTO_URI];
+                       break;
                case CONTACT_LAST_UPDATED_TIME_STAMP :
                        field_name = field_key[FIELD_CHANGED_TIME];
                        break;
@@ -944,7 +944,7 @@ char* _convert_person_attribute_to_table_name(contact_attribute_e attribute)
        char* table_name = NULL;
        switch(attribute)
        {
-//             case CONTACT_PHOTO_URI:
+               case CONTACT_PHOTO_URI:
 //             case CONTACT_READ_ONLY:
 //             case CONTACT_SEND_TO_VOICE_MAIL:
                case CONTACT_LAST_UPDATED_TIME_STAMP:
@@ -975,7 +975,7 @@ char* _convert_attribute_to_table_name(contact_attribute_e attribute)
        char* table_name = NULL;
        switch(attribute)
        {
-//             case CONTACT_PHOTO_URI:
+               case CONTACT_PHOTO_URI:
 //             case CONTACT_READ_ONLY:
 //             case CONTACT_SEND_TO_VOICE_MAIL:
                case CONTACT_LAST_UPDATED_TIME_STAMP:
@@ -1670,7 +1670,6 @@ void _free_handle_info(advanced_handle_t* handle)
                _free_anniversary_info(handle->result_set[i].contact_info->event_info);
                _free_x_info(handle->result_set[i].contact_info->x_info);
 
-               OBJ_FREE(handle->result_set[i].contact_info->photo_uri);
                OBJ_FREE(handle->result_set[i].contact_info);
        }
 
index c9848fc..871ab6f 100755 (executable)
@@ -78,6 +78,7 @@ typedef enum
        FIELD_CONTACT_ACCOUNT_ID,
        FIELD_CHANGED_TIME,
        FIELD_IS_FAVORITE,
+       FIELD_PHOTO_URI,
        FIELD_RINGTONE,
        FIELD_NOTE,
        FIELD_UID,
@@ -95,6 +96,7 @@ typedef enum
        FIELD_DATA8,
        FIELD_DATA9,
        FIELD_DATA10,
+       FIELD_DATA11,
        FIELD_PRESENCE_CONTACT_ID,
        FIELD_PRESENCE_STATE,
        FIELD_PRESENCE_MESSAGE,
@@ -126,6 +128,7 @@ static char* field_key[FIELD_MAX] =
        "contacts.addrbook_id",
        "contacts.changed_time",
        "contacts.is_favorite",
+       "contacts.image0",
        "contacts.ringtone",
        "contacts.note",
        "contacts.uid",
@@ -142,6 +145,7 @@ static char* field_key[FIELD_MAX] =
        "data.data8",
        "data.data9",
        "data.data10",
+       "data.data11",
        "presence.contact_id",
        "presence.state",
        "presence.message",
@@ -172,6 +176,7 @@ static char* condition_field_key[FIELD_MAX] =
        "addrbook_id",
        "changed_time",
        "is_favorite",
+       "image0",
        "ringtone",
        "note",
        "uid",
@@ -188,6 +193,7 @@ static char* condition_field_key[FIELD_MAX] =
        "data8",
        "data9",
        "data10",
+       "data11",
        "contact_id",
        "state",
        "message",
index 6f8e9f7..a32ad46 100755 (executable)
@@ -22,7 +22,7 @@
 #include <cassert>
 #include <algorithm>
 #include <Commons/Exception.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "Message.h"
 
 namespace TizenApis {
@@ -241,8 +241,8 @@ Connection::MessageDispatcher::MessageDispatcher(Connection* connection) :
     m_connection(connection)
 {
     assert(m_connection && "Connection cannot be NULL.");
-    DPL::ControllerEventHandler<AddDescriptorSyncEvent>::Touch();
-    DPL::ControllerEventHandler<RemoveDescriptorSyncEvent>::Touch();
+    DPL::Event::ControllerEventHandler<AddDescriptorSyncEvent>::Touch();
+    DPL::Event::ControllerEventHandler<RemoveDescriptorSyncEvent>::Touch();
 }
 
 Connection::MessageDispatcher::~MessageDispatcher()
@@ -256,7 +256,7 @@ void Connection::MessageDispatcher::addDescriptor(DPL::WaitableHandle handle,
     LogDebug("ENTER");
     DPL::WaitableEvent wait;
     AddDescriptorSyncEvent event(handle, mode, &wait);
-    DPL::ControllerEventHandler<AddDescriptorSyncEvent>::PostEvent(event);
+    DPL::Event::ControllerEventHandler<AddDescriptorSyncEvent>::PostEvent(event);
     DPL::WaitForSingleHandle(wait.GetHandle());
 }
 
@@ -266,7 +266,7 @@ void Connection::MessageDispatcher::removeDescriptor(DPL::WaitableHandle handle,
     LogDebug("ENTER");
     DPL::WaitableEvent wait;
     RemoveDescriptorSyncEvent event(handle, mode, &wait);
-    DPL::ControllerEventHandler<RemoveDescriptorSyncEvent>::PostEvent(event);
+    DPL::Event::ControllerEventHandler<RemoveDescriptorSyncEvent>::PostEvent(event);
     DPL::WaitForSingleHandle(wait.GetHandle());
 }
 
index 32883fc..4f09c2e 100755 (executable)
 #include <dbus/dbus.h>
 #include <dpl/shared_ptr.h>
 #include <dpl/generic_event.h>
-#include <dpl/event_support.h>
-#include <dpl/event_listener.h>
+#include <dpl/event/event_support.h>
+#include <dpl/event/event_listener.h>
 #include <dpl/waitable_event.h>
 #include <dpl/thread.h>
 #include <dpl/noncopyable.h>
-#include <dpl/controller.h>
+#include <dpl/event/controller.h>
 #include <dpl/type_list.h>
 #include <dpl/mutex.h>
 #include "MessageEvent.h"
 namespace TizenApis {
 namespace Platform {
 namespace DBus {
-class Connection : public DPL::EventSupport<MessageEvent>
+class Connection : public DPL::Event::EventSupport<MessageEvent>
 {
   public:
-    typedef DPL::EventListener<MessageEvent> EventListener;
+    typedef DPL::Event::EventListener<MessageEvent> EventListener;
 
   public:
     Connection();
@@ -66,7 +66,7 @@ class Connection : public DPL::EventSupport<MessageEvent>
                             DPL::WaitMode::Type,
                             DPL::WaitableEvent*)
 
-    class MessageDispatcher : public DPL::Controller<DPL::TypeListDecl<
+    class MessageDispatcher : public DPL::Event::Controller<DPL::TypeListDecl<
                                                          AddDescriptorSyncEvent,
                                                          RemoveDescriptorSyncEvent>
                                                          ::Type >,
diff --git a/src/platform/Tizen/Filesystem/Command.cpp b/src/platform/Tizen/Filesystem/Command.cpp
new file mode 100755 (executable)
index 0000000..7c5a1b4
--- /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. 
+ */
+
+
+#include "Command.h"
+#include <cstdlib>
+#include <Commons/Exception.h>
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+void Command::execute()
+{
+    int result = system(prepare().c_str());
+    if (-1 != result) {
+        if (0 != WIFEXITED(result)) {
+            if (0 != WEXITSTATUS(result)) {
+                ThrowMsg(Commons::PlatformException, "Command failed.");
+            }
+        } else {
+            ThrowMsg(Commons::PlatformException,
+                     "Command terminated abnormally.");
+        }
+    } else {
+        ThrowMsg(Commons::PlatformException, "Couldn't launch command.");
+    }
+}
+}
+}
+}
diff --git a/src/platform/Tizen/Filesystem/Command.h b/src/platform/Tizen/Filesystem/Command.h
new file mode 100755 (executable)
index 0000000..088a0fc
--- /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_FILESYSTEM_COMMAND_H_
+#define TIZENAPIS_FILESYSTEM_COMMAND_H_
+
+#include <string>
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+class Command
+{
+  public:
+    virtual ~Command()
+    {
+    }
+    void execute();
+
+  protected:
+    /**
+     * Returns command converted into string that has to be safe to be executed
+     * using system() function (@see man 3p system).
+     * @attention Underlying command has to be passed by absolute path.
+     *            E.g. use '/bin/cp' instead of just 'cp'.
+     * @attention Do not chain a few commands as one.
+     *            This is wrong: 'cmd1 && cmd2; cmd3'.
+     * @return Command string - please ensure that the command is safe to run.
+     */
+    virtual std::string prepare() = 0;
+};
+}
+}
+}
+
+#endif // TIZENAPIS_FILESYSTEM_COMMAND_H_
\ No newline at end of file
diff --git a/src/platform/Tizen/Filesystem/CopyCommand.cpp b/src/platform/Tizen/Filesystem/CopyCommand.cpp
new file mode 100755 (executable)
index 0000000..f97733e
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+
+#include "CopyCommand.h"
+#include <sstream>
+
+namespace {
+const char* COMMAND_NAME = "/bin/cp";
+const char* COMMAND_SWITCH_RECURSIVE = "-r";
+const char* COMMAND_SWITCH_FORCE = "-f";
+}
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+CopyCommand::CopyCommand(const Api::Filesystem::IPathPtr& src,
+        const Api::Filesystem::IPathPtr& dest) :
+    m_src(src),
+    m_dest(dest),
+    m_recursive(false),
+    m_force(false)
+{
+}
+
+void CopyCommand::setRecursive(bool recursive)
+{
+    m_recursive = recursive;
+}
+
+void CopyCommand::setForce(bool force)
+{
+    m_force = force;
+}
+
+std::string CopyCommand::prepare()
+{
+    std::ostringstream oss;
+    oss << COMMAND_NAME;
+
+    if (m_recursive) {
+        oss << " " << COMMAND_SWITCH_RECURSIVE;
+    }
+
+    if (m_force) {
+        oss << " " << COMMAND_SWITCH_FORCE;
+    }
+
+    oss << " \"" << m_src->getFullPath().c_str() << "\"";
+    oss << " \"" << m_dest->getFullPath().c_str() << "\"";
+
+    return oss.str();
+}
+}
+}
+}
diff --git a/src/platform/Tizen/Filesystem/CopyCommand.h b/src/platform/Tizen/Filesystem/CopyCommand.h
new file mode 100755 (executable)
index 0000000..de6527b
--- /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_FILESYSTEM_COPYCOMMAND_H_
+#define TIZENAPIS_FILESYSTEM_COPYCOMMAND_H_
+
+#include "Command.h"
+#include <API/Filesystem/IPath.h>
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+class CopyCommand : public Command
+{
+  public:
+    CopyCommand(const Api::Filesystem::IPathPtr& src,
+            const Api::Filesystem::IPathPtr& dest);
+    void setRecursive(bool recursive);
+    void setForce(bool force);
+
+  protected:
+    std::string prepare();
+
+  private:
+    Api::Filesystem::IPathPtr m_src;
+    Api::Filesystem::IPathPtr m_dest;
+    bool m_recursive;
+    bool m_force;
+};
+}
+}
+}
+
+#endif // TIZENAPIS_FILESYSTEM_COPYCOMMAND_H_
\ No newline at end of file
diff --git a/src/platform/Tizen/Filesystem/Manager.cpp b/src/platform/Tizen/Filesystem/Manager.cpp
new file mode 100755 (executable)
index 0000000..7103806
--- /dev/null
@@ -0,0 +1,733 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "Manager.h"
+
+#include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <pcrecpp.h>
+#include <ctime>
+#include <sstream>
+#include <dirent.h>
+#include <dpl/log/log.h>
+#include <dpl/scoped_ptr.h>
+
+#include <Commons/Exception.h>
+#include <Commons/Regex.h>
+#include <API/Filesystem/PathUtils.h>
+#include <API/Filesystem/StorageProperties.h>
+#include "Node.h"
+#include "System.h"
+#include "CopyCommand.h"
+#include "MoveCommand.h"
+#include "RemoveCommand.h"
+#include "Utils.h"
+
+using namespace TizenApis::Api::Filesystem;
+
+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/Videos";
+const char* PATH_VIDEOS = "/opt/media/Images and videos";
+}
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+Manager::Locations Manager::m_locations;
+Manager::RootList Manager::m_rootlist;
+Manager::SubRootList Manager::m_subrootlist;
+const std::size_t Manager::m_maxPathLength = 256;
+NodeList Manager::m_openedNodes;
+std::vector<Manager::WatcherPtr> Manager::m_watchers;
+
+bool Manager::fileExists(const std::string &file)
+{
+    errno = 0;
+    struct stat info;
+    memset(&info, 0, sizeof(struct stat));
+    int status = lstat(file.c_str(), &info);
+    if (status == 0) {
+        return true;
+    } else if (errno == ENOENT) {
+        return false;
+    }
+    ThrowMsg(Commons::PlatformException, "Cannot stat file.");
+}
+
+bool Manager::getSupportedDeviceCB(int storage, storage_type_e type, storage_state_e state, const char *path, void *user_data)
+{
+       std::vector<Api::Filesystem::StoragePropertiesPtr>* storageVector = (std::vector<Api::Filesystem::StoragePropertiesPtr>*)user_data;
+       Api::Filesystem::StoragePropertiesPtr storageItem(new StorageProperties());
+
+       int size = 12;
+       char buf[size];
+       std::string lable;
+       std::string fullpath(path);
+       if (type == STORAGE_TYPE_INTERNAL) {
+               snprintf(buf, size, "internal%d", storage);
+               lable.append(buf);
+       } else if (type == STORAGE_TYPE_EXTERNAL) {
+               snprintf(buf, size, "removable%d", storage);
+               lable.append(buf);
+       }
+
+       storageItem->setId(storage);
+       storageItem->setLabel(lable);
+       storageItem->setType((short)type);
+       storageItem->setState((short)state);
+       storageItem->setFullPath(fullpath);
+
+       storageVector->insert(storageVector->end(), storageItem);
+
+       return true;
+}
+
+void Manager::storageStateChangedCB(int storage, storage_state_e state, void *user_data)
+{
+       if (user_data != NULL) {
+               watcherList* m_watcherList = (watcherList *)user_data;
+               watcherList::iterator it = m_watcherList->begin();
+               for(; it!= m_watcherList->end(); ++it) {
+                       (*it)->StorageStateHasChanged(storage, state);
+               }
+       }
+}
+
+void Manager::addOpenedNode(const Api::Filesystem::INodePtr& node)
+{
+    NodeListIterator it = m_openedNodes.begin();
+    for (; it != m_openedNodes.end(); ++it) {
+        if (node.Get() == (*it).Get()) {
+            //node is added already
+            return;
+        }
+    }
+    m_openedNodes.push_back(node);
+}
+
+void Manager::removeOpenedNode(const Api::Filesystem::INodePtr& node)
+{
+    NodeListIterator it = m_openedNodes.begin();
+    for (; it != m_openedNodes.end(); ++it) {
+        if ((*it).Get() == node.Get()) {
+            m_openedNodes.erase(it);
+            break;
+        }
+    }
+}
+
+bool Manager::checkIfOpened(const Api::Filesystem::IPathPtr& path) const
+{
+    NodeListIterator it = m_openedNodes.begin();
+    for (; it != m_openedNodes.end(); ++it) {
+        if (*path == *(*it)->getPath()) {
+            return true;
+        }
+    }
+    return false;
+}
+
+Manager::Manager()
+{
+    static bool initialized = init();
+    (void) initialized;
+}
+
+Manager::~Manager()
+{
+}
+
+StorageList Manager::getStorageList() const
+{
+    return m_locations;
+}
+
+IPathPtr Manager::getBasePath() const
+{
+    Locations::const_iterator it = m_locations.find(m_subrootlist.find(LT_ROOT)->second);
+    if (it == m_locations.end()) {
+        ThrowMsg(Commons::PlatformException, "Base path not available.");
+    }
+    return it->second;
+}
+
+IPathPtr Manager::getLocationPath(LocationType type) const
+{
+    Locations::const_iterator it = m_locations.find(m_subrootlist.find(type)->second);
+    if (it != m_locations.end()) {
+        return it->second->clone();
+    }
+    return IPathPtr();
+}
+
+LocationPaths Manager::getLocationPaths() const
+{
+    LocationPaths result;
+    Locations::const_iterator it = m_locations.begin();
+    for (; it != m_locations.end(); ++it) {
+        result.push_back(it->second->clone());
+    }
+    return result;
+}
+
+LocationTypes Manager::getLocations() const
+{
+    LocationTypes result;
+    SubRootList::const_iterator it = m_subrootlist.begin();
+    for (; it != m_subrootlist.end(); ++it) {
+        result.push_back(it->first);
+    }
+    return result;
+}
+
+void Manager::getNode(const EventResolvePtr& event)
+{
+    EventRequestReceiver<EventResolve>::PostRequest(event);
+}
+
+void Manager::getStorage(const EventGetStoragePtr& event)
+{
+       EventRequestReceiver<EventGetStorage>::PostRequest(event);
+}
+
+void Manager::listStorages(const EventListStoragesPtr& event)
+{
+       EventRequestReceiver<EventListStorages>::PostRequest(event);
+}
+
+std::size_t Manager::getMaxPathLength() const
+{
+    return m_maxPathLength;
+}
+
+void Manager::copy(const EventCopyPtr& event)
+{
+    EventRequestReceiver<EventCopy>::PostRequest(event);
+}
+
+void Manager::move(const EventMovePtr& event)
+{
+    EventRequestReceiver<EventMove>::PostRequest(event);
+}
+
+void Manager::create(const EventCreatePtr& event)
+{
+    EventRequestReceiver<EventCreate>::PostRequest(event);
+}
+
+void Manager::remove(const EventRemovePtr& event)
+{
+    EventRequestReceiver<EventRemove>::PostRequest(event);
+}
+
+void Manager::find(const EventFindPtr& event)
+{
+    EventRequestReceiver<EventFind>::PostRequest(event);
+}
+
+void Manager::find(const Api::Filesystem::IPathPtr& path,
+        const Api::Filesystem::FiltersMap& filters,
+        NodeList& result,
+        const Api::Filesystem::EventFindPtr& event)
+{
+    Try {
+        DIR* dir = opendir(path->getFullPath().c_str());
+        if (!dir) {
+            return;
+        }
+
+        errno = 0;
+        struct dirent* entry = NULL;
+        while ((entry = readdir(dir))) {
+            if (event && event->checkCancelled()) {
+                break;
+            }
+            if (!strncmp(entry->d_name, ".",
+                         1) || !strncmp(entry->d_name, "..", 2)) {
+                continue;
+            }
+            IPathPtr childPath = *path + entry->d_name;
+            struct stat info;
+            memset(&info, 0, sizeof(struct stat));
+            if (lstat(childPath->getFullPath().c_str(), &info) == 0) {
+                if (matchFilters(entry->d_name, info, filters)) {
+                    result.push_back(Node::resolve(childPath));
+                }
+                if (S_ISDIR(info.st_mode)) {
+                    find(childPath, filters, result, event);
+                }
+            }
+        }
+
+        if (errno != 0) {
+            ThrowMsg(Commons::PlatformException,
+                     "Error while reading directory.");
+        }
+
+        if (closedir(dir) != 0) {
+            ThrowMsg(Commons::PlatformException,
+                     "Could not close platform node.");
+        }
+    }
+    Catch(WrtDeviceApis::Commons::Exception) {
+    }
+}
+
+bool Manager::access(const IPathPtr& path,
+        int accessType) const
+{
+    int amode = 0;
+    if (accessType & AT_EXISTS) { amode |= F_OK; }
+    if (accessType & AT_READ) { amode |= R_OK; }
+    if (accessType & AT_WRITE) { amode |= W_OK; }
+    if (accessType & AT_EXEC) { amode |= X_OK; }
+    return (::access(path->getFullPath().c_str(), amode) == 0);
+}
+
+long Manager::addStorageStateChangeListener(
+        const EventStorageStateChangedEmitterPtr& emitter)
+{
+       RootList::const_iterator it = m_rootlist.begin();
+       WatcherPtr watcher(new Watcher(emitter));
+       Manager::m_watchers.push_back(watcher);
+
+       for (; it != m_rootlist.end(); ++it) {
+               storage_set_state_changed_cb(it->second, Manager::storageStateChangedCB, (void *)(&m_watchers));
+       }
+
+       watcher->getCurrentStoargeStateForWatch();
+       return static_cast<long>(emitter->getId());
+}
+
+void Manager::removeStorageStateChangeListener(EventStorageStateChangedEmitter::IdType id)
+{
+       watcherList::iterator itWatcher = Manager::m_watchers.begin();
+
+       for (;itWatcher != Manager::m_watchers.end();) {
+               if (id == (*itWatcher)->getEmitter()->getId()) {
+                       itWatcher = Manager::m_watchers.erase(itWatcher);
+                       continue;
+               }
+               ++itWatcher;
+       }
+
+       if (Manager::m_watchers.size() == 0) {
+               RootList::const_iterator itRoot;
+               for (itRoot = m_rootlist.begin(); itRoot != m_rootlist.end(); ++itRoot) {
+                       storage_unset_state_changed_cb(itRoot->second);
+               }
+       }
+}
+
+bool Manager::matchFilters(const std::string& name,
+        const struct stat& info,
+        const Api::Filesystem::FiltersMap& filters)
+{
+    Api::Filesystem::FiltersMap::const_iterator it = filters.begin();
+    for (; it != filters.end(); ++it) {
+        if (it->first == FF_NAME) {
+            if (!pcrecpp::RE(it->second).PartialMatch(name)) { return false; }
+        } else if (it->first == FF_SIZE) {
+            std::size_t size;
+            std::stringstream ss(it->second);
+            ss >> size;
+            if (!ss ||
+                (size != static_cast<size_t>(info.st_size))) { return false; }
+        } else if (it->first == FF_CREATED) {
+            std::time_t created;
+            std::stringstream ss(it->second);
+            ss >> created;
+            if (!ss || (created != info.st_ctime)) { return false; }
+        } else if (it->first == FF_MODIFIED) {
+            std::time_t modified;
+            std::stringstream ss(it->second);
+            ss >> modified;
+            if (!ss || (modified != info.st_mtime)) { return false; }
+        }
+    }
+    return true;
+}
+
+void Manager::OnRequestReceived(const EventResolvePtr& event)
+{
+    try {
+        event->setResult(Node::resolve(event->getPath()));
+    }
+    catch (const Commons::PlatformException& ex) {
+        event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+    }
+}
+
+void Manager::OnRequestReceived(const EventGetStoragePtr& event)
+{
+       try {
+
+               Api::Filesystem::StoragePropertiesPtr storage(new StorageProperties());
+
+               RootList::const_iterator it = m_rootlist.find(event->getLabel());
+               if (it == m_rootlist.end()) {
+                       Locations::const_iterator itL = m_locations.find(event->getLabel());
+                       if (itL == m_locations.end()) {
+                               ThrowMsg(Commons::PlatformException, "Base path not available.");
+                       } else {
+                               storage->setId(0xff);
+                               storage->setLabel(event->getLabel());
+                               storage->setType(StorageProperties::TYPE_INTERNAL);
+                               storage->setState(StorageProperties::STATE_MOUNTED);
+                       }
+               } else {
+                       int id = it->second;
+
+                       storage_type_e currentType;
+                       storage_state_e currentState;
+
+                       storage_get_type(id, &currentType);
+                       storage_get_state(id, &currentState);
+
+                       storage->setId(id);
+                       storage->setLabel(event->getLabel());
+                       storage->setType((short)currentType);
+                       storage->setState((short)currentState);
+               }
+
+               event->setResult(storage);
+       } catch (const Commons::PlatformException& ex) {
+               event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+       }
+}
+
+void Manager::OnRequestReceived(const EventListStoragesPtr& event)
+{
+       try {
+               std::vector<Api::Filesystem::StoragePropertiesPtr> storageList;
+               storage_foreach_device_supported(Manager::getSupportedDeviceCB, &storageList);
+               addLocalStorage("downloads", storageList);
+               addLocalStorage("documents", storageList);
+               addLocalStorage("music", storageList);
+               addLocalStorage("images", storageList);
+               addLocalStorage("videos", storageList);
+               event->setResult(storageList);
+       } catch (const Commons::PlatformException& ex) {
+               event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+       }
+}
+
+void Manager::OnRequestReceived(const EventCopyPtr& event)
+{
+    Try {
+        INodePtr srcNode = Node::resolve(event->getSource());
+        if ((srcNode->getMode() & PERM_READ) == 0) {
+            ThrowMsg(Commons::SecurityException,
+                     "Not enough permissions to read source node.");
+        }
+
+        IPathPtr src = event->getSource();
+        IPathPtr dest = event->getDestination();
+        if (!dest->isAbsolute()) {
+            dest = src->getPath() + *dest;
+        }
+
+        if (src == dest) {
+            ThrowMsg(Commons::PlatformException,
+                     "Destination is same as source.");
+        }
+
+        INodePtr parent;
+        Try {
+            parent = Node::resolve(IPath::create(dest->getPath()));
+        }
+        Catch(Commons::PlatformException) {
+            ReThrowMsg(Commons::PlatformException,
+                       "Could not get destination's parent node.");
+        }
+
+        if (parent->getType() != NT_DIRECTORY) {
+            ThrowMsg(Commons::PlatformException,
+                     "Destination's parent node is not directory.");
+        }
+
+        std::string realSrc = src->getFullPath();
+        std::string realDest = dest->getFullPath();
+
+        errno = 0;
+        struct stat info;
+        memset(&info, 0, sizeof(struct stat));
+        int status = lstat(realDest.c_str(), &info);
+        if ((status != 0) && (errno != ENOENT)) {
+            ThrowMsg(Commons::PlatformException,
+                     "No access to platform destination node.");
+        }
+
+        if (((event->getOptions() & OPT_OVERWRITE) == 0) && (status == 0)) {
+            ThrowMsg(Commons::PlatformException, "Overwrite is not set.");
+        }
+
+        if (event->getOptions() & OPT_OVERWRITE) {
+            DPL::ScopedPtr<RemoveCommand> remove(new RemoveCommand(dest));
+            remove->setRecursive(true);
+            remove->setForce(true);
+            System::run(remove.Get());
+        }
+
+        DPL::ScopedPtr<CopyCommand> copy(new CopyCommand(src, dest));
+        copy->setRecursive(true);
+        System::run(copy.Get());
+
+        event->setResult(Node::resolve(dest));
+    }
+    Catch(Commons::PlatformException) {
+        event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+    }
+    Catch(Commons::SecurityException) {
+        event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
+    }
+}
+
+void Manager::OnRequestReceived(const EventMovePtr& event)
+{
+    try {
+        INodePtr srcNode = Node::resolve(event->getSource());
+        if ((srcNode->getMode() & PERM_WRITE) == 0) {
+            ThrowMsg(Commons::SecurityException,
+                     "Not enough permissions to move source node.");
+        }
+
+        IPathPtr src = event->getSource();
+        IPathPtr dest = event->getDestination();
+        if (!dest->isAbsolute()) {
+            dest = src->getPath() + *dest;
+        }
+
+        if (src == dest) {
+            ThrowMsg(Commons::PlatformException,
+                     "Destination is same as source.");
+        }
+
+        INodePtr parent;
+        Try {
+            parent = Node::resolve(IPath::create(dest->getPath()));
+        }
+        Catch(Commons::PlatformException) {
+            ReThrowMsg(Commons::PlatformException,
+                       "Could not get destination's parent node.");
+        }
+
+        if (parent->getType() != NT_DIRECTORY) {
+            ThrowMsg(Commons::PlatformException,
+                     "Destination's parent node is not directory.");
+        }
+
+        std::string realSrc = src->getFullPath();
+        std::string realDest = dest->getFullPath();
+
+        errno = 0;
+        struct stat info;
+        memset(&info, 0, sizeof(struct stat));
+        int status = lstat(realDest.c_str(), &info);
+        if ((status != 0) && (errno != ENOENT)) {
+            ThrowMsg(Commons::PlatformException,
+                     "No access to platform destination node.");
+        }
+
+        if (((event->getOptions() & OPT_OVERWRITE) == 0) && (status == 0)) {
+            ThrowMsg(Commons::PlatformException, "Overwrite is not set.");
+        }
+
+        if (event->getOptions() & OPT_OVERWRITE) {
+            DPL::ScopedPtr<RemoveCommand> remove(new RemoveCommand(dest));
+            remove->setRecursive(true);
+            remove->setForce(true);
+            System::run(remove.Get());
+        }
+
+        DPL::ScopedPtr<MoveCommand> move(new MoveCommand(src, dest));
+        System::run(move.Get());
+
+        event->setResult(Node::resolve(dest));
+    }
+    catch (const Commons::PlatformException& ex) {
+        event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+    }
+    catch (const Commons::SecurityException& ex) {
+        event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
+    }
+}
+
+void Manager::OnRequestReceived(const EventCreatePtr& event)
+{
+    Try {
+    }
+    Catch(Commons::PlatformException) {
+        event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+    }
+}
+
+void Manager::OnRequestReceived(const EventRemovePtr& event)
+{
+    Try {
+        INodePtr node = Node::resolve(event->getPath());
+        node->remove(event->getOptions());
+    }
+    Catch(Commons::PlatformException) {
+        event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+    }
+    Catch(Commons::SecurityException) {
+        event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
+    }
+}
+
+void Manager::OnRequestReceived(const EventFindPtr& event)
+{
+    try {
+        NodeList result;
+        find(event->getPath(), event->getFilters(), result, event);
+        event->setResult(result);
+    }
+    catch (const Commons::Exception& ex) {
+        event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+    }
+}
+
+void Manager::addLocalStorage(std::string label, std::vector<Api::Filesystem::StoragePropertiesPtr> &storageList)
+{
+       Api::Filesystem::StoragePropertiesPtr storage(new StorageProperties());
+       storage->setId(0xff);
+       storage->setLabel(label);
+       storage->setType(Api::Filesystem::StorageProperties::TYPE_INTERNAL);
+
+       storage_state_e currentState;
+       storage_get_state(0, &currentState);
+       storage->setState((short)currentState);
+
+       storageList.insert(storageList.end(), storage);
+}
+
+bool Manager::init()
+{
+       std::vector<Api::Filesystem::StoragePropertiesPtr> storageList;
+       storage_foreach_device_supported(Manager::getSupportedDeviceCB, &storageList);
+
+       for (size_t i = 0; i < storageList.size(); i++) {
+               m_locations[storageList[i]->getLabel()] = IPath::create(storageList[i]->getFullPath());
+               m_rootlist[storageList[i]->getLabel()] = storageList[i]->getId();
+       }
+
+       /* for Tizen */
+       setupLocation("downloads", PATH_DOWNLOADS);
+       setupLocation("documents", PATH_DOCUMENTS);
+       setupLocation("music", PATH_SOUNDS);
+       setupLocation("images", PATH_IMAGES);
+       setupLocation("videos", PATH_VIDEOS);
+
+       m_subrootlist[LT_ROOT] = "internal0";
+       m_subrootlist[LT_SDCARD] = "removable1";
+       m_subrootlist[LT_DOWNLOADS] = "downloads";
+       m_subrootlist[LT_DOCUMENTS] = "documents";
+       m_subrootlist[LT_SOUNDS] = "music";
+       m_subrootlist[LT_IMAGES] = "images";
+       m_subrootlist[LT_VIDEOS] = "videos";
+       return true;
+
+}
+
+void Manager::setupLocation(std::string location, const char* path)
+{
+    if (!nodeExists(path)) {
+        try {
+            makePath(path, 0755);
+        }
+        catch (const Commons::PlatformException& ex) {
+            LogError("Exception: " << ex.DumpToString());
+            return;
+        }
+    }
+    m_locations[location] = IPath::create(path);
+}
+
+void Manager::Watcher::getCurrentStoargeStateForWatch()
+{
+       std::string label("");
+       storage_type_e type;
+       storage_state_e state;
+       RootList::const_iterator it = m_rootlist.begin();
+       for (; it != m_rootlist.end(); ++it) {
+               label = it->first;
+               if (label.compare("") != 0) {
+                       Api::Filesystem::StoragePropertiesPtr storageItem(new StorageProperties());
+
+                       if (storage_get_type(it->second, &type) != STORAGE_ERROR_NONE) {
+                               Throw(Commons::PlatformException);
+                       }
+                       if (storage_get_state(it->second, &state) != STORAGE_ERROR_NONE) {
+                               Throw(Commons::PlatformException);
+                       }
+
+                       storageItem->setId(it->second);
+                       storageItem->setLabel(it->first);
+                       storageItem->setType(static_cast<short>(type));
+                       storageItem->setState(static_cast<short>(state));
+
+                       EventStorageStateChangedPtr event(new EventStorageStateChanged());
+
+                       event->setResult(storageItem);
+                       emit(event);
+               }
+       }
+}
+
+void Manager::Watcher::StorageStateHasChanged(int storage, storage_state_e state)
+{
+       Api::Filesystem::StoragePropertiesPtr storageItem(new StorageProperties());
+
+       std::string label;
+       storage_type_e type;
+
+       RootList::const_iterator it = m_rootlist.begin();
+       for (; it != m_rootlist.end(); ++it) {
+               if (it->second == storage) {
+                       label = it->first;
+                       break;
+               }
+       }
+
+       if (storage_get_type(storage, &type) != STORAGE_ERROR_NONE) {
+               Throw(Commons::PlatformException);
+       }
+
+       if (label.compare("") != 0) {
+               storageItem->setId(storage);
+               storageItem->setLabel(label);
+               storageItem->setType(static_cast<short>(type));
+               storageItem->setState(static_cast<short>(state));
+
+               EventStorageStateChangedPtr event(new EventStorageStateChanged());
+
+               event->setResult(storageItem);
+               emit(event);
+       }
+}
+
+}
+}
+}
\ No newline at end of file
diff --git a/src/platform/Tizen/Filesystem/Manager.h b/src/platform/Tizen/Filesystem/Manager.h
new file mode 100755 (executable)
index 0000000..c83d646
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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_FILESYSTEMMANAGER_H_
+#define TIZENAPIS_FILESYSTEMMANAGER_H_
+
+#include <string>
+#include <map>
+#include <vector>
+#include <cstddef>
+#include <dpl/shared_ptr.h>
+#include <API/Filesystem/IManager.h>
+#include <API/Filesystem/IPath.h>
+#include <appfw/app_storage.h>
+#include "Node.h"
+#include "Path.h"
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+class Manager : public Api::Filesystem::IManager
+{
+  public:
+    /**
+     * Checks if file exists.
+     * @param real file path.
+     * @return true when file exists, false otherwise.
+     * @throw PlatformException If unable to validate if file exists.
+     */
+    static bool fileExists(const std::string &file);
+    static bool getSupportedDeviceCB(int storage, storage_type_e type, storage_state_e state, const char *path, void *user_data);
+    static void storageStateChangedCB(int storage, storage_state_e state, void *user_data);
+
+  public:
+    Manager();
+    ~Manager();
+
+    Api::Filesystem::IPathPtr getBasePath() const;
+
+    Api::Filesystem::StorageList getStorageList() const;
+
+    Api::Filesystem::IPathPtr getLocationPath(
+            Api::Filesystem::LocationType type) const;
+
+    Api::Filesystem::LocationPaths getLocationPaths() const;
+
+    Api::Filesystem::LocationTypes getLocations() const;
+
+    void getNode(const Api::Filesystem::EventResolvePtr& event);
+
+    void getStorage(const Api::Filesystem::EventGetStoragePtr& event);
+
+    void listStorages(const Api::Filesystem::EventListStoragesPtr& event);
+
+    std::size_t getMaxPathLength() const;
+
+    void copy(const Api::Filesystem::EventCopyPtr& event);
+
+    void move(const Api::Filesystem::EventMovePtr& event);
+
+    void create(const Api::Filesystem::EventCreatePtr& event);
+
+    void remove(const Api::Filesystem::EventRemovePtr& event);
+
+    void find(const Api::Filesystem::EventFindPtr& event);
+
+    /**
+     * Finds files in the filesystem whish match specified filters.
+     * @param path Starting path.
+     * @param filter Filters @see Api::Filesystem::FindFilters.
+     * @param result List with found files.
+     * @param event DPL event, if set then search process can be cancelled
+     * @remarks For filter FF_NAME value is treated as perl like regex pattern.
+     *          Use @Regex::escpae() if you want to treat it as normal string.
+     */
+    void find(
+            const Api::Filesystem::IPathPtr& path,
+            const Api::Filesystem::FiltersMap& filter,
+            Api::Filesystem::NodeList& result,
+            const Api::Filesystem::EventFindPtr& event =
+                Api::Filesystem::EventFindPtr(NULL));
+
+    /**
+     * @warning Operates on specified as it is - it DOES NOT take its real path.
+     *          This is because all filesystem operation will probably change
+     *          their approach to real path and will allow to refer to nodes
+     *          only by virtual roots.
+     */
+    bool access(const Api::Filesystem::IPathPtr& path,
+            int accessType) const;
+
+    void addOpenedNode(const Api::Filesystem::INodePtr& node);
+    void removeOpenedNode(const Api::Filesystem::INodePtr& node);
+    bool checkIfOpened(const Api::Filesystem::IPathPtr& path) const;
+
+    long addStorageStateChangeListener(const Api::Filesystem::EventStorageStateChangedEmitterPtr& emitter);
+    void removeStorageStateChangeListener(Api::Filesystem::EventStorageStateChangedEmitter::IdType id);
+
+public :
+       class Watcher
+       {
+               private:
+               Api::Filesystem::EventStorageStateChangedEmitterPtr m_emitter;
+
+               public:
+               Watcher(const Api::Filesystem::EventStorageStateChangedEmitterPtr& emitter) :
+                       m_emitter(emitter)
+               {
+               }
+
+               Api::Filesystem::EventStorageStateChangedEmitterPtr getEmitter()
+               {
+                       return m_emitter;
+               }
+
+               void emit(const Api::Filesystem::EventStorageStateChangedPtr& event)
+               {
+                       m_emitter->emit(event);
+               }
+               void getCurrentStoargeStateForWatch();
+               void StorageStateHasChanged(int storage, storage_state_e state);
+       };
+       typedef DPL::SharedPtr<Watcher> WatcherPtr;
+
+  protected:
+    bool matchFilters(const std::string& name,
+            const struct stat& info,
+            const Api::Filesystem::FiltersMap& filter);
+
+    void OnRequestReceived(const Api::Filesystem::EventResolvePtr& event);
+    void OnRequestReceived(const Api::Filesystem::EventGetStoragePtr& event);
+    void OnRequestReceived(const Api::Filesystem::EventListStoragesPtr& event);
+    void OnRequestReceived(const Api::Filesystem::EventCopyPtr& event);
+    void OnRequestReceived(const Api::Filesystem::EventMovePtr& event);
+    void OnRequestReceived(const Api::Filesystem::EventCreatePtr& event);
+    void OnRequestReceived(const Api::Filesystem::EventRemovePtr& event);
+    void OnRequestReceived(const Api::Filesystem::EventFindPtr& event);
+
+    void addLocalStorage(std::string label, std::vector<Api::Filesystem::StoragePropertiesPtr> &storageList);
+  private:
+    typedef std::map<std::string,
+                     Api::Filesystem::IPathPtr> Locations;
+
+    typedef std::map<std::string, int> RootList;
+    typedef std::map<Api::Filesystem::LocationType, std::string> SubRootList;
+  private:
+    /**
+     * Initializes statics of Manager class.
+     * Used only internally.
+     * @return True on success, false otherwsie.
+     */
+    static bool init();
+    static void setupLocation(std::string location, const char* path);
+
+  private:
+    static RootList m_rootlist;
+    static SubRootList m_subrootlist;
+    static Locations m_locations; ///< Paths to default locations.
+    static const std::size_t m_maxPathLength; ///< Maximum path length.
+    static Api::Filesystem::NodeList m_openedNodes; ///< List of nodes that has opened streams.
+
+public:
+    typedef std::vector<WatcherPtr> watcherList;
+    static watcherList m_watchers;
+};
+} // Filesystem
+} // Platform
+} // TizenApis
+
+#endif // TIZENAPIS_FILESYSTEMMANAGER_H_
\ No newline at end of file
diff --git a/src/platform/Tizen/Filesystem/MoveCommand.cpp b/src/platform/Tizen/Filesystem/MoveCommand.cpp
new file mode 100755 (executable)
index 0000000..1d950b3
--- /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. 
+ */
+
+
+#include "MoveCommand.h"
+#include <sstream>
+
+namespace {
+const char* COMMAND_NAME = "/bin/mv";
+const char* COMMAND_SWITCH_FORCE = "-f";
+}
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+MoveCommand::MoveCommand(const Api::Filesystem::IPathPtr& src,
+        const Api::Filesystem::IPathPtr& dest) :
+    m_src(src),
+    m_dest(dest),
+    m_force(false)
+{
+}
+
+void MoveCommand::setForce(bool force)
+{
+    m_force = force;
+}
+
+std::string MoveCommand::prepare()
+{
+    std::ostringstream oss;
+    oss << COMMAND_NAME;
+
+    if (m_force) {
+        oss << " " << COMMAND_SWITCH_FORCE;
+    }
+
+    oss << " \"" << m_src->getFullPath().c_str() << "\"";
+    oss << " \"" << m_dest->getFullPath().c_str() << "\"";
+
+    return oss.str();
+}
+}
+}
+}
diff --git a/src/platform/Tizen/Filesystem/MoveCommand.h b/src/platform/Tizen/Filesystem/MoveCommand.h
new file mode 100755 (executable)
index 0000000..a50e282
--- /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_FILESYSTEM_MOVECOMMAND_H_
+#define TIZENAPIS_FILESYSTEM_MOVECOMMAND_H_
+
+#include "Command.h"
+#include <API/Filesystem/IPath.h>
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+class MoveCommand : public Command
+{
+  public:
+    MoveCommand(const Api::Filesystem::IPathPtr& src,
+            const Api::Filesystem::IPathPtr& dest);
+    void setForce(bool force);
+
+  protected:
+    std::string prepare();
+
+  private:
+    Api::Filesystem::IPathPtr m_src;
+    Api::Filesystem::IPathPtr m_dest;
+    bool m_force;
+};
+}
+}
+}
+
+#endif // TIZENAPIS_FILESYSTEM_MOVECOMMAND_H_
\ No newline at end of file
diff --git a/src/platform/Tizen/Filesystem/Node.cpp b/src/platform/Tizen/Filesystem/Node.cpp
new file mode 100755 (executable)
index 0000000..5f8d1a9
--- /dev/null
@@ -0,0 +1,527 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "Node.h"
+
+#include <algorithm>
+#include <memory>
+#include <typeinfo>
+#include <sys/types.h>
+#include <cstdio>
+#include <unistd.h>
+#include <dirent.h>
+#include <errno.h>
+#include <pcrecpp.h>
+#include <sstream>
+
+#include <Commons/Exception.h>
+#include <API/Filesystem/PathUtils.h>
+#include <API/Filesystem/Enums.h>
+#include "Manager.h"
+#include "NodeFilterMatcher.h"
+
+using namespace TizenApis::Api::Filesystem;
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+Api::Filesystem::INodePtr Node::resolve(const Api::Filesystem::IPathPtr& path)
+{
+    struct stat info;
+    if (lstat(path->getFullPath().c_str(), &info) != 0) {
+        LogError("File: " << path->getFullPath().c_str());
+        ThrowMsg(Commons::PlatformException,
+                 "Node does not exist or access denied.");
+    }
+
+    if (!S_ISDIR(info.st_mode) & !S_ISREG(info.st_mode)) {
+        ThrowMsg(Commons::PlatformException,
+                 "Platform node is of unsupported type.");
+    }
+
+    NodeType type = S_ISDIR(info.st_mode) ? NT_DIRECTORY : NT_FILE;
+    NodePtr result(new Node(path, type));
+    return DPL::StaticPointerCast<INode>(result);
+}
+
+IPathPtr Node::getPath() const
+{
+    return IPath::create(m_path->getFullPath());
+}
+
+INodePtr Node::getChild(const IPathPtr& path)
+{
+    if (m_type != NT_DIRECTORY) {
+        ThrowMsg(Commons::PlatformException, "Not a directory.");
+    }
+    return Node::resolve(*m_path + *path);
+}
+
+NodeType Node::getType() const
+{
+    return m_type;
+}
+
+int Node::getPermissions() const
+{
+    return m_perms;
+}
+
+void Node::setPermissions(int perms)
+{
+    m_perms = perms;
+}
+
+Node::NameList Node::getChildNames() const
+{
+    if (m_type != NT_DIRECTORY) {
+        ThrowMsg(Commons::PlatformException, "Node is not directory.");
+    }
+
+    if ((m_perms & PERM_READ) == 0) {
+        ThrowMsg(Commons::SecurityException, "No permission.");
+    }
+
+    DIR* dir = opendir(m_path->getFullPath().c_str());
+    if (!dir) {
+        ThrowMsg(Commons::PlatformException,
+                 "Node has been deleted from platform.");
+    }
+
+    NameList result;
+    errno = 0;
+    struct dirent *entry = NULL;
+    while ((entry = readdir(dir))) {
+        if (!strncmp(entry->d_name, ".",
+                     1) || !strncmp(entry->d_name, "..", 2)) {
+            continue;
+        }
+        result.push_back(entry->d_name);
+    }
+    if (errno != 0) {
+        ThrowMsg(Commons::PlatformException, "Error while reading directory.");
+    }
+
+    if (closedir(dir) != 0) {
+        ThrowMsg(Commons::PlatformException, "Could not close platform node.");
+    }
+
+    return result;
+}
+
+NodeList Node::getChildNodes(const NodeFilterPtr& filter) const
+{
+    if (m_type != NT_DIRECTORY) {
+        ThrowMsg(Commons::PlatformException, "Node is not directory.");
+    }
+
+    if ((m_perms & PERM_READ) == 0) {
+        ThrowMsg(Commons::SecurityException, "No permission.");
+    }
+
+    DIR* dir = opendir(m_path->getFullPath().c_str());
+    if (!dir) {
+        ThrowMsg(Commons::PlatformException,
+                 "Node has been deleted from platform.");
+    }
+
+    errno = 0;
+    NodeList result;
+    struct dirent *entry = NULL;
+    while ((entry = readdir(dir))) {
+        if (!strncmp(entry->d_name, ".",
+                     1) || !strncmp(entry->d_name, "..", 2)) {
+            continue;
+        }
+        Try {
+            INodePtr node = Node::resolve(*m_path + entry->d_name);
+            if (NodeFilterMatcher::match(node, filter)) {
+                result.push_back(node);
+            }
+        }
+        Catch(Commons::PlatformException) {
+        }
+    }
+
+    if (errno != 0) {
+        ThrowMsg(Commons::PlatformException, "Error while reading directory.");
+    }
+
+    if (closedir(dir) != 0) {
+        ThrowMsg(Commons::PlatformException, "Could not close platform node.");
+    }
+
+    return result;
+}
+
+void Node::getChildNodes(const EventListNodesPtr& event)
+{
+    EventRequestReceiver<EventListNodes>::PostRequest(event);
+}
+
+Api::Filesystem::INodePtr Node::createChild(
+        const Api::Filesystem::IPathPtr& path,
+        NodeType type,
+        int options)
+{
+    if (m_type != NT_DIRECTORY) {
+        ThrowMsg(Commons::PlatformException, "Parent node is not a directory.");
+    }
+
+    if ((m_perms & PERM_WRITE) == 0) {
+        ThrowMsg(Commons::SecurityException, "Not enough permissions.");
+    }
+
+    IPathPtr childPath = *m_path + *path;
+    if (exists(childPath)) {
+        ThrowMsg(Commons::PlatformException, "Node already exists.");
+    }
+
+    NodePtr result;
+    switch (type) {
+    case NT_FILE:
+        result.Reset(createAsFile(childPath, options));
+        break;
+    case NT_DIRECTORY:
+        result.Reset(createAsDirectory(childPath, options));
+        break;
+    default:
+        ThrowMsg(Commons::PlatformException, "Unsupported node type.");
+    }
+    if (!!result) {
+        result->m_perms = m_perms;
+    } else {
+        ThrowMsg(Commons::PlatformException, "Node creation error");
+    }
+
+    return DPL::StaticPointerCast<INode>(result);
+}
+
+IStreamPtr Node::open(int mode)
+{
+    if (m_type == NT_DIRECTORY) {
+        ThrowMsg(Commons::PlatformException,
+                 "Cannot attach stream to directory.");
+    }
+
+    if (((mode & AM_READ) && ((m_perms & PERM_READ) == 0)) ||
+        (((mode & AM_WRITE) ||
+          (mode & AM_APPEND)) && ((m_perms & PERM_WRITE) == 0))) {
+        ThrowMsg(Commons::SecurityException, "Not enough permissions.");
+    }
+
+    DPL::Mutex::ScopedLock lock(&m_openStreamsMutex);
+    StreamPtr stream(new Stream(SharedFromThis(), mode));
+    m_openStreams.insert(stream);
+    IManager::getInstance().addOpenedNode(DPL::StaticPointerCast<INode>(
+                                              SharedFromThis()));
+    return DPL::StaticPointerCast<IStream>(stream);
+}
+
+void Node::open(const EventOpenPtr& event)
+{
+    EventRequestReceiver<EventOpen>::PostRequest(event);
+}
+
+void Node::remove(int options)
+{
+    switch (m_type) {
+    case NT_FILE:
+        removeAsFile(m_path);
+        break;
+    case NT_DIRECTORY:
+        removeAsDirectory(m_path, (options & OPT_RECURSIVE));
+        break;
+    }
+}
+
+std::size_t Node::getSize() const
+{
+    if (m_type == NT_DIRECTORY) {
+        ThrowMsg(Commons::PlatformException,
+                 "Getting size for directories is not supported.");
+    }
+
+    struct stat info = stat(m_path);
+    if (!S_ISREG(info.st_mode)) {
+        ThrowMsg(Commons::PlatformException,
+                 "Specified node is not a regular file.");
+    }
+
+    return info.st_size;
+}
+
+std::time_t Node::getCreated() const
+{
+    return stat(m_path).st_ctime;
+}
+
+std::time_t Node::getModified() const
+{
+    return stat(m_path).st_mtime;
+}
+
+// TODO Optimize it, maybe store a flag indicating that node is a root.
+INodePtr Node::getParent() const
+{
+    LocationPaths roots = IManager::getInstance().getLocationPaths();
+    for (LocationPaths::iterator it = roots.begin(); it != roots.end(); ++it) {
+        if (*(*it) == *m_path) {
+            return INodePtr();
+        }
+    }
+    return Node::resolve(IPath::create(m_path->getPath()));
+}
+
+int Node::getMode() const
+{
+    int result = 0;
+    struct stat info = stat(m_path);
+    if (info.st_mode & S_IRUSR) { result |= PM_USER_READ; }
+    if (info.st_mode & S_IWUSR) { result |= PM_USER_WRITE; }
+    if (info.st_mode & S_IXUSR) { result |= PM_USER_EXEC; }
+    if (info.st_mode & S_IRGRP) { result |= PM_GROUP_READ; }
+    if (info.st_mode & S_IWGRP) { result |= PM_GROUP_WRITE; }
+    if (info.st_mode & S_IXGRP) { result |= PM_GROUP_EXEC; }
+    if (info.st_mode & S_IROTH) { result |= PM_OTHER_READ; }
+    if (info.st_mode & S_IWOTH) { result |= PM_OTHER_WRITE; }
+    if (info.st_mode & S_IXOTH) { result |= PM_OTHER_EXEC; }
+    return result;
+}
+
+void Node::read(const EventReadTextPtr& event)
+{
+    EventRequestReceiver<EventReadText>::PostRequest(event);
+}
+
+void Node::onStreamClose(const StreamPtr& stream)
+{
+    {
+        DPL::Mutex::ScopedLock lock(&m_openStreamsMutex);
+        m_openStreams.erase(stream);
+    }
+    if (m_openStreams.empty()) {
+        IManager::getInstance().removeOpenedNode(DPL::StaticPointerCast<INode>(
+                                                     SharedFromThis()));
+    }
+}
+
+bool Node::exists(const IPathPtr& path)
+{
+    struct stat info;
+    memset(&info, 0, sizeof(struct stat));
+    int status = lstat(path->getFullPath().c_str(), &info);
+    if ((status == 0) || ((status != 0) && (errno != ENOENT))) {
+        return true;
+    }
+    return false;
+}
+
+struct stat Node::stat(const IPathPtr& path)
+{
+    struct stat result;
+    memset(&result, 0, sizeof(struct stat));
+    if (::stat(path->getFullPath().c_str(),
+                &result) != 0)
+    {
+        ThrowMsg(Commons::PlatformException, "Node does not exist or no access");
+    }
+    return result;
+}
+
+Node::Node(const IPathPtr& path,
+        NodeType type) :
+    m_path(path),
+    m_type(type),
+    m_perms(PERM_NONE)
+{
+}
+
+Node* Node::createAsFile(const IPathPtr& path,
+        int options)
+{
+    createAsFileInternal(path);
+    return new Node(path, NT_FILE);
+}
+
+void Node::createAsFileInternal(const IPathPtr& path)
+{
+    FILE* file = std::fopen(path->getFullPath().c_str(), "wb");
+    if (!file) {
+        ThrowMsg(Commons::PlatformException,
+                 "Platform node could not be created.");
+    }
+    std::fclose(file);
+}
+
+Node* Node::createAsDirectory(const IPathPtr& path,
+        int options)
+{
+    if (options & OPT_RECURSIVE) {
+        PathUtils::PathList parts = PathUtils::getParts(path);
+        PathUtils::PathListIterator it = parts.begin();
+        for (; it != parts.end(); ++it) {
+            if (!exists(*it)) { createAsDirectoryInternal(*it); }
+        }
+    }
+    createAsDirectoryInternal(path);
+    return new Node(path, NT_DIRECTORY);
+}
+
+void Node::createAsDirectoryInternal(const IPathPtr& path)
+{
+    if (mkdir(path->getFullPath().c_str(), S_IRWXU | S_IRWXG | S_IROTH |
+              S_IXOTH) != 0) {
+        ThrowMsg(Commons::PlatformException,
+                 "Platform node could not be created.");
+    }
+}
+
+void Node::removeAsFile(const IPathPtr& path)
+{
+    DPL::Mutex::ScopedLock lock(&m_openStreamsMutex);
+    if (!m_openStreams.empty()) {
+        ThrowMsg(Commons::PlatformException, "Node is locked for I/O.");
+    }
+    if (IManager::getInstance().checkIfOpened(path)) {
+        ThrowMsg(Commons::PlatformException, "Node is locked for I/O.");
+    }
+
+    if (unlink(path->getFullPath().c_str()) != 0) {
+        ThrowMsg(Commons::PlatformException,
+                 "Error while removing platform node.");
+    }
+}
+
+void Node::removeAsDirectory(const IPathPtr& path,
+        bool recursive)
+{
+    if (recursive) {
+        DIR* dir = opendir(path->getFullPath().c_str());
+        if (!dir) {
+            LogError("File: " << path->getFullPath().c_str());
+            ThrowMsg(Commons::PlatformException,
+                     "Node does not exist or access denied.");
+        }
+        errno = 0;
+        struct dirent *entry = NULL;
+        while ((entry = readdir(dir))) {
+            if (!strncmp(entry->d_name, ".",
+                         1) || !strncmp(entry->d_name, "..", 2)) {
+                continue;
+            }
+            IPathPtr subPath = *path + entry->d_name;
+            struct stat info;
+            memset(&info, 0, sizeof(struct stat));
+            if (lstat(subPath->getFullPath().c_str(), &info) == 0) {
+                Try {
+                    if (S_ISDIR(info.st_mode)) {
+                        removeAsDirectory(subPath, true);
+                    } else if (S_ISREG(info.st_mode)) {
+                        removeAsFile(subPath);
+                    }
+                }
+                Catch(Commons::PlatformException) {
+                }
+            }
+        }
+        closedir(dir);
+    }
+
+    errno = 0;
+    if (rmdir(path->getFullPath().c_str()) != 0) {
+        if (errno == EEXIST) {
+            ThrowMsg(Commons::PlatformException, "Node has child nodes.");
+        }
+        ThrowMsg(Commons::PlatformException,
+                 "Error while removing platform node.");
+    }
+}
+
+void Node::OnRequestReceived(const EventListNodesPtr& event)
+{
+    try {
+        NodeList list = event->getNode()->getChildNodes(event->getFilter());
+        event->setResult(list);
+    }
+    catch (const Commons::PlatformException& ex) {
+        LogError("Exception: " << ex.GetMessage());
+        event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+    }
+    catch (const Commons::SecurityException& ex) {
+        LogError("Exception: " << ex.GetMessage());
+        event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
+    }
+}
+
+void Node::OnRequestReceived(const EventOpenPtr& event)
+{
+    try {
+        IStreamPtr result = open(event->getMode());
+        event->setResult(result);
+    }
+    catch (const Commons::PlatformException& ex) {
+        LogError("Exception: " << ex.GetMessage());
+        event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+    }
+    catch (const Commons::SecurityException& ex) {
+        LogError("Exception: " << ex.GetMessage());
+        event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
+    }
+}
+
+void Node::OnRequestReceived(const EventReadTextPtr& event)
+{
+    Try {
+        event->setResult(readText());
+    }
+    Catch(Commons::PlatformException) {
+        event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+    }
+    Catch(Commons::SecurityException) {
+        event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
+    }
+}
+
+std::string Node::readText()
+{
+    if (m_type != NT_FILE) {
+        ThrowMsg(Commons::PlatformException, "Node is not a file.");
+    }
+
+    if ((m_perms & PERM_READ) == 0) {
+        ThrowMsg(Commons::SecurityException, "No permission.");
+    }
+
+    std::stringstream result;
+    DPL::SharedPtr<Stream> stream(new Stream(SharedFromThis(), AM_READ));
+    while (!stream->isEof()) {
+        result << stream->getLine();
+    }
+    stream->close();
+    return result.str();
+}
+
+std::string Node::toUri(int widgetId) const
+{
+    return "file://" + m_path->getFullPath();
+}
+}
+}
+}
\ No newline at end of file
diff --git a/src/platform/Tizen/Filesystem/Node.h b/src/platform/Tizen/Filesystem/Node.h
new file mode 100755 (executable)
index 0000000..0c31f9b
--- /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. 
+ */
+
+#ifndef TIZENAPIS_FILESYSTEM_NODE_H_
+#define TIZENAPIS_FILESYSTEM_NODE_H_
+
+#include <ctime>
+#include <cstddef>
+#include <sys/stat.h>
+#include <set>
+#include <dpl/shared_ptr.h>
+#include <dpl/enable_shared_from_this.h>
+#include <dpl/mutex.h>
+
+#include <API/Filesystem/Enums.h>
+#include <API/Filesystem/INode.h>
+#include "Path.h"
+#include "Stream.h"
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+class Node : public Api::Filesystem::INode,
+    public DPL::EnableSharedFromThis<Node>
+{
+  public:
+    static Api::Filesystem::INodePtr resolve(
+            const Api::Filesystem::IPathPtr& path);
+
+  public:
+    Api::Filesystem::IPathPtr getPath() const;
+    Api::Filesystem::NodeType getType() const;
+    int getPermissions() const;
+    void setPermissions(int perms);
+    std::size_t getSize() const;
+    std::time_t getCreated() const;
+    std::time_t getModified() const;
+    Api::Filesystem::INodePtr getParent() const;
+    int getMode() const;
+
+    Api::Filesystem::INodePtr getChild(const Api::Filesystem::IPathPtr& path);
+    NameList getChildNames() const;
+    Api::Filesystem::NodeList getChildNodes(
+            const Api::Filesystem::NodeFilterPtr& filter =
+                Api::Filesystem::NodeFilterPtr()) const;
+    void getChildNodes(const Api::Filesystem::EventListNodesPtr& event);
+    Api::Filesystem::INodePtr createChild(
+        const Api::Filesystem::IPathPtr & path,
+        Api::Filesystem::NodeType,
+        int options);
+    Api::Filesystem::IStreamPtr open(int mode);
+    void open(const Api::Filesystem::EventOpenPtr& event);
+    void remove(int options);
+    void read(const Api::Filesystem::EventReadTextPtr& event);
+
+    void onStreamClose(const StreamPtr& stream);
+
+  private:
+    typedef std::set<StreamPtr> StreamList;
+
+  private:
+    static bool exists(const Api::Filesystem::IPathPtr& path);
+    static struct stat stat(const Api::Filesystem::IPathPtr& path);
+
+  private:
+    Node(const Api::Filesystem::IPathPtr& path,
+            Api::Filesystem::NodeType type);
+
+    Node* createAsFile(const Api::Filesystem::IPathPtr& path,
+            int options);
+    void createAsFileInternal(const Api::Filesystem::IPathPtr& path);
+
+    Node* createAsDirectory(const Api::Filesystem::IPathPtr& path,
+            int options);
+    void createAsDirectoryInternal(const Api::Filesystem::IPathPtr& path);
+
+    void removeAsFile(const Api::Filesystem::IPathPtr& path);
+    void removeAsDirectory(const Api::Filesystem::IPathPtr& path,
+            bool recursive);
+
+    void OnRequestReceived(const Api::Filesystem::EventListNodesPtr& event);
+    void OnRequestReceived(const Api::Filesystem::EventOpenPtr& event);
+
+    void OnRequestReceived(const Api::Filesystem::EventReadTextPtr& event);
+    std::string readText();
+
+    std::string toUri(int widgetId) const;
+
+  private:
+    Api::Filesystem::IPathPtr m_path;
+    Api::Filesystem::NodeType m_type;
+    int m_perms;
+    StreamList m_openStreams;
+    mutable DPL::Mutex m_openStreamsMutex;
+};
+
+typedef DPL::SharedPtr<Node> NodePtr;
+} // Filesystem
+} // Platform
+} // TizenApis
+
+#endif /* TIZENAPIS_FILESYSTEM_NODE_H_ */
diff --git a/src/platform/Tizen/Filesystem/NodeFilterMatcher.cpp b/src/platform/Tizen/Filesystem/NodeFilterMatcher.cpp
new file mode 100755 (executable)
index 0000000..5db7a90
--- /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. 
+ */
+
+#include "NodeFilterMatcher.h"
+
+#include <pcrecpp.h>
+
+using namespace TizenApis::Api::Filesystem;
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+bool NodeFilterMatcher::match(const INodePtr& value,
+        const NodeFilterPtr& filter)
+{
+    if (filter) {
+        if (!matchString(value->getPath()->getName(), filter->getName())) {
+            return false;
+        }
+
+        if (!matchRange(value->getCreated(),
+                        filter->getMinCreated(),
+                        filter->getMaxCreated())) {
+            return false;
+        }
+
+        if (!matchRange(value->getModified(),
+                        filter->getMinModified(),
+                        filter->getMaxModified())) {
+            return false;
+        }
+
+        if (!matchRange(value->getSize(),
+                        filter->getMinSize(),
+                        filter->getMaxSize())) {
+            return false;
+        }
+    }
+    return true;
+}
+
+bool NodeFilterMatcher::matchString(const std::string& value,
+        const OptionalString& filter)
+{
+    if (!filter.IsNull()) {
+        return pcrecpp::RE(*filter).PartialMatch(value);
+    }
+    return true;
+}
+
+template<typename Type>
+bool NodeFilterMatcher::matchRange(const Type& value,
+        const DPL::Optional<Type>& min,
+        const DPL::Optional<Type>& max)
+{
+    if ((!min.IsNull() && (value < *min)) ||
+        (!max.IsNull() && (value > *max))) {
+        return false;
+    }
+    return true;
+}
+} // Filesystem
+} // Platform
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/Tizen/Filesystem/NodeFilterMatcher.h b/src/platform/Tizen/Filesystem/NodeFilterMatcher.h
new file mode 100755 (executable)
index 0000000..f0af72b
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+
+#ifndef TIZENAPIS_FILESYSTEM_NODEFILTERMATCHER_H_
+#define TIZENAPIS_FILESYSTEM_NODEFILTERMATCHER_H_
+
+#include <string>
+#include <dpl/optional.h>
+#include <API/Filesystem/INode.h>
+#include <API/Filesystem/NodeFilter.h>
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+class NodeFilterMatcher
+{
+  public:
+    static bool match(const Api::Filesystem::INodePtr& value,
+            const Api::Filesystem::NodeFilterPtr& filter);
+
+  private:
+    static bool matchString(const std::string& value,
+            const Api::Filesystem::OptionalString& filter);
+
+    template<typename Type>
+    static bool matchRange(const Type& value,
+            const DPL::Optional<Type>& min,
+            const DPL::Optional<Type>& max);
+
+  private:
+    NodeFilterMatcher();
+};
+} // Filesystem
+} // Platform
+} // TizenApis
+
+#endif // TIZENAPIS_FILESYSTEM_NODEFILTERMATCHER_H_
diff --git a/src/platform/Tizen/Filesystem/Path.cpp b/src/platform/Tizen/Filesystem/Path.cpp
new file mode 100755 (executable)
index 0000000..b927a4c
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include <memory>
+#include <algorithm>
+#include <iterator>
+#include <stdlib.h>
+#include <limits.h>
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+#include <Commons/Exception.h>
+#include <Commons/StringUtils.h>
+#include "Path.h"
+
+using namespace TizenApis::Api::Filesystem;
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+const Path::SeparatorType Path::m_pathSeparator = '/';
+
+IPathPtr Path::create(const std::string& path)
+{
+    DPL::SharedPtr<Path> result(new Path());
+    result->reset(path);
+    return DPL::StaticPointerCast<IPath>(result);
+}
+
+std::string Path::getFullPath() const
+{
+    return m_fullPath;
+}
+
+std::string Path::getPath() const
+{
+    return m_path;
+}
+
+std::string Path::getName() const
+{
+    return m_name;
+}
+
+IPathPtr Path::append(const std::string& path)
+{
+    reset(m_fullPath + m_pathSeparator + path);
+    return DPL::StaticPointerCast<IPath>(SharedFromThis());
+}
+
+IPathPtr Path::append(const IPathPtr& path)
+{
+    reset(m_fullPath + m_pathSeparator + path->getFullPath());
+    return DPL::StaticPointerCast<IPath>(SharedFromThis());
+}
+
+bool Path::isAbsolute() const
+{
+    return (!m_fullPath.empty() && (m_fullPath[0] == m_pathSeparator));
+}
+
+IPath::SeparatorType Path::getSeparator()
+{
+    return m_pathSeparator;
+}
+
+bool Path::isValid(const std::string& str)
+{
+    return !str.empty();
+}
+
+IPathPtr Path::clone() const
+{
+    return Path::create(m_fullPath);
+}
+
+Path::Path()
+{
+}
+
+void Path::reset(const std::string& str)
+{
+    if (!isValid(str)) {
+        ThrowMsg(Commons::InvalidArgumentException,
+                 "Not a valid path: " + str + ".");
+    }
+
+    std::string tmp = Commons::String::unique(Commons::String::trim(
+                                                  str), m_pathSeparator);
+    std::string::size_type pos = tmp.find_last_of(m_pathSeparator);
+    if (pos == std::string::npos) {
+        m_fullPath = m_name = tmp;
+        m_path.clear();
+    } else {
+        if (0 == pos) {
+            m_fullPath = m_path = m_pathSeparator;
+        } else {
+            m_fullPath = m_path = tmp.substr(0, pos);
+            m_fullPath += m_pathSeparator;
+        }
+        m_name = tmp.substr(pos + 1);
+        m_fullPath += m_name;
+    }
+}
+} // Filesystem
+} // Platform
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/Tizen/Filesystem/Path.h b/src/platform/Tizen/Filesystem/Path.h
new file mode 100755 (executable)
index 0000000..795d292
--- /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_FILESYSTEM_PATH_H_
+#define TIZENAPIS_FILESYSTEM_PATH_H_
+
+#include <string>
+#include <vector>
+#include <dpl/enable_shared_from_this.h>
+#include <API/Filesystem/IPath.h>
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+class Path : public Api::Filesystem::IPath,
+    public DPL::EnableSharedFromThis<Path>
+{
+  public:
+    static Api::Filesystem::IPathPtr create(const std::string& path);
+    static Api::Filesystem::IPath::SeparatorType getSeparator();
+
+  public:
+    std::string getFullPath() const;
+    std::string getPath() const;
+    std::string getName() const;
+    Api::Filesystem::IPathPtr append(const std::string& path);
+    Api::Filesystem::IPathPtr append(const Api::Filesystem::IPathPtr& path);
+    bool isAbsolute() const;
+    Api::Filesystem::IPathPtr clone() const;
+
+  private:
+    /**
+     * Checks whether specified string is a valid path.
+     * @param path String to verify.
+     * @return True when string is a valid path, false otherwise.
+     */
+    static bool isValid(const std::string& str);
+
+  private:
+    Path();
+    void reset(const std::string& str);
+
+  private:
+    static const SeparatorType m_pathSeparator; ///< Path separator.
+
+  private:
+    std::string m_fullPath; ///< Full path.
+    std::string m_path;   ///< Base path.
+    std::string m_name;   ///< Last part of the path.
+};
+} // Filesystem
+} // Platform
+} // TizenApis
+
+#endif /* TIZENAPIS_FILESYSTEM_PATH_H_ */
diff --git a/src/platform/Tizen/Filesystem/RemoveCommand.cpp b/src/platform/Tizen/Filesystem/RemoveCommand.cpp
new file mode 100755 (executable)
index 0000000..172d2bb
--- /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. 
+ */
+
+#include "RemoveCommand.h"
+#include <sstream>
+
+namespace {
+const char* COMMAND_NAME = "/bin/rm";
+const char* COMMAND_SWITCH_RECURSIVE = "-r";
+const char* COMMAND_SWITCH_FORCE = "-f";
+}
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+RemoveCommand::RemoveCommand(const Api::Filesystem::IPathPtr& path) :
+    m_path(path),
+    m_recursive(false),
+    m_force(false)
+{
+}
+
+void RemoveCommand::setRecursive(bool recursive)
+{
+    m_recursive = recursive;
+}
+
+void RemoveCommand::setForce(bool force)
+{
+    m_force = force;
+}
+
+std::string RemoveCommand::prepare()
+{
+    std::ostringstream oss;
+    oss << COMMAND_NAME;
+
+    if (m_recursive) {
+        oss << " " << COMMAND_SWITCH_RECURSIVE;
+    }
+
+    if (m_force) {
+        oss << " " << COMMAND_SWITCH_FORCE;
+    }
+
+    oss << " \"" << m_path->getFullPath().c_str() << "\"";
+
+    return oss.str();
+}
+}
+}
+}
diff --git a/src/platform/Tizen/Filesystem/RemoveCommand.h b/src/platform/Tizen/Filesystem/RemoveCommand.h
new file mode 100755 (executable)
index 0000000..1ee2719
--- /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_FILESYSTEM_REMOVECOMMAND_H_
+#define TIZENAPIS_FILESYSTEM_REMOVECOMMAND_H_
+
+#include "Command.h"
+#include <API/Filesystem/IPath.h>
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+class RemoveCommand : public Command
+{
+  public:
+    explicit RemoveCommand(const Api::Filesystem::IPathPtr& path);
+    void setRecursive(bool recursive);
+    void setForce(bool force);
+
+  protected:
+    std::string prepare();
+
+  private:
+    Api::Filesystem::IPathPtr m_path;
+    bool m_recursive;
+    bool m_force;
+};
+}
+}
+}
+
+#endif // TIZENAPIS_FILESYSTEM_REMOVECOMMAND_H_
\ No newline at end of file
diff --git a/src/platform/Tizen/Filesystem/Stream.cpp b/src/platform/Tizen/Filesystem/Stream.cpp
new file mode 100755 (executable)
index 0000000..5fd8036
--- /dev/null
@@ -0,0 +1,308 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "Stream.h"
+
+#include <stdio.h>
+#include <new>
+#include <dpl/assert.h>
+#include <dpl/scoped_array.h>
+
+#include <Commons/Exception.h>
+#include "Manager.h"
+#include "Node.h"
+
+using namespace TizenApis::Api::Filesystem;
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+Stream::Stream(const NodePtr& parent,
+        int mode) :
+    m_parent(parent),
+    m_mode(mode)
+{
+    Assert(m_parent && "Stream needs to have parent.");
+
+    std::ios_base::openmode mode_ = std::ios_base::binary;
+    if (mode & AM_READ) { mode_ |= std::ios_base::in; }
+    if (mode & AM_WRITE) { mode_ |= std::ios_base::out; } else if (mode &
+                                                                   AM_APPEND) {
+        mode_ |= (std::ios_base::app | std::ios_base::out);
+    }
+
+    m_stream.open(m_parent->getPath()->getFullPath().c_str(), mode_);
+    if (!m_stream) {
+        ThrowMsg(Commons::PlatformException, "Could not open stream.");
+    }
+}
+
+Stream::~Stream()
+{
+    close();
+}
+
+Api::Filesystem::IStreamPtr Stream::write(bool arg)
+{
+    return write_(arg);
+}
+
+Api::Filesystem::IStreamPtr Stream::write(unsigned char arg)
+{
+    return write_(arg);
+}
+
+Api::Filesystem::IStreamPtr Stream::write(char arg)
+{
+    return write_(arg);
+}
+
+Api::Filesystem::IStreamPtr Stream::write(int arg)
+{
+    return write_(arg);
+}
+
+Api::Filesystem::IStreamPtr Stream::write(double arg)
+{
+    return write_(arg);
+}
+
+Api::Filesystem::IStreamPtr Stream::write(const std::string& arg)
+{
+    return write_(arg);
+}
+
+Api::Filesystem::IStreamPtr Stream::read(bool& arg)
+{
+    return read_(arg);
+}
+
+Api::Filesystem::IStreamPtr Stream::read(unsigned char& arg)
+{
+    return read_(arg);
+}
+
+Api::Filesystem::IStreamPtr Stream::read(char& arg)
+{
+    return read_(arg);
+}
+
+Api::Filesystem::IStreamPtr Stream::read(int& arg)
+{
+    return read_(arg);
+}
+
+Api::Filesystem::IStreamPtr Stream::read(double& arg)
+{
+    return read_(arg);
+}
+
+Api::Filesystem::IStreamPtr Stream::read(std::string& arg)
+{
+    return read_(arg);
+}
+
+char* Stream::getChars(std::size_t num)
+{
+    checkForReading();
+
+    std::size_t maxChars = num + 1;
+    DPL::ScopedArray<char> result;
+    Try {
+        result.Reset(new char[maxChars]);
+    }
+    Catch(std::bad_alloc) {
+        ThrowMsg(Commons::PlatformException, "Couldn't allocate output buffer.");
+    }
+    if (m_stream.get(result.Get(), maxChars).bad()) {
+        ThrowMsg(Commons::PlatformException,
+                 "Error while reading from the stream.");
+    }
+
+    return result.Release();
+}
+
+unsigned char* Stream::getBytes(std::size_t num)
+{
+    checkForReading();
+
+    DPL::ScopedArray<char> buffer;
+    Try {
+        buffer.Reset(new char[num]);
+    }
+    Catch(std::bad_alloc) {
+        ThrowMsg(Commons::PlatformException, "Couldn't allocate output buffer.");
+    }
+    if (m_stream.read(buffer.Get(), num).bad()) {
+        ThrowMsg(Commons::PlatformException,
+                 "Error while reading from the stream.");
+    }
+
+    return static_cast<unsigned char*>(static_cast<void*>(buffer.Release()));
+}
+
+std::size_t Stream::getCount() const
+{
+    if (!isOpen()) {
+        ThrowMsg(Commons::PlatformException, "Stream is closed.");
+    }
+
+    if (!isReadable()) {
+        ThrowMsg(Commons::PlatformException, "Stream is not readable.");
+    }
+
+    return m_stream.gcount();
+}
+
+std::string Stream::getLine()
+{
+    checkForReading();
+
+    std::string result;
+    if (!std::getline(m_stream, result)) {
+        ThrowMsg(Commons::PlatformException,
+                 "Error while reading from the stream.");
+    }
+
+    return result;
+}
+
+bool Stream::isOpen() const
+{
+    return m_stream.is_open();
+}
+
+bool Stream::isEof() const
+{
+    return m_stream.eof();
+}
+
+void Stream::close()
+{
+    if (isOpen()) {
+        m_stream.close();
+        m_parent->onStreamClose(SharedFromThis());
+    }
+}
+
+int Stream::getMode() const
+{
+    return m_mode;
+}
+
+long Stream::getPosition() const
+{
+    return static_cast<long>(m_stream.tellg());
+}
+
+void Stream::setPosition(long position)
+{
+    if (m_stream.rdstate() & std::ios_base::eofbit) {
+        m_stream.clear();
+    }
+    if (!(m_stream.seekg(position)) || !(m_stream.seekp(position))) {
+        ThrowMsg(PlatformException, "Could not set position.");
+    }
+}
+
+long Stream::getSize() const
+{
+    std::fstream::streampos pos = m_stream.tellg();
+    if (pos == -1) {
+        return -1;
+    }
+
+    if (!m_stream.seekg(0, std::_S_end)) {
+        return -1;
+    }
+
+    long result = m_stream.tellg();
+    m_stream.seekg(pos, std::_S_beg);
+
+    return (result == -1 ? result : result + 1);
+}
+
+template<typename T>
+Api::Filesystem::IStreamPtr Stream::write_(T arg)
+{
+    checkForWriting();
+
+    if (!(m_stream << arg)) {
+        LogError("Error while writing to the stream.");
+        ThrowMsg(Commons::PlatformException,
+                 "Error while writing to the stream.");
+    }
+    m_stream.flush();
+
+    return DPL::StaticPointerCast<IStream>(SharedFromThis());
+}
+
+template<typename T>
+Api::Filesystem::IStreamPtr Stream::read_(T& arg)
+{
+    checkForReading();
+
+    if (!(m_stream >> arg)) {
+        ThrowMsg(Commons::PlatformException,
+                 "Error while reading from the stream.");
+    }
+
+    return DPL::StaticPointerCast<IStream>(SharedFromThis());
+}
+
+bool Stream::isReadable() const
+{
+    return (m_mode & AM_READ);
+}
+
+bool Stream::isWriteable() const
+{
+    return ((m_mode & AM_WRITE) || (m_mode & AM_APPEND));
+}
+
+void Stream::checkForReading() const
+{
+    if (!isOpen()) {
+        ThrowMsg(Commons::PlatformException, "Stream is closed.");
+    }
+
+    if (isEof()) {
+        ThrowMsg(Commons::PlatformException, "Stream is marked as EOF.");
+    }
+
+    if (!isReadable()) {
+        ThrowMsg(Commons::PlatformException, "Stream is not readable.");
+    }
+}
+
+void Stream::checkForWriting() const
+{
+    if (!isOpen()) {
+        LogError("Stream is closed.");
+        ThrowMsg(Commons::PlatformException, "Stream is closed.");
+    }
+
+    if (!isWriteable()) {
+        LogError("Stream is not writeable.");
+        ThrowMsg(Commons::PlatformException, "Stream is not writeable.");
+    }
+}
+} // Filesystem
+} // Platform
+} // TizenApis
\ No newline at end of file
diff --git a/src/platform/Tizen/Filesystem/Stream.h b/src/platform/Tizen/Filesystem/Stream.h
new file mode 100755 (executable)
index 0000000..84cbf2a
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef TIZENAPIS_FILESYSTEM_STREAM_H_
+#define TIZENAPIS_FILESYSTEM_STREAM_H_
+
+#include <cstddef>
+#include <fstream>
+#include <dpl/shared_ptr.h>
+#include <dpl/enable_shared_from_this.h>
+#include <API/Filesystem/IStream.h>
+#include <API/Filesystem/Enums.h>
+#include <API/Filesystem/INode.h>
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+class Node;
+typedef DPL::SharedPtr<Node> NodePtr;
+
+class Stream : public Api::Filesystem::IStream,
+    public DPL::EnableSharedFromThis<Stream>
+{
+    friend class Node;
+
+  public:
+    ~Stream();
+
+    Api::Filesystem::IStreamPtr write(bool arg);
+    Api::Filesystem::IStreamPtr write(unsigned char arg);
+    Api::Filesystem::IStreamPtr write(char arg);
+    Api::Filesystem::IStreamPtr write(int arg);
+    Api::Filesystem::IStreamPtr write(double arg);
+    Api::Filesystem::IStreamPtr write(const std::string& arg);
+
+    Api::Filesystem::IStreamPtr read(bool& arg);
+    Api::Filesystem::IStreamPtr read(unsigned char& arg);
+    Api::Filesystem::IStreamPtr read(char& arg);
+    Api::Filesystem::IStreamPtr read(int& arg);
+    Api::Filesystem::IStreamPtr read(double& arg);
+    Api::Filesystem::IStreamPtr read(std::string& arg);
+
+    unsigned char* getBytes(std::size_t num);
+
+    std::size_t getCount() const;
+
+    char* getChars(std::size_t num);
+
+    std::string getLine();
+
+    bool isOpen() const;
+    bool isEof() const;
+
+    void close();
+
+    long getPosition() const;
+    void setPosition(long position);
+
+    int getMode() const;
+
+    long getSize() const;
+
+  private:
+    template<typename T>
+    Api::Filesystem::IStreamPtr read_(T& arg);
+    template<typename T>
+    Api::Filesystem::IStreamPtr write_(T arg);
+
+    inline bool isReadable() const;
+    inline bool isWriteable() const;
+    void checkForReading() const;
+    void checkForWriting() const;
+
+  private:
+    Stream(const NodePtr& parent,
+            int mode);
+
+  private:
+    NodePtr m_parent;
+    int m_mode;
+    mutable std::fstream m_stream;
+};
+
+typedef DPL::SharedPtr<Stream> StreamPtr;
+} // Filesystem
+} // Platform
+} // TizenApis
+
+#endif /* TIZENAPIS_FILESYSTEM_STREAM_H_ */
diff --git a/src/platform/Tizen/Filesystem/System.cpp b/src/platform/Tizen/Filesystem/System.cpp
new file mode 100755 (executable)
index 0000000..b17b1ad
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "System.h"
+#include <stdlib.h>
+#include <string.h>
+#include <dpl/scoped_free.h>
+#include <Commons/Exception.h>
+#include "Command.h"
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+void System::run(Command* cmd)
+{
+    cmd->execute();
+}
+}
+}
+}
diff --git a/src/platform/Tizen/Filesystem/System.h b/src/platform/Tizen/Filesystem/System.h
new file mode 100755 (executable)
index 0000000..7046238
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef TIZENAPIS_FILESYSTEM_SYSTEM_H_
+#define TIZENAPIS_FILESYSTEM_SYSTEM_H_
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+class Command;
+
+class System
+{
+  public:
+    static void run(Command* cmd);
+};
+}
+}
+}
+
+#endif
diff --git a/src/platform/Tizen/Filesystem/Utils.cpp b/src/platform/Tizen/Filesystem/Utils.cpp
new file mode 100755 (executable)
index 0000000..1047481
--- /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. 
+ */
+
+
+#include <sys/stat.h>
+#include <cerrno>
+#include <cstring>
+#include <cstdlib>
+#include <unistd.h>
+
+#include <Commons/Exception.h>
+#include "Utils.h"
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+namespace {
+int try_mkdir(const char* path,
+        mode_t mode)
+{
+    struct stat st;
+    int err = 0;
+
+    if (::stat(path, &st) != 0) {
+        if (::mkdir(path, mode) != 0) {
+            err = -1;
+        }
+    } else if (!S_ISDIR(st.st_mode)) {
+        errno = ENOTDIR;
+        err = -1;
+    }
+
+    return err;
+}
+
+int mkpath(const char* path,
+        mode_t mode)
+{
+    char* copy = ::strdup(path);
+    if (NULL == copy) {
+        return -1;
+    }
+
+    int err = 0;
+    char* ptr = copy;
+    char* slash = NULL;
+
+    while ((0 == err) && (NULL != (slash = ::strchr(ptr, '/')))) {
+        if (slash != ptr) {
+            *slash = '\0';
+            err = try_mkdir(copy, mode);
+            *slash = '/';
+        }
+        ptr = slash + 1;
+    }
+
+    if (0 == err) {
+        err = try_mkdir(path, mode);
+    }
+
+    ::free(copy);
+    return err;
+}
+}
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+bool nodeExists(const std::string& path)
+{
+    struct stat info;
+    if (stat(path.c_str(), &info) == 0) {
+        if (S_ISDIR(info.st_mode)) {
+            return true;
+        }
+    }
+    return false;
+}
+
+void makePath(const std::string& path,
+        mode_t mode)
+{
+    if (mkpath(path.c_str(), mode) == -1) {
+        ThrowMsg(Commons::PlatformException, "Couldn't create path: " << path);
+    }
+}
+}
+}
+}
diff --git a/src/platform/Tizen/Filesystem/Utils.h b/src/platform/Tizen/Filesystem/Utils.h
new file mode 100755 (executable)
index 0000000..7779c6a
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+
+#ifndef TIZENAPIS_FILESYSTEM_UTILS_H_
+#define TIZENAPIS_FILESYSTEM_UTILS_H_
+
+#include <sys/types.h>
+#include <string>
+
+namespace TizenApis {
+namespace Platform {
+namespace Filesystem {
+bool nodeExists(const std::string& path);
+
+void makePath(const std::string& path,
+        mode_t mode);
+}
+}
+}
+
+#endif
diff --git a/src/platform/Tizen/Filesystem/config.cmake b/src/platform/Tizen/Filesystem/config.cmake
new file mode 100755 (executable)
index 0000000..2bdbf8e
--- /dev/null
@@ -0,0 +1,31 @@
+get_current_path()
+
+pkg_search_module(capiappfw REQUIRED capi-appfw-application)
+pkg_search_module(pcrecpp REQUIRED libpcrecpp)
+
+set(INCLUDES_PLATFORM_IMPLEMENTATION_FILESYSTEM
+  ${capiappfw_INCLUDE_DIRS}
+  ${pcrecpp_INCLUDE_DIRS}
+  PARENT_SCOPE
+)
+
+set(LIBS_PLATFORM_IMPLEMENTATION_FILESYSTEM
+  ${capiappfw_LIBRARIES}
+  ${pcrecpp_LIBRARIES}
+  PARENT_SCOPE
+)
+
+set(SRCS_PLATFORM_IMPLEMENTATION_FILESYSTEM
+  ${CURRENT_PATH}/Manager.cpp
+  ${CURRENT_PATH}/Node.cpp
+  ${CURRENT_PATH}/Path.cpp
+  ${CURRENT_PATH}/Stream.cpp
+  ${CURRENT_PATH}/System.cpp
+  ${CURRENT_PATH}/NodeFilterMatcher.cpp
+  ${CURRENT_PATH}/Command.cpp
+  ${CURRENT_PATH}/CopyCommand.cpp
+  ${CURRENT_PATH}/MoveCommand.cpp
+  ${CURRENT_PATH}/RemoveCommand.cpp
+  ${CURRENT_PATH}/Utils.cpp
+  PARENT_SCOPE
+)
index b1cdd99..1ed0162 100755 (executable)
@@ -22,7 +22,7 @@
  * @brief
  */
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/Exception.h>
 #include <Filesystem/Manager.h>
 #include "Attachment.h"
@@ -88,7 +88,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
     {
         Api::Filesystem::IPathPtr currentPath = Api::Filesystem::IPath::create(
@@ -100,8 +100,9 @@ std::string Attachment::getRealPath(const std::string &path) const
         LogError("invalid path");
         ReThrow(WrtDeviceApis::Commons::InvalidArgumentException);
     }
-       
+#endif
 }
+
 }
 }
 }
index 9339e10..e33b361 100755 (executable)
@@ -24,7 +24,7 @@
  * @brief
  */
 #include "BinarySms.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 using namespace std;
 using namespace TizenApis::Api::Messaging;
@@ -87,6 +87,12 @@ void BinarySms::updateIsRead()
     //#warning "TODO"
 }
 
+void BinarySms::addMessageToDraft()
+{
+    //#warning "TODO"
+}
+
+
 int BinarySms::send()
 {
     //#warning "TODO"
index e5d0efc..b8d0214 100755 (executable)
@@ -59,6 +59,8 @@ class BinarySms :
 
     virtual void updateIsRead();       
 
+    virtual void addMessageToDraft();
+
     virtual int send();
 
     virtual void sendCancel(int handle);
index fabe932..3a85097 100755 (executable)
@@ -25,7 +25,7 @@
  */
 
 #include "CallbackMgr.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "ISendingObserver.h"
 #include "MsgServiceHandleMgr.h"
 
index a3b55df..a1deaa3 100755 (executable)
 * limitations under the License. 
 */
  
-/**
-* @file                 Conversation.cpp
-* @author       Kangsoo Lee (wpeter.lee@samsung.com)
-* @version      0.1
-*/
-
 
 #include "Conversation.h"
 #include <CommonsJavaScript/JSUtils.h>
 #include <Emf_Mapi_Message.h>
 #include <time.h>
 
-extern "C" {
-#include <MapiStorage.h>
-#include <MapiControl.h>
-#include <MsgMmsTypes.h>
-#include <MapiTransport.h>
-#include <MapiMessage.h>
-}
 
 using namespace DPL;
 
@@ -80,6 +67,177 @@ Conversation::Conversation(unsigned int threadIndex)
        makeConversationFromThreadIndex(threadIndex);
 }
 
+Conversation::Conversation(msg_thread_view_t msg_thread)
+{
+       makeConversationFromThread(msg_thread);
+}
+
+void Conversation::makeConversationFromThread(msg_thread_view_t msg_thread)
+{
+       LogDebug("Enter");
+       MSG_HANDLE_T handle = MsgGetCommonHandle();
+       MSG_LIST_S convViewList = {0, NULL};
+       msg_message_t msgForLastIndex = msg_new_message();
+       MSG_SENDINGOPT_S sendOpt = {0, };
+       MSG_ERROR_T err = MSG_SUCCESS;
+       unsigned int lastMsgIndex = 0;
+       char *tempString = NULL;
+       int addressCount = 0;
+       int index = 0;
+       
+       m_result = true;
+
+       try 
+       {
+               if (msg_thread_view_get_thread_id(msg_thread) >= 0)
+               {
+                       m_Id = msg_thread_view_get_thread_id(msg_thread);
+               }
+               
+               switch(msg_thread_view_get_message_type(msg_thread))
+               {
+                       case MSG_TYPE_SMS:
+                       case MSG_TYPE_SMS_CB:
+                       case MSG_TYPE_SMS_JAVACB:
+                       case MSG_TYPE_SMS_WAPPUSH:
+                       case MSG_TYPE_SMS_MWI:
+                       case MSG_TYPE_SMS_SYNCML:
+                       case MSG_TYPE_SMS_REJECT:
+                               m_type = Api::Messaging::SMS;
+                               LogDebug("Type:SMS");
+                               break;
+                       case MSG_TYPE_MMS:
+                       case MSG_TYPE_MMS_JAVA:
+                       case MSG_TYPE_MMS_NOTI:
+                               m_type = Api::Messaging::MMS;;
+                               LogDebug("Type:MMS");
+                               break;
+//                     default:
+                               // Todo email / chat
+               } 
+               
+               m_time = *(msg_thread_view_get_time(msg_thread));
+               m_unreadMessages = msg_thread_view_get_unread_cnt(msg_thread);
+               tempString = (char*)msg_thread_view_get_data(msg_thread);
+
+               if (tempString != NULL)
+               {
+                       m_preview = tempString; 
+                       LogDebug("preview" << m_preview);
+               }
+
+               
+               err = msg_get_conversation_view_list(handle, m_Id, &convViewList);
+               
+               if (err != MSG_SUCCESS)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get conversation(msg) view list fail");
+               }
+
+               lastMsgIndex = convViewList.nCount - 1;
+               m_messageCount = convViewList.nCount;
+               m_read = msg_is_read(convViewList.msgInfo[lastMsgIndex]);
+
+               if (msg_get_message_id(convViewList.msgInfo[lastMsgIndex]) >= 0 )
+               {
+                       m_lastMessageId = msg_get_message_id(convViewList.msgInfo[lastMsgIndex]);
+                       LogDebug("message id" << m_lastMessageId);
+               }
+               else
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get message id fail");
+               }
+
+               if (msg_get_message(handle, m_lastMessageId, msgForLastIndex, &sendOpt) != MSG_SUCCESS)
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get message fail");
+               }
+
+               LogDebug("lastMsgIndex:" << lastMsgIndex << ",message count:" << m_messageCount << ",read" << m_read);
+
+               if (msg_get_direction_info(msgForLastIndex) == MSG_DIRECTION_TYPE_MT)
+               {
+                       addressCount = msg_get_address_count(msgForLastIndex);
+
+                       if (addressCount > 0 && addressCount < MAX_TO_ADDRESS_CNT )
+                       {
+                               tempString = (char*)msg_get_ith_address(msgForLastIndex, 0);
+                               
+                               if (tempString != NULL)
+                               {
+                                       m_from = tempString;
+                               }
+                               else
+                               {
+                                       LogDebug("address is null ");
+                               }
+                       }
+                       else 
+                       {
+                               LogDebug("address count index fail");
+                       }
+                       LogDebug("from" << m_from);
+               }
+               else
+               {
+                       LogDebug("Msg direction: MO, from will be omitted");
+               }
+
+
+               tempString = (char*)msg_get_subject(msgForLastIndex);
+
+               if (tempString != NULL)
+               {
+                       m_subject = tempString;
+               }
+
+               LogDebug("subject" << m_subject);
+               
+
+               addressCount = msg_get_address_count(msgForLastIndex);
+
+
+               if (addressCount > 0 && addressCount < MAX_TO_ADDRESS_CNT )
+               {
+                       for (index = 0; index < addressCount; index++)
+                       {
+                               tempString = (char*)msg_get_ith_address(msgForLastIndex, index);
+
+                               if (tempString != NULL)
+                               {
+                                       m_to.push_back(tempString);
+                               }
+                       }
+                       LogDebug("address count" << addressCount);
+               }
+               else
+               {
+                       LogDebug("address fetch fail" << addressCount);
+               }
+
+
+
+       }
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               m_result = false;
+               LogError("Exception: " << ex.GetMessage());
+       }
+       
+       if (convViewList.msgInfo != NULL) 
+       {
+               msg_release_message_list(&convViewList);
+       }
+
+       if (msgForLastIndex != NULL)
+       {
+               msg_release_message(&msgForLastIndex);
+       }
+}
+
+
+
+// It is worth for below function to do test for fetching all conversations
 void Conversation::makeConversationFromThreadIndex(unsigned int threadIndex)
 {
        LogDebug("Enter");
@@ -161,16 +319,32 @@ void Conversation::makeConversationFromThreadIndex(unsigned int threadIndex)
 
                if (msg_get_direction_info(convViewList.msgInfo[lastMsgIndex]) == MSG_DIRECTION_TYPE_MT)
                {
-            tempString = (char*)msg_get_ith_address(convViewList.msgInfo[lastMsgIndex], 0);
+                       addressCount = msg_get_address_count(convViewList.msgInfo[lastMsgIndex]);
 
-                       if (tempString != NULL)
+                       if (addressCount > 0 && addressCount < MAX_TO_ADDRESS_CNT )
+                       {
+                   tempString = (char*)msg_get_ith_address(convViewList.msgInfo[lastMsgIndex], 0);
+                               
+                               if (tempString != NULL)
+                               {
+                                       m_from = tempString;
+                               }
+                               else
+                               {
+                                       LogDebug("address is null ");
+                               }
+                       }
+                       else 
                        {
-                               m_from = tempString;
+                               LogDebug("address count index fail");
                        }
+                       LogDebug("from" << m_from);
+               }
+               else
+               {
+                       LogDebug("Msg direction: MO, from will be omitted");
                }
 
-               LogDebug("from" << m_from);
-               
 
                tempString = (char*)msg_get_subject(convViewList.msgInfo[lastMsgIndex]);
 
index d3f435d..3380bc3 100755 (executable)
 * limitations under the License. 
 */
  
-/**
-* @file                 Conversation.h
-* @author       Kangsoo Lee (wpeter.lee@samsung.com)
-* @version      0.1
-*/
 
 #ifndef CONVERSATION_H
 #define CONVERSATION_H
 #include <vector>
 #include <API/Messaging/IConversation.h>
 
+extern "C" {
+#include <MapiStorage.h>
+#include <MapiControl.h>
+#include <MsgMmsTypes.h>
+#include <MapiTransport.h>
+#include <MapiMessage.h>
+}
+
 namespace TizenApis {
 namespace Platform {
 namespace Messaging {
@@ -39,8 +42,9 @@ class Conversation : public Api::Messaging::IConversation
 public:        
        Conversation();
        Conversation(unsigned int threadId, Api::Messaging::MessageType msgType);
-       Conversation(unsigned int threadIndex);
+       Conversation(unsigned int threadIndex); // msg thread with index of all thread view for test
        Conversation(std::string msgId, Api::Messaging::MessageType msgType);
+       Conversation(msg_thread_view_t msg_thread); // msg thread with thread data
 
        ~Conversation();
 
@@ -61,6 +65,7 @@ public:
        bool getResult();
        bool makeConversationFromMsgId(unsigned int msgId, Api::Messaging::MessageType msgType);
        void makeConversationFromThreadIndex(unsigned int threadIndex);
+       void makeConversationFromThread(msg_thread_view_t msg_thread);
        bool makeConversationFromEmailThreadId(unsigned int emailTreadId);
 #if 0  
        // setter
index 5b95434..f7f0214 100755 (executable)
@@ -23,7 +23,7 @@
 #include "ConversationQueryGenerator.h"
 #include "API/Messaging/ConversationFilterValidatorFactory.h"
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <API/Messaging/log.h>
 
 namespace TizenApis {
index b47cf63..a40b319 100755 (executable)
@@ -29,7 +29,7 @@
 #include <ctime>
 #include <emf-types.h>
 #include <Emf_Mapi.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/assert.h>
 #include <dpl/scoped_fclose.h>
 #include <dpl/scoped_ptr.h>
@@ -46,9 +46,7 @@
 #include "MailSync.h"
 #include "MessagingService.h"
 #include "MessagingServiceManager.h"
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
 #include "Attachment.h"
-#endif
 
 #define LOG_ENTER LogDebug("---> ENTER");
 #define LOG_EXIT LogDebug("---> EXIT");
@@ -75,14 +73,12 @@ const char* DEFAULT_FOLDER_NAME = EMF_DRAFTBOX_NAME;
 }
 #endif
 
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
 namespace {
 const char* TEMP_FOLDER = "/tmp";
 const char* COMMAND_NAME = "/bin/cp";
 const char* COMMAND_SWITCH_RECURSIVE = "-r";
 const char* COMMAND_SWITCH_FORCE = "-f";
 }
-#endif
 
 Email::Email(const string& id) :
        IMessage(EMAIL, id) {
@@ -97,7 +93,6 @@ Email::Email(const string& id) :
 
                //get account ID
                
-               
                reload();
        } catch (const WrtDeviceApis::Commons::PlatformException& ex) {
                LogError("Exception: " << ex.DumpToString());
@@ -190,16 +185,14 @@ void Email::downloadBodyCancel( int handle)
        return ;
 }
 
-#if 0// MESSAGING ATTACHMENT IS BLOCKED
-void Email::downloadAttachment( const Api::Messaging::IAttachmentPtr& attachment)
+int Email::downloadAttachment( const Api::Messaging::IAttachmentPtr& attachment)
 {
        LOG_ENTER
 
-       MailSync::getInstance().downloadAttachment( Api::Messaging::MessageFactory::convertToEmail(SharedFromThis()), attachment );
+       return MailSync::getInstance().downloadAttachment( Api::Messaging::MessageFactory::convertToEmail(SharedFromThis()), attachment );
        
        LOG_EXIT
 }
-#endif
 
 void Email::update(bool draftsOnly)
 {
@@ -217,9 +210,7 @@ void Email::update(bool draftsOnly)
         updateSubject();
         updateRecipients();
         updateFrom();
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
         updateAttachments();
-#endif
         updatePriority();
     } else {
         LogWarning("Updating only read status. Folder: " << getCurrentFolder());
@@ -470,7 +461,7 @@ void Email::readBody() {
                fread(data.Get(), 1, size, file.Get());
                setHtmlBody(data.Get()); //setHtmlBody declarate in Email Calss.
        }
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
+       
        if (m_mail->body->attachment && m_mail->body->attachment_num > 0) {
                LogDebug("reading attachments , attahcment count = " << m_mail->body->attachment_num);
                emf_attachment_info_t* attach = m_mail->body->attachment;
@@ -497,50 +488,7 @@ void Email::readBody() {
                                        appendAttachment(tmpAtt);
                                        LogError(" append complete");
                                }
-                               
-#if 0
-                               if( (attach->name != NULL && !attach->downloaded))
-                               {
-
-                               }
-                               else if (attach->savename != NULL)
-                               {
-                                       tmpAtt = appendAttachment(attach->savename, false);
-                               }
-
-                               
-
-                               
-                               IAttachmentPtr tmpAtt;
-                               if( (attach->name != NULL && !attach->downloaded))
-                               {
-                                       IAttachmentPtr tAtt(new Attachment(attach));                                                    
-                                       appendAttachment(tmpAtt);
-                                       tmpAtt = tAtt;
-                               }
-                               else if (attach->savename != NULL)
-                               {
-                                       tmpAtt = appendAttachment(attach->savename, false);
-                               }
-
-                               /*
-                               if(attach->savename != NULL){
-                                       tmpAtt = appendAttachment(attach->savename, false);
-                               
-                               }
-                               */
-                               if (tmpAtt)
-                               {
-                                       //tmpAtt->setMessage(IMessagePtr(this));                                //set IMessagePtr
-                                       //IMessagePtr msg = DPL::DynamicPointerCast<IMessage>(this);
-                                       tmpAtt->setMessage(SharedFromThis());                                                                   //set IMessagePtr
-                                       tmpAtt->rename(attach->name);
-                                       tmpAtt->setAttachmentID(attach->attachment_id);
-                                       tmpAtt->setDownloaded(attach->downloaded);
-                               }
-                       
-#endif
-                               
+                                                               
                                attach = attach->next;
                }
                catch (const WrtDeviceApis::Commons::Exception& ex) {
@@ -549,7 +497,7 @@ void Email::readBody() {
                        }
                }
        }
-#endif 
+
        LOG_EXIT
 }
 
@@ -685,6 +633,27 @@ void Email::updateIsRead()
     LOG_EXIT
 }
 
+void Email::addMessageToDraft()
+{
+    LOG_ENTER
+
+    DPL::Mutex::ScopedLock mx(&m_updateMutex);
+
+    if (!m_mail) {
+        ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Mail is NULL.");
+    }
+
+    updateBody();
+    updateSubject();
+    updateRecipients();
+    updateFrom();
+    updatePriority();
+
+    int error = email_update_message(getIntId(), m_mail.Get());        
+    LogDebug("add finished, mailId = " << error);              
+    LOG_EXIT
+}
+
 void Email::updateRecipients()
 {
     LOG_ENTER
@@ -752,7 +721,6 @@ void Email::updateFrom()
     LOG_EXIT
 }
 
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
 void Email::updateAttachments()
 {
     LOG_ENTER
@@ -882,7 +850,6 @@ void Email::updateAttachments()
 
     LOG_EXIT
 }
-#endif
 
 void Email::updatePriority()
 {
index babc3ce..b9ee5f1 100755 (executable)
@@ -75,9 +75,8 @@ class Email : public Api::Messaging::IEmail
        virtual int downloadBody();
 
        virtual void downloadBodyCancel( int handle );
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
-       virtual void downloadAttachment(const Api::Messaging::IAttachmentPtr& attachment);
-#endif
+
+       virtual int downloadAttachment(const Api::Messaging::IAttachmentPtr& attachment);
 
     // implementation of interface of IMessage class
     virtual void update(bool draftsOnly = false);
@@ -118,15 +117,17 @@ class Email : public Api::Messaging::IEmail
     void updateRecipients();
 
     void updateFrom();
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
+       
     void updateAttachments();
-#endif
+
     void updateSubject();
 
     void updateReadStatus();
 
     void updateIsRead();
        
+    void addMessageToDraft();
+       
     void updatePriority();
 
     int getIntId() const;
index eb2baf6..2559123 100755 (executable)
@@ -17,7 +17,7 @@
 /**
  * @author          Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
  */
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <Commons/Exception.h>
 
index 5655126..0efab2f 100644 (file)
@@ -30,7 +30,7 @@
 
 #include <emf-types.h>
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 using namespace std;
 using namespace TizenApis::Api::Tizen;
index e4132e8..d882ec1 100755 (executable)
@@ -24,7 +24,7 @@
 #include <Emf_Mapi_Init.h>
 #include <Emf_Mapi_Account.h>
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/assert.h>
 #include <Commons/Exception.h>
 #include <Commons/ThreadPool.h>
index 48c6ece..b564759 100755 (executable)
@@ -11,7 +11,7 @@
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
-* limitations under the License. 
+* limitations under the License.
 */
 
 /**
@@ -22,7 +22,7 @@
 #define MAILSENDER_H_
 
 #include <map>
-#include <dpl/event_listener.h>
+#include <dpl/event/event_listener.h>
 #include <dpl/thread.h>
 #include <dpl/scoped_ptr.h>
 #include <DBus/Connection.h>
@@ -34,7 +34,7 @@ namespace Platform {
 namespace Messaging {
 
 // TODO Not thread-safe, make it.
-class MailSender : private DPL::EventListener<DBus::MessageEvent>
+class MailSender : private DPL::Event::EventListener<DBus::MessageEvent>
 {
   public:
     static MailSender& getInstance();
index 2050442..5d559e2 100755 (executable)
 #include <Emf_Mapi_Init.h>
 #include <Emf_Mapi_Account.h>
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/assert.h>
 #include <Commons/Exception.h>
 #include <Commons/ThreadPool.h>
 #include <API/Messaging/ReqReceiverMessage.h>
 #include <API/Messaging/EventMessagingService.h>
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
 #include <API/Messaging/IAttachment.h>
-#endif
 
 #include "MailSync.h"
 #include "SyncNetworkStatus.h"
@@ -165,8 +163,7 @@ void MailSync::cancelDownloadBody(int handle)
        
 }
 
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
-void MailSync::downloadAttachment(const Api::Messaging::IEmailPtr& mail, const Api::Messaging::IAttachmentPtr& attachment)
+int MailSync::downloadAttachment(const Api::Messaging::IEmailPtr& mail, const Api::Messaging::IAttachmentPtr& attachment)
 {      
        if ( mail && attachment )
        {       
@@ -184,10 +181,10 @@ void MailSync::downloadAttachment(const Api::Messaging::IEmailPtr& mail, const A
                        }
                }
        }
-       downloadAttachmentInternal(mail, mail->getAccountID(), attachment);
+
+       return downloadAttachmentInternal(mail, mail->getAccountID(), attachment);
 
 }
-#endif
 
 int MailSync::syncAccount(const Api::Messaging::IMessagingServicePtr& messagingService, const int limit)
 {
@@ -369,11 +366,10 @@ void MailSync::OnEventReceived(const DBus::MessageEvent& event)
 {
     LogDebug("OnEventReceived");
     SyncNetworkStatusPtr syncNetworkStatus(new SyncNetworkStatus(event.GetArg0()));
-//    int mailId = syncNetworkStatus->getMailId();     //if email body download mode.
+    int mailId = syncNetworkStatus->getMailId();       //if email body download mode.
     int status = syncNetworkStatus->getStatus();
     int handle = syncNetworkStatus->getHandle();
 
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED       
        // if Attachment Load
        if ( status == NOTI_DOWNLOAD_ATTACH_FINISH ||
        status == NOTI_DOWNLOAD_ATTACH_FAIL )
@@ -444,7 +440,6 @@ void MailSync::OnEventReceived(const DBus::MessageEvent& event)
                LogDebug("DownLoading... attachment : size = " << syncNetworkStatus->getErrorCode());
                return;
        }
-#endif
 
     SyncRequestIterator it = m_SyncRequests.find(handle);
     if ( m_SyncRequests.end() != it)
@@ -555,12 +550,18 @@ int MailSync::downloadBodyInternal( const Api::Messaging::IEmailPtr& mail, int a
        int err = 0;
        int mailId = mail->convertId(mail->getIdRef());
        unsigned int emf_handle = 0;
+
+
+       LogDebug("folder type = " << mail->getCurrentFolder());
        
        emf_mailbox_t mailbox;
        memset(&mailbox, 0, sizeof(emf_mailbox_t));
+
+       mailbox.name = strdup("INBOX");
+       
        mailbox.account_id = account_id;        //set account id.       
-       LogDebug("mailbox.account_id " << mailbox.account_id );
-       err = email_download_body(&mailbox, mailId,0, &emf_handle);
+       LogDebug("mailbox.account_id " << mailbox.account_id << " mailId : " << mailId);
+       err = email_download_body(&mailbox, mailId, 0, &emf_handle);
        
        if (err != EMF_ERROR_NONE) {
                LogDebug("fail to downloadBody - err : " << err);
@@ -578,8 +579,7 @@ int MailSync::downloadBodyInternal( const Api::Messaging::IEmailPtr& mail, int a
 
 }
 
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
-void MailSync::downloadAttachmentInternal(const Api::Messaging::IEmailPtr& mail, int account_id, const Api::Messaging::IAttachmentPtr& attachment)
+int MailSync::downloadAttachmentInternal(const Api::Messaging::IEmailPtr& mail, int account_id, const Api::Messaging::IAttachmentPtr& attachment)
 {
        LogDebug("downloadAttachmentInternal");
 
@@ -633,9 +633,10 @@ void MailSync::downloadAttachmentInternal(const Api::Messaging::IEmailPtr& mail,
                        MESSAGING_SERVICE_SYNC_TYPE_DOWNLOAD_ATTACHMENT, mail, attachment );
                m_SyncRequests.insert(std::make_pair(emf_handle, data));
        }
+
+       return emf_handle;
        
 }
-#endif
 
 void MailSync::cancelEmailJobInternal(int accountId, int handle)
 {
index 96a8e37..3ec8501 100755 (executable)
 #define MAILSYNC_H_
 
 #include <map>
-#include <dpl/event_listener.h>
+#include <dpl/event/event_listener.h>
 #include <dpl/thread.h>
 #include <dpl/scoped_ptr.h>
 #include <DBus/Connection.h>
 #include <DBus/MessageEvent.h>
 #include <API/Messaging/IEmail.h>
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
 #include <API/Messaging/IAttachment.h>
-#endif
 #include <API/Messaging/IMessagingService.h>
 #include <API/Messaging/IMessageFolder.h>
 
@@ -48,7 +46,7 @@ enum MessagingServiceSyncType
        MESSAGING_SERVICE_SYNC_TYPE_COUNT,
 };
 
-class MailSync : private DPL::EventListener<DBus::MessageEvent>
+class MailSync : private DPL::Event::EventListener<DBus::MessageEvent>
 {
        public :
                static MailSync& getInstance();
@@ -56,10 +54,8 @@ class MailSync : private DPL::EventListener<DBus::MessageEvent>
        public :
                int downloadBody(const Api::Messaging::IEmailPtr& mail);        //downloadBody
                void cancelDownloadBody(int handle);
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED               
-               void downloadAttachment(const Api::Messaging::IEmailPtr& mail, const Api::Messaging::IAttachmentPtr& attachment);
-               void cancelDownloadAttachment(int AttachmentId );
-#endif
+               int downloadAttachment(const Api::Messaging::IEmailPtr& mail, const Api::Messaging::IAttachmentPtr& attachment);
+               void cancelDownloadAttachment(int AttachmentId);
                int syncAccount(const Api::Messaging::IMessagingServicePtr& messagingService, const int limit);
                void syncAccountCancel(const int handle);
                int syncFolder(const Api::Messaging::IMessagingServicePtr& messagingService, const std::string& folderName, const int limit);
@@ -87,9 +83,7 @@ class MailSync : private DPL::EventListener<DBus::MessageEvent>
                        unsigned int handle;
                        int syncType;
                        Api::Messaging::IEmailPtr mail;                                 //mail
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
                        Api::Messaging::IAttachmentPtr attachment;              //attachment
-#endif
                        Api::Messaging::IMessagingServicePtr messagingService; //MessagingService
                        std::string folderName;         //Folder
                                                        //Type
@@ -98,17 +92,13 @@ class MailSync : private DPL::EventListener<DBus::MessageEvent>
                                        unsigned int handle,
                                        int syncType, 
                                        const Api::Messaging::IEmailPtr& mail,
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
                                        const Api::Messaging::IAttachmentPtr& attachment, 
-#endif
                                        const Api::Messaging::IMessagingServicePtr& messagingService,
                                        std::string& folderName) :
                                handle(handle),
                                syncType(syncType),
                                mail(mail),
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
                                attachment(attachment),
-#endif
                                messagingService(messagingService),
                                folderName(folderName)                          
                        {
@@ -146,7 +136,6 @@ class MailSync : private DPL::EventListener<DBus::MessageEvent>
                                mail(mail)                      
                        {
                        }
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
                        explicit SyncRequestData (
                                        unsigned int handel,
                                        int syncType,
@@ -159,7 +148,7 @@ class MailSync : private DPL::EventListener<DBus::MessageEvent>
                                attachment(attachment)
                        {
                        }
-#endif
+
                };
 
                typedef std::map<int, SyncRequestData> SyncRequests;
@@ -172,13 +161,12 @@ class MailSync : private DPL::EventListener<DBus::MessageEvent>
        int syncAccountInternal(const Api::Messaging::IMessagingServicePtr& messagingService, const int limit);
        int syncFolderInternal(const Api::Messaging::IMessagingServicePtr& messagingService, const std::string& folderName, const int limit);
        int downloadBodyInternal( const Api::Messaging::IEmailPtr& mail, int account_id );
+       int downloadAttachmentInternal(const Api::Messaging::IEmailPtr& mail, int account_id, const Api::Messaging::IAttachmentPtr& attachment );
        
        void cancelEmailJobInternal(int accountId, int handle);
-       
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
-       void downloadAttachmentInternal(const Api::Messaging::IEmailPtr& mail, int account_id, const Api::Messaging::IAttachmentPtr& attachment );
-       void cancelDownloadAttachmentInternal( const SyncAttachmentDownloadRequests& data );    
-#endif 
+
+       //void cancelDownloadAttachmentInternal( const SyncAttachmentDownloadRequests& data );  
+
        private:
                DPL::ScopedPtr<DPL::Thread> m_dbusThread;
                DBus::ConnectionPtr m_dbus;
index 63e53ef..f7eab61 100755 (executable)
 * limitations under the License. 
 */
 
-/**
-* @file                 EmailFolder.cpp
-* @author       Oy Kwon (sirot.kwon@samsung.com)
-* @version      0.1
-*/
-
 
 #include "MessageFolder.h"
 #include <CommonsJavaScript/JSUtils.h>
index 7a645fd..05f4112 100755 (executable)
 * limitations under the License. 
 */
  
- /**
- * @file               MessageFolder.h
- * @author     Oy Kwon (sirot.kwon@samsung.com)
- * @version    0.1
- */
-
 #ifndef MESSAGEFOLDER_H
 #define MESSAGEFOLDER_H
 
index 39cbb73..0682c79 100755 (executable)
@@ -30,7 +30,7 @@
 
 #include <emf-types.h>
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 using namespace std;
 using namespace TizenApis::Api::Tizen;
@@ -581,11 +581,11 @@ namespace TizenApis {
 
                        int retMessageType = -1;
 
-                       if(stringType.compare("SMS") ==0){
+                       if(stringType.compare("tizen.sms") ==0){
                                retMessageType = Api::Messaging::SMS;
-                       }else if(stringType.compare("MMS") ==0){
+                       }else if(stringType.compare("tizen.mms") ==0){
                                retMessageType = Api::Messaging::MMS;
-                       }else if(stringType.compare("EMAIL") ==0){
+                       }else if(stringType.compare("tizen.email") ==0){
                                retMessageType = Api::Messaging::EMAIL;
                        }else{
                                MsgLogError("invalid type:[" << stringType << "]");
index 7727097..9dbe3e3 100755 (executable)
@@ -28,7 +28,7 @@
 
 #include <Commons/Exception.h>
 #include <Commons/StringUtils.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/scoped_free.h>
 #include "Messaging.h"
 #include "Sms.h"
@@ -344,7 +344,9 @@ std::string Messaging::generateFilterSql(const Api::Tizen::FilterPtr& filter){
                        LogDebug("Empty...");
                }       else    {
                        for (int i = 0; i < threadViewList.nCount; i++)         {
-                               Api::Messaging::IConversationPtr convPtr(new Conversation(i));
+//                             Api::Messaging::IConversationPtr convPtr(new Conversation(i));
+                               Api::Messaging::IConversationPtr convPtr(new Conversation(threadViewList.msgThreadInfo[i]));
+
                                recVec.push_back(convPtr);
                        }
                }
@@ -1152,11 +1154,11 @@ void Messaging::OnEventReceived(const DBus::MessageEvent& event)
                     folder) {
                     IEmailPtr email = MessageFactory::convertToEmail(msg);
                     jsEvent->setMessage(msg);
-                    if(m_onMessageReceived.size() == 1){
+                    if(m_onMessageReceived.size() > 0){
                     m_onMessageReceived.emit(jsEvent);
                     }
 
-                    if(m_onConversationReceived.size() == 1){
+                    if(m_onConversationReceived.size() > 0){
                     m_onConversationReceived.emit(jsEvent);
                     }
 
@@ -1189,10 +1191,10 @@ void Messaging::OnEventReceived(const DBus::MessageEvent& event)
                                if (true) { // if (OUTBOX != folder && SENTBOX != folder && DRAFTBOX != folder)
                                    IEmailPtr email = MessageFactory::convertToEmail(msg);
                                    jsEvent->setMessage(msg);
-                                   if(m_onMessageReceived.size() == 1){
+                                   if(m_onMessageReceived.size() > 0){
                                            m_onMessageReceived.emit(jsEvent);
                                    }
-                                   if(m_onConversationReceived.size() == 1){
+                                   if(m_onConversationReceived.size() > 0){
                                        m_onConversationReceived.emit(jsEvent);
                                    }
                                } else {
@@ -1217,9 +1219,9 @@ void Messaging::OnEventReceived(const DBus::MessageEvent& event)
                 if (true) { // if (OUTBOX != folder && SENTBOX != folder && DRAFTBOX != folder)
                     IEmailPtr email = MessageFactory::convertToEmail(msg);
                     jsEvent->setMessage(msg);
-                    if(m_onMessageReceived.size() == 1)
+                    if(m_onMessageReceived.size() > 0)
                        m_onMessageReceived.emit(jsEvent);
-                    if(m_onConversationReceived.size() == 1)
+                    if(m_onConversationReceived.size() > 0)
                     m_onConversationReceived.emit(jsEvent);
                 } else {
                     LogWarning(
@@ -1237,8 +1239,10 @@ void Messaging::OnEventReceived(const DBus::MessageEvent& event)
                 Api::Messaging::IMessageFolderPtr folderPtr(new MessageFolder(m_mailboxes));
                 jsEvent->setMessageFolder(folderPtr);
                 jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);
-                               
+               if(m_onFolderReceived.size() > 0)
+               {               
                 m_onFolderReceived.emit(jsEvent);
+               }
 
             }
             else if (NOTI_MAILBOX_UPDATE == status) 
@@ -1253,7 +1257,11 @@ void Messaging::OnEventReceived(const DBus::MessageEvent& event)
                 jsEvent->setMessageFolder(folderPtr);
                 jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);
                                
+               if(m_onFolderReceived.size() > 0)
+               {               
                 m_onFolderReceived.emit(jsEvent);
+               }
+
 
             }
             else if (NOTI_MAILBOX_DELETE == status) 
@@ -1268,7 +1276,10 @@ void Messaging::OnEventReceived(const DBus::MessageEvent& event)
                 jsEvent->setMessageFolder(folderPtr);
                 jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
                                
+               if(m_onFolderReceived.size() > 0)
+               {               
                 m_onFolderReceived.emit(jsEvent);
+               }
 
             }
             else 
@@ -1283,10 +1294,29 @@ void Messaging::OnEventReceived(const DBus::MessageEvent& event)
 
 void Messaging::onMessageStorageChanged(MSG_HANDLE_T handle,
         MSG_STORAGE_CHANGE_TYPE_T storageChangeType,
-        msg_message_t msg,
+        MSG_MSGID_LIST_S *pMsgIdList,
         void* data)
 {
+
     LogDebug("ENTER");
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       msg_message_t msg = msg_new_message();
+       MSG_SENDINGOPT_S sendOpt = {0, };
+
+       err = msg_get_message(handle, *pMsgIdList->msgIdList, msg, &sendOpt);
+
+    LogDebug("err" << err);    
+       
+
+       if (err != MSG_SUCCESS)
+       {
+               LogDebug("Get Message Failed!");
+               msg_release_message(&msg);
+               return;
+       }
+       
     Messaging* this_ = static_cast<Messaging*>(data);
     if (this_) {
         Try {
@@ -1301,32 +1331,32 @@ void Messaging::onMessageStorageChanged(MSG_HANDLE_T handle,
                                           msg_get_message_id(
                                           msg));
                     ISmsPtr sms = MessageFactory::convertToSms(message);
-                    IConversationPtr conversation(new Conversation(message->getId(), SMS));                            
+                    IConversationPtr conversation(new Conversation(message->getId(), SMS));
                     EventMessageReceivedPtr event(new EventMessageReceived());
                     event->setMessage(message);
                     event->setConversation(conversation);
-                               
+
                     if(storageChangeType == MSG_STORAGE_CHANGE_INSERT)
                     {
-                        event->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);                     
+                        event->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);
                     }
                     else if(storageChangeType == MSG_STORAGE_CHANGE_UPDATE)
                     {
-                        event->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);                   
+                        event->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);
                     }
                     else if(storageChangeType == MSG_STORAGE_CHANGE_DELETE)
                     {
-                        event->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);                   
+                        event->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
                     }
-                    else if(storageChangeType == MSG_STORAGE_CHANGE_MULTIPLE)
+                    else if(storageChangeType == MSG_STORAGE_CHANGE_CONTACT)
                     {
-                        event->setMsg_Event_Type(EventMessageReceived::MSG_MULTIPLE);                  
+                        event->setMsg_Event_Type(EventMessageReceived::MSG_MULTIPLE);
                     }
 
-                    if(this_->m_onMessageReceived.size() == 1){
+                    if(this_->m_onMessageReceived.size() > 0){
                        this_->m_onMessageReceived.emit(event);
                     }
-                    if(this_->m_onConversationReceived.size() == 1){
+                    if(this_->m_onConversationReceived.size() > 0){
                     this_->m_onConversationReceived.emit(event);
                     }
                 }
@@ -1344,38 +1374,38 @@ void Messaging::onMessageStorageChanged(MSG_HANDLE_T handle,
                                           msg_get_message_id(
                                           msg));
                                        IMmsPtr mms = MessageFactory::convertToMms(message);
-                    IConversationPtr conversation(new Conversation(message->getId(), MMS));                                                                    
+                    IConversationPtr conversation(new Conversation(message->getId(), MMS));
                                        EventMessageReceivedPtr event(new EventMessageReceived());
                                        event->setMessage(message);
                     event->setConversation(conversation);
-                    
+
                     if(storageChangeType == MSG_STORAGE_CHANGE_INSERT)
                     {
-                        event->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);                     
+                        event->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);
                     }
                     else if(storageChangeType == MSG_STORAGE_CHANGE_UPDATE)
                     {
-                        event->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);                   
+                        event->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);
                     }
                     else if(storageChangeType == MSG_STORAGE_CHANGE_DELETE)
                     {
-                        event->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);                   
+                        event->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
                     }
-                    else if(storageChangeType == MSG_STORAGE_CHANGE_MULTIPLE)
+                    else if(storageChangeType == MSG_STORAGE_CHANGE_CONTACT)
                     {
-                        event->setMsg_Event_Type(EventMessageReceived::MSG_MULTIPLE);                  
+                       event->setMsg_Event_Type(EventMessageReceived::MSG_MULTIPLE);
                     }
-                    if(this_->m_onMessageReceived.size() == 1){
+                    if(this_->m_onMessageReceived.size() > 0){
                        this_->m_onMessageReceived.emit(event);
                     }
-                    if(this_->m_onConversationReceived.size() == 1){
+                    if(this_->m_onConversationReceived.size() > 0){
                         this_->m_onConversationReceived.emit(event);
                     }
                 }
                 else
                 {
                                LogError("Ignore this mms, this is mms noti.");
-                       }
+               }
 
             }
         }
@@ -1873,7 +1903,7 @@ vector<Api::Messaging::IMessagePtr> Messaging::findEmail(const std::string &fold
 
 
             if (!filter
-//                     || filter->compare(MessageFactory::convertToEmail(msg))         //TODO implemnet compare in filter sangtai.kim
+//                     || filter->compare(MessageFactory::convertToEmail(msg))         //TODO implemnet compare in filter
                        ) {
                 retVal.push_back(msg);
             }
@@ -1933,7 +1963,7 @@ vector<Api::Messaging::IMessagePtr> Messaging::findEmail(Api::Messaging::FolderT
             Api::Messaging::IMessagePtr msg =
                 MessageFactory::createMessage(EMAIL, messages[i].mail_id);
             if (!filter
-//                     ||filter->compare(MessageFactory::convertToEmail(msg))          //TODO implement compare in filter sangtai.kim
+//                     ||filter->compare(MessageFactory::convertToEmail(msg))          //TODO implement compare in filter 
                 ) {
                 result.push_back(msg);
             }
index d06d60d..1106dee 100755 (executable)
@@ -11,7 +11,7 @@
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
-* limitations under the License. 
+* limitations under the License.
 */
 
 
@@ -34,7 +34,7 @@ extern "C" {
 #include <MsgTypes.h>
 #include <MsgStorageTypes.h>
 }
-#include <dpl/event_listener.h>
+#include <dpl/event/event_listener.h>
 #include <API/Messaging/IMessaging.h>
 #include <API/Messaging/IMessage.h>
 #include <API/Messaging/EmailAccountInfo.h>
@@ -54,7 +54,7 @@ namespace Platform {
 namespace Messaging {
 
 class Messaging : public Api::Messaging::IMessaging,
-    private DPL::EventListener<DBus::MessageEvent>
+    private DPL::Event::EventListener<DBus::MessageEvent>
 {
   public:
     static Messaging& getInstance();
@@ -111,18 +111,18 @@ class Messaging : public Api::Messaging::IMessaging,
 
     void addOnMessageReceived(const Api::Messaging::EmitterConversationReceivedPtr& emitter, const Api::Tizen::FilterPtr& filter, const int funtionIndex);
 
-    void addOnMessageReceived(const Api::Messaging::EmitterFolderReceivedPtr& emitter, const Api::Tizen::FilterPtr& filter, const int funtionIndex);   
+    void addOnMessageReceived(const Api::Messaging::EmitterFolderReceivedPtr& emitter, const Api::Tizen::FilterPtr& filter, const int funtionIndex);
 
-    bool validateFilter(const Api::Tizen::FilterPtr& filter, const int funtionIndex);  
+    bool validateFilter(const Api::Tizen::FilterPtr& filter, const int funtionIndex);
 
     void removeOnMessageMsgReceived(Api::Messaging::EmitterMessageReceived::IdType id);
 
     void removeOnMessageConvReceived(Api::Messaging::EmitterConversationReceived::IdType id);
 
-    void removeOnMessageFolderReceived(Api::Messaging::EmitterFolderReceived::IdType id);      
+    void removeOnMessageFolderReceived(Api::Messaging::EmitterFolderReceived::IdType id);
 
     std::vector<Api::Messaging::IConversationPtr> queryConversations(const Api::Tizen::SortModePtr& sortMode, const Api::Tizen::FilterPtr& filter, long limit=0, long offset=0);
-       
+
     bool deleteConversations(const Api::Tizen::SortModePtr& sortMode, const Api::Tizen::FilterPtr& filter);
 
     bool deleteConversations(const std::vector<Api::Messaging::IConversationPtr>& conversations);
@@ -155,14 +155,14 @@ class Messaging : public Api::Messaging::IMessaging,
   private:
     typedef WrtDeviceApis::Commons::Emitters<Api::Messaging::EmitterMessageReceived> EmittersMessageReceived;
     typedef WrtDeviceApis::Commons::Emitters<Api::Messaging::EmitterConversationReceived> EmittersConversationReceived;
-    typedef WrtDeviceApis::Commons::Emitters<Api::Messaging::EmitterFolderReceived> EmittersFolderReceived;    
+    typedef WrtDeviceApis::Commons::Emitters<Api::Messaging::EmitterFolderReceived> EmittersFolderReceived;
 
   private:
     Messaging();
 
     static void onMessageStorageChanged(MSG_HANDLE_T handle,
             MSG_STORAGE_CHANGE_TYPE_T storageChangeType,
-            msg_message_t msg,
+            MSG_MSGID_LIST_S *pMsgIdList,
             void* data);
 
     static void onSmsReceived(MSG_HANDLE_T handle,
@@ -227,7 +227,7 @@ class Messaging : public Api::Messaging::IMessaging,
   private:
     EmittersMessageReceived m_onMessageReceived;
     EmittersConversationReceived m_onConversationReceived;
-    EmittersFolderReceived m_onFolderReceived; 
+    EmittersFolderReceived m_onFolderReceived;
     MsgServiceHandleMgrPtr m_onMessageReceivedHandleMgr;
     DBus::ConnectionPtr m_dbusConnection;
     DPL::Thread* m_dbusWorkerThread;
index c47a865..6d8af53 100755 (executable)
@@ -116,7 +116,7 @@ void MessagingServiceManager::OnRequestReceived(const EventGetMessagingServicePt
                        {
                                MessagingService* messagingService = new MessagingService();
                                messagingService->setMessagingServiceType(Api::Messaging::SMS);
-                               messagingService->setMessagingServiceName("SMS");
+                               messagingService->setMessagingServiceName("tizen.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("MMS");
+                               messagingService->setMessagingServiceName("tizen.mms");
                                
                                m_messagingServices.push_back(Api::Messaging::IMessagingServicePtr(messagingService));
                        }
index 7402654..a39f078 100755 (executable)
@@ -26,7 +26,7 @@
 #include "Mms.h"
 
 #include <vector>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/Exception.h>
 #include <API/Messaging/ReqReceiverMessage.h>
 #include "Messaging.h"
@@ -314,7 +314,7 @@ void Mms::readBodyAndAttachments(msg_message_t& messageData)
                 fclose(f);
             } else {
                 LogDebug("adding attachment " << media->szFilePath);
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
+
                 IAttachmentPtr attachment = appendAttachment(media->szFilePath,
                                                              false);
                     //attachment->setMessage(this);    //set IMessagePtr
@@ -328,11 +328,10 @@ void Mms::readBodyAndAttachments(msg_message_t& messageData)
                     LogDebug("renaming to " << newName.str());
                     attachment->rename(newName.str());
                 }
-#endif
+
             }
         }
     }
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
 
     LogDebug("attachment count: " << msgBody.attachCnt);
     for (int a = 0; a < msgBody.attachCnt; ++a) {
@@ -348,7 +347,7 @@ void Mms::readBodyAndAttachments(msg_message_t& messageData)
             att->rename(attachment->szFileName);
         }
     }
-#endif
+
 }
 
 
@@ -495,16 +494,10 @@ void Mms::updateSubject()
 void Mms::updateBodyAndAttachments()
 {
 
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
     // check if attachment or body source address value has been changed
     if (isAttachmentsValid() && isBodyValid()) {
         return;
     }
-#else
-    if (isBodyValid()) {
-        return;
-    }  
-#endif
 
     MMS_MESSAGE_DATA_S *mmsData = NULL;
     LogInfo("updating platform body and attachment");
@@ -563,7 +556,6 @@ void Mms::updateBodyAndAttachments()
             media->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
         }
                
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
         //attachments
         struct stat buffer;
         int errnum = 0;
@@ -597,16 +589,14 @@ void Mms::updateBodyAndAttachments()
             errnum = 0;
         }
 
-#endif
        if (MSG_SUCCESS != msg_mms_set_message_body(m_messageData, mmsData)) {
                LogError("set message body error");
                ThrowMsg(WrtDeviceApis::Commons::PlatformException, "set message body error");
        }
        
        msg_mms_destroy_message(mmsData);
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
+
        setAttachmentsValidity(true);
-#endif
        setBodyValidity(true);
        
     }
@@ -675,6 +665,59 @@ void Mms::updateIsRead()
 
 }
 
+void Mms::addMessageToDraft()
+{
+    LogDebug("convert m_id= " << convertId(getIdRef()));       
+
+    //prepare for add sms to draft folder
+    if (!m_messageData) {
+        //error if platform message not exists
+        LogError("message can not be updated");
+        Throw(WrtDeviceApis::Commons::PlatformException);
+    }
+
+    //update all sms data
+    if (getCurrentFolder() == Api::Messaging::DRAFTBOX) {
+        updateSubject();
+        updateBodyAndAttachments();
+        updateRecipientList();
+        updatePriority();
+    }
+
+    Try
+    {
+        MSG_SENDINGOPT_S option = { false, false, false };
+        option.option.smsSendOpt.bReplyPath = true;
+        // trying to get message from platform
+
+        const MSG_FOLDER_ID_T platfromFolderId =
+        Messaging::convertFolderToPlatform(DRAFTBOX);
+
+        msg_set_message_id(m_messageData, 0);          
+        msg_set_folder_id(m_messageData, platfromFolderId);
+        msg_set_network_status(m_messageData, MSG_NETWORK_NOT_SEND);
+
+        // trying to add message
+        int ret = msg_add_message(MsgGetCommonHandle(), m_messageData, &option);
+        if (ret < MSG_SUCCESS) {
+            LogError("msg_add_message failed, error code=" << ret);
+            Throw(WrtDeviceApis::Commons::PlatformException);
+        }
+
+        //releasing platform message structure
+            msg_release_message(&m_messageData);
+    }
+    Catch(WrtDeviceApis::Commons::PlatformException) {
+        LogError("remove message error");
+        if (m_messageData) {
+            //releasing platform message structure
+            msg_release_message(&m_messageData);
+        }
+        throw;
+    }
+
+}      
+
 void Mms::readAllData()
 {
     readExistingMessage();
index d41ad16..33e1ecf 100755 (executable)
@@ -91,6 +91,8 @@ class Mms : public Api::Messaging::IMms,
 
     void updateIsRead();       
 
+    void addMessageToDraft();
+
     void readPriority(msg_message_t& messageData);
 
     void readRecipientList(msg_message_t& messageData);
index ce27c2e..5494339 100755 (executable)
@@ -28,7 +28,7 @@
 #define MSGSERVICEHANDLEMGR_H
 
 #include <dpl/singleton.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include <dpl/thread.h>
 #include <Commons/Exception.h>
index 4cb36fd..8511ae1 100755 (executable)
@@ -21,7 +21,7 @@
 #ifndef TIZEN_MESSAGING_SCOPEDMAIL_H_
 #define TIZEN_MESSAGING_SCOPEDMAIL_H_
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/scoped_ptr.h>
 #include <emf-types.h>
 #include <Emf_Mapi_Message.h>
index b8e760d..6900f06 100755 (executable)
@@ -21,7 +21,7 @@
 #ifndef TIZEN_MESSAGING_SCOPEDMAILBOX_H_
 #define TIZEN_MESSAGING_SCOPEDMAILBOX_H_
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/scoped_ptr.h>
 #include <emf-types.h>
 #include <Emf_Mapi_Message.h>
index c6fbc0c..cf6b018 100755 (executable)
@@ -24,7 +24,7 @@
  * @brief
  */
 #include "Sms.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/Exception.h>
 #include <API/Messaging/ReqReceiverMessage.h>
 #include "Messaging.h"
@@ -592,6 +592,60 @@ void Sms::updateIsRead()
 }
 
 
+void Sms::addMessageToDraft()
+{
+    LogDebug("convert m_id= " << convertId(getIdRef()));       
+
+    //prepare for add sms to draft folder
+    if (!m_messageData) {
+        //error if platform message not exists
+        LogError("message can not be updated");
+        Throw(WrtDeviceApis::Commons::PlatformException);
+    }
+
+    //update all sms data
+    if (getCurrentFolder() == Api::Messaging::DRAFTBOX) {
+        updateBody();
+        updateFrom();
+        updateTo();
+        updateSourceAddress();
+    }
+
+    Try
+    {
+        MSG_SENDINGOPT_S option = { false, false, false };
+        option.option.smsSendOpt.bReplyPath = true;
+        // trying to get message from platform
+
+        const MSG_FOLDER_ID_T platfromFolderId =
+        Messaging::convertFolderToPlatform(DRAFTBOX);
+
+        msg_set_message_id(m_messageData, 0);          
+        msg_set_folder_id(m_messageData, platfromFolderId);
+        msg_set_network_status(m_messageData, MSG_NETWORK_NOT_SEND);
+
+        // trying to add message
+        int ret = msg_add_message(MsgGetCommonHandle(), m_messageData, &option);
+        if (ret < MSG_SUCCESS) {
+            LogError("msg_add_message failed, error code=" << ret);
+            Throw(WrtDeviceApis::Commons::PlatformException);
+        }
+
+        //releasing platform message structure
+        msg_release_message(&m_messageData);
+    }
+    Catch(WrtDeviceApis::Commons::PlatformException) {
+        LogError("remove message error");
+        if (m_messageData) {
+            //releasing platform message structure
+            msg_release_message(&m_messageData);
+        }
+        throw;
+    }
+
+}
+
+
 void Sms::readRecipientList(msg_message_t& messageData)
 {
     LogDebug("Adding recipients to message, count=" <<
index cee75ad..4ef1ded 100755 (executable)
@@ -11,7 +11,7 @@
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
-* limitations under the License. 
+* limitations under the License.
 */
 
 
@@ -41,7 +41,7 @@ namespace Messaging {
 
 class Sms : public Api::Messaging::ISms,
     public ISendingObserver,
-    public DPL::Controller<DPL::TypeListDecl<int>::Type >
+        public DPL::Event::Controller<DPL::TypeListDecl<int>::Type >
 {
   public:
     explicit Sms(const std::string& id = "");
@@ -96,7 +96,9 @@ class Sms : public Api::Messaging::ISms,
 
     void updateReadStatus();
 
-    void updateIsRead();       
+    void updateIsRead();
+
+    void addMessageToDraft();
 
     void readRecipientList(msg_message_t& messageData);
 
index 4f1714d..ee74848 100755 (executable)
@@ -21,7 +21,7 @@
 #include <dpl/assert.h>
 #include <Commons/Exception.h>
 #include "SyncNetworkStatus.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 namespace {
 const char* DBUS_INTERFACE_NETWORK_STATUS = "User.Email.NetworkStatus";
index d014587..5fc8b91 100755 (executable)
@@ -21,7 +21,7 @@ set(SRCS_PLATFORM_IMPLEMENTATION_MESSAGING
     ${CURRENT_PATH}/MessagingServiceManager.cpp
     ${CURRENT_PATH}/MessagingService.cpp
     
#   ${CURRENT_PATH}/Attachment.cpp
+    ${CURRENT_PATH}/Attachment.cpp
     ${CURRENT_PATH}/BinarySms.cpp
     ${CURRENT_PATH}/Email.cpp
     ${CURRENT_PATH}/Messaging.cpp
index eb653b5..4e2e461 100755 (executable)
@@ -23,7 +23,7 @@
 #include "MessageStorageReader.h"
 #include "MsgSqliteWrapper.h"
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 namespace{
 //TODO copied from MsgInternalTypes.h
@@ -58,7 +58,7 @@ namespace{
                MSG_DIRECTION_TYPE_T  direction;                /**< Indicates whether the message is MO or MT, affecting address. */
                MSG_PORT_INFO_S       msgPort;          /**< Indicates the port number information. */
                int                   attachCount;              /**< Indicates the count of attached files in mms. */
-               char                  thumbPath[MSG_FILEPATH_LEN_MAX+1];
+               char                  thumbPath[MSG_FILEPATH_LEN_MAX];
                size_t                dataSize;         /**< Indicates the data size. The unit is byte. */
                void                  *pData;                   /**< Indicates the message payload information as a body. default character encoding is UTF-8*/
                void                  *pMmsData;                        /**< Indicates the message payload information as a body. default character encoding is UTF-8*/
index 05911ba..591b683 100755 (executable)
@@ -20,7 +20,7 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 //#include "MsgDebug.h"
 #include "MsgSqliteWrapper.h"
 
index 407b9d4..a7aa296 100755 (executable)
@@ -15,7 +15,7 @@
  */
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/scoped_ptr.h>
 #include <Commons/Exception.h>
 #include <nfc.h>
index 2f18479..6f89865 100755 (executable)
@@ -17,7 +17,7 @@
 
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <Commons/Exception.h>
 
index 636ffff..c14ac62 100755 (executable)
@@ -17,7 +17,7 @@
 
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <Commons/Exception.h>
 
index eddd85e..1054435 100755 (executable)
@@ -17,7 +17,7 @@
 
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <Commons/Exception.h>
 
index c8bb234..5434aa0 100755 (executable)
@@ -17,7 +17,7 @@
 
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <Commons/Exception.h>
 
index 6bb6ad7..e2b10b9 100755 (executable)
@@ -19,7 +19,7 @@
 #include <Commons/Exception.h>
 
 #include "NFCUtil.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <nfc.h>
 
 
index b6e86f1..f834b78 100755 (executable)
@@ -15,7 +15,7 @@
  */
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <Commons/Exception.h>
 
index 5fdc93e..084fd52 100755 (executable)
@@ -17,7 +17,7 @@
 
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/Exception.h>
 
 #include "NdefRecord.h"
old mode 100755 (executable)
new mode 100644 (file)
index cea6e5e..0d254a7
@@ -20,7 +20,7 @@
 #include <stddef.h>
 #include <cassert>
 #include <pcrecpp.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <network-cm-intf.h>
 #include <Commons/Exception.h>
 #include <CommonsJavaScript/Converter.h>
@@ -38,20 +38,31 @@ namespace Systeminfo {
     
 namespace {
 
-void systemInfoValueCallback(keynode_t *node, void *event_ptr)
+void PowerValueCallback(keynode_t *node, void *event_ptr)
 {
     if(event_ptr) {
-        ((EventWatchSysteminfo*)event_ptr)->getWatchValue();
+        ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TPYE_POWER);
     }
 }
 
-void systemInfoNetworkCallback(keynode_t *node, void *event_ptr)
+void DisplayValueCallback(keynode_t *node, void *event_ptr)
 {
     if(event_ptr) {
-        ((Systeminfo*)event_ptr)->getWatchValue();
+        ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_DISPLAY);
     }
 }
     
+void NetworkValueCallback(keynode_t *node, void *event_ptr)
+{
+    if(event_ptr) {
+        ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_NETWORK);
+    }
+}
+
+void NetworkEventCallback (net_event_info_t*  event_cb, void* user_data)
+{
+}
+
 }
 
 #define STORAGE_INTERNAL_PATH   "/opt/media"
@@ -83,11 +94,16 @@ Systeminfo::Systeminfo() : m_networkRegist(REGIST_NOT)
         (*m_Property)["WifiNetwork"] = BasePropertyPtr(new WifiNetwork());
         (*m_Property)["CellularNetwork"] = BasePropertyPtr(new CellularNetwork());
     }
+
+    if (net_register_client((net_event_cb_t) NetworkEventCallback, (void *)this) != NET_ERR_NONE) {
+        LogError("registration is failed");
+    }
 }
 
 Systeminfo::~Systeminfo()
 {
     m_EventMgrPtr->clearAllEvent();
+    net_deregister_client();
 }
 
 bool Systeminfo::isPropertyValid(JSContextRef context, JSValueRef property)
@@ -115,48 +131,52 @@ void Systeminfo::watch(const EventWatchSysteminfoPtr& event)
         LogDebug("watch method is not supported");
         return;
     }
-    // we don't support multi watch, check duplication
 
     event->setSysteminfoPtr(this);
-    m_EventMgrPtr->addEvent(event);
+    m_EventMgrPtr->addEvent(event, event->getWatchType());
 
     EventRequestReceiver<EventWatchSysteminfo>::PostRequest(event);
 }
 
 void Systeminfo::clearWatch(const int id)
 {
-    switch(m_EventMgrPtr->getWatchType(id)) {
+    int watchType = m_EventMgrPtr->getWatchType(id);
+    switch(watchType) {
         case WATCH_TPYE_POWER:
-            vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, systemInfoValueCallback);
-            vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, systemInfoValueCallback);
+            if ((m_EventMgrPtr->getEventPowerList()).size() == 1) {
+                vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, PowerValueCallback);
+                vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, PowerValueCallback);
+            }                
             break;
         case WATCH_TYPE_DISPLAY:
-            vconf_ignore_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, systemInfoValueCallback);
+            if ((m_EventMgrPtr->getEventDisplayList()).size() == 1) {                        
+                vconf_ignore_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, DisplayValueCallback);
+            }                
             break;
         case WATCH_TPYE_WIFINETWORK:
-            vconf_ignore_key_changed(VCONFKEY_WIFI_STRENGTH, systemInfoValueCallback);
+            if ((m_EventMgrPtr->getEventWifiNetworkList()).size() == 1) {                        
+                vconf_ignore_key_changed(VCONFKEY_WIFI_STRENGTH, NetworkValueCallback);
             if (m_networkRegist == REGIST_WIFI) {
-                vconf_ignore_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, systemInfoNetworkCallback);
+                    vconf_ignore_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, NetworkValueCallback);
                 m_networkRegist = REGIST_NOT;
             } else if (m_networkRegist== REGIST_ALL) {
                 m_networkRegist = REGIST_CELLULAR;
             }            
+            }                
             break;
         case WATCH_TPYE_CELLULARNETWORK:
-            vconf_ignore_key_changed(VCONFKEY_TELEPHONY_PLMN, systemInfoValueCallback);
-            vconf_ignore_key_changed(VCONFKEY_TELEPHONY_LAC, systemInfoValueCallback);
-            vconf_ignore_key_changed(VCONFKEY_TELEPHONY_CELLID, systemInfoValueCallback);            
-            vconf_ignore_key_changed(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, systemInfoValueCallback);
+            if ((m_EventMgrPtr->getEventCellularNetworkList()).size() == 1) {                        
             if (m_networkRegist == REGIST_CELLULAR) {
-                vconf_ignore_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, systemInfoNetworkCallback);
+                    vconf_ignore_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, NetworkValueCallback);
                 m_networkRegist = REGIST_NOT;
             } else if (m_networkRegist== REGIST_ALL) {
                 m_networkRegist = REGIST_WIFI;
             }            
+            }                
             break;
     }
 
-    m_EventMgrPtr->removeEvent(id);
+    m_EventMgrPtr->removeEvent(id, watchType);
 }
 
 BasePropertyPtr Systeminfo::getBasePropertyPtr(JSContextRef context, JSValueRef property)
@@ -172,44 +192,29 @@ BasePropertyPtr Systeminfo::getBasePropertyPtr(JSContextRef context, JSValueRef
 
     return it->second;
 }
-
-bool Systeminfo::isDuplicateWatch(const char * property)
-{
-    EventList eventList = m_EventMgrPtr->getEventList();
-    int cnt = 0;
-    for (EventList::iterator it = eventList.begin(); it != eventList.end(); it++) {
-        LogDebug("event idx=" << cnt++ << ", property=" << (*it)->getProperty());
-        if (strcmp(property, (*it)->getProperty()) == 0) {
-            LogDebug("property is duplicated");
-                       return true;
-        }
-    }          
-       return false;
-}
-
-void Systeminfo::getWatchValue()
+            
+void Systeminfo::getWatchValue(const int watchType)
 {
-    EventList eventList = m_EventMgrPtr->getEventList();    
-    
-    if (m_networkRegist == REGIST_WIFI) {
-        for (EventList::iterator it = eventList.begin(); it != eventList.end(); it++) {
-            if (WATCH_TPYE_WIFINETWORK == (*it)->getWatchType()) {
+    if (watchType == WATCH_TPYE_POWER) {
+        EventPowerList eventList = m_EventMgrPtr->getEventPowerList();
+        for (EventPowerList::iterator it = eventList.begin(); it != eventList.end(); it++) {
                 (*it)->getWatchValue();
-                break;
             }
+    } else if (watchType == WATCH_TYPE_DISPLAY) {
+        EventDisplayList eventList = m_EventMgrPtr->getEventDisplayList();    
+        for (EventDisplayList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+            (*it)->getWatchValue();
         }
-    } else if (m_networkRegist == REGIST_CELLULAR) {
-        for (EventList::iterator it = eventList.begin(); it != eventList.end(); it++) {
-            if (WATCH_TPYE_CELLULARNETWORK == (*it)->getWatchType()) {
+    } else if (watchType == WATCH_TYPE_NETWORK) {
+        EventWifiNetworkList eventListWifi = m_EventMgrPtr->getEventWifiNetworkList();
+        EventWifiNetworkList eventListCellular = m_EventMgrPtr->getEventCellularNetworkList();
+        if (eventListWifi.size() > 0) {
+            for (EventWifiNetworkList::iterator it = eventListWifi.begin(); it != eventListWifi.end(); it++) {
                 (*it)->getWatchValue();
-                break;
             }
-        }
-    } else if (m_networkRegist == REGIST_ALL) {
-        for (EventList::iterator it = eventList.begin(); it != eventList.end(); it++) {
-            if (WATCH_TPYE_WIFINETWORK == (*it)->getWatchType()) {
-                (*it)->getWatchValue();
-            } else if (WATCH_TPYE_CELLULARNETWORK == (*it)->getWatchType()) {
+        } 
+        if (eventListCellular.size() > 0) {        
+            for (EventCellularNetworkList::iterator it = eventListCellular.begin(); it != eventListCellular.end(); it++) {
                 (*it)->getWatchValue();
             }
         }    
@@ -230,32 +235,36 @@ void Systeminfo::OnRequestReceived(const EventWatchSysteminfoPtr& event)
 
     switch(event->getWatchType()) {
         case WATCH_TPYE_POWER:
-            vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, systemInfoValueCallback, event.Get());
-            vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, systemInfoValueCallback, event.Get());
+            if ((m_EventMgrPtr->getEventPowerList()).size() == 1) {
+                vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, PowerValueCallback, (void *)this);
+                vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, PowerValueCallback, (void *)this);
+            }
             break;
         case WATCH_TYPE_DISPLAY:
-            vconf_notify_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, systemInfoValueCallback, event.Get());
+            if ((m_EventMgrPtr->getEventDisplayList()).size() == 1) {            
+                vconf_notify_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, DisplayValueCallback, (void *)this);
+            }                
             break;
         case WATCH_TPYE_WIFINETWORK:
-            vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH, systemInfoValueCallback, event.Get());
+            if ((m_EventMgrPtr->getEventWifiNetworkList()).size() == 1) {
+                vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH, NetworkValueCallback, (void *)this);
             if (m_networkRegist == REGIST_NOT) {
-                vconf_notify_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, systemInfoNetworkCallback, (void *)this);
+                    vconf_notify_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, NetworkValueCallback, (void *)this);
                 m_networkRegist = REGIST_WIFI;
             } else if (m_networkRegist== REGIST_CELLULAR) {
                 m_networkRegist = REGIST_ALL;
             }
+            }                
             break;
         case WATCH_TPYE_CELLULARNETWORK:
-            vconf_notify_key_changed(VCONFKEY_TELEPHONY_PLMN, systemInfoValueCallback, event.Get());
-            vconf_notify_key_changed(VCONFKEY_TELEPHONY_LAC, systemInfoValueCallback, event.Get());
-            vconf_notify_key_changed(VCONFKEY_TELEPHONY_CELLID, systemInfoValueCallback, event.Get());            
-            vconf_notify_key_changed(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, systemInfoValueCallback, event.Get());
+            if ((m_EventMgrPtr->getEventCellularNetworkList()).size() == 1) {            
             if (m_networkRegist == REGIST_NOT) {
-                vconf_notify_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, systemInfoNetworkCallback, (void *)this);
+                    vconf_notify_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, NetworkValueCallback, (void *)this);
                 m_networkRegist = REGIST_CELLULAR;
             } else if (m_networkRegist== REGIST_WIFI) {
                 m_networkRegist = REGIST_ALL;
             }
+            }                
             break;      
     }
     event->processGetValue();
@@ -276,24 +285,55 @@ void Systeminfo::EventMgr::clearAllEvent()
 {
     DPL::Mutex::ScopedLock lock(&m_synchro);
 
-    LogDebug("removing all registered events, unRemoved event=" << m_eventList.size());
-    while (!m_eventList.empty()) {
-        EventWatchSysteminfoPtr event = m_eventList.front();
+    LogDebug("removing all registered events, unRemoved power event=" << m_eventPowerList.size() 
+        <<  " unRemoved display event=" << m_eventDisplayList.size() <<  " unRemoved wifi network event=" << m_eventWifiNetworkList.size() 
+        <<  " unRemoved cellular network event=" << m_eventCelluarNetworkList.size());
+    while (!m_eventPowerList.empty()) {
+        EventWatchSysteminfoPtr event = m_eventPowerList.front();
+        LogDebug("removing EventId=" << event->getId());
+        event->clearWatch();
+        m_eventPowerList.pop_front();
+    }
+    while (!m_eventDisplayList.empty()) {
+        EventWatchSysteminfoPtr event = m_eventDisplayList.front();
+        LogDebug("removing EventId=" << event->getId());
+        event->clearWatch();
+        m_eventDisplayList.pop_front();
+    }
+    while (!m_eventWifiNetworkList.empty()) {
+        EventWatchSysteminfoPtr event = m_eventWifiNetworkList.front();
+        LogDebug("removing EventId=" << event->getId());
+        event->clearWatch();
+        m_eventWifiNetworkList.pop_front();
+    }
+    while (!m_eventCelluarNetworkList.empty()) {
+        EventWatchSysteminfoPtr event = m_eventCelluarNetworkList.front();
         LogDebug("removing EventId=" << event->getId());
         event->clearWatch();
-        m_eventList.pop_front();
+        m_eventCelluarNetworkList.pop_front();
     }
 }
 
-void Systeminfo::EventMgr::addEvent(const EventWatchSysteminfoPtr& arg)
+void Systeminfo::EventMgr::addEvent(const EventWatchSysteminfoPtr& arg, const int watchType)
 {
     DPL::Mutex::ScopedLock lock(&m_synchro);
 
-    m_eventList.push_back(arg);
-    LogDebug("Event list size=" << m_eventList.size());
+    if (watchType == WATCH_TPYE_POWER) {
+        m_eventPowerList.push_back(arg);
+        LogDebug("Event power list size=" << m_eventPowerList.size());
+    } else if (watchType == WATCH_TYPE_DISPLAY) {
+        m_eventDisplayList.push_back(arg);
+        LogDebug("Event display list size=" << m_eventDisplayList.size());
+    } else if (watchType == WATCH_TPYE_WIFINETWORK) {
+        m_eventWifiNetworkList.push_back(arg);
+        LogDebug("Event wifi network list size=" << m_eventWifiNetworkList.size());
+    } else if (watchType == WATCH_TPYE_CELLULARNETWORK) {
+        m_eventCelluarNetworkList.push_back(arg);
+        LogDebug("Event cellular network list size=" << m_eventCelluarNetworkList.size());
+    }
 }
 
-void Systeminfo::EventMgr::removeEvent(WatchId id) 
+void Systeminfo::EventMgr::removeEvent(WatchId id, const int watchType
 {
     DPL::Mutex::ScopedLock lock(&m_synchro);
     LogDebug("Event id : " << id);
@@ -302,7 +342,38 @@ void Systeminfo::EventMgr::removeEvent(WatchId id)
 
     LogDebug("trying to delete event, id=" << id);
 
-    for (EventList::iterator it = m_eventList.begin(); it != m_eventList.end(); it++) {
+    if (watchType == WATCH_TPYE_POWER) {
+        for (EventPowerList::iterator it = m_eventPowerList.begin(); it != m_eventPowerList.end(); it++) {
+            if (id == (*it)->getId()) {
+                event = *it;
+                break;
+            }
+        }
+        if (!event) {
+            LogError("event id not in the list, nothing to do");
+            return;
+        }
+
+        LogDebug("event power list size=" << m_eventPowerList.size());
+        m_eventPowerList.remove(event);
+        LogDebug( "event removed, event power list size=" << m_eventPowerList.size());        
+    } else if (watchType == WATCH_TYPE_DISPLAY) {
+        for (EventDisplayList::iterator it = m_eventDisplayList.begin(); it != m_eventDisplayList.end(); it++) {
+            if (id == (*it)->getId()) {
+                event = *it;
+                break;
+            }
+        }
+        if (!event) {
+            LogError("event id not in the list, nothing to do");
+            return;
+        }
+
+        LogDebug("event display list size=" << m_eventDisplayList.size());
+        m_eventDisplayList.remove(event);
+        LogDebug( "event removed, event display list size=" << m_eventDisplayList.size());
+    } else if (watchType == WATCH_TPYE_WIFINETWORK) {
+        for (EventWifiNetworkList::iterator it = m_eventWifiNetworkList.begin(); it != m_eventWifiNetworkList.end(); it++) {
         if (id == (*it)->getId()) {
             event = *it;
             break;
@@ -313,10 +384,25 @@ void Systeminfo::EventMgr::removeEvent(WatchId id)
         return;
     }
 
-    LogDebug("event list size=" << m_eventList.size());
-    m_eventList.remove(event);
-    LogDebug( "event removed, event list size=" << m_eventList.size());
+        LogDebug("event wifi network list size=" << m_eventWifiNetworkList.size());
+        m_eventWifiNetworkList.remove(event);
+        LogDebug( "event removed, event wifi network list size=" << m_eventCelluarNetworkList.size());
+    } else if (watchType == WATCH_TPYE_WIFINETWORK) {
+        for (EventCellularNetworkList::iterator it = m_eventCelluarNetworkList.begin(); it != m_eventCelluarNetworkList.end(); it++) {
+            if (id == (*it)->getId()) {
+                event = *it;
+                break;
+            }
+        }
+        if (!event) {
+            LogError("event id not in the list, nothing to do");
+            return;
+        }
 
+        LogDebug("event cellular network list size=" << m_eventCelluarNetworkList.size());
+        m_eventCelluarNetworkList.remove(event);
+        LogDebug( "event removed, event cellular network list size=" << m_eventCelluarNetworkList.size());    
+    }
 }    
 
 const int Systeminfo::EventMgr::getWatchType(const int id)
@@ -325,12 +411,34 @@ const int Systeminfo::EventMgr::getWatchType(const int id)
     
     EventWatchSysteminfoPtr event(NULL);
 
-    for (EventList::iterator it = m_eventList.begin(); it != m_eventList.end(); it++) {
+    for (EventPowerList::iterator it = m_eventPowerList.begin(); it != m_eventPowerList.end(); it++) {
+        if (id == (*it)->getId()) {
+            event = *it;
+            break;
+        }
+    }
+
+    for (EventDisplayList::iterator it = m_eventDisplayList.begin(); it != m_eventDisplayList.end(); it++) {
+        if (id == (*it)->getId()) {
+            event = *it;
+            break;
+        }
+    }
+
+    for (EventWifiNetworkList::iterator it = m_eventWifiNetworkList.begin(); it != m_eventWifiNetworkList.end(); it++) {
         if (id == (*it)->getId()) {
             event = *it;
             break;
         }
     }
+
+    for (EventCellularNetworkList::iterator it = m_eventCelluarNetworkList.begin(); it != m_eventCelluarNetworkList.end(); it++) {
+        if (id == (*it)->getId()) {
+            event = *it;
+            break;
+        }
+    }
+    
     if (!event) {
         LogError("event id not in the list, nothing to do");
         return WATCH_TPYE_UNKNOWN;
@@ -339,9 +447,24 @@ const int Systeminfo::EventMgr::getWatchType(const int id)
     return event->getWatchType();
 }
 
-EventList Systeminfo::EventMgr::getEventList()
+EventPowerList Systeminfo::EventMgr::getEventPowerList()
 {
-    return m_eventList;
+    return m_eventPowerList;
+}
+
+EventDisplayList Systeminfo::EventMgr::getEventDisplayList()
+{
+    return m_eventDisplayList;
+}
+
+EventWifiNetworkList Systeminfo::EventMgr::getEventWifiNetworkList()
+{
+    return m_eventWifiNetworkList;
+}
+
+EventCellularNetworkList Systeminfo::EventMgr::getEventCellularNetworkList()
+{
+    return m_eventCelluarNetworkList;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////
@@ -384,9 +507,10 @@ PROPERTY_GET_SYSTEMINFO_DEFINITION(Cpu) {
     }
 
        pcrecpp::RE re("(\\d+).(\\d+)%id");
+       pcrecpp::RE re2("(\\d+)% idle");    
 
        while (fgets(line, LINE_MAX-1, pipe)) {
-               if (re.PartialMatch(line, &a, &b)) {
+               if (re.PartialMatch(line, &a, &b)||re2.PartialMatch(line, &a)) {
                        matched = true;
                        break;
                }
@@ -395,14 +519,19 @@ PROPERTY_GET_SYSTEMINFO_DEFINITION(Cpu) {
     pclose(pipe);
 
     if (matched) {
+        if (a == 100) {
+            cpuPtr.load = (double)1;
+        } else {
         if(b>5) {
             cpuPtr.load = (double)(a+1)/100;
         } else {
             cpuPtr.load = (double)(a)/100;
         }
+        }
         return Tizen1_0::JSCpuInfo::createJSObject(context, cpuPtr);
     } else {
         return JSValueMakeNull(context);    
+
     }
 }
 
@@ -464,6 +593,7 @@ PROPERTY_GET_SYSTEMINFO_DEFINITION(Storage) {
 
 PROPERTY_GET_SYSTEMINFO_DEFINITION(Display) {
     Converter converter(context);
+
     DisplayProperties display;
     int brightness=0, dotsPerInchX=0, dotsPerInchY=0, physicalW=0, physicalH=0, resolutionW=0, resolutionH=0;
 
@@ -473,7 +603,7 @@ PROPERTY_GET_SYSTEMINFO_DEFINITION(Display) {
     }
 
     if(vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness) == 0) {
-        display.brightness = (double)(brightness)/10;
+        display.brightness = (double)(brightness)/24;
     }
     
     pcrecpp::RE reResolution("dimensions:\\s+(\\d+)x(\\d+)");
@@ -481,7 +611,7 @@ PROPERTY_GET_SYSTEMINFO_DEFINITION(Display) {
     pcrecpp::RE reDot("resolution:\\s+(\\d+)x(\\d+)");
     char line[LINE_MAX] = {0};
     while (fgets(line, LINE_MAX-1, pipe)) {
-        if (rePhysical.PartialMatch(line, &resolutionW, &resolutionH)) {
+        if (reResolution.PartialMatch(line, &resolutionW, &resolutionH)) {
             display.resolutionWidth = resolutionW;
             display.resolutionHeight = resolutionH;
         }        
old mode 100755 (executable)
new mode 100644 (file)
index 46e4ba2..1eb5f48
@@ -46,7 +46,8 @@ enum {
     WATCH_TPYE_POWER = 1,
     WATCH_TYPE_DISPLAY = 2,
     WATCH_TPYE_WIFINETWORK = 3,
-    WATCH_TPYE_CELLULARNETWORK = 4
+    WATCH_TPYE_CELLULARNETWORK = 4,
+    WATCH_TYPE_NETWORK = 5
 };
 
 enum {
@@ -85,7 +86,10 @@ PROPERTY_DECLARATION(Device, "Device", WATCH_TPYE_UNKNOWN)
 PROPERTY_DECLARATION(WifiNetwork, "WifiNetwork", WATCH_TPYE_WIFINETWORK)
 PROPERTY_DECLARATION(CellularNetwork, "CellularNetwork", WATCH_TPYE_CELLULARNETWORK)
 
-typedef std::list<Api::Systeminfo::EventWatchSysteminfoPtr> EventList;
+typedef std::list<Api::Systeminfo::EventWatchSysteminfoPtr> EventPowerList;
+typedef std::list<Api::Systeminfo::EventWatchSysteminfoPtr> EventDisplayList;
+typedef std::list<Api::Systeminfo::EventWatchSysteminfoPtr> EventWifiNetworkList;
+typedef std::list<Api::Systeminfo::EventWatchSysteminfoPtr> EventCellularNetworkList;
 
 class Systeminfo : public Api::Systeminfo::ISysteminfo
 {
@@ -100,8 +104,7 @@ class Systeminfo : public Api::Systeminfo::ISysteminfo
     virtual void watch(const Api::Systeminfo::EventWatchSysteminfoPtr& event);    
        virtual Api::Systeminfo::BasePropertyPtr getBasePropertyPtr(JSContextRef context, JSValueRef property);
        virtual void clearWatch(const int id);
-       virtual bool isDuplicateWatch(const char * property);
-       void getWatchValue();
+       void getWatchValue(const int watchType);
        
        class EventMgr
        {
@@ -110,13 +113,19 @@ class Systeminfo : public Api::Systeminfo::ISysteminfo
            ~EventMgr();
 
            void clearAllEvent();
-           void addEvent(const Api::Systeminfo::EventWatchSysteminfoPtr& arg);
-           void removeEvent(WatchId id);
+           void addEvent(const Api::Systeminfo::EventWatchSysteminfoPtr& arg, const int watchType);
+           void removeEvent(WatchId id, const int watchType);
            const int getWatchType(const int id);
-           EventList getEventList();
+           EventPowerList getEventPowerList();
+           EventDisplayList getEventDisplayList();
+           EventWifiNetworkList getEventWifiNetworkList();
+           EventCellularNetworkList getEventCellularNetworkList();         
                
          private:
-               EventList m_eventList;
+            EventPowerList m_eventPowerList;
+            EventDisplayList m_eventDisplayList;
+            EventWifiNetworkList m_eventWifiNetworkList;
+            EventCellularNetworkList m_eventCelluarNetworkList;                
            DPL::Mutex m_synchro;       
        };
        typedef DPL::SharedPtr<EventMgr> EventMgrPtr;
index 134e991..82858ca 100755 (executable)
@@ -17,7 +17,7 @@
 
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <vconf.h>
 
@@ -58,6 +58,25 @@ TZDate::TZDate(const bool isNotNull)
        }
 }
 
+TZDate::TZDate(const std::string &timezone)
+{
+       LogDebug("entered");
+       
+       UErrorCode ec = U_ZERO_ERROR;
+       TimeUtilTools Util;     
+       myCalendar = Calendar::createInstance(Util.makeTimeZone(timezone) ,ec);
+
+       if (U_SUCCESS(ec)) {
+               TimeUtilTools Util;
+               Util.printDate(myCalendar);
+       }
+       else {
+               myCalendar = NULL;
+               ThrowMsg(Commons::PlatformException, "Can't make to ICU Calendar");
+       }
+
+}
+
 TZDate::TZDate(const TZDateProperties &properties)
 {
        LogDebug("entered");
@@ -220,6 +239,8 @@ TZDateProperties TZDate::toTimezone(const std::string timezone) {
        
        TZDateProperties newProps =  _makeProperties(newCalendar);
        delete newCalendar;
+       if ((newProps.timezone != timezone) && (newProps.timezone == "Etc/Unknown"))
+               ThrowMsg(Commons::InvalidArgumentException, "Unsupported Timezone.");
        return newProps;
 }
 
@@ -454,7 +475,9 @@ double TZDate::getTime() {
 
                if (U_SUCCESS(ec)) {
                        std::string result = Util.toString(str);
-                       result.erase(result.length() - 3, 1); //GMT +XX:XX -> delete ':'
+                       if ((result.at(result.length() - 3) > 0) && (result.at(result.length() - 3) == ':'))
+                               result.erase(result.length() - 3, 1); //GMT +XX:XX -> delete ':'
+
                        str.remove();
 
                        LogDebug (result);
index 3bdee3d..e0a278b 100755 (executable)
@@ -39,6 +39,7 @@ class TZDate : public ITZDate
        
        public:
                TZDate(const bool isNotNull);
+               TZDate(const std::string &timezone);
                TZDate(const TZDateProperties &properties); 
                virtual      ~TZDate();
 
index d27d373..850ebd7 100755 (executable)
@@ -17,7 +17,7 @@
 
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <ctime>
 #include <vconf.h>
 
index 093fcdb..30d9faa 100755 (executable)
@@ -24,7 +24,7 @@
 #include <Commons/Exception.h>
 
 #include "TimeUtilTools.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 namespace TizenApis {
 namespace Platform {
index a56580b..9ae5e61 100755 (executable)
@@ -9,9 +9,9 @@ include_config_file(Messaging)
 include_config_file(TimeUtil)
 include_config_file(Systeminfo)
 include_config_file(NFC)
+include_config_file(Filesystem)
+include_config_file(Account)
 
-#include_config_file(Account)
 #include_config_file(Accelerometer)
 #include_config_file(Orientation)
 #include_config_file(Gyroscope)
-#include_config_file(Filesystem)
diff --git a/src/standards/Tizen/Account/AccountConverter.cpp b/src/standards/Tizen/Account/AccountConverter.cpp
new file mode 100755 (executable)
index 0000000..4f6b8fc
--- /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        EventFilterConverter.cpp
+ * @author      Jihwa Park (jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ */
+
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <Commons/RegexUtils.h>
+#include "JSAccount.h"
+#include "AccountConverter.h"
+#include "JSAccountService.h"
+#include "JSAccountServiceType.h"
+#include "JSAccountManager.h"
+#include "JSFeatureArray.h"
+#include "JSAccountServices.h"
+#include "JSAccountServiceProvider.h"
+
+#define ACCOUNT_SERVICES_NAME "serviceName"
+#define ACCOUNT_SERVICES_TYPE "serviceType"
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace {
+const int DEFAULT_EVENT_INTERVAL = 1;
+}
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Account{
+
+std::vector<std::string> AccountConverter::m_allowedAttributes;
+std::vector<std::string> AccountConverter::m_allowedCreateProperties;
+
+AccountConverter::AccountConverter(JSContextRef context) : Converter(context)
+{
+    LogDebug("entered");
+    if (m_allowedAttributes.size() == 0) {
+        m_allowedAttributes.push_back("id");
+        m_allowedAttributes.push_back("iconPath");
+    }
+    if (m_allowedCreateProperties.size() == 0) {
+               m_allowedCreateProperties.push_back("id");
+               m_allowedCreateProperties.push_back("iconPath");
+    }
+}
+
+AccountConverter::~AccountConverter()
+{
+
+}
+
+JSValueRef AccountConverter::toJSValueRefAccount(const EventAccountPtr& arg)
+{
+    LogDebug("<<<");
+    return JSAccount::createJSAccount(m_context, arg);
+}
+
+JSValueRef AccountConverter::toJSValueRefAccountServiceType(const AccountServiceTypePropertyPtr& arg)
+{
+    LogDebug("<<<");
+    return JSAccountServiceType::createJSObject(m_context, arg);
+}
+
+JSValueRef AccountConverter::toJSValueRefAccountServiceProvider(const AccountServiceProviderPropertyPtr& arg)
+{
+       LogDebug("<<<");
+       return JSAccountServiceProvider::createJSObject(m_context, arg);
+}
+
+
+
+
+JSValueRef AccountConverter::toJSValueRef(
+        const std::vector<EventAccountPtr> &arg)
+{
+    LogDebug("entered");
+    return toJSValueRef_(arg, &AccountConverter::toJSValueRefAccount, this);
+}
+
+JSValueRef AccountConverter::toJSValueRefAccountService(const IAccountServicePtr& arg)
+{
+    LogDebug("entered");
+    AccountServicePrivObject *priv = new AccountServicePrivObject(m_context, arg);
+    return JSObjectMake(m_context, JSAccountService::getClassRef(), priv);
+}
+
+JSValueRef AccountConverter::toJSValueRef(const std::vector<IAccountServicePtr> &arg)
+{
+    LogDebug("entered");
+    return toJSValueRef_(arg, &AccountConverter::toJSValueRefAccountService, this);
+}
+
+
+JSValueRef AccountConverter::toFunctionOrNull(const JSValueRef& arg)
+{
+    LogDebug("entered");
+    if (Validator(m_context).isCallback(arg)) {
+        return arg;
+    } else if (!JSValueIsNull(m_context,
+                              arg) && !JSValueIsUndefined(m_context, arg)) {
+        ThrowMsg(InvalidArgumentException, "Not a function nor JS null.");
+    }
+    return NULL;
+}
+
+JSValueRef AccountConverter::toFunction(const JSValueRef& arg)
+{
+    LogDebug("entered");
+    if (Validator(m_context).isCallback(arg)) {
+        return arg;
+    } else if (JSValueIsNull(m_context,
+                             arg) || JSValueIsUndefined(m_context, arg)) {
+        ThrowMsg(ConversionException, "JS null passed as function.");
+    }
+    ThrowMsg(InvalidArgumentException, "Not a function nor JS null.");
+}
+
+AccountServicesPtr AccountConverter::toService(const JSValueRef jsValue)
+{
+       const ScopedJSStringRef serviceNameStr(JSStringCreateWithUTF8CString(ACCOUNT_SERVICES_NAME));
+       const ScopedJSStringRef serviceTypeStr(JSStringCreateWithUTF8CString(ACCOUNT_SERVICES_TYPE));
+
+       JSObjectRef jsObject = toJSObjectRef(jsValue);
+
+       JSValueRef serviceNameData = JSObjectGetProperty(m_context, jsObject, serviceNameStr.get(), NULL);
+       JSValueRef serviceTypeData = JSObjectGetProperty(m_context, jsObject, serviceTypeStr.get(), NULL);
+
+       std::string serviceName;
+       std::string serviceTypeId;
+
+       AccountServicesPtr result = AccountServicesPtr(new AccountServices());
+       if (!result) {
+               Throw(ConversionException);
+       }
+
+       if (!JSValueIsUndefined(m_context, serviceNameData)) {
+               serviceName = toString(serviceNameData);
+               result->setName(serviceName);
+       }
+
+       if (!JSValueIsUndefined(m_context, serviceTypeData)) {
+               serviceTypeId = toString(serviceTypeData);
+               result->setServiceTypeId(serviceTypeId);
+       }
+
+       return result;
+}
+
+AccountServicesArrayPtr AccountConverter::toAccountService(const JSValueRef jsValue)
+{
+    AccountServicesArrayPtr result(new AccountServicesArray());
+
+    std::vector<AccountServicesPtr> resultVector;
+    JSObjectRef objArg = toJSObjectRef(jsValue);
+    LogDebug("array length "<<JSGetArrayLength(m_context, objArg));
+    for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); i++) {
+        JSValueRef element = JSGetArrayElement(m_context, objArg, i);
+        resultVector.push_back(toService(element));
+    }
+
+    *result = resultVector;
+    return result;
+}
+
+void AccountConverter::setProvider(const JSValueRef jsValue)
+{
+    LogDebug("entered");
+/*
+    const ScopedJSStringRef providerStr(JSStringCreateWithUTF8CString("providerId"));
+    JSObjectRef arg = toJSObjectRef(jsValue);
+    JSValueRef providerData = JSObjectGetProperty(m_context, arg, providerStr.get(), NULL);
+
+    if (!JSValueIsUndefined(m_context, providerData)) {
+        m_provider = toString(providerData);
+           LogDebug("m_provider : " << m_provider);
+    }
+*/
+    m_provider = toString(jsValue);
+}
+
+std::string AccountConverter::convertTostring(const JSValueRef jsValue)
+{
+       std::string string;
+    LogDebug("entered");
+    string = toString(jsValue);
+       return string;
+}
+
+EventAccountPtr AccountConverter::toAccount(const std::string& accountServiceProviderId){
+       LogDebug("<<<");
+       EventAccountPtr result(new EventAccount());
+
+       const ScopedJSStringRef displayNameStr(JSStringCreateWithUTF8CString("displayName"));
+       const ScopedJSStringRef iconPathStr(JSStringCreateWithUTF8CString("iconPath"));
+
+       //TODO set displayName
+       //TODO set iconPath
+//     JSValueRef displayNameData = JSObjectGetProperty(m_context, arg, displayNameStr.get(), NULL);
+//     JSValueRef iconPathData = JSObjectGetProperty(m_context, arg, iconPathStr.get(), NULL);
+
+//     if (!JSValueIsUndefined(m_context, displayNameData)) {
+//             result->setDisplayName(toString(displayNameData));
+//     }
+
+//     if (!JSValueIsUndefined(m_context, iconPathData)) {
+//             result->setIconPath(toString(iconPathData));
+//     }
+
+       result->setProviderName(accountServiceProviderId);
+
+       return result;
+}
+
+
+EventAccountPtr AccountConverter::toAccount(const JSValueRef account)
+{
+    LogDebug("<<<");
+    EventAccountPtr result(new EventAccount());
+
+    const ScopedJSStringRef displayNameStr(JSStringCreateWithUTF8CString("displayName"));
+    const ScopedJSStringRef iconPathStr(JSStringCreateWithUTF8CString("iconPath"));
+
+    JSObjectRef arg = toJSObjectRef(account);
+
+    JSValueRef displayNameData = JSObjectGetProperty(m_context, arg, displayNameStr.get(), NULL);
+    JSValueRef iconPathData = JSObjectGetProperty(m_context, arg, iconPathStr.get(), NULL);
+
+    if (!JSValueIsUndefined(m_context, displayNameData)) {
+        result->setDisplayName(toString(displayNameData));
+    }
+
+    if (!JSValueIsUndefined(m_context, iconPathData)) {
+        result->setIconPath(toString(iconPathData));
+    }
+
+    result->setProviderName(m_provider);
+/*
+    if (!JSValueIsUndefined(m_context, providerNameData)) {
+        result->setProviderName(toString(providerNameData));
+    }
+
+    if (!JSValueIsUndefined(m_context, emailAddressData)) {
+        result->setEmailAddress(toString(emailAddressData));
+    }
+
+    if (!JSValueIsUndefined(m_context, domainNameData)) {
+        result->setDomainName(toString(domainNameData));
+    }
+
+       if (!JSValueIsUndefined(m_context, serviceData)) {
+               AccountServicesArrayPtr m_service = toAccountService(serviceData);
+               result->setService(m_service);
+       }
+*/
+    return result;
+}
+
+void AccountConverter::toEventFilterConvertId(
+        const AccountFilterPtr &result,
+        const JSValueRef &filters)
+{
+    const ScopedJSStringRef idStr(JSStringCreateWithUTF8CString("id"));
+    JSObjectRef filterObj = toJSObjectRef(filters);
+    if (JSObjectHasProperty(m_context, filterObj, idStr.get())) {
+        LogDebug("converting id");
+        JSValueRef value = JSObjectGetProperty(m_context, filterObj, idStr.get(), NULL);
+        result->setIdFilter(toString(value));
+    }
+}
+
+AccountFilterPtr AccountConverter::toAccountFilter(const JSValueRef &filters)
+{
+    LogDebug("entered");
+    AccountFilterPtr result(new AccountFilter());
+    Validator validator(m_context);
+    if (!JSValueIsObject(m_context, filters)) {
+        LogError("Wrong filter parameter");
+        Throw(InvalidArgumentException);
+    }
+    if (!validator.checkArrayKeys(m_allowedAttributes, filters)) {
+        LogError("Wrong filter's attribue");
+        Throw(ConversionException);
+    }
+
+    toEventFilterConvertId(result, filters);
+    return result;
+}
+
+EventAccountListPtr AccountConverter::toVectorOfAccounts(JSValueRef events)
+{
+    LogDebug("entered");
+    EventAccountListPtr result(new EventAccountList());
+
+    std::vector<EventAccountPtr> resultVector;
+    JSObjectRef objArg = toJSObjectRef(events);
+    LogDebug("array length " + JSGetArrayLength(m_context, objArg));
+    for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); i++) {
+        JSValueRef element = JSGetArrayElement(m_context, objArg, i);
+        resultVector.push_back(toAccount(element));
+    }
+
+    *result = resultVector;
+    return result;
+}
+
+}
+}
+}
diff --git a/src/standards/Tizen/Account/AccountConverter.h b/src/standards/Tizen/Account/AccountConverter.h
new file mode 100755 (executable)
index 0000000..9c4e52e
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/*
+ * @file        Converter.h
+ * @author      Jihwa Park (jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ */
+
+#ifndef _JS_TIZEN_ACCOUNT_CONVERTER_H_
+#define _JS_TIZEN_ACCOUNT_CONVERTER_H_
+
+#include <vector>
+#include <string>
+#include <API/Account/AccountFilter.h>
+#include <API/Account/IAccountService.h>
+#include <API/Account/AccountServices.h>
+
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Account{
+class AccountConverter : public Converter
+{
+  public:
+    using Converter::toJSValueRef;
+  public:
+    explicit AccountConverter(JSContextRef context);
+    virtual ~AccountConverter();
+    AccountFilterPtr toAccountFilter(const JSValueRef &filters);
+    EventAccountPtr toAccount(const JSValueRef account);
+    EventAccountPtr toAccount(const std::string& accountServiceProviderId);
+    EventAccountListPtr toVectorOfAccounts(JSValueRef accounts);
+
+       AccountServicesArrayPtr toAccountService(const JSValueRef jsValue);
+       AccountServicesPtr toService(JSValueRef jsValue);
+
+       void setProvider(const JSValueRef jsValue);
+       std::string convertTostring(const JSValueRef jsValue);
+
+    JSValueRef toJSValueRefAccount(const EventAccountPtr& arg);
+    JSValueRef toJSValueRef(const std::vector<EventAccountPtr> &arg);
+    JSValueRef toJSValueRefAccountService(const IAccountServicePtr& arg);
+    JSValueRef toJSValueRefAccountServiceType(const AccountServiceTypePropertyPtr& arg);
+    JSValueRef toJSValueRefAccountServiceProvider(const AccountServiceProviderPropertyPtr& arg);
+    JSValueRef toJSValueRef(const std::vector<IAccountServicePtr> &arg);
+
+    /**
+     * @throw InvalidArgumentException If not a callback nor JS null.
+     */
+    JSValueRef toFunctionOrNull(const JSValueRef& arg);
+
+    /**
+     * @throw ConversionException If JS null.
+     * @throw InvalidArgumentException If not a callback nor JS null.
+     */
+    JSValueRef toFunction(const JSValueRef& arg);
+
+  private:
+       void toEventFilterConvertId(const AccountFilterPtr &result, const JSValueRef &filters);
+
+    static std::vector<std::string> m_allowedAttributes;
+    static std::vector<std::string> m_allowedCreateProperties;
+
+    std::string m_provider;
+
+};
+
+typedef ConverterFactory<AccountConverter> AccountConverterFactory;
+}
+}
+}
+
+#endif /* _JS_TIZEN_ACCOUNT_CONVERTER_H_ */
diff --git a/src/standards/Tizen/Account/AccountManagerController.cpp b/src/standards/Tizen/Account/AccountManagerController.cpp
new file mode 100755 (executable)
index 0000000..1d81455
--- /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. 
+ */
+
+
+/*
+ * @file               AccountManagerController.cpp
+ * @author      Jihwa Park (jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ * @brief
+ */
+
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include "AccountManagerController.h"
+#include "JSAccountService.h"
+#include "AccountConverter.h"
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Account{
+       
+AccountManagerController::AccountManagerController(JSContextRef context,
+        IAccountManagerPtr accountManager) :
+    GetAccountServicesEventAnswerReceiver(ThreadEnum::NULL_THREAD),
+    AccountManagerPrivObject(context, accountManager)
+{
+    LogDebug("entered");
+}
+
+AccountManagerController::~AccountManagerController()
+{
+    LogDebug("entered");
+}
+
+void AccountManagerController::OnAnswerReceived(
+        const IEventGetAccountServicesPtr &event)
+{
+    LogDebug("entered");
+    JSCallbackManagerPtr cbm =
+        DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
+    if (!cbm) {
+        LogError("no callback manager");
+        return;
+    }
+    Try
+    {
+        if (event->getResult()) {
+            AccountConverterFactory::ConverterType converter =
+                AccountConverterFactory::getConverter(cbm->getContext());
+            const std::vector<IAccountServicePtr> &results = event->getAccountServices();
+            LogDebug("found accounts: " << results.size());
+            JSValueRef result = converter->toJSValueRef(results);
+            cbm->callOnSuccess(result);
+            return;
+        }
+    }
+    Catch(Exception)
+    {
+        LogError("error during processing answer");
+    }
+    JSValueRef errorObject = JSDOMExceptionFactory::UnknownException.make(
+            cbm->getContext());
+    cbm->callOnError(errorObject);
+}
+
+
+}
+}
+}
diff --git a/src/standards/Tizen/Account/CMakeLists.txt b/src/standards/Tizen/Account/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..ebeb18d
--- /dev/null
@@ -0,0 +1,36 @@
+set(TARGET_NAME "wrt-plugins-tizen-1.0-account")
+set(DESTINATION_NAME  "tizen-1.0-account")
+set(SRCS
+  ${SRCS_PLATFORM_API_ACCOUNT}
+  ${SRCS_PLATFORM_API_FILTER}
+  ${SRCS_PLATFORM_IMPLEMENTATION_ACCOUNT}
+  ResponseDispatcher.cpp
+  AccountConverter.cpp
+  JSAccount.cpp
+  JSAccountService.cpp
+  JSAccountManager.cpp
+  JSFeatureArray.cpp
+  JSAccountServices.cpp
+  JSAccountServiceType.cpp
+  JSAccountServiceProvider.cpp
+  plugin_initializer.cpp
+  plugin_config.cpp
+  ../Tizen/FilterConverter.cpp
+  ../Common/JSTizenException.cpp
+  ../Common/TizenExceptionData.cpp
+  ../Common/JSTizenExceptionFactory.cpp
+)
+
+include_directories(
+  ${INCLUDES_PLATFORM_IMPLEMENTATION_ACCOUNT}
+)
+
+add_library(${TARGET_NAME} SHARED ${SRCS})
+target_link_libraries(${TARGET_NAME}
+  wrt-plugins-tizen-1.0-tizen
+  ${LIBS_PLATFORM_IMPLEMENTATION_ACCOUNT}
+  ${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/Account/JSAccount.cpp b/src/standards/Tizen/Account/JSAccount.cpp
new file mode 100755 (executable)
index 0000000..7b4e570
--- /dev/null
@@ -0,0 +1,448 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/*
+ * @file        JSAccount.cpp
+ *
+ * @version     0.1
+ */
+
+#include "JSAccount.h"
+#include "JSFeatureArray.h"
+#include "JSAccountServices.h"
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <CommonsJavaScript/Converter.h>
+#include "AccountConverter.h"
+#include "plugin_config.h"
+
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/SecurityExceptions.h>
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Account{
+
+namespace {
+
+#define ACCOUNT_ATTRIBUTE_NAME  "Account"
+
+#define ACCOUNT_ATTRIBUTE_ACCOUNT_ID  "id"
+#define ACCOUNT_ATTRIBUTE_DISPLAY_NAME  "displayName"
+#define ACCOUNT_ATTRIBUTE_ICON_PATH  "icon"
+#define ACCOUNT_ATTRIBUTE_ENABLED  "enabled"
+#define ACCOUNT_ATTRIBUTE_PROVIDER_ID  "providerId"
+#define ACCOUNT_ATTRIBUTE_CREDENTIAL_ID  "credentialId"
+#define ACCOUNT_ATTRIBUTE_SERVICES  "services"
+#define ACCOUNT_ATTRIBUTE_SETTINGS  "settings"
+
+#define ACCOUNT_FUNCTION_GET_SERVICE_BY_ID    "getServiceById"
+#define ACCOUNT_FUNCTION_GET_SERVICE_BY_NAME  "getServiceByName"
+
+}
+
+JSClassDefinition JSAccount::m_classInfo = {
+    0,
+    kJSClassAttributeNone,
+    ACCOUNT_ATTRIBUTE_NAME,
+    0,
+    m_property,
+    m_function, //m_function,
+    initialize,
+    finalize,
+    NULL, //hasProperty,
+    NULL, //getProperty,
+    NULL, //setProperty,
+    NULL, //deleteProperty,
+    NULL, //getPropertyNames,
+    NULL, //callAsFunction,
+    NULL, //callAsConstructor,
+    hasInstance, //hasInstance,
+    NULL, //convertToType,
+};
+
+JSStaticValue JSAccount::m_property[] = {
+    { ACCOUNT_ATTRIBUTE_ACCOUNT_ID, getProperty, setProperty, kJSPropertyAttributeNone },
+    { ACCOUNT_ATTRIBUTE_DISPLAY_NAME, getProperty, setProperty, kJSPropertyAttributeNone },
+    { ACCOUNT_ATTRIBUTE_ICON_PATH, getProperty, setProperty, kJSPropertyAttributeNone },
+    { ACCOUNT_ATTRIBUTE_ENABLED, getProperty, setProperty, kJSPropertyAttributeNone },
+    { ACCOUNT_ATTRIBUTE_PROVIDER_ID, getProperty, setProperty, kJSPropertyAttributeNone },
+    { ACCOUNT_ATTRIBUTE_CREDENTIAL_ID, getProperty, setProperty, kJSPropertyAttributeNone },
+    { ACCOUNT_ATTRIBUTE_SERVICES, getServices, setServices, kJSPropertyAttributeNone },
+    { ACCOUNT_ATTRIBUTE_SETTINGS, getProperty, setProperty, kJSPropertyAttributeNone },
+    { 0, 0, 0, 0 }
+};
+
+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());
+
+const JSClassDefinition* JSAccount::getClassInfo()
+{
+    return &(m_classInfo);
+}
+
+JSClassRef JSAccount::getClassRef()
+{
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+EventAccountPtr JSAccount::getIEvent(JSObjectRef object)
+{
+    LogDebug("entered");
+    AccountPrivateObject *priv =
+        static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
+    if (!priv) {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    EventAccountPtr result = priv->getObject();
+    if (!result) {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    return result;
+}
+
+void JSAccount::setIEvent(const EventAccountPtr &event,
+        JSContextRef ctx,
+        const JSObjectRef object)
+{
+    LogDebug("entered");
+    Try
+    {
+        AccountPrivateObject *priv =
+            static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
+        delete priv;
+        priv = new AccountPrivateObject(ctx, event);
+        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+            delete priv;
+        }
+    }
+    Catch(Exception)
+    {
+        LogError("Error during replacing account object");
+    }
+}
+
+
+bool JSAccount::validate(JSContextRef ctx,
+        const JSObjectRef object,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    AccountPrivateObject *priv =
+        static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
+    if (priv == NULL) {
+        return false;
+    }
+    EventAccountPtr account = priv->getObject();
+    if (!account) {
+        return false;
+    }
+    return account->validate();
+}
+
+
+JSObjectRef JSAccount::createJSAccount(JSContextRef context, EventAccountPtr account)
+{
+       LogDebug("<<< ");
+       AccountPrivateObject *priv = new AccountPrivateObject(context, account);
+       JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+       return jsValueRef;
+}
+
+void JSAccount::initialize(JSContextRef context,
+        JSObjectRef object)
+{
+       LogDebug("<<< ");
+
+       AccountPrivateObject *privateObject = static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
+       if (NULL == privateObject) {
+               LogDebug("privateObject is NULL");
+       }
+}
+
+void JSAccount::finalize(JSObjectRef object)
+{
+    LogDebug("enter");
+    AccountPrivateObject* priv =
+        static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
+    delete priv;
+    JSObjectSetPrivate(object, NULL);
+}
+
+
+JSValueRef JSAccount::getProperty(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+    LogDebug("<<<");
+    AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
+    Try
+    {
+        AccountPrivateObject* priv = static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
+        if (!priv) {
+            Throw(NullPointerException);
+        }
+        EventAccountPtr account = priv->getObject();
+
+        if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_ACCOUNT_ID)) {
+            return converter->toJSValueRef(account->getAccountId());
+               } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_DISPLAY_NAME)) {
+                       return converter->toJSValueRef(account->getDisplayName());
+               } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_ICON_PATH)) {
+                       return converter->toJSValueRef(account->getIconPath());
+               } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_ENABLED)) {
+                       return converter->toJSValueRef(account->getEnabled());
+               } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_PROVIDER_ID)) {
+                       return converter->toJSValueRef(account->getProviderName());
+               } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_CREDENTIAL_ID)) {
+                       return converter->toJSValueRefLong(account->getCredentailId());
+               } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_SETTINGS)) {
+                       return converter->toJSValueRef(account->getSettings());
+               }
+    }
+    Catch(Exception)
+    {
+        LogError("invalid property");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+bool JSAccount::setProperty(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        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;
+}
+
+JSValueRef JSAccount::getServices(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+       LogDebug("<<<");
+
+       AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
+       Try{
+               AccountPrivateObject* priv = static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(NullPointerException);
+               }
+               EventAccountPtr account = priv->getObject();
+
+               AccountServicesArrayPtr services = account->getService();
+               if (services) {
+                       JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
+                       if (NULL == jsResult) {
+                               ThrowMsg(NullPointerException, "Could not create js array object");
+                       }
+                       for(unsigned int i = 0; i < services->size(); i++) {
+                               if (!JSSetArrayElement(context, jsResult, i, JSAccountServices::createJSObject(context, services->at(i)))) {
+                                       ThrowMsg(UnknownException, "Could not insert value into js array");
+                               }
+                       }
+
+                       LogDebug(">>> jsResult");
+                       return jsResult;
+               }
+       }       Catch(Exception)        {
+               LogWarning("trying to get incorrect value");
+       }
+
+       LogDebug(">>> undefined");
+       return JSValueMakeUndefined(context);
+}
+
+bool JSAccount::setServices(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        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;
+}
+
+JSValueRef JSAccount::getServiceById(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_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 << "]");
+
+                       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));
+                                       }
+                               }
+
+                               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");
+               }
+
+               LogDebug(">>> return null");
+               return JSValueMakeNull(context);
+}
+
+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);
+
+               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 << "]");
+
+               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));
+                               }
+                       }
+
+                       AccountLogWarning("not supported service name:[" << serviceName << "]");
+               }else{
+                       AccountLogWarning("services is NULL");
+               }
+       }Catch(Exception){
+               LogDebug(">>> UNKNOWN EXCEPTION");
+               return JSTizenExceptionFactory::postException(context, exception,
+                                                                                               JSTizenException::UNKNOWN_ERROR, "UNKNOWN EXCEPTION");
+       }
+
+       LogDebug(">>> return null");
+       return JSValueMakeNull(context);
+}
+
+bool JSAccount::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+}
+}
+}
diff --git a/src/standards/Tizen/Account/JSAccount.h b/src/standards/Tizen/Account/JSAccount.h
new file mode 100755 (executable)
index 0000000..212cd69
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/*
+ * @file        JSAttendee.h
+ *
+ * @version     0.1
+ */
+
+#ifndef _JS_ACCOUNT_H_
+#define _JS_ACCOUNT_H_
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Account/EventAccount.h>
+#include <API/Account/log.h>
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Account{
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<EventAccountPtr>::Type AccountPrivateObject;
+
+class JSAccount
+{
+  public:
+
+    static const JSClassDefinition* getClassInfo();
+
+    static JSClassRef getClassRef();
+
+   //TODO: check if createJSAccount is necessary.
+    static JSObjectRef createJSAccount(JSContextRef context, EventAccountPtr event);
+
+
+    static EventAccountPtr getIEvent(JSObjectRef object);
+
+    static void setIEvent(const EventAccountPtr &account,
+            JSContextRef ctx,
+            const JSObjectRef object);
+
+    static bool validate(JSContextRef ctx,
+            const JSObjectRef object,
+            JSValueRef* exception);
+
+  private:
+
+    /**
+     * The callback invoked when an object is first created.
+     */
+    static void initialize(JSContextRef context, JSObjectRef object);
+
+    /**
+     * The callback invoked when an object is finalized.
+     */
+    static void finalize(JSObjectRef object);
+
+    static JSValueRef getProperty(JSContextRef context,
+            JSObjectRef object,
+            JSStringRef propertyName,
+            JSValueRef* exception);
+
+    static bool setProperty(JSContextRef context,
+            JSObjectRef object,
+            JSStringRef propertyName,
+            JSValueRef value,
+            JSValueRef* exception);
+
+       static JSValueRef getServices(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception);
+
+       static bool setServices(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef value,
+        JSValueRef* exception);
+
+       static 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);
+
+       /**
+                * The callback invoked when an object is used as the target of an 'instanceof' expression.
+                */
+               static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+
+
+    static JSClassRef m_jsClassRef;
+
+    /**
+     * This structure 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_ATTENDEE_H_ */
diff --git a/src/standards/Tizen/Account/JSAccountManager.cpp b/src/standards/Tizen/Account/JSAccountManager.cpp
new file mode 100755 (executable)
index 0000000..db6fdb6
--- /dev/null
@@ -0,0 +1,654 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * @file        JSAccountManager.cpp
+* @author              Jihwa Park (jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ */
+
+#include <dpl/log/log.h>
+
+#include <string>
+#include <API/Account/IAccountService.h>
+#include <API/Account/IAccountManager.h>
+#include <API/Account/AccountFactory.h>
+#include <API/Account/IEventCreateAccount.h>
+#include <API/Account/IEventDeleteAccount.h>
+#include <API/Account/IEventFindAccounts.h>
+#include <API/Account/IEventUpdateAccount.h>
+#include <API/Account/IEventFindServiceTypes.h>
+
+#include <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
+#include <CommonsJavaScript/Utils.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 "AccountConverter.h"
+#include "ResponseDispatcher.h"
+#include "plugin_config.h"
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Commons;
+
+namespace {
+#define TIZEN_ACCOUNT_MANAGER_ATTRIBUTENAME  "account"
+
+#define TIZEN_ACCOUNT_PROP_TYPE_NONE  "TYPE_NONE"
+#define TIZEN_ACCOUNT_PROP_TYPE_INTERNET "TYPE_INTERNET"
+}
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Account{
+JSClassDefinition JSAccountManager::m_classInfo = {
+    0,
+    kJSClassAttributeNone,
+    TIZEN_ACCOUNT_MANAGER_ATTRIBUTENAME,
+    0,
+    m_property,
+    m_function,
+    initialize,
+    finalize,
+    NULL, //HasProperty,
+    NULL, //GetProperty,
+    NULL, //SetProperty,
+    NULL, //DeleteProperty,
+    NULL, //GetPropertyNames,
+    NULL, //CallAsFunction,
+    NULL, //CallAsConstructor,
+    NULL, //HasInstance,
+    NULL  //ConvertToType
+};
+
+JSStaticValue JSAccountManager::m_property[] = {
+    //event properties - recurence
+    { TIZEN_ACCOUNT_PROP_TYPE_NONE, getTypeProperty,NULL, kJSPropertyAttributeReadOnly },
+    { TIZEN_ACCOUNT_PROP_TYPE_INTERNET, getTypeProperty,NULL, kJSPropertyAttributeReadOnly },
+    { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSAccountManager::m_function[] = {
+       { ACCOUNT_FUNCTION_API_GET_ACCOUNT_BY_ID,             getAccountById,            kJSPropertyAttributeNone },
+       { ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID,         getServiceTypeById,        kJSPropertyAttributeNone },
+       { ACCOUNT_FUNCTION_API_GET_PROVIDER_BY_ID,            getProviderById,           kJSPropertyAttributeNone },
+       { ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_SERVICETYPE,  findAccountsByServiceType, kJSPropertyAttributeNone },
+       { ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_TAGS,         findAccountsByTags,        kJSPropertyAttributeNone },
+       { ACCOUNT_FUNCTION_API_FIND_SERVICES_BY_TAGS,         findServicesByTags,        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 },
+       { 0, 0, 0 }
+};
+
+JSClassRef JSAccountManager::m_jsClassRef = JSClassCreate(
+        JSAccountManager::getClassInfo());
+
+void JSAccountManager::initialize(JSContextRef context,
+        JSObjectRef object)
+{
+    LogDebug("entered");
+    AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(object));
+    if (NULL == privateObject) {
+        IAccountManagerPtr accountManager = AccountFactory::getInstance().createAccountManagerObject();
+        privateObject = new AccountManagerPrivObject(context, accountManager);
+        if (!JSObjectSetPrivate(object, static_cast<void*>(privateObject))) {
+            delete privateObject;
+        }
+    }
+}
+
+void JSAccountManager::finalize(JSObjectRef object)
+{
+    AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(object));
+    delete privateObject;
+}
+
+/**
+ *     definition
+ * Account addAccount(AccountServiceProviderId providerId, optional AccountProperties? properties);
+ */
+JSValueRef JSAccountManager::addAccount(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        JSValueRef* exception)
+{
+       LogDebug("<<<");
+       AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
+       assert(privateObject);
+
+       JSContextRef globalContext = privateObject->getContext();
+       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_ADD_ACCOUNT);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       Try{
+               if (argumentCount > 3) {
+                       LogError("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);
+               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);
+
+
+               if (!account) {
+                       LogError("Failed to get an event.");
+                       return JSTizenExceptionFactory::postException(context, exception,
+                                                                                                       JSTizenException::UNKNOWN_ERROR, "Failed to get an event");
+               }
+
+               IEventAddAccountPtr dplEvent(new IEventAddAccount());
+               dplEvent->setEvent(account);
+               dplEvent->setForSynchronousCall();
+               privateObject->getObject()->addAccount(dplEvent);
+
+               if (dplEvent->getResult()){
+                       LogDebug(">>>");
+                       return converter->toJSValueRefAccount(dplEvent->getEvent());
+               }else{
+                       return JSTizenExceptionFactory::postException(context, exception,
+                                                                                                       JSTizenException::UNKNOWN_ERROR, "Unknown error");
+               }
+       }       Catch(InvalidArgumentException){
+               LogError("Invalid argument");
+               return JSTizenExceptionFactory::postException(context, exception,
+                                                                                               JSTizenException::TYPE_MISMATCH_ERROR, "Invalid argument");
+       }       Catch(Exception)        {
+               LogError("Unexpected error during adding account");
+               return JSTizenExceptionFactory::postException(context, exception,
+                                                                                               JSTizenException::UNKNOWN_ERROR, "Unexpected error during adding account");
+       }
+
+       return JSValueMakeNull(context);
+}
+
+
+/**
+ * @throw InvalidArgumentException If not a callback nor JS null nor JS undefined.
+ */
+JSValueRef getFunctionOrNull(JSContextRef ctx,
+        JSValueRef arg)
+{
+    if (Validator(ctx).isCallback(arg))
+       {
+               LogDebug("isCallback");
+        return arg;
+    }else if(!JSValueIsNull(ctx, arg) && !JSValueIsUndefined(ctx, arg))
+    {
+               LogDebug("not Callback");
+        ThrowMsg(InvalidArgumentException, "Not a function nor JS null.");
+    }
+    return NULL;
+}
+
+JSValueRef JSAccountManager::addAccountlistener(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    return JSDOMExceptionFactory::UnknownException.make(context, exception);
+}
+
+JSValueRef JSAccountManager::removeAccountlistener(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    return JSDOMExceptionFactory::UnknownException.make(context, exception);
+}
+
+JSValueRef JSAccountManager::getAccountById(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        JSValueRef* exception)
+{
+       LogDebug("<<<");
+
+       AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
+       assert(privateObject);
+
+       JSContextRef globalContext = privateObject->getContext();
+       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_GET_ACCOUNT_BY_ID);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       Try{
+               if (argumentCount != 1) {
+                       LogError(">>> Wrong number of parameters.");
+                       return JSTizenExceptionFactory::postException(context, exception,
+                                                                               JSTizenException::TYPE_MISMATCH_ERROR, "Wrong argument count:"+argumentCount);
+               }
+
+               if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0]) || !JSValueIsString(context, arguments[0])){
+                       return JSTizenExceptionFactory::postException(context, exception,
+                                                                                                       JSTizenException::INVALID_VALUES_ERROR, "Invlid value");
+               }
+
+               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
+
+               EventAccountPtr account(new EventAccount());
+               std::string accountId = converter->convertTostring(arguments[0]);
+               account->setAccountId(accountId);
+               if (!account) {
+                       AccountLogError(">>> Failed to get an event.");
+                       return JSTizenExceptionFactory::postException(context, exception,
+                                                                                                                               JSTizenException::UNKNOWN_ERROR, "UNKNOWN ERROR");
+               }
+
+               IEventGetAccountByIdPtr dplEvent(new IEventGetAccountById());
+               dplEvent->setEvent(account);
+               dplEvent->setForSynchronousCall();
+               privateObject->getObject()->getAccountById(dplEvent);
+
+               if (dplEvent->getResult()){
+                       LogDebug(">>>");
+                       return converter->toJSValueRefAccount(dplEvent->getEvent());
+               }else{
+                       AccountLogError("Unexpected error");
+                       return JSDOMExceptionFactory::UnknownException.make(context, exception);
+               }
+       }       Catch(InvalidArgumentException){
+               AccountLogError("Invalid argument");
+               return JSTizenExceptionFactory::postException(context, exception,
+                                                                                                                                               JSTizenException::TYPE_MISMATCH_ERROR, "Invalid argument");
+       }Catch(Exception){
+               AccountLogError("Unexpected error");
+               return JSTizenExceptionFactory::postException(context, exception,
+                                                                                                                                                               JSTizenException::UNKNOWN_ERROR, "Unexpected error");
+       }
+
+       AccountLogWarning(">>> return NULL");
+       return JSValueMakeNull(context);
+}
+
+JSValueRef JSAccountManager::getServiceTypeById(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        JSValueRef* exception)
+{
+       LogDebug("<<<");
+
+       AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
+       assert(privateObject);
+
+       JSContextRef globalContext = privateObject->getContext();
+       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       Try{
+               if (argumentCount != 1) {
+                       AccountLogError(">>> Wrong number of parameters.");
+                       return JSTizenExceptionFactory::postException(context, exception,
+                                                                                               JSTizenException::TYPE_MISMATCH_ERROR, "Wrong number of parameters.");
+               }
+
+               if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0]) || !JSValueIsString(context, arguments[0])){
+                       AccountLogError(">>> invalid value argument 0");
+                       return JSTizenExceptionFactory::postException(context, exception,
+                                                                       JSTizenException::INVALID_VALUES_ERROR, "invalid value argument 0");
+               }
+
+               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
+
+               EventAccountPtr account(new EventAccount());
+               std::string serviceTypeId = converter->convertTostring(arguments[0]);
+               LogDebug("serviceTypeId:[" << serviceTypeId << "]");
+               account->setServiceTypeId(serviceTypeId);
+               if (!account) {
+                       AccountLogError(">>> Failed to get an event.");
+                       return JSTizenExceptionFactory::postException(context, exception,
+                                                                                               JSTizenException::UNKNOWN_ERROR, "Failed to get an event.");
+               }
+
+               IEventGetServiceTypeByIdPtr dplEvent(new IEventGetServiceTypeById());
+               dplEvent->setEvent(account);
+               dplEvent->setForSynchronousCall();
+               privateObject->getObject()->getServiceTypeById(dplEvent);
+
+               if (dplEvent->getResult()){
+                       JSValueRef retVal = converter->toJSValueRefAccountServiceType(dplEvent->getAccountServiceTypeProperty());
+                       LogDebug(">>> RESULT");
+                       return retVal;
+               }       else{
+                       AccountLogError(">>> Get result fail");
+                       return JSTizenExceptionFactory::postException(context, exception,
+                                                                                                                       JSTizenException::UNKNOWN_ERROR, "Get result fail");
+               }
+       }       Catch(InvalidArgumentException) {
+               AccountLogError("Invalid argument");
+               return JSTizenExceptionFactory::postException(context, exception,
+                                                                                                                                       JSTizenException::TYPE_MISMATCH_ERROR, "Invalid argument");
+       }       Catch(Exception)        {
+               AccountLogError("Unexpected error during adding account");
+               return JSTizenExceptionFactory::postException(context, exception,
+                                                                                                                                                       JSTizenException::TYPE_MISMATCH_ERROR, "Unexpected error during adding account");
+       }
+
+       AccountLogWarning(">>> return NULL");
+       return JSValueMakeNull(context);
+}
+
+JSValueRef JSAccountManager::getProviderById(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        JSValueRef* exception)
+{
+       LogDebug("<<<");
+       AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
+       assert(privateObject);
+
+       JSContextRef globalContext = privateObject->getContext();
+       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       Try{
+               if (argumentCount != 1) {
+                       AccountLogError(">>> Wrong number of parameters.");
+                       return JSTizenExceptionFactory::postException(context, exception,
+             JSTizenException::TYPE_MISMATCH_ERROR, "Wrong number of parameters.");
+               }
+
+               if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0]) || !JSValueIsString(context, arguments[0])){
+                       AccountLogError(">>> invalid value argument 0");
+                       return JSTizenExceptionFactory::postException(context, exception,
+             JSTizenException::INVALID_VALUES_ERROR, "invalid value argument 0");
+               }
+
+               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
+
+               EventAccountPtr account(new EventAccount());
+               std::string accountServiceProviderId = converter->convertTostring(arguments[0]);
+               LogDebug("accountServiceProviderId:[" << accountServiceProviderId << "]");
+
+               account->setProviderId(accountServiceProviderId);
+               if (!account) {
+                       AccountLogError(">>> Failed to get an event.");
+                       return JSTizenExceptionFactory::postException(context, exception,
+             JSTizenException::UNKNOWN_ERROR, "Failed to get an event.");
+               }
+
+               IEventGetProviderByIdPtr dplEvent(new IEventGetProviderById());
+               dplEvent->setEvent(account);
+               dplEvent->setForSynchronousCall();
+               privateObject->getObject()->getProviderById(dplEvent);
+
+               if (dplEvent->getResult()){
+                       LogDebug(">>>");
+                       JSValueRef retVal = converter->toJSValueRefAccountServiceProvider(dplEvent->getAccountServiceProviderProperty());
+                       LogDebug(">>>");
+                       return retVal;
+               }else{
+                       AccountLogError(">>> Get result fail");
+                       return JSTizenExceptionFactory::postException(context, exception,
+             JSTizenException::UNKNOWN_ERROR, "Get result fail");
+               }
+       }Catch(InvalidArgumentException){
+               AccountLogError("Invalid argument");
+               return JSTizenExceptionFactory::postException(context, exception,
+           JSTizenException::TYPE_MISMATCH_ERROR, "Invalid argument");
+       }       Catch(Exception)        {
+               AccountLogError("Unexpected error during adding account");
+               return JSTizenExceptionFactory::postException(context, exception,
+           JSTizenException::TYPE_MISMATCH_ERROR, "Unexpected error during adding account");
+       }
+
+       return JSValueMakeNull(context);
+}
+
+JSValueRef JSAccountManager::findAccountsByServiceType(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    return JSDOMExceptionFactory::UnknownException.make(context, exception);
+}
+
+JSValueRef JSAccountManager::findAccountsByTags(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    return JSDOMExceptionFactory::UnknownException.make(context, exception);
+}
+
+JSValueRef JSAccountManager::findServicesByTags(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    return JSDOMExceptionFactory::UnknownException.make(context, exception);
+}
+
+JSValueRef JSAccountManager::findProviders(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        JSValueRef* exception)
+{
+    LogDebug("entered!!!!");
+       AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
+    assert(privateObject);
+
+       JSContextRef globalContext = privateObject->getContext();
+       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_FIND_PROVIDERS);
+       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);
+               }
+
+               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());
+               }
+
+               IEventFindProvidersPtr dplEvent(new IEventFindProviders());
+               dplEvent->setEvent(account);
+               dplEvent->setForSynchronousCall();
+               privateObject->getObject()->FindProviders(dplEvent);
+
+               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);
+}
+
+/**
+ * AccountServiceType[]? findServiceTypes(DOMString? prefix)
+ */
+JSValueRef JSAccountManager::findServiceTypes(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        JSValueRef* exception)
+{
+       LogDebug("<<<");
+
+       AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
+       assert(privateObject);
+
+       JSContextRef globalContext = privateObject->getContext();
+       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       Try{
+               IEventFindServiceTypesPtr eventPtr(new IEventFindServiceTypes());
+
+               if (argumentCount == 1) {
+                       if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0]) || !JSValueIsString(context, arguments[0])){
+                               AccountLogError(">>> invalid value argument 0");
+                               return JSTizenExceptionFactory::postException(context, exception,
+                                                                               JSTizenException::INVALID_VALUES_ERROR, "invalid value argument 0");
+                       }
+
+                       //TODO input argument
+                       AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
+                       std::string prefix = converter->convertTostring(arguments[0]);
+                       LogDebug("prefix:[" << prefix << "]");
+                       eventPtr->setPrefix(prefix);
+               }
+
+               eventPtr->setForSynchronousCall();
+               privateObject->getObject()->findServiceTypes(eventPtr);
+
+               if (eventPtr->getResult()){
+                       AccountServiceTypePropertyArrayPtr properties = eventPtr->getAccountServiceTypeProperties();
+                       if(properties){
+                               JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
+                               if (NULL == jsResult) {
+                                       ThrowMsg(NullPointerException, "Could not create js array object");
+                               }
+
+                               for(unsigned int i = 0; i < properties->size(); i++) {
+                                       if (!JSSetArrayElement(context, jsResult, i, JSAccountServiceType::createJSObject(context, properties->at(i)))) {
+                                               ThrowMsg(UnknownException, "Could not insert value into js array");
+                                       }
+                               }// for
+
+                               LogDebug(">>>");
+                               return jsResult;
+                       }// if(properties)
+               }else{
+                       AccountLogError(">>> Get result fail");
+                       return JSTizenExceptionFactory::postException(context, exception,
+               JSTizenException::UNKNOWN_ERROR, "Get result fail");
+               }
+       }       Catch(InvalidArgumentException) {
+               AccountLogError("Invalid argument");
+               return JSTizenExceptionFactory::postException(context, exception,
+                                                                                                                                       JSTizenException::TYPE_MISMATCH_ERROR, "Invalid argument");
+       }       Catch(Exception)        {
+               AccountLogError("Unexpected error during adding account");
+               return JSTizenExceptionFactory::postException(context, exception,
+                                                                                                                                                       JSTizenException::TYPE_MISMATCH_ERROR, "Unexpected error during adding account");
+       }
+
+       AccountLogWarning(">>> return undefined");
+       return JSValueMakeUndefined(context);
+}
+
+const JSClassRef JSAccountManager::getClassRef()
+{
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+const JSClassDefinition* JSAccountManager::getClassInfo()
+{
+    return &m_classInfo;
+}
+
+JSValueRef JSAccountManager::getTypeProperty(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter conveter(context);
+        std::string property = conveter.toString(propertyName);
+               if (property == TIZEN_ACCOUNT_PROP_TYPE_NONE) {
+                       return conveter.toJSValueRef(JSAccountManager::TYPE_NONE);
+               }else if(property == TIZEN_ACCOUNT_PROP_TYPE_INTERNET) {
+                       return conveter.toJSValueRef(JSAccountManager::TYPE_INTERNET);
+               }
+    }
+    Catch(Exception)
+    {
+        LogWarning("conversion error");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+}
+}
+}
+
diff --git a/src/standards/Tizen/Account/JSAccountManager.h b/src/standards/Tizen/Account/JSAccountManager.h
new file mode 100755 (executable)
index 0000000..9cf010d
--- /dev/null
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * @file               JSAccountManager.h
+* @author              Jihwa Park (jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ */
+
+#ifndef _JS_TIZEN_ACCOUNT_MANAGER_H_
+#define _JS_TIZEN_ACCOUNT_MANAGER_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Account/IAccountManager.h>
+#include <API/Account/IAccountService.h>
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Account{
+typedef PrivateObject<IAccountManagerPtr, NoOwnership> AccountManagerPrivObject;
+
+class JSAccountManager
+{
+  public:
+
+    enum AccountType
+    {
+        TYPE_NONE,      //0
+     //   TYPE_SIM,   //1
+        TYPE_INTERNET,  //2//1
+        INVALID_TYPE = 10000
+    };
+
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+
+  private:
+    /**
+     * This structure describes a statically declared function property.
+     */
+    static JSStaticFunction m_function[];
+
+    /**
+     * This member variable contains the initialization values for the
+     * properties of this class. The values are given according to
+     * the data structure JSPropertySpec
+     */
+    static JSStaticValue m_property[];
+
+    /**
+     * This structure contains properties and callbacks
+     * that define a type of object.
+     */
+    static JSClassDefinition m_classInfo;
+
+    static JSClassRef m_jsClassRef;
+
+    /**
+     * The callback invoked when an object is first created.
+     */
+    static void initialize(JSContextRef context,
+            JSObjectRef object);
+
+    /**
+     * The callback invoked when an object is finalized.
+     */
+    static void finalize(JSObjectRef object);
+
+    /**
+     * Get Accounts.
+     */
+
+    static JSValueRef addAccount(JSContextRef context,
+            JSObjectRef object,
+            JSObjectRef thisObject,
+            size_t argumentCount,
+            const JSValueRef arguments[],
+            JSValueRef* exception);
+
+       static JSValueRef addAccountlistener(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       static JSValueRef removeAccountlistener(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       static JSValueRef getAccountById(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       static JSValueRef getServiceTypeById(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       static JSValueRef getProviderById(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       static JSValueRef findAccountsByServiceType(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       static JSValueRef findAccountsByTags(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       static JSValueRef findServicesByTags(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       static JSValueRef findProviders(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       static JSValueRef findServiceTypes(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+    static JSValueRef getTypeProperty(JSContextRef context,
+            JSObjectRef object,
+            JSStringRef propertyName,
+            JSValueRef* exception);
+
+
+
+
+
+};
+}
+}
+}
+#endif /* _JS_TIZEN_ACCOUNT_MANAGER_H_ */
diff --git a/src/standards/Tizen/Account/JSAccountService.cpp b/src/standards/Tizen/Account/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/JSAccountService.h b/src/standards/Tizen/Account/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_ */
+
diff --git a/src/standards/Tizen/Account/JSAccountServiceProvider.cpp b/src/standards/Tizen/Account/JSAccountServiceProvider.cpp
new file mode 100755 (executable)
index 0000000..b74d78f
--- /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.
+ */
+
+
+
+/*
+ * JSAccountServiceProvider.cpp
+ *
+ *  Created on: 2012. 2. 1.
+ *      Author: sangtai
+ */
+
+#include "JSAccountServiceProvider.h"
+
+#include <CommonsJavaScript/Converter.h>
+#include "AccountConverter.h"
+
+namespace TizenApis {
+       namespace Tizen1_0{
+               namespace Account {
+                       namespace {
+                               #define ACCOUNT_SERVICE_PROVIDER               "AccountServiceProvider"
+                               #define ACCOUNT_SERVICE_PROVIDER_ID            "id"
+                               #define ACCOUNT_SERVICE_PROVIDER_DISPLAY_NAME  "displayName"
+                               #define ACCOUNT_SERVICE_PROVIDER_ICON_PATH     "icon"
+                       }
+
+                       JSClassDefinition JSAccountServiceProvider::m_classInfo = {
+                               0,
+                               kJSClassAttributeNone,
+                               ACCOUNT_SERVICE_PROVIDER,
+                               0,
+                               m_property,
+                               NULL, //m_function,
+                               initialize,
+                               finalize,
+                               NULL, //hasProperty,
+                               NULL, //getProperty,
+                               NULL, //setProperty,
+                               NULL, //deleteProperty,
+                               NULL, //getPropertyNames,
+                               NULL, //callAsFunction,
+                               NULL, //callAsConstructor,
+                               NULL, //hasInstance,
+                               NULL, //convertToType,
+                       };
+
+                       JSStaticValue JSAccountServiceProvider::m_property[] = {
+                               { ACCOUNT_SERVICE_PROVIDER_ID,           getProperty, NULL, kJSPropertyAttributeNone },
+                               { ACCOUNT_SERVICE_PROVIDER_DISPLAY_NAME, getProperty, NULL, kJSPropertyAttributeNone },
+                               { ACCOUNT_SERVICE_PROVIDER_ICON_PATH,    getProperty, NULL, kJSPropertyAttributeNone },
+                               { 0, 0, 0, 0 }
+                       };
+
+                       JSClassRef JSAccountServiceProvider::m_jsClassRef = JSClassCreate(
+                                       JSAccountServiceProvider::getClassInfo());
+
+                       const JSClassDefinition* JSAccountServiceProvider::getClassInfo(){
+                               return &(m_classInfo);
+                       }
+
+                       JSClassRef JSAccountServiceProvider::getClassRef()                      {
+                               if (!m_jsClassRef) {
+                                       m_jsClassRef = JSClassCreate(&m_classInfo);
+                               }
+                               return m_jsClassRef;
+                       }
+
+                       JSObjectRef JSAccountServiceProvider::createJSObject(JSContextRef context, AccountServiceProviderPropertyPtr propertyPtr){
+                               LogDebug("<<<");
+
+                               AccountServiceProviderPrivateObject *priv = new AccountServiceProviderPrivateObject(context, propertyPtr);
+
+                               JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+                               LogDebug(">>>");
+                               return jsValueRef;
+                       }
+
+                       void JSAccountServiceProvider::initialize(JSContextRef context, JSObjectRef object) {
+                               LogDebug("<<< ");
+                               AccountServiceProviderPrivateObject *privateObject = static_cast<AccountServiceProviderPrivateObject*>(JSObjectGetPrivate(object));
+                               if (NULL == privateObject) {
+                                       AccountLogWarning("privateObject is NULL");
+                               }
+                       }
+
+                       void JSAccountServiceProvider::finalize(JSObjectRef object) {
+                               LogDebug("<<<");
+                               AccountServiceProviderPrivateObject* priv = static_cast<AccountServiceProviderPrivateObject*>(JSObjectGetPrivate(object));
+                               delete priv;
+                               JSObjectSetPrivate(object, NULL);
+                       }
+
+                               JSValueRef JSAccountServiceProvider::getProperty(JSContextRef context,
+                                       JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
+                               LogDebug("<<<");
+                               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
+                               Try{
+                                       AccountServiceProviderPrivateObject* priv = static_cast<AccountServiceProviderPrivateObject*>(JSObjectGetPrivate(object));
+                                       if (!priv) {
+                                               Throw(NullPointerException);
+                                       }
+                                       AccountServiceProviderPropertyPtr accountServicePropertyProperty = priv->getObject();
+
+                                       if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICE_PROVIDER_ID)) {
+                                               return converter->toJSValueRef(accountServicePropertyProperty->getId());
+                                       } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICE_PROVIDER_DISPLAY_NAME)) {
+                                               return converter->toJSValueRef(accountServicePropertyProperty->getDisplayName());
+                                       } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICE_PROVIDER_ICON_PATH)) {
+                                               return converter->toJSValueRef(accountServicePropertyProperty->getIconPath());
+                                       }
+                               }       Catch(Exception){
+                                       AccountLogError("invalid property");
+                               }
+
+                               AccountLogWarning(">>> return undefined");
+                               return JSValueMakeUndefined(context);
+                       }
+
+               } /* namespace Account */
+       } /* namespace Tizen1_0 */
+} /* namespace TizenApis */
diff --git a/src/standards/Tizen/Account/JSAccountServiceProvider.h b/src/standards/Tizen/Account/JSAccountServiceProvider.h
new file mode 100755 (executable)
index 0000000..b8f1ee8
--- /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.
+ */
+
+
+
+
+/*
+ * JSAccountServiceProvider.h
+ *
+ *  Created on: 2012. 2. 1.
+ *      Author: sangtai
+ */
+
+#ifndef JSACCOUNTSERVICEPROVIDER_H_
+#define JSACCOUNTSERVICEPROVIDER_H_
+
+#include <string>
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Account/AccountServiceProviderProperty.h>
+#include <API/Account/log.h>
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+       namespace Tizen1_0 {
+               namespace Account {
+
+                       typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<AccountServiceProviderPropertyPtr>::Type AccountServiceProviderPrivateObject;
+
+                       class JSAccountServiceProvider {
+
+                               public:
+                                       static const JSClassDefinition* getClassInfo();
+
+                                       static JSClassRef getClassRef();
+                                       static JSObjectRef createJSObject(JSContextRef context, AccountServiceProviderPropertyPtr propertyPtr);
+
+                               private:
+                                       /**
+                                        * The callback invoked when an object is first created.
+                                        */
+                                       static void initialize(JSContextRef context, JSObjectRef object);
+
+                                       /**
+                                        * The callback invoked when an object is finalized.
+                                        */
+                                       static void finalize(JSObjectRef object);
+
+                                       static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+                                       static JSClassRef m_jsClassRef;
+
+                                       /**
+                                        * This structure contains properties and callbacks that define a type of object.
+                                        */
+                                       static JSClassDefinition m_classInfo;
+
+                                       /**
+                                        * This member variable contains the initialization values for the static properties of this class.
+                                        * The values are given according to the data structure JSPropertySpec
+                                        */
+                                       static JSStaticValue m_property[];
+                       };
+
+               } /* namespace Account */
+       } /* namespace Api */
+} /* namespace Tizen1_0 */
+#endif /* JSACCOUNTSERVICEPROVIDER_H_ */
diff --git a/src/standards/Tizen/Account/JSAccountServiceType.cpp b/src/standards/Tizen/Account/JSAccountServiceType.cpp
new file mode 100755 (executable)
index 0000000..82b9990
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/*
+ * JSServiceType.cpp
+ *
+ *  Created on: 2012. 1. 30.
+ *      Author: sangtai
+ */
+
+#include "JSAccountServiceType.h"
+
+#include <CommonsJavaScript/Converter.h>
+#include "AccountConverter.h"
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+//using namespace TizenApis::Commons;
+
+namespace TizenApis {
+       namespace Tizen1_0 {
+               namespace Account {
+
+                       namespace {
+                               #define ACCOUNT_SERVICE_TYPE               "AccountServiceType"
+                               #define ACCOUNT_SERVICE_TYPE_ID            "id"
+                               #define ACCOUNT_SERVICE_TYPE_DISPLAY_NAME  "displayName"
+                               #define ACCOUNT_SERVICE_TYPE_ICON_PATH     "icon"
+                               #define ACCOUNT_SERVICE_TYPE_TAGS          "tags"
+                       }
+
+                       JSClassDefinition JSAccountServiceType::m_classInfo = {
+                               0,
+                               kJSClassAttributeNone,
+                               ACCOUNT_SERVICE_TYPE,
+                               0,
+                               m_property,
+                               NULL, //m_function,
+                               initialize,
+                               finalize,
+                               NULL, //hasProperty,
+                               NULL, //getProperty,
+                               NULL, //setProperty,
+                               NULL, //deleteProperty,
+                               NULL, //getPropertyNames,
+                               NULL, //callAsFunction,
+                               NULL, //callAsConstructor,
+                               NULL, //hasInstance,
+                               NULL, //convertToType,
+                       };
+
+                       JSStaticValue JSAccountServiceType::m_property[] = {
+                               { ACCOUNT_SERVICE_TYPE_ID,           getProperty, NULL, kJSPropertyAttributeNone },
+                               { ACCOUNT_SERVICE_TYPE_DISPLAY_NAME, getProperty, NULL, kJSPropertyAttributeNone },
+                               { ACCOUNT_SERVICE_TYPE_ICON_PATH,    getProperty, NULL, kJSPropertyAttributeNone },
+                               { ACCOUNT_SERVICE_TYPE_TAGS,         getProperty, NULL, kJSPropertyAttributeNone },
+                               { 0, 0, 0, 0 }
+                       };
+
+
+                       JSClassRef JSAccountServiceType::m_jsClassRef = JSClassCreate(
+                                       JSAccountServiceType::getClassInfo());
+
+                       const JSClassDefinition* JSAccountServiceType::getClassInfo(){
+                               return &(m_classInfo);
+                       }
+
+                       JSClassRef JSAccountServiceType::getClassRef()                  {
+                               if (!m_jsClassRef) {
+                                       m_jsClassRef = JSClassCreate(&m_classInfo);
+                               }
+                               return m_jsClassRef;
+                       }
+
+                       JSObjectRef JSAccountServiceType::createJSObject(JSContextRef context, AccountServiceTypePropertyPtr account){
+                               LogDebug("<<<");
+
+                               AccountServiceTypePrivateObject *priv = new AccountServiceTypePrivateObject(context, account);
+
+                               JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+                               LogDebug(">>>");
+                               return jsValueRef;
+                       }
+
+                       void JSAccountServiceType::initialize(JSContextRef context, JSObjectRef object) {
+                               LogDebug("<<< ");
+                               AccountServiceTypePrivateObject *privateObject = static_cast<AccountServiceTypePrivateObject*>(JSObjectGetPrivate(object));
+                               if (NULL == privateObject) {
+                                       LogDebug("privateObject is NULL");
+                               }
+                       }
+
+                       void JSAccountServiceType::finalize(JSObjectRef object) {
+                               LogDebug("<<<");
+                               AccountServiceTypePrivateObject* priv = static_cast<AccountServiceTypePrivateObject*>(JSObjectGetPrivate(object));
+                               delete priv;
+                               JSObjectSetPrivate(object, NULL);
+                       }
+
+                       JSValueRef JSAccountServiceType::getProperty(JSContextRef context,
+                                       JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
+                               LogDebug("<<<");
+                               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
+                               Try{
+                                       AccountServiceTypePrivateObject* priv = static_cast<AccountServiceTypePrivateObject*>(JSObjectGetPrivate(object));
+                                       if (!priv) {
+                                               Throw(NullPointerException);
+                                       }
+                                       AccountServiceTypePropertyPtr accountServiceTypeProperty = priv->getObject();
+
+                                       if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICE_TYPE_ID)) {
+                                               return converter->toJSValueRef(accountServiceTypeProperty->getId());
+                                       } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICE_TYPE_DISPLAY_NAME)) {
+                                               return converter->toJSValueRef(accountServiceTypeProperty->getDisplayName());
+                                       } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICE_TYPE_ICON_PATH)) {
+                                               return converter->toJSValueRef(accountServiceTypeProperty->getIconPath());
+                                       } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICE_TYPE_TAGS)) {
+                                                       return converter->toJSValueRef(accountServiceTypeProperty->getTags());
+                                       }
+                               }       Catch(Exception){
+                                       LogError("invalid property");
+                               }
+
+                               return JSValueMakeUndefined(context);
+                       }
+
+JSAccountServiceType::~JSAccountServiceType() {
+       // TODO Auto-generated destructor stub
+}
+
+               } //namespace Account
+       } //namespace Tizen1_0
+} //namespace TizenApis
diff --git a/src/standards/Tizen/Account/JSAccountServiceType.h b/src/standards/Tizen/Account/JSAccountServiceType.h
new file mode 100755 (executable)
index 0000000..d6d3519
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * JSServiceType.h
+ *
+ *  Created on: 2012. 1. 30.
+ *      Author: sangtai
+ */
+
+#ifndef JSACCOUNTSERVICETYPE_H_
+#define JSACCOUNTSERVICETYPE_H_
+
+#include <string>
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Account/AccountServiceTypeProperty.h>
+#include <API/Account/log.h>
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+       namespace Tizen1_0 {
+               namespace Account {
+
+                       typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<AccountServiceTypePropertyPtr>::Type AccountServiceTypePrivateObject;
+
+                       class JSAccountServiceType {
+                               public:
+                                       static const JSClassDefinition* getClassInfo();
+
+                                       static JSClassRef getClassRef();
+                                       static JSObjectRef createJSObject(JSContextRef context, AccountServiceTypePropertyPtr propertyPtr);
+
+                               private:
+                                       /**
+                                        * The callback invoked when an object is first created.
+                                        */
+                                       static void initialize(JSContextRef context, JSObjectRef object);
+
+                                       /**
+                                        * The callback invoked when an object is finalized.
+                                        */
+                                       static void finalize(JSObjectRef object);
+
+                                       static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+                                       virtual ~JSAccountServiceType();
+
+                                       static JSClassRef m_jsClassRef;
+
+                                       /**
+                                        * This structure contains properties and callbacks that define a type of object.
+                                        */
+                                       static JSClassDefinition m_classInfo;
+
+                                       /**
+                                        * This member variable contains the initialization values for the static properties of this class.
+                                        * The values are given according to the data structure JSPropertySpec
+                                        */
+                                       static JSStaticValue m_property[];
+                       };
+
+               } //namespace Account
+       } //namespace Tizen1_0
+} //namespace TizenApis
+
+#endif /* JSACCOUNTSERVICETYPE_H_ */
diff --git a/src/standards/Tizen/Account/JSAccountServices.cpp b/src/standards/Tizen/Account/JSAccountServices.cpp
new file mode 100755 (executable)
index 0000000..cc6b6cf
--- /dev/null
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file        JSAccountServices.cpp
+ * @author      Jihwa park (jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ * @brief       Implementation of the JSAccountServices class
+ */
+
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/Converter.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include "AccountConverter.h"
+#include "JSAccountServices.h"
+
+namespace {
+#define TIZEN_ACCOUNT_CLASS_ACCOUNT_SERVICE    "service"
+
+#define ACCOUNT_SERVICES_ATTR_SERVICE_ID                "id"
+#define ACCOUNT_SERVICES_ATTR_SERVICE_NAME              "name"
+#define ACCOUNT_SERVICES_ATTR_SERVICE_APPLICATION_ID    "applicationId"
+#define ACCOUNT_SERVICES_ATTR_SERVICE_DISPLAY_NAME      "displayName"
+#define ACCOUNT_SERVICES_ATTR_SERVICE_ICON              "icon"
+#define ACCOUNT_SERVICES_ATTR_SERVICE_ACCOUNT_ID        "accountId"
+#define ACCOUNT_SERVICES_ATTR_SERVICE_SERVICE_TYPE_ID   "serviceTypeId"
+#define ACCOUNT_SERVICES_ATTR_SERVICE_PROVIDER_ID       "providerId"
+#define ACCOUNT_SERVICES_ATTR_SERVICE_TAGS              "tags"
+#define ACCOUNT_SERVICES_ATTR_SERVICE_SETTINGS          "settings"
+
+}
+
+namespace TizenApis {
+namespace Api {
+namespace Account {
+
+using namespace TizenApis::Commons;
+using namespace TizenApis::Api::Account;
+using namespace TizenApis::Tizen1_0::Account;
+
+JSClassRef JSAccountServices::m_classRef = NULL;
+
+JSClassDefinition JSAccountServices::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       TIZEN_ACCOUNT_CLASS_ACCOUNT_SERVICE,
+       NULL,
+       m_property,
+       NULL,
+       Initialize,
+       Finalize,
+       NULL, //hasProperty,
+       NULL, //GetProperty,
+       NULL, //SetProperty,
+       NULL, //DeleteProperty,
+       NULL, //getPropertyNames,
+       NULL,
+       NULL,
+       NULL,
+       NULL, //ConvertToType,
+};
+
+JSStaticValue JSAccountServices::m_property[] = {
+       { ACCOUNT_SERVICES_ATTR_SERVICE_ID,              getProperty, setProperty, kJSPropertyAttributeNone },
+       { ACCOUNT_SERVICES_ATTR_SERVICE_NAME,            getProperty, setProperty, kJSPropertyAttributeNone },
+       { ACCOUNT_SERVICES_ATTR_SERVICE_APPLICATION_ID,  getProperty, setProperty, kJSPropertyAttributeNone },
+       { ACCOUNT_SERVICES_ATTR_SERVICE_DISPLAY_NAME,    getProperty, setProperty, kJSPropertyAttributeNone },
+       { ACCOUNT_SERVICES_ATTR_SERVICE_ICON,            getProperty, setProperty, kJSPropertyAttributeNone },
+       { ACCOUNT_SERVICES_ATTR_SERVICE_ACCOUNT_ID,      getProperty, setProperty, kJSPropertyAttributeNone },
+       { ACCOUNT_SERVICES_ATTR_SERVICE_SERVICE_TYPE_ID, getProperty, setProperty, kJSPropertyAttributeNone },
+       { ACCOUNT_SERVICES_ATTR_SERVICE_PROVIDER_ID,     getProperty, setProperty, kJSPropertyAttributeNone },
+       { ACCOUNT_SERVICES_ATTR_SERVICE_TAGS,            getProperty, setProperty, kJSPropertyAttributeNone },
+       { ACCOUNT_SERVICES_ATTR_SERVICE_SETTINGS,        getProperty, setProperty, kJSPropertyAttributeNone },
+       { 0, 0, 0, 0 }
+};
+
+
+JSClassRef JSAccountServices::getClassRef()
+{
+       if (!m_classRef) {
+               m_classRef = JSClassCreate(&m_classInfo);
+       }
+       return m_classRef;
+}
+
+JSObjectRef JSAccountServices::createJSObject(JSContextRef context, AccountServicesPtr service)
+{
+    AccountServicesPrivObj *priv = new AccountServicesPrivObj(context, service);
+    return JSObjectMake(context, getClassRef(), priv);
+}
+
+bool JSAccountServices::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+       return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+AccountServicesPtr JSAccountServices::getAccountServices(JSContextRef context, JSValueRef value)
+{
+       if (!isObjectOfClass(context, value)) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+
+       AccountServicesPrivObj *priv = static_cast<AccountServicesPrivObj*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(WrtDeviceApis::Commons::NullPointerException);
+       }
+
+       return priv->getObject();
+}
+
+void JSAccountServices::Initialize(JSContextRef context, JSObjectRef object)
+{
+       LogDebug("entered");
+}
+
+void JSAccountServices::Finalize(JSObjectRef object)
+{
+    AccountServicesPrivObj *privateObject = static_cast<AccountServicesPrivObj*>(JSObjectGetPrivate(object));
+    delete privateObject;
+}
+
+AccountServicesPtr JSAccountServices::getPrivData(JSObjectRef object)
+{
+       LogDebug("entered");
+       AccountServicesPrivObj *priv = static_cast<AccountServicesPrivObj*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+
+       AccountServicesPtr result = priv->getObject();
+       if (!result) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+
+       return result;
+}
+
+JSValueRef JSAccountServices::getProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       LogDebug("<<<");
+       Try{
+               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
+               AccountServicesPtr accountServicePtr = getPrivData(object);
+
+               if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_ID)) {
+                       return converter->toJSValueRef(accountServicePtr->getId());
+               } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_NAME)) {
+                       return converter->toJSValueRef(accountServicePtr->getName());
+               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_APPLICATION_ID)) {
+                       return converter->toJSValueRef(accountServicePtr->getApplicationId());
+               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_DISPLAY_NAME)) {
+                       return converter->toJSValueRef(accountServicePtr->getDisplayName());
+               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_ICON)) {
+                       return converter->toJSValueRef(accountServicePtr->getIcon());
+               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_ACCOUNT_ID)) {
+                       return converter->toJSValueRef(accountServicePtr->getAccountId());
+               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_SERVICE_TYPE_ID)) {
+                       return converter->toJSValueRef(accountServicePtr->getServiceTypeId());
+               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_PROVIDER_ID)) {
+                       return converter->toJSValueRef(accountServicePtr->getProviderId());
+               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_TAGS)) {
+//                     return converter->toJSValueRef(accountServicePtr->getTags());
+               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_SETTINGS)) {
+                       return converter->toJSValueRef(accountServicePtr->getSettings());
+               }
+       }Catch(WrtDeviceApis::Commons::Exception){
+               AccountLogWarning("trying to get incorrect value");
+       }
+
+       LogDebug(">>> return UNDEFINED");
+       return JSValueMakeUndefined(context);
+}
+
+bool JSAccountServices::setProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+       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");
+       }
+
+       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       return false;
+}
+
+} // Account
+} // Api
+} // TizenApis
+
diff --git a/src/standards/Tizen/Account/JSAccountServices.h b/src/standards/Tizen/Account/JSAccountServices.h
new file mode 100755 (executable)
index 0000000..fb14537
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file        JSAccountServices.h
+ * @author      Jihwa Park (jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ * @brief       Declaration of the JSAccountServices class
+ */
+
+#ifndef _TIZEN_ACCOUNT_JS_ACCOUNT_SERVICES_H_
+#define _TIZEN_ACCOUNT_JS_ACCOUNT_SERVICES_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <Commons/IEvent.h>
+#include <API/Account/AccountServices.h>
+#include <API/Account/log.h>
+
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+using namespace TizenApis::Api::Account;
+
+namespace TizenApis {
+namespace Api {
+namespace Account {
+
+typedef PrivateObject<AccountServicesPtr, NoOwnership> AccountServicesPrivObj;
+
+class JSAccountServices {
+public:
+       /*
+       * This initializes this JS class in the JS Engine.
+       */
+       static JSClassRef getClassRef();
+
+       static JSObjectRef createJSObject(JSContextRef context, TizenApis::Api::Account::AccountServicesPtr service);
+
+       static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+
+       static AccountServicesPtr getAccountServices(JSContextRef context, JSValueRef value);
+
+private:
+   /**
+       * The callback invoked when an object is first created.
+       */
+       static void Initialize(JSContextRef context, JSObjectRef object);
+
+   /**
+       * The callback invoked when an object is finalized.
+       */
+       static void Finalize(JSObjectRef object);
+
+   /**
+       * This structure contains properties and callbacks that define a type of object.
+       */
+       static JSClassDefinition m_classInfo;
+
+   /**
+       * This structure describes a statically declared function property.
+       */
+       static JSStaticFunction m_functions[];
+
+       /**
+        * This member variable contains the initialization values for the static properties of this class.
+        * The values are given according to the data structure JSPropertySpec
+        */
+       static JSStaticValue m_property[];
+
+       static JSClassRef m_classRef;
+
+       static AccountServicesPtr getPrivData(JSObjectRef object);
+
+       static JSValueRef getProperty(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setProperty(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+
+};
+
+} // Account
+} // Tizen1_0
+} // TizenApis
+
+#endif // _TIZEN_ACCOUNT_JS_ACCOUNT_SERVICES_H_
+
similarity index 66%
rename from src/standards/Tizen/Calendar/JSCategoryArray.cpp
rename to src/standards/Tizen/Account/JSFeatureArray.cpp
index 8b56f09..b5277da 100755 (executable)
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License. 
  */
 
 
-#include "JSCategoryArray.h"
+/*
+ * @file        JSFeatureArray.cpp
+ * @author      Jihwa Park (jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ */
+
+#include "JSFeatureArray.h"
 #include <algorithm>
-#include <dpl/log.h>
-#include <Tizen/Common/JSTizenException.h>
-#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
 #include <CommonsJavaScript/Converter.h>
 
-using namespace TizenApis::Api::Calendar;
+using namespace TizenApis::Api::Account;
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 
-#define FUNCTION_CONCAT "concat"
-#define FUNCTION_JOIN "join"
-#define FUNCTION_POP "pop"
-#define FUNCTION_PUSH "push"
-#define FUNCTION_REVERSE "reverse"
-#define FUNCTION_SHIFT "shift"
-#define FUNCTION_SLICE "slice"
-#define FUNCTION_SORT "sort"
-#define FUNCTION_SPLICE "splice"
-#define FUNCTION_TOSTRING "toString"
-#define FUNCTION_UNSHIFT "unshift"
-#define FUNCTION_VALUEOF "valueOf"
-#define ARRAY "Array"
-#define ATTRIBUTE_LENGTH "length"
+namespace {
+
+#define FUNCTION_CONCAT  "concat"
+#define FUNCTION_JOIN  "join"
+#define FUNCTION_POP  "pop"
+#define FUNCTION_PUSH  "push"
+#define FUNCTION_REVERSE  "reverse"
+#define FUNCTION_SHIFT  "shift"
+#define FUNCTION_SLICE  "slice"
+#define FUNCTION_SORT  "sort"
+#define FUNCTION_SPLICE  "splice"
+#define FUNCTION_TOSTRING  "toString"
+#define FUNCTION_UNSHIFT  "unshift"
+#define FUNCTION_VALUEOF  "valueOf"
+#define ARRAY  "Array"
+#define ATTRIBUTE_LENGTH  "length"
+
+}
 
 namespace TizenApis {
-namespace Tizen1_0 { 
-namespace Calendar {
-JSClassDefinition JSCategoryArray::m_classInfo = {
+namespace Tizen1_0 {
+namespace Account{
+JSClassDefinition JSFeatureArray::m_classInfo = {
     0,
     kJSClassAttributeNone,
     ARRAY,
@@ -65,12 +74,12 @@ JSClassDefinition JSCategoryArray::m_classInfo = {
     NULL, //convertToType,
 };
 
-JSStaticValue JSCategoryArray::m_property[] = {
+JSStaticValue JSFeatureArray::m_property[] = {
     { ATTRIBUTE_LENGTH, getLength, NULL, kJSPropertyAttributeReadOnly },
     { 0, 0, 0, 0 }
 };
 
-JSStaticFunction JSCategoryArray::m_function[] = {
+JSStaticFunction JSFeatureArray::m_function[] = {
     { FUNCTION_CONCAT, concat, kJSPropertyAttributeNone },
     { FUNCTION_JOIN, join, kJSPropertyAttributeNone },
     { FUNCTION_POP, pop, kJSPropertyAttributeNone },
@@ -86,10 +95,10 @@ JSStaticFunction JSCategoryArray::m_function[] = {
     { 0, 0, 0 }
 };
 
-JSClassRef JSCategoryArray::m_jsClassRef = JSClassCreate(
-        JSCategoryArray::getClassInfo());
+JSClassRef JSFeatureArray::m_jsClassRef = JSClassCreate(
+        JSFeatureArray::getClassInfo());
 
-JSValueRef JSCategoryArray::getLength(JSContextRef context,
+JSValueRef JSFeatureArray::getLength(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName,
         JSValueRef* exception)
@@ -97,12 +106,12 @@ JSValueRef JSCategoryArray::getLength(JSContextRef context,
     LogDebug("enter");
     Try
     {
-        JSCategoryArrayPrivate* priv =
-            static_cast<JSCategoryArrayPrivate*>(JSObjectGetPrivate(object));
+        JSFeatureArrayPrivate* priv =
+            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(object));
         if (!priv) {
             Throw(NullPointerException);
         }
-        CategoryListPtr categories = priv->getObject();
+        FeatureListPtr categories = priv->getObject();
         if (categories) {
             Converter converter(context);
             return converter.toJSValueRef(categories->size());
@@ -115,32 +124,32 @@ JSValueRef JSCategoryArray::getLength(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
-CategoryListPtr JSCategoryArray::getCategories(JSContextRef context,
+FeatureListPtr JSFeatureArray::getFeatures(JSContextRef context,
         JSObjectRef object)
 {
     LogDebug("enter");
-    JSCategoryArrayPrivate* priv =
-        static_cast<JSCategoryArrayPrivate*>(JSObjectGetPrivate(object));
+    JSFeatureArrayPrivate* priv =
+        static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(object));
     if (!priv) {
         Throw(NullPointerException);
     }
     return priv->getObject();
 }
 
-JSObjectRef JSCategoryArray::createArray(JSContextRef context,
-        const CategoryListPtr &categories)
+JSObjectRef JSFeatureArray::createArray(JSContextRef context,
+        const FeatureListPtr &features)
 {
-    JSCategoryArrayPrivate *priv = new JSCategoryArrayPrivate(context,
-                                                              categories);
-    return JSObjectMake(context, getClassRef(), priv);
+       LogDebug("entered");
+       JSFeatureArrayPrivate *priv = new JSFeatureArrayPrivate(context,features);
+       return JSObjectMake(context, getClassRef(), priv);
 }
 
-const JSClassDefinition* JSCategoryArray::getClassInfo()
+const JSClassDefinition* JSFeatureArray::getClassInfo()
 {
     return &(m_classInfo);
 }
 
-JSClassRef JSCategoryArray::getClassRef()
+JSClassRef JSFeatureArray::getClassRef()
 {
     if (!m_jsClassRef) {
         m_jsClassRef = JSClassCreate(&m_classInfo);
@@ -148,22 +157,22 @@ JSClassRef JSCategoryArray::getClassRef()
     return m_jsClassRef;
 }
 
-void JSCategoryArray::initialize(JSContextRef context,
+void JSFeatureArray::initialize(JSContextRef context,
         JSObjectRef object)
 {
     LogDebug("enter");
 }
 
-void JSCategoryArray::finalize(JSObjectRef object)
+void JSFeatureArray::finalize(JSObjectRef object)
 {
     LogDebug("enter");
-    JSCategoryArrayPrivate* priv =
-        static_cast<JSCategoryArrayPrivate*>(JSObjectGetPrivate(object));
+    JSFeatureArrayPrivate* priv =
+        static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(object));
     delete priv;
     JSObjectSetPrivate(object, NULL);
 }
 
-bool JSCategoryArray::hasProperty(JSContextRef context,
+bool JSFeatureArray::hasProperty(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName)
 {
@@ -172,12 +181,12 @@ bool JSCategoryArray::hasProperty(JSContextRef context,
     Try
     {
         size_t index = converter.toSizeT(propertyName);
-        JSCategoryArrayPrivate* priv =
-            static_cast<JSCategoryArrayPrivate*>(JSObjectGetPrivate(object));
+        JSFeatureArrayPrivate* priv =
+            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(object));
         if (!priv) {
             Throw(NullPointerException);
         }
-        CategoryListPtr categories = priv->getObject();
+        FeatureListPtr categories = priv->getObject();
         if (index < categories->size()) {
             return true;
         }
@@ -189,7 +198,7 @@ bool JSCategoryArray::hasProperty(JSContextRef context,
     return false;
 }
 
-JSValueRef JSCategoryArray::getProperty(JSContextRef context,
+JSValueRef JSFeatureArray::getProperty(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName,
         JSValueRef* exception)
@@ -199,12 +208,12 @@ JSValueRef JSCategoryArray::getProperty(JSContextRef context,
     Try
     {
         size_t index = converter.toSizeT(propertyName);
-        JSCategoryArrayPrivate* priv =
-            static_cast<JSCategoryArrayPrivate*>(JSObjectGetPrivate(object));
+        JSFeatureArrayPrivate* priv =
+            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(object));
         if (!priv) {
             Throw(NullPointerException);
         }
-        CategoryListPtr categories = priv->getObject();
+        FeatureListPtr categories = priv->getObject();
         if (index < categories->size()) {
             std::string result = categories->at(index);
             if (!result.empty()) {
@@ -219,7 +228,7 @@ JSValueRef JSCategoryArray::getProperty(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
-bool JSCategoryArray::setProperty(JSContextRef context,
+bool JSFeatureArray::setProperty(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName,
         JSValueRef value,
@@ -234,12 +243,12 @@ bool JSCategoryArray::setProperty(JSContextRef context,
         if (!JSValueIsUndefined(context, value)) {
             category = converter.toString(value);
         }
-        JSCategoryArrayPrivate* priv =
-            static_cast<JSCategoryArrayPrivate*>(JSObjectGetPrivate(object));
+        JSFeatureArrayPrivate* priv =
+            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(object));
         if (!priv) {
             Throw(NullPointerException);
         }
-        CategoryListPtr categories = priv->getObject();
+        FeatureListPtr categories = priv->getObject();
         if (!categories) {
             Throw(NullPointerException);
         }
@@ -252,12 +261,12 @@ bool JSCategoryArray::setProperty(JSContextRef context,
     Catch(Exception)
     {
         LogError("error occured");
-        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+        JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
     }
     return false;
 }
 
-JSValueRef JSCategoryArray::concat(JSContextRef context,
+JSValueRef JSFeatureArray::concat(JSContextRef context,
         JSObjectRef function,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -267,17 +276,17 @@ JSValueRef JSCategoryArray::concat(JSContextRef context,
     LogDebug("enter");
     Try
     {
-        CategoryListPtr categories = CategoryListPtr(new CategoryList());
-        JSCategoryArrayPrivate *newPrivateObject = new JSCategoryArrayPrivate(
+        FeatureListPtr categories = FeatureListPtr(new FeatureList());
+        JSFeatureArrayPrivate *newPrivateObject = new JSFeatureArrayPrivate(
                 context,
                 categories);
         JSValueRef result = JSObjectMake(context,
                                          getClassRef(), newPrivateObject);
 
         //copy current categories
-        JSCategoryArrayPrivate* priv =
-            static_cast<JSCategoryArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        CategoryListPtr currentCategories = priv->getObject();
+        JSFeatureArrayPrivate* priv =
+            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
+        FeatureListPtr currentCategories = priv->getObject();
         for (size_t i = 0; i < currentCategories->size(); ++i) {
             categories->push_back(currentCategories->at(i));
         }
@@ -302,10 +311,10 @@ JSValueRef JSCategoryArray::concat(JSContextRef context,
     {
         LogError("error occured");
     }
-    return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+    return JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
 }
 
-JSValueRef JSCategoryArray::join(JSContextRef context,
+JSValueRef JSFeatureArray::join(JSContextRef context,
         JSObjectRef function,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -318,9 +327,9 @@ JSValueRef JSCategoryArray::join(JSContextRef context,
         std::string result;
         std::string separator(",");
         Converter converter(context);
-        JSCategoryArrayPrivate* priv =
-            static_cast<JSCategoryArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        CategoryListPtr currentCategories = priv->getObject();
+        JSFeatureArrayPrivate* priv =
+            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
+        FeatureListPtr currentCategories = priv->getObject();
         if (argumentCount > 0 && JSValueIsString(context, arguments[0])) {
             separator = converter.toString(arguments[0]);
         }
@@ -336,10 +345,10 @@ JSValueRef JSCategoryArray::join(JSContextRef context,
     {
         LogError("error occured");
     }
-    return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+    return JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
 }
 
-JSValueRef JSCategoryArray::pop(JSContextRef context,
+JSValueRef JSFeatureArray::pop(JSContextRef context,
         JSObjectRef function,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -350,9 +359,9 @@ JSValueRef JSCategoryArray::pop(JSContextRef context,
     Try
     {
         Converter converter(context);
-        JSCategoryArrayPrivate* priv =
-            static_cast<JSCategoryArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        CategoryListPtr currentCategories = priv->getObject();
+        JSFeatureArrayPrivate* priv =
+            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
+        FeatureListPtr currentCategories = priv->getObject();
         if (currentCategories->size() > 0) {
             std::string result = currentCategories->at(
                     currentCategories->size() - 1);
@@ -367,7 +376,7 @@ JSValueRef JSCategoryArray::pop(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSCategoryArray::push(JSContextRef context,
+JSValueRef JSFeatureArray::push(JSContextRef context,
         JSObjectRef function,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -378,9 +387,9 @@ JSValueRef JSCategoryArray::push(JSContextRef context,
     Try
     {
         Converter converter(context);
-        JSCategoryArrayPrivate* priv =
-            static_cast<JSCategoryArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        CategoryListPtr currentCategories = priv->getObject();
+        JSFeatureArrayPrivate* priv =
+            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
+        FeatureListPtr currentCategories = priv->getObject();
         for (size_t i = 0; i < argumentCount; ++i) {
             currentCategories->push_back(converter.toString(arguments[i]));
         }
@@ -390,10 +399,10 @@ JSValueRef JSCategoryArray::push(JSContextRef context,
     {
         LogError("error occured");
     }
-    return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+    return JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
 }
 
-JSValueRef JSCategoryArray::reverse(JSContextRef context,
+JSValueRef JSFeatureArray::reverse(JSContextRef context,
         JSObjectRef function,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -404,9 +413,9 @@ JSValueRef JSCategoryArray::reverse(JSContextRef context,
     Try
     {
         Converter converter(context);
-        JSCategoryArrayPrivate* priv =
-            static_cast<JSCategoryArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        CategoryListPtr currentCategories = priv->getObject();
+        JSFeatureArrayPrivate* priv =
+            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
+        FeatureListPtr currentCategories = priv->getObject();
         std::reverse(currentCategories->begin(), currentCategories->end());
         return thisObject;
     }
@@ -417,7 +426,7 @@ JSValueRef JSCategoryArray::reverse(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSCategoryArray::shift(JSContextRef context,
+JSValueRef JSFeatureArray::shift(JSContextRef context,
         JSObjectRef function,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -428,9 +437,9 @@ JSValueRef JSCategoryArray::shift(JSContextRef context,
     Try
     {
         Converter converter(context);
-        JSCategoryArrayPrivate* priv =
-            static_cast<JSCategoryArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        CategoryListPtr currentCategories = priv->getObject();
+        JSFeatureArrayPrivate* priv =
+            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
+        FeatureListPtr currentCategories = priv->getObject();
         if (currentCategories->size() > 0) {
             std::string result = currentCategories->at(0);
             currentCategories->erase(currentCategories->begin());
@@ -444,7 +453,7 @@ JSValueRef JSCategoryArray::shift(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSCategoryArray::slice(JSContextRef context,
+JSValueRef JSFeatureArray::slice(JSContextRef context,
         JSObjectRef function,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -458,17 +467,17 @@ JSValueRef JSCategoryArray::slice(JSContextRef context,
             return JSValueMakeUndefined(context);
         }
         Converter converter(context);
-        CategoryListPtr categories = CategoryListPtr(new CategoryList());
-        JSCategoryArrayPrivate *newPrivateObject = new JSCategoryArrayPrivate(
+        FeatureListPtr categories = FeatureListPtr(new FeatureList());
+        JSFeatureArrayPrivate *newPrivateObject = new JSFeatureArrayPrivate(
                 context,
                 categories);
         JSValueRef result = JSObjectMake(context,
                                          getClassRef(), newPrivateObject);
 
         //copy current categories
-        JSCategoryArrayPrivate* priv =
-            static_cast<JSCategoryArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        CategoryListPtr currentCategories = priv->getObject();
+        JSFeatureArrayPrivate* priv =
+            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
+        FeatureListPtr currentCategories = priv->getObject();
         std::size_t first = converter.toSizeT(arguments[0]);
         std::size_t last = currentCategories->size() - 1;
         if (argumentCount > 1) {
@@ -490,10 +499,10 @@ JSValueRef JSCategoryArray::slice(JSContextRef context,
     {
         LogError("error occured");
     }
-    return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+    return JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
 }
 
-JSValueRef JSCategoryArray::sort(JSContextRef context,
+JSValueRef JSFeatureArray::sort(JSContextRef context,
         JSObjectRef function,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -504,9 +513,9 @@ JSValueRef JSCategoryArray::sort(JSContextRef context,
     Try
     {
         Converter converter(context);
-        JSCategoryArrayPrivate* priv =
-            static_cast<JSCategoryArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        CategoryListPtr currentCategories = priv->getObject();
+        JSFeatureArrayPrivate* priv =
+            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
+        FeatureListPtr currentCategories = priv->getObject();
         std::sort(currentCategories->begin(), currentCategories->end());
         return thisObject;
     }
@@ -517,7 +526,7 @@ JSValueRef JSCategoryArray::sort(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSCategoryArray::splice(JSContextRef context,
+JSValueRef JSFeatureArray::splice(JSContextRef context,
         JSObjectRef function,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -528,7 +537,7 @@ JSValueRef JSCategoryArray::splice(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSCategoryArray::toString(JSContextRef context,
+JSValueRef JSFeatureArray::toString(JSContextRef context,
         JSObjectRef function,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -539,7 +548,7 @@ JSValueRef JSCategoryArray::toString(JSContextRef context,
     return join(context, function, thisObject, 0, arguments, exception);
 }
 
-JSValueRef JSCategoryArray::unshift(JSContextRef context,
+JSValueRef JSFeatureArray::unshift(JSContextRef context,
         JSObjectRef function,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -550,7 +559,7 @@ JSValueRef JSCategoryArray::unshift(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSCategoryArray::valueOf(JSContextRef context,
+JSValueRef JSFeatureArray::valueOf(JSContextRef context,
         JSObjectRef function,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -560,7 +569,6 @@ JSValueRef JSCategoryArray::valueOf(JSContextRef context,
     LogDebug("entered");
     return JSValueMakeUndefined(context);
 }
-
 }
 }
 }
similarity index 90%
rename from src/standards/Tizen/Calendar/JSCategoryArray.h
rename to src/standards/Tizen/Account/JSFeatureArray.h
index 84b9432..0ce1f20 100755 (executable)
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License. 
  */
 
 
-#ifndef _JS_CATEGORY_ARRAY_H_
-#define _JS_CATEGORY_ARRAY_H_
+/*
+ * @file        JSFeatureArray.h
+ * @author      Jihwa Park (jh7979.park@samsung.com)
+ * @author      Sangtai Kim
+ * @version     0.1
+ */
+
+#ifndef _JS_FEATURE_ARRAY_H_
+#define _JS_FEATURE_ARRAY_H_
 
 #include <string>
 #include <vector>
 #include <JavaScriptCore/JavaScript.h>
 #include <CommonsJavaScript/PrivateObject.h>
-#include <API/Calendar/CalendarEvent.h>
+#include <API/Account/EventAccount.h>
 
-using namespace TizenApis::Api::Calendar;
+
+using namespace TizenApis::Api::Account;
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 
 namespace TizenApis {
 namespace Tizen1_0 {
-namespace Calendar {
-
-typedef PrivateObjectT<Api::Calendar::CategoryListPtr>::Type
-JSCategoryArrayPrivate;
+namespace Account{
+typedef PrivateObjectT<FeatureListPtr>::Type
+JSFeatureArrayPrivate;
 
-class JSCategoryArray
+class JSFeatureArray
 {
   public:
 
@@ -44,9 +51,9 @@ class JSCategoryArray
     static JSClassRef getClassRef();
 
     static JSObjectRef createArray(JSContextRef context,
-            const Api::Calendar::CategoryListPtr &categories);
+            const FeatureListPtr &categories);
 
-    static Api::Calendar::CategoryListPtr getCategories(JSContextRef context,
+    static FeatureListPtr getFeatures(JSContextRef context,
             JSObjectRef object);
 
   private:
@@ -172,9 +179,8 @@ class JSCategoryArray
      */
     static JSStaticValue m_property[];
 };
-
 }
 }
 }
 
-#endif /* _JS_ARRAY_H_ */
+#endif /* _JS_ARRAY_H_ */
\ No newline at end of file
diff --git a/src/standards/Tizen/Account/ResponseDispatcher.cpp b/src/standards/Tizen/Account/ResponseDispatcher.cpp
new file mode 100755 (executable)
index 0000000..3816592
--- /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 "ResponseDispatcher.h"
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include "AccountConverter.h"
+
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Account{
+AccountResponseDispatcher& AccountResponseDispatcher::getInstance()
+{
+    static AccountResponseDispatcher instance;
+    return instance;
+}
+
+AccountResponseDispatcher::AccountResponseDispatcher() :
+    AccountEventAnswerReceiverCreate(ThreadEnum::NULL_THREAD),
+    AccountEventAnswerReceiverAdd(ThreadEnum::NULL_THREAD),
+    AccountEventAnswerReceiverDelete(ThreadEnum::NULL_THREAD),
+    AccountEventAnswerReceiverUpdate(ThreadEnum::NULL_THREAD),
+    AccountEventAnswerReceiverFind(ThreadEnum::NULL_THREAD),
+    GetAccountServicesEventAnswerReceiver(ThreadEnum::NULL_THREAD)
+{
+    LogDebug("entered");
+}
+
+AccountResponseDispatcher::~AccountResponseDispatcher()
+{
+    LogDebug("entered");
+}
+
+void AccountResponseDispatcher::OnAnswerReceived(
+        const IEventCreateAccountPtr &event)
+{
+    LogDebug("entered");
+    JSCallbackManagerPtr cbm =
+        DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
+    Try
+    {
+        if (!cbm) {
+            LogDebug("no callback manager");
+            return;
+        }
+        if (event->getResult()) {
+            LogDebug("result success");
+            AccountConverterFactory::ConverterType converter =
+                AccountConverterFactory::getConverter(cbm->getContext());
+            cbm->callOnSuccess(converter->toJSValueRefAccount(event->getEvent()));
+            return;
+        }
+        LogDebug("result fail");
+    }
+    Catch(ConversionException)
+    {
+        LogError("cannot convert event");
+    }
+    JSValueRef errorObject = JSDOMExceptionFactory::UnknownException.make(
+            cbm->getContext());
+    cbm->callOnError(errorObject);
+}
+
+
+
+void AccountResponseDispatcher::OnAnswerReceived(
+        const IEventAddAccountPtr &event)
+{
+    LogDebug("entered");
+    JSCallbackManagerPtr cbm =
+        DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
+    Try
+    {
+        if (!cbm) {
+            LogDebug("no callback manager");
+            return;
+        }
+        if (event->getResult()) {
+            LogDebug("result success");
+            AccountConverterFactory::ConverterType converter =
+                AccountConverterFactory::getConverter(cbm->getContext());
+            cbm->callOnSuccess(converter->toJSValueRefAccount(event->getEvent()));
+            return;
+        }
+        LogDebug("result fail");
+    }
+    Catch(ConversionException)
+    {
+        LogError("cannot convert event");
+    }
+    JSValueRef errorObject = JSDOMExceptionFactory::UnknownException.make(
+            cbm->getContext());
+    cbm->callOnError(errorObject);
+}
+
+void AccountResponseDispatcher::OnAnswerReceived(
+        const IEventDeleteAccountPtr &event)
+{
+    LogDebug("entered");
+    JSCallbackManagerPtr cbm =
+        DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
+    if (!cbm) {
+        LogDebug("no callback manager");
+        return;
+    }
+    if (event->getResult()) {
+        cbm->callOnSuccess();
+    } else {
+        JSValueRef errorObject;
+        if (event->getExceptionCode() ==
+            ExceptionCodes::NotFoundException) {
+            errorObject = JSDOMExceptionFactory::NotFoundException.make(
+                    cbm->getContext());
+        } else {
+            errorObject = JSDOMExceptionFactory::UnknownException.make(
+                    cbm->getContext());
+        }
+        cbm->callOnError(errorObject);
+    }
+}
+
+
+
+void AccountResponseDispatcher::OnAnswerReceived(
+        const IEventUpdateAccountPtr &event)
+{
+    LogDebug("entered");
+    JSCallbackManagerPtr cbm =
+        DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
+    if (!cbm) {
+        LogDebug("no callback manager");
+        return;
+    }
+    if (event->getResult()) {
+        cbm->callOnSuccess();
+    } else {
+        JSValueRef errorObject = JSDOMExceptionFactory::UnknownException.make(
+                cbm->getContext());
+        cbm->callOnError(errorObject);
+    }
+}
+
+
+
+void AccountResponseDispatcher::OnAnswerReceived(
+        const IEventFindAccountsPtr &event)
+{
+    LogDebug("entered");
+    JSCallbackManagerPtr cbm =
+        DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
+    if (!cbm) {
+        LogError("no callback manager");
+        return;
+    }
+    Try
+    {
+        if (event->getResult()) {
+            AccountConverterFactory::ConverterType converter =
+                AccountConverterFactory::getConverter(cbm->getContext());
+            const std::vector<EventAccountPtr> &results = event->getEvents();
+            JSValueRef result = converter->toJSValueRef(results);
+            cbm->callOnSuccess(result);
+            return;
+        }
+    }
+    Catch(Exception)
+    {
+        LogError("error during processing answer");
+    }
+    JSValueRef errorObject =
+        JSDOMExceptionFactory::UnknownException.make(cbm->getContext());
+    cbm->callOnError(errorObject);
+}
+
+void AccountResponseDispatcher::OnAnswerReceived(
+        const IEventGetAccountServicesPtr &event)
+{
+    LogDebug("entered");
+    JSCallbackManagerPtr cbm =
+        DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
+    if (!cbm) {
+        LogError("no callback manager");
+        return;
+    }
+    Try
+    {
+        if (event->getResult()) {
+
+                       LogDebug("event->getResult() entered");
+            AccountConverterFactory::ConverterType converter =
+                AccountConverterFactory::getConverter(cbm->getContext());
+            const std::vector<IAccountServicePtr> &results = event->getAccountServices();
+            LogDebug("found AccountServices: " << results.size());
+            JSValueRef result = converter->toJSValueRef(results);
+            cbm->callOnSuccess(result);
+            return;
+        }
+    }
+    Catch(Exception)
+    {
+        LogError("error during processing answer");
+    }
+    JSValueRef errorObject = JSDOMExceptionFactory::UnknownException.make(
+            cbm->getContext());
+    cbm->callOnError(errorObject);
+}
+
+
+
+}
+}
+}
diff --git a/src/standards/Tizen/Account/ResponseDispatcher.h b/src/standards/Tizen/Account/ResponseDispatcher.h
new file mode 100755 (executable)
index 0000000..8615a87
--- /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_ACCOUNT_RESPONSEDISPATCHER_H_
+#define WRTPLUGINS_ACCOUNT_RESPONSEDISPATCHER_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <API/Account/IEventCreateAccount.h>
+#include <API/Account/IEventAddAccount.h>
+#include <API/Account/IEventDeleteAccount.h>
+#include <API/Account/IEventFindAccounts.h>
+#include <API/Account/IEventUpdateAccount.h>
+#include <API/Account/IEventGetAccountServices.h>
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+//using namespace WrtDeviceApis::CommonsJavaScript;
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Account{
+       
+typedef EventAnswerReceiver< IEventGetAccountServices >
+GetAccountServicesEventAnswerReceiver;
+
+typedef EventAnswerReceiver< IEventCreateAccount >
+AccountEventAnswerReceiverCreate;
+
+typedef EventAnswerReceiver< IEventAddAccount >
+AccountEventAnswerReceiverAdd;
+
+typedef EventAnswerReceiver< IEventDeleteAccount >
+AccountEventAnswerReceiverDelete;
+
+typedef EventAnswerReceiver< IEventUpdateAccount >
+AccountEventAnswerReceiverUpdate;
+
+typedef EventAnswerReceiver< IEventFindAccounts >
+AccountEventAnswerReceiverFind;
+
+
+class AccountResponseDispatcher :
+    public AccountEventAnswerReceiverCreate,
+    public AccountEventAnswerReceiverAdd,
+    public AccountEventAnswerReceiverDelete,
+    public AccountEventAnswerReceiverUpdate,
+    public AccountEventAnswerReceiverFind,
+    public GetAccountServicesEventAnswerReceiver
+
+{
+  public:
+    static AccountResponseDispatcher& getInstance();
+  private:
+    AccountResponseDispatcher();
+    virtual ~AccountResponseDispatcher();
+  protected:
+    void OnAnswerReceived(const IEventCreateAccountPtr &event);
+    void OnAnswerReceived(const IEventAddAccountPtr &event);   
+    void OnAnswerReceived(const IEventDeleteAccountPtr &event);
+    void OnAnswerReceived(const IEventUpdateAccountPtr &event);
+    void OnAnswerReceived(const IEventFindAccountsPtr &event);
+    void OnAnswerReceived(const IEventGetAccountServicesPtr &event);
+
+};
+}
+}
+}
+
+#endif
diff --git a/src/standards/Tizen/Account/config.xml b/src/standards/Tizen/Account/config.xml
new file mode 100755 (executable)
index 0000000..30fecc1
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" ?>
+<!DOCTYPE plugin-properties SYSTEM "/usr/etc/tizen-apis/config.dtd">
+<plugin-properties>
+    <library-name>libwrt-plugins-tizen-1.0-account.so</library-name>
+    <feature-install-uri>account.install.uri</feature-install-uri>
+    <feature-key-cn>SAMSUNG plugin group</feature-key-cn>
+    <feature-root-cn>SAMSUNG certificate authority</feature-root-cn>
+    <feature-root-fingerprint>AAAABBBBCCCCDDDEEEE0000</feature-root-fingerprint>
+
+    <api-feature>
+        <name>http://tizen.org/api/account</name>
+        <device-capability>account.read</device-capability>
+        <device-capability>account.write</device-capability>
+    </api-feature>
+
+    <api-feature>
+        <name>http://tizen.org/api/account.read</name>
+        <device-capability>account.read</device-capability>
+    </api-feature>
+
+    <api-feature>
+        <name>http://tizen.org/api/account.write</name>
+        <device-capability>account.write</device-capability>
+    </api-feature> 
+</plugin-properties>
\ No newline at end of file
diff --git a/src/standards/Tizen/Account/plugin_config.cpp b/src/standards/Tizen/Account/plugin_config.cpp
new file mode 100755 (executable)
index 0000000..5568f30
--- /dev/null
@@ -0,0 +1,245 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <Commons/FunctionDefinition.h>
+#include <Commons/FunctionDeclaration.h>
+#include <iostream>
+#include <Commons/Exception.h>
+#include <dpl/exception.h>
+#include <map>
+
+#include "plugin_config.h"
+
+#define ACCOUNT_FEATURE_API "http://tizen.org/api/account"
+#define ACCOUNT_FEATURE_API_READ  "http://tizen.org/api/account.read"
+#define ACCOUNT_FEATURE_API_WRITE "http://tizen.org/api/account.write"
+
+#define ACCOUNT_DEVICE_CAP_READ "account.read"
+#define ACCOUNT_DEVICE_CAP_WRITE "account.write"
+
+//using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+//using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Account{
+
+static FunctionMapping createAccountFunctions();
+
+static FunctionMapping AccountFunctions =
+    createAccountFunctions();
+
+DEFINE_FUNCTION_GETTER(Account, AccountFunctions);
+
+static FunctionMapping createAccountFunctions()
+{
+
+    /**
+     * Device capabilities
+     */
+    ACE_CREATE_DEVICE_CAP(DEVICE_CAP_ACCOUNT_READ, ACCOUNT_DEVICE_CAP_READ);
+    ACE_CREATE_DEVICE_CAP(DEVICE_CAP_ACCOUNT_WRITE, ACCOUNT_DEVICE_CAP_WRITE);
+
+    ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
+
+    ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_ACCOUNT_READ);
+    ACE_ADD_DEVICE_CAP(DEVICE_LIST_ACCOUNT_READ, DEVICE_CAP_ACCOUNT_READ);
+
+    ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_ACCOUNT_WRITE);
+    ACE_ADD_DEVICE_CAP(DEVICE_LIST_ACCOUNT_WRITE, DEVICE_CAP_ACCOUNT_WRITE);
+
+    /**
+     * Api Features
+     */
+    ACE_CREATE_FEATURE(FEATURE_ACCOUNT, ACCOUNT_FEATURE_API);
+    ACE_CREATE_FEATURE(FEATURE_ACCOUNT_READ, ACCOUNT_FEATURE_API_READ);
+    ACE_CREATE_FEATURE(FEATURE_ACCOUNT_WRITE, ACCOUNT_FEATURE_API_WRITE);
+
+    ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_ACCOUNT_READ_WRITE);
+    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ_WRITE, FEATURE_ACCOUNT);
+    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ_WRITE, FEATURE_ACCOUNT_READ);
+    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ_WRITE, FEATURE_ACCOUNT_WRITE);
+
+    ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_ACCOUNT_READ);
+    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ, FEATURE_ACCOUNT);
+    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ, FEATURE_ACCOUNT_READ);
+
+    ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_ACCOUNT_WRITE);
+    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_WRITE, FEATURE_ACCOUNT);
+    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_WRITE, FEATURE_ACCOUNT_WRITE);
+
+    ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_ACCOUNT);
+    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT, FEATURE_ACCOUNT);
+
+    ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_READ);
+    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ,FEATURE_ACCOUNT_READ);
+
+    ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_WRITE);
+    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_WRITE,FEATURE_ACCOUNT_WRITE);
+
+    /**
+     * Functions
+     */
+
+    FunctionMapping accountMapping;
+
+    //addAccount
+    AceFunction addAccountFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_CREATE_ACCOUNT,
+            ACCOUNT_FUNCTION_API_ADD_ACCOUNT,
+            ACCOUNT_FEATURES_ACCOUNT_READ_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    accountMapping.insert(std::make_pair(
+                               ACCOUNT_FUNCTION_API_ADD_ACCOUNT,
+                               addAccountFunc));
+
+    //Add listener
+    AceFunction listenerAccountsFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_ADD_LISTENER_ACCOUNTS,
+            ACCOUNT_FUNCTION_API_ADD_LISTENER_ACCOUNTS,
+            ACCOUNT_FEATURES_ACCOUNT_READ,
+            DEVICE_LIST_ACCOUNT_READ);
+
+    accountMapping.insert(std::make_pair(
+                               ACCOUNT_FUNCTION_API_ADD_LISTENER_ACCOUNTS,
+                               listenerAccountsFunc));
+
+    //Remove listener
+    AceFunction removelistenerAccountsFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_REMOVE_LISTENER_ACCOUNTS,
+            ACCOUNT_FUNCTION_API_REMOVE_LISTENER_ACCOUNTS,
+            ACCOUNT_FEATURES_ACCOUNT_READ,
+            DEVICE_LIST_ACCOUNT_READ);
+
+    accountMapping.insert(std::make_pair(
+                               ACCOUNT_FUNCTION_API_REMOVE_LISTENER_ACCOUNTS,
+                               removelistenerAccountsFunc));
+
+    //Get Account by ID
+    AceFunction getAccountbyId = ACE_CREATE_FUNCTION(
+            FUNCTION_GET_ACCOUNT_BY_ID,
+            ACCOUNT_FUNCTION_API_GET_ACCOUNT_BY_ID,
+            ACCOUNT_FEATURES_ACCOUNT_READ,
+            DEVICE_LIST_ACCOUNT_READ);
+
+    accountMapping.insert(std::make_pair(
+                               ACCOUNT_FUNCTION_API_GET_ACCOUNT_BY_ID,
+                               getAccountbyId));
+
+    //Get ServiceTypes by ID
+    AceFunction getServicetypesbyId = ACE_CREATE_FUNCTION(
+            FUNCTION_GET_SERVICETYPE_BY_ID,
+            ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID,
+            ACCOUNT_FEATURES_ACCOUNT_READ,
+            DEVICE_LIST_ACCOUNT_READ);
+
+    accountMapping.insert(std::make_pair(
+                               ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID,
+                               getServicetypesbyId));
+
+    //Get Provider by ID
+    AceFunction getProviderbyId = ACE_CREATE_FUNCTION(
+            FUNCTION_GET_PROVIDER_BY_ID,
+            ACCOUNT_FUNCTION_API_GET_PROVIDER_BY_ID,
+            ACCOUNT_FEATURES_ACCOUNT_READ,
+            DEVICE_LIST_ACCOUNT_READ);
+
+    accountMapping.insert(std::make_pair(
+                               ACCOUNT_FUNCTION_API_GET_PROVIDER_BY_ID,
+                               getProviderbyId));
+
+    //Find Accounts by ServiceType
+    AceFunction findAccountsbyServicetype = ACE_CREATE_FUNCTION(
+            FUNCTION_FIND_ACCOUNTS_BY_SERVICETYPE,
+            ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_SERVICETYPE,
+            ACCOUNT_FEATURES_ACCOUNT_READ,
+            DEVICE_LIST_ACCOUNT_READ);
+
+    accountMapping.insert(std::make_pair(
+                               ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_SERVICETYPE,
+                               findAccountsbyServicetype));
+
+    //Find Accounts by Tags
+    AceFunction findAccountsbyTags = ACE_CREATE_FUNCTION(
+            FUNCTION_FIND_ACCOUNTS_BY_TAGS,
+            ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_TAGS,
+            ACCOUNT_FEATURES_ACCOUNT_READ,
+            DEVICE_LIST_ACCOUNT_READ);
+
+    accountMapping.insert(std::make_pair(
+                               ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_TAGS,
+                               findAccountsbyTags));
+
+    //Find Services by Tags
+    AceFunction findServicesbyTags = ACE_CREATE_FUNCTION(
+            FUNCTION_FIND_SERVICES_BY_TAGS,
+            ACCOUNT_FUNCTION_API_FIND_SERVICES_BY_TAGS,
+            ACCOUNT_FEATURES_ACCOUNT_READ,
+            DEVICE_LIST_ACCOUNT_READ);
+
+    accountMapping.insert(std::make_pair(
+                               ACCOUNT_FUNCTION_API_FIND_SERVICES_BY_TAGS,
+                               findServicesbyTags));
+
+    //Find Providers
+    AceFunction findProviders = ACE_CREATE_FUNCTION(
+            FUNCTION_FIND_PROVIDERS,
+            ACCOUNT_FUNCTION_API_FIND_PROVIDERS,
+            ACCOUNT_FEATURES_ACCOUNT_READ,
+            DEVICE_LIST_ACCOUNT_READ);
+
+    accountMapping.insert(std::make_pair(
+                               ACCOUNT_FUNCTION_API_FIND_PROVIDERS,
+                               findProviders));
+
+    //Find ServiceTypes
+    AceFunction findServicetypes = ACE_CREATE_FUNCTION(
+            FUNCTION_FIND_SERVICETYPES,
+            ACCOUNT_FUNCTION_API_FIND_SERVICETYPES,
+            ACCOUNT_FEATURES_ACCOUNT_READ,
+            DEVICE_LIST_ACCOUNT_READ);
+
+    accountMapping.insert(std::make_pair(
+                               ACCOUNT_FUNCTION_API_FIND_SERVICETYPES,
+                               findServicetypes));
+
+    //getServiceByName
+       AceFunction getServiceByName = ACE_CREATE_FUNCTION(
+                                       FUNCTION_GET_SERVICE_BY_NAME,
+                                       ACCOUNT_FUNCTION_API_GET_SERVICE_BY_NAME,
+                                       ACCOUNT_FEATURES_ACCOUNT_READ,
+                                       DEVICE_LIST_ACCOUNT_READ);
+       accountMapping.insert(std::make_pair(
+                                       ACCOUNT_FUNCTION_API_GET_SERVICE_BY_NAME,
+                                       getServiceByName));
+
+       //getServiceById
+               AceFunction getServiceById = ACE_CREATE_FUNCTION(
+                                               FUNCTION_GET_SERVICE_BY_ID,
+                                               ACCOUNT_FUNCTION_API_GET_SERVICE_BY_ID,
+                                               ACCOUNT_FEATURES_ACCOUNT_READ,
+                                               DEVICE_LIST_ACCOUNT_READ);
+               accountMapping.insert(std::make_pair(
+                                               ACCOUNT_FUNCTION_API_GET_SERVICE_BY_ID,
+                                               getServiceById));
+
+    return accountMapping;
+}
+}
+}
+}
diff --git a/src/standards/Tizen/Account/plugin_config.h b/src/standards/Tizen/Account/plugin_config.h
new file mode 100755 (executable)
index 0000000..f3ba0d9
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACCOUNT_PLUGIN_CONFIG_H_
+#define _ACCOUNT_PLUGIN_CONFIG_H_
+
+#include <string>
+#include <Commons/FunctionDeclaration.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Account{
+
+#define ACCOUNT_FUNCTION_API_ADD_ACCOUNT                  "addAccount"
+#define ACCOUNT_FUNCTION_API_ADD_LISTENER_ACCOUNTS        "addAccountListener"
+#define ACCOUNT_FUNCTION_API_REMOVE_LISTENER_ACCOUNTS     "removeAccountListener"
+#define ACCOUNT_FUNCTION_API_GET_ACCOUNT_BY_ID            "getAccountById"
+#define ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID        "getServiceTypeById"
+#define ACCOUNT_FUNCTION_API_GET_PROVIDER_BY_ID           "getProviderById"
+#define ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_SERVICETYPE "findAccountsByServiceType"
+#define ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_TAGS        "findAccountsByTags"
+#define ACCOUNT_FUNCTION_API_FIND_SERVICES_BY_TAGS        "findServicesByTags"
+#define ACCOUNT_FUNCTION_API_FIND_PROVIDERS               "findProviders"
+#define ACCOUNT_FUNCTION_API_FIND_SERVICETYPES            "findServiceTypes"
+#define ACCOUNT_FUNCTION_API_GET_SERVICE_BY_NAME          "getServiceByName"
+#define ACCOUNT_FUNCTION_API_GET_SERVICE_BY_ID            "getServiceById"
+
+
+
+DECLARE_FUNCTION_GETTER(Account);
+
+// TODO : should confirm getAccountFunctionData
+#define ACCOUNT_CHECK_ACCESS(globalContext, functionName)                     \
+    aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(                \
+        globalContext,                     \
+        getAccountFunctionData,           \
+        functionName)
+
+}
+}
+}
+
+#endif //  _CALENDAR_PLUGIN_CONFIG_H_
diff --git a/src/standards/Tizen/Account/plugin_initializer.cpp b/src/standards/Tizen/Account/plugin_initializer.cpp
new file mode 100755 (executable)
index 0000000..9b98d5a
--- /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. 
+ */
+
+
+/*
+ * @author      Karol Majewski (k.majewski@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#include <dpl/log/log.h>
+
+#include <Commons/plugin_initializer_def.h>
+#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/Exception.h>
+#include "JSAccountManager.h"
+
+using namespace TizenApis::Api::Account;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+void on_widget_start_callback(int widgetId,
+        JavaScriptContext context,
+        const engine_interface_t *interface)
+{
+    LogDebug("[Tizen\\account] on_widget_start_callback (" << widgetId << ")");
+    Try
+    {
+        WrtWrappersMgr::getInstance().registerWrapper(
+            widgetId,
+            context,
+            interface);
+    }
+    Catch(Exception)
+    {
+        LogError("Wrt wrapper registration failed");
+    }
+}
+
+void on_widget_stop_callback(int widgetId)
+{
+    LogDebug("[Tizen\\account] on_widget_stop_callback (" << widgetId << ")");
+    WrtWrappersMgr::getInstance().removeWrapper(widgetId);
+}
+
+PLUGIN_ON_WIDGET_START(on_widget_start_callback)
+PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
+
+PLUGIN_CLASS_MAP_BEGIN
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN ,
+        "account",
+        TizenApis::Tizen1_0::Account::JSAccountManager::getClassRef(),
+        NULL)
+PLUGIN_CLASS_MAP_END
+
+#undef PIM
index 5c1b7c4..b43cee8 100755 (executable)
@@ -33,14 +33,12 @@ using namespace TizenApis::Commons;
 
 ApplicationAnswerReceiver::ApplicationAnswerReceiver(const CommonsJavaScript::JSCallbackManagerPtr &callbackManager) :
        EventAnswerReceiver<EventListInstalledApplications> (WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
-       EventAnswerReceiver<EventGetApplication> (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<EventGetApplication> (WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),     
        EventAnswerReceiver<EventLaunchService> (WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
        m_privateData(launchServiceCallbackManager) {
        LogDebug("<<<");
@@ -89,47 +87,6 @@ void ApplicationAnswerReceiver::OnAnswerReceived(const EventListInstalledApplica
        }       
 }
 
-void ApplicationAnswerReceiver::OnAnswerReceived(const EventGetApplicationPtr &event) 
-{
-       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
-               Try
-               {
-                       ApplicationInformationPtr appinfo = event->getApplicationInformation();
-                       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(m_callbackManager->getContext());
-                       JSValueRef result = converter->toJSValueRef(appinfo);
-                       
-                       m_callbackManager->callOnSuccess(result);
-               }
-               Catch(WrtDeviceApis::Commons::Exception)
-               {
-                       LogError("error during getApplication() executing");
-                       JSContextRef context = m_callbackManager->getContext();
-                       JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"unknown error");
-                       m_callbackManager->callOnError(errorObject);
-               }
-       }
-       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);
-       }       
-       LogDebug(">>>");        
-}
-
 void ApplicationAnswerReceiver::OnAnswerReceived(const EventLaunchServicePtr &event) 
 {
        LogDebug("<<<");
index fdceee1..a0552a7 100755 (executable)
 #ifndef TIZENAPIS_TIZEN_APPLICATION_ANSWER_RECEIVER_H_
 #define TIZENAPIS_TIZEN_APPLICATION_ANSWER_RECEIVER_H_
 
-#include <dpl/controller.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <CommonsJavaScript/JSCallbackManager.h>
 #include <API/Application/EventListInstalledApplications.h>
-#include <API/Application/EventGetApplication.h>
 #include <API/Application/EventLaunchService.h>
 #include "LaunchServicePrivateData.h"
 
@@ -35,7 +33,6 @@ using namespace WrtDeviceApis::CommonsJavaScript;
 
 class ApplicationAnswerReceiver :
         public WrtDeviceApis::Commons::EventAnswerReceiver< Api::Application::EventListInstalledApplications>,
-               public WrtDeviceApis::Commons::EventAnswerReceiver< Api::Application::EventGetApplication>,
                public WrtDeviceApis::Commons::EventAnswerReceiver< Api::Application::EventLaunchService>
 {
     public:
@@ -45,15 +42,14 @@ class ApplicationAnswerReceiver :
 
     protected:
         void OnAnswerReceived(const Api::Application::EventListInstalledApplicationsPtr &event);
-        void OnAnswerReceived(const Api::Application::EventGetApplicationPtr &event);
                void OnAnswerReceived(const Api::Application::EventLaunchServicePtr &event);
 
     private:
         JSCallbackManagerPtr m_callbackManager;
-               LaunchServicePrivateDataPtr m_privateData;              
+               LaunchServicePrivateDataPtr m_privateData;
 };
 
-} 
-} 
+}
+}
 }
 #endif
index 477394d..b370af4 100755 (executable)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/JSUtils.h>
 #include <CommonsJavaScript/Validator.h>
 #include <CommonsJavaScript/ScopedJSStringRef.h>
index 89f8399..0b796c5 100755 (executable)
@@ -496,14 +496,12 @@ JSValueRef JSApplication::launchService(JSContextRef context,
                        {
                                replyCallbackManager = JSCallbackManager::createObject(priv->getContext(), 
                                                                result.onsuccess, result.onfail);
-                               replyCallbackManager->setObject(thisObject);
                        }
 
                        if(result.oncancel)
                        {
                                replyCancelCallbackManager = JSCallbackManager::createObject(priv->getContext(), 
                                                                result.oncancel, NULL);
-                               replyCancelCallbackManager->setObject(thisObject);
                        }
 
                }
index 8dfbaa4..3e452fc 100755 (executable)
@@ -17,7 +17,7 @@
 
 #include <cassert>
 #include <memory>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/JSUtils.h>
 #include <CommonsJavaScript/Converter.h>
 #include <Commons/Exception.h>
index 36cea3a..b6197fa 100755 (executable)
@@ -16,7 +16,7 @@
 
 #include <cassert>
 #include <memory>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/JSUtils.h>
 #include <CommonsJavaScript/Converter.h>
 #include <Commons/Exception.h>
index eb5a65a..2fa1ce6 100755 (executable)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
 #include "JSApplicationInformationArray.h"
index 50423ce..b65ee2c 100755 (executable)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
index d9d436c..6b6e29b 100755 (executable)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
 #include "JSApplicationServiceExtraDataArray.h"
index 4e488c1..ed51755 100755 (executable)
@@ -16,7 +16,7 @@
 
 #include <cassert>
 #include <memory>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/JSUtils.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
index 3d519d0..320930b 100755 (executable)
@@ -16,7 +16,7 @@
 
 #include <cassert>
 #include <memory>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/JSUtils.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
index 81b9758..2d5fd1b 100755 (executable)
@@ -15,7 +15,7 @@
  */
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
 #include <Commons/WrtWrapper/WrtWrappersMgr.h>
 #include "JSApplication.h"
old mode 100755 (executable)
new mode 100644 (file)
index bbf760d..5bb9a85
@@ -15,7 +15,7 @@
  */
 
 #include <JavaScriptCore/JavaScript.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
@@ -28,6 +28,7 @@
 #include <CommonsJavaScript/JSUtils.h>
 #include "BluetoothMultiCallback.h"
 #include "JSBluetoothSocket.h"
+#include "JSBluetoothServiceHandler.h"
 #include "BluetoothConverter.h"
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
@@ -50,10 +51,11 @@ BluetoothAdapterListener::BluetoothAdapterListener() :
        EventBTSetPoweredAnswerReceiver(ThreadEnum::NULL_THREAD),
        EventBTSetVisibleAnswerReceiver(ThreadEnum::NULL_THREAD),
        EventBTOnDiscoveryDevicesListener(ThreadEnum::NULL_THREAD),
-       EventBTRegisterRFCOMMListener(ThreadEnum::NULL_THREAD),
+       EventBTRegisterRFCOMMAnswerReceiver(ThreadEnum::NULL_THREAD),
        EventBTUnregisterRFCOMMServiceAnswerReceiver(ThreadEnum::NULL_THREAD),
        EventBTStopDiscoveryAnswerReceiver(ThreadEnum::NULL_THREAD),
-       EventBTSetNameAnswerReceiver(ThreadEnum::NULL_THREAD)
+       EventBTSetNameAnswerReceiver(ThreadEnum::NULL_THREAD),
+       EventBTServiceOnConnectListener(ThreadEnum::NULL_THREAD)        
 {
        LogDebug("entered");
 }
@@ -99,22 +101,14 @@ void BluetoothAdapterListener::OnAnswerReceived(const EventBTCreateDestroyBondin
 
        if (event->getExceptionCode() == ExceptionCodes::None)
        {
-               if (event->isCreateBonding())
-               {
-                       BluetoothDeviceData device = event->getDevice();
-                       JSObjectRef deviceObject = JSBluetoothDevice::createJSObject(l_globalContext, device);
-                       callbackManager->callOnSuccess(deviceObject);
-               }
-               else
-               {
-                       callbackManager->callOnSuccess();
-               }
+               BluetoothDeviceData device = event->getDevice();
+               JSObjectRef deviceObject = JSBluetoothDevice::createJSObject(l_globalContext, device);
+               callbackManager->callOnSuccess(deviceObject);
        }
        else
        {
                MakeErrorJSCallBack(callbackManager, l_globalContext, event->getExceptionCode());
        }
-               
 }
 
 void BluetoothAdapterListener::OnAnswerReceived(const EventBTGetKnownDevicesPtr& event)
@@ -263,46 +257,29 @@ void BluetoothAdapterListener::onAnswerReceived(const EventBTOnDiscoveryDevicesP
        }
 }
 
-void BluetoothAdapterListener::onAnswerReceived(const EventBTRegisterRFCOMMPtr& event)
+void BluetoothAdapterListener::OnAnswerReceived(const EventBTRegisterRFCOMMPtr& event)
 {
-       LogDebug("Enter");
        
-       BluetoothRegisterServiceSuccessCallbackPrivateDataPtr multiCallbacks = 
-               DPL::DynamicPointerCast<BluetoothRegisterServiceSuccessCallbackPrivateData>(event->getPrivateData());
+       LogDebug("Enter - EventBTRegisterRFCOMMPtr");
 
-       BluetoothSocketData socketData;
-       JSObjectRef adapterObject;
-       assert(multiCallbacks != NULL);
-       assert(multiCallbacks->getOnSuccess() != NULL);
-       assert(multiCallbacks->getOnConnected() != NULL);
-       assert(multiCallbacks->getOnSuccess()->getContext() != NULL);
+       JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast<JSCallbackManager > (event->getPrivateData());
+       JSContextRef l_globalContext = callbackManager->getContext();
 
        if (event->getExceptionCode() == ExceptionCodes::None)
        {
-               switch(event->getConnectionState())
-               {
-               case EventBTRegisterRFCOMM::REGISTER_SUCCESS:
-                       multiCallbacks->getOnSuccess()->callOnSuccess();
-                       break;                  
-               case EventBTRegisterRFCOMM::REGISTER_CONNECTED:
-                       socketData = event->getSocketData();
-                       adapterObject = JSBluetoothSocket::createJSObject(multiCallbacks->getOnSuccess()->getContext(), socketData);
-                       multiCallbacks->getOnConnected()->callOnSuccess(adapterObject);
-                       break;
-               case EventBTRegisterRFCOMM::REGISTER_DISCONNECTED:
-               default:
-                       MakeErrorJSCallBack(multiCallbacks->getOnSuccess(), 
-                               multiCallbacks->getOnSuccess()->getContext(), event->getExceptionCode());
-                       break;
-               }
-
+               JSObjectRef adapterObject; 
+               int socketFd = event->getSocketFd();
+               std::string uuid = event->getUuid();
+               std::string name = event->getName();
+               adapterObject = JSBluetoothServiceHandler::createJSObject(l_globalContext, name, uuid, socketFd);
+               callbackManager->callOnSuccess(adapterObject);
        }
        else
        {
-               MakeErrorJSCallBack(multiCallbacks->getOnSuccess(), 
-                       multiCallbacks->getOnSuccess()->getContext(), event->getExceptionCode());
+               MakeErrorJSCallBack(callbackManager, l_globalContext, event->getExceptionCode());
        }
 
+
 }      
 
 void BluetoothAdapterListener::OnAnswerReceived(const EventBTStopDiscoveryPtr& event)
@@ -336,5 +313,31 @@ void BluetoothAdapterListener::OnAnswerReceived(const EventBTSetNamePtr& event)
                MakeErrorJSCallBack(callbackManager, l_globalContext, event->getExceptionCode());
        }
 }
+
+void BluetoothAdapterListener::onAnswerReceived(const EventBTServiceOnConnectPtr& event)
+{
+       LogDebug("Enter - EventBTServiceOnConnectPtr");
+
+       JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast<JSCallbackManager > (event->getPrivateData());
+       JSContextRef l_globalContext = callbackManager->getContext();
+
+       BluetoothSocketData socketData;
+       JSObjectRef adapterObject;
+
+       if (event->getExceptionCode() == ExceptionCodes::None)
+       {
+               socketData = event->getSocketData();
+               adapterObject = JSBluetoothSocket::createJSObject(l_globalContext, socketData);
+               callbackManager->callOnSuccess(adapterObject);
+       }
+       else
+       {
+               MakeErrorJSCallBack(callbackManager, l_globalContext, event->getExceptionCode());
+       }
+
+}
+
+
+
 }
 }
old mode 100755 (executable)
new mode 100644 (file)
index 9599220..c31b2cf
@@ -22,6 +22,8 @@
 #include <dpl/noncopyable.h>
 #include <API/Bluetooth/IBluetoothAdapterManager.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
+#include <API/Bluetooth/EventBTServiceOnConnect.h>
+#include <API/Bluetooth/EventBTUnregisterRFCOMM.h>
 
 
 using namespace TizenApis::Api;
@@ -39,10 +41,11 @@ typedef EventAnswerReceiver<EventBTGetDevice> EventBTGetDeviceAnswerReceiver;
 typedef EventAnswerReceiver<EventBTSetPowered> EventBTSetPoweredAnswerReceiver;
 typedef EventAnswerReceiver<EventBTSetVisible> EventBTSetVisibleAnswerReceiver;
 typedef EventListener<EventBTOnDiscoveryDevices> EventBTOnDiscoveryDevicesListener;
-typedef EventListener<EventBTRegisterRFCOMM> EventBTRegisterRFCOMMListener;
+typedef EventAnswerReceiver<EventBTRegisterRFCOMM> EventBTRegisterRFCOMMAnswerReceiver;
 typedef EventAnswerReceiver<EventBTUnregisterRFCOMMService> EventBTUnregisterRFCOMMServiceAnswerReceiver;
 typedef EventAnswerReceiver<EventBTStopDiscovery> EventBTStopDiscoveryAnswerReceiver;
 typedef EventAnswerReceiver<EventBTSetName> EventBTSetNameAnswerReceiver;
+typedef EventListener<EventBTServiceOnConnect> EventBTServiceOnConnectListener;
 
 
        
@@ -53,10 +56,11 @@ class BluetoothAdapterListener :
        public EventBTSetPoweredAnswerReceiver,
        public EventBTSetVisibleAnswerReceiver,
        public EventBTOnDiscoveryDevicesListener,
-       public EventBTRegisterRFCOMMListener,
+       public EventBTRegisterRFCOMMAnswerReceiver,
        public EventBTUnregisterRFCOMMServiceAnswerReceiver,
        public EventBTStopDiscoveryAnswerReceiver,
-       public EventBTSetNameAnswerReceiver
+       public EventBTSetNameAnswerReceiver,
+       public EventBTServiceOnConnectListener
 {
 
 private:
@@ -65,7 +69,7 @@ private:
 public:
        static BluetoothAdapterListener& getInstance();
        virtual void onAnswerReceived(const EventBTOnDiscoveryDevicesPtr& event);
-       virtual void onAnswerReceived(const EventBTRegisterRFCOMMPtr& event);
+       virtual void onAnswerReceived(const EventBTServiceOnConnectPtr& event);
 
        virtual ~BluetoothAdapterListener();
 protected:
@@ -78,6 +82,7 @@ protected:
        virtual void OnAnswerReceived(const EventBTUnregisterRFCOMMServicePtr& event);
        virtual void OnAnswerReceived(const EventBTStopDiscoveryPtr& event);
        virtual void OnAnswerReceived(const EventBTSetNamePtr& event);
+       virtual void OnAnswerReceived(const EventBTRegisterRFCOMMPtr& event);
 
 
 };
index b3c5a0a..abcc4a9 100644 (file)
@@ -116,9 +116,6 @@ EventBTOnDiscoveryDevicesPrivateDataPtr
        JSCallbackManagerPtr onFoundCbm = JSCallbackManager::createObject(m_context, result.onFound, NULL);
        JSCallbackManagerPtr onFinishedCbm = JSCallbackManager::createObject(m_context, result.onFinished, NULL);
 
-       onSuccessCbm->setObject(thisObject);
-       onFoundCbm->setObject(thisObject);
-       onFinishedCbm->setObject(thisObject);                   
        onSuccessCbm->setOnError(errorCalback);
        onFoundCbm->setOnError(errorCalback);
        onFinishedCbm->setOnError(errorCalback);
@@ -128,84 +125,40 @@ EventBTOnDiscoveryDevicesPrivateDataPtr
 }
 
 BluetoothSocketNotifierPrivateDataPtr 
-       BluetoothConverter::toBluetoothSocketNotifierPrivateData(JSObjectRef thisObject, JSValueRef successParam)
+       BluetoothConverter::getInitalBluetoothSocketNotifierPrivateData()
 {
+       JSCallbackManagerPtr onMessageCbm = JSCallbackManager::createObject(m_context, NULL, NULL);
+       JSCallbackManagerPtr onErrorCbm = JSCallbackManager::createObject(m_context, NULL, NULL);
+       JSCallbackManagerPtr onCloseCbm = JSCallbackManager::createObject(m_context, NULL, NULL);
 
-       if (JSValueIsNull(m_context, successParam) || JSValueIsUndefined(m_context, successParam) 
-               || !JSValueIsObject(m_context, successParam))
-       {
-               LogError("not a object");
-               Throw(ConversionException);
-       }
-
-       Validator validator(m_context);
-       JSObjectRef objectCallbacks = toJSObjectRef(successParam);
-       BluetoothSocketNotifier result;
-
-       result.onMessage = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onMessage");
-       result.onError = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onError");
-       result.onClose = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onClose");
-       
-       if ((!validator.isNullOrUndefined(result.onMessage) && !validator.isCallback(result.onMessage)) ||
-               (!validator.isNullOrUndefined(result.onError) && !validator.isCallback(result.onError)) ||
-               (!validator.isNullOrUndefined(result.onClose) && !validator.isCallback(result.onClose)))
-       {
-               LogError("java script call back set error");
-               Throw(ConversionException);
-       }
-       
-       JSCallbackManagerPtr onMessageCbm = JSCallbackManager::createObject(m_context, result.onMessage, NULL);
-       JSCallbackManagerPtr onErrorCbm = JSCallbackManager::createObject(m_context, result.onError, NULL);
-       JSCallbackManagerPtr onCloseCbm = JSCallbackManager::createObject(m_context, result.onClose, NULL);
-       
-       onMessageCbm->setObject(thisObject);
-       onErrorCbm->setObject(thisObject);
-       onCloseCbm->setObject(thisObject);
-       
        return BluetoothSocketNotifierPrivateDataPtr(
                new BluetoothSocketNotifierPrivateData(onMessageCbm, onErrorCbm, onCloseCbm));
+       
 }
 
-BluetoothRegisterServiceSuccessCallbackPrivateDataPtr 
-       BluetoothConverter::toBluetoothRegisterServiceSuccessCallbackPrivateData(
-       JSObjectRef thisObject, JSValueRef successParam, JSValueRef errorParam)
+void BluetoothConverter::setBluetoothSocketNotifierCallback(JSStringRef propertyName, JSValueRef value, 
+       JSObjectRef object, BluetoothSocketNotifierPrivateDataPtr& privData)
 {
-       JSValueRef errorCalback;
+       JSValueRef successCallback = toFunction(value);
 
-       if (JSValueIsNull(m_context, successParam) || JSValueIsUndefined(m_context, successParam) 
-               || !JSValueIsObject(m_context, successParam))
+       if(JSStringIsEqualToUTF8CString(propertyName, "onClose")) 
        {
-               LogError("not a object");
-               Throw(ConversionException);
+               privData->getOnClose()->setOnSuccess(successCallback);
        }
-
-       Validator validator(m_context);
-       JSObjectRef objectCallbacks = toJSObjectRef(successParam);
-       BluetoothRegisterServiceSuccessCallback result;
-
-       
-       errorCalback = toFunctionOrNull(errorParam);
-
-
-       result.onSuccess = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onSuccess");
-       result.onConnected = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onConnect");        
-       
-       if ((!validator.isNullOrUndefined(result.onSuccess) && !validator.isCallback(result.onSuccess)) ||
-               (!validator.isNullOrUndefined(result.onConnected) && !validator.isCallback(result.onConnected)))
+       else if(JSStringIsEqualToUTF8CString(propertyName, "onError")) 
        {
-               LogError("java script call back set error");
-               Throw(ConversionException);
+               privData->getOnError()->setOnSuccess(successCallback);
        }
-       JSCallbackManagerPtr onSuccess = JSCallbackManager::createObject(m_context, result.onSuccess, NULL);
-       JSCallbackManagerPtr onConnectedCbm = JSCallbackManager::createObject(m_context, result.onConnected, NULL);
-       
-       onSuccess->setObject(thisObject);
-       onConnectedCbm->setObject(thisObject);
-       onSuccess->setOnError(errorCalback);
-       onConnectedCbm->setOnError(errorCalback);
-
-       return BluetoothRegisterServiceSuccessCallbackPrivateDataPtr(
-               new BluetoothRegisterServiceSuccessCallbackPrivateData(onSuccess, onConnectedCbm));
+       else if(JSStringIsEqualToUTF8CString(propertyName, "onMessage")) 
+       {
+               privData->getOnMessage()->setOnSuccess(successCallback);
+               privData->setObject(object);
+       }
+       else
+       {
+               ThrowMsg(ConversionException, "unknown property");
+       }
+                       
 }
 
 JSObjectRef BluetoothConverter::toBluetoothDevices(const std::vector<TizenApis::Api::Bluetooth::BluetoothDeviceData>& devices)
@@ -232,6 +185,7 @@ JSObjectRef BluetoothConverter::toBluetoothByteArray(std::vector<char>& data)
                ThrowMsg(WrtDeviceApis::Commons::UnknownException, "Could not create array object.");
        }
 
+       LogDebug("size" << length);
        for (int i = 0; i < length; ++i) 
        {
                JSValueRef value = JSValueMakeNumber(m_context, data[i]);
old mode 100755 (executable)
new mode 100644 (file)
index f8ea118..abdf7dd
@@ -15,7 +15,7 @@
 */
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include <API/Bluetooth/BTDevice.h>
 #include "BluetoothMultiCallback.h"
@@ -39,11 +39,9 @@ class BluetoothConverter : public WrtDeviceApis::CommonsJavaScript::Converter
        EventBTOnDiscoveryDevicesPrivateDataPtr 
                toEventBTOnDiscoveryDevicesPrivateData(JSObjectRef thisObject, 
                JSValueRef successParam, JSValueRef errorParam);
-       BluetoothSocketNotifierPrivateDataPtr 
-               toBluetoothSocketNotifierPrivateData(JSObjectRef thisObject, JSValueRef successParam);
-       BluetoothRegisterServiceSuccessCallbackPrivateDataPtr 
-               toBluetoothRegisterServiceSuccessCallbackPrivateData(JSObjectRef thisObject, 
-               JSValueRef successParam, JSValueRef errorParam);
+       BluetoothSocketNotifierPrivateDataPtr getInitalBluetoothSocketNotifierPrivateData();
+       void setBluetoothSocketNotifierCallback(JSStringRef propertyName, JSValueRef value, 
+               JSObjectRef object, BluetoothSocketNotifierPrivateDataPtr& privData);
        JSObjectRef toBluetoothDevices(const std::vector<TizenApis::Api::Bluetooth::BluetoothDeviceData>& devices);
        JSObjectRef toBluetoothByteArray(std::vector<char>& data);
        unsigned short toBluetoothSecurityLevelInt(JSValueRef level);
old mode 100755 (executable)
new mode 100644 (file)
index 58655cf..496599a
@@ -15,7 +15,7 @@
  */
 
 #include <JavaScriptCore/JavaScript.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
index 2b49488..5a224ad 100644 (file)
@@ -44,7 +44,7 @@ JSCallbackManagerPtr EventBTOnDiscoveryDevicesPrivateData::getOnFinished() const
 BluetoothSocketNotifierPrivateData::BluetoothSocketNotifierPrivateData
                        (const JSCallbackManagerPtr& onMessage, const JSCallbackManagerPtr& onError,
                        const JSCallbackManagerPtr& onClose) :
-                       m_onMessage(onMessage), m_onError(onError), m_onClose(onClose)  {}
+                       m_onMessage(onMessage), m_onError(onError), m_onClose(onClose){}
 
 JSCallbackManagerPtr BluetoothSocketNotifierPrivateData::getOnMessage() const
 {
@@ -61,6 +61,17 @@ JSCallbackManagerPtr BluetoothSocketNotifierPrivateData::getOnClose() const
        return m_onClose;
 }
 
+JSObjectRef BluetoothSocketNotifierPrivateData::getObject() const
+{
+       return m_object;
+}
+
+void BluetoothSocketNotifierPrivateData::setObject(JSObjectRef object)
+{
+       m_object = object;
+}
+
+
 
 BluetoothRegisterServiceSuccessCallbackPrivateData ::BluetoothRegisterServiceSuccessCallbackPrivateData
                        (const JSCallbackManagerPtr& onSuccess, const JSCallbackManagerPtr& onConnected) :
index 19bc74a..6af3da2 100644 (file)
@@ -97,11 +97,14 @@ public:
        JSCallbackManagerPtr getOnMessage() const;
        JSCallbackManagerPtr getOnError() const;
        JSCallbackManagerPtr getOnClose() const;
+       JSObjectRef getObject() const;
+       void setObject(const JSObjectRef object);
 
 private:
        JSCallbackManagerPtr m_onMessage;
        JSCallbackManagerPtr m_onError;
        JSCallbackManagerPtr m_onClose; 
+       JSObjectRef m_object;
 };
 
 typedef DPL::SharedPtr<BluetoothSocketNotifierPrivateData> BluetoothSocketNotifierPrivateDataPtr;
index 8301803..b366782 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 #include <JavaScriptCore/JavaScript.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
@@ -56,28 +56,29 @@ void BluetoothSocketListener::onAnswerReceived(const EventBTSocketNotificationPt
 
        BluetoothSocketNotifierPrivateDataPtr multiCallbacks = 
                DPL::DynamicPointerCast<BluetoothSocketNotifierPrivateData>(event->getPrivateData());
-       BluetoothSocketData socketData = event->getSocketData();
-       EventBTReadDataType readData;
-       JSObjectRef adapterObject;
-
 
        switch(event->getConnectionState())
        {
        case EventBTSocketNotification::DISCONNECTED:
-               adapterObject = JSBluetoothSocket::createJSObject(multiCallbacks->getOnClose()->getContext(), socketData);
-               multiCallbacks->getOnClose()->callOnSuccess(adapterObject);
+               multiCallbacks->getOnClose()->callOnSuccess();
                break;                  
        case EventBTSocketNotification::DATARECEIVED:
+       {
+               EventBTReadDataType readData;
+               JSBluetoothSocketPriv *priv = 
+                       static_cast<JSBluetoothSocketPriv*>(JSObjectGetPrivate(multiCallbacks->getObject()));
+               IBluetoothSocketManagerPtr BluetoothSocketManager(priv->getObject());
+
                readData = event->getReadData();
-               adapterObject = JSBluetoothSocket::createJSObject(multiCallbacks->getOnMessage()->getContext(), socketData, readData);
-               multiCallbacks->getOnMessage()->callOnSuccess(adapterObject);
+               LogDebug("Size" << readData.size());
+               BluetoothSocketManager->setReadData(readData);
+               multiCallbacks->getOnMessage()->callOnSuccess();
+       }
                break;
        case EventBTSocketNotification::SOCKETERROR:
        default:
-               adapterObject = JSBluetoothSocket::createJSObject(multiCallbacks->getOnError()->getContext(), socketData);
-               JSValueRef socketCallbackArray[2] = {JSTizenExceptionFactory::makeErrorObject(multiCallbacks->getOnError()->getContext(), 
-                               JSTizenException::UNKNOWN_ERROR, "unknown error"), adapterObject};
-               multiCallbacks->getOnError()->callOnSuccess(socketCallbackArray, 2);
+               multiCallbacks->getOnError()->callOnSuccess(JSTizenExceptionFactory::makeErrorObject(multiCallbacks->getOnError()->getContext(), 
+                               JSTizenException::UNKNOWN_ERROR, "unknown error"));
                break;
        }
 }
old mode 100755 (executable)
new mode 100644 (file)
index 0ff4948..59253e3
@@ -16,20 +16,21 @@ set(SRCS
        plugin_initializer.cpp
        plugin_config.cpp
        BluetoothAdapterListener.cpp  
-       JSBluetoothAdapter.cpp  
-       JSBluetoothDevice.cpp  
        BluetoothSocketListener.cpp   
        BluetoothDeviceManagerListener.cpp
+       BluetoothClass.cpp 
+       BluetoothMultiCallback.cpp
+       BluetoothConverter.cpp
+       JSBluetoothAdapter.cpp  
+       JSBluetoothDevice.cpp  
        JSBluetoothClass.cpp    
        JSBluetoothClassDeviceMajor.cpp 
        JSBluetoothClassDeviceMinor.cpp 
        JSBluetoothClassDeviceService.cpp
+       JSBluetoothServiceHandler.cpp
        JSBluetoothManager.cpp 
-       BluetoothClass.cpp 
        JSBluetoothSocket.cpp
        JSBluetoothDevice.cpp
-       BluetoothMultiCallback.cpp
-       BluetoothConverter.cpp
 )
 
 add_library(${TARGET_NAME} SHARED ${SRCS})
index 4478cb5..e6717e5 100644 (file)
@@ -79,7 +79,6 @@ JSStaticFunction JSBluetoothAdapter::m_function[] =
        { "createBonding", JSBluetoothAdapter::createBonding, kJSPropertyAttributeNone },
        { "destroyBonding", JSBluetoothAdapter::destroyBonding, kJSPropertyAttributeNone },
        { "registerRFCOMMServiceByUUID", JSBluetoothAdapter::registerRFCOMMServiceByUUID, kJSPropertyAttributeNone },   
-       { "unregisterRFCOMMService", JSBluetoothAdapter::unregisterRFCOMMService, kJSPropertyAttributeNone },   
        { 0, 0, 0 }
 };
 
@@ -185,7 +184,6 @@ JSValueRef JSBluetoothAdapter::setName(JSContextRef context, JSObjectRef object,
                
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
-               cbm->setObject(thisObject);
                
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
                std::string name = converter.toString(arguments[0]);
@@ -491,7 +489,6 @@ JSValueRef JSBluetoothAdapter::setPowered(JSContextRef context, JSObjectRef obje
                }
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
-               cbm->setObject(thisObject);
        
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
                EventBTSetPoweredPtr event(new EventBTSetPowered);
@@ -583,7 +580,6 @@ JSValueRef JSBluetoothAdapter::setVisible(JSContextRef context, JSObjectRef obje
 
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
-               cbm->setObject(thisObject);
 
                if (JSValueIsNull(context, arguments[0]) == true || JSValueIsBoolean(context, arguments[0]) == false)
                {
@@ -622,10 +618,9 @@ JSValueRef JSBluetoothAdapter::setVisible(JSContextRef context, JSObjectRef obje
                                        LogError("Wrong parameter passed");
                                        Throw(ConversionException);
                                }
-
-                               LogDebug("timeout " << (unsigned short)converter.toInt(arguments[3]));
-                               event->setTimeout((unsigned short)converter.toInt(arguments[3]));
                        }
+                       LogDebug("timeout " << (unsigned short)converter.toInt(arguments[3]));
+                       event->setTimeout((unsigned short)converter.toInt(arguments[3]));
                }
                else
                {
@@ -793,7 +788,6 @@ JSValueRef JSBluetoothAdapter::stopDiscovery(JSContextRef context, JSObjectRef o
                        
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
-               cbm->setObject(thisObject);
 
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
                EventBTStopDiscoveryPtr  event(new EventBTStopDiscovery);
@@ -880,7 +874,6 @@ JSValueRef JSBluetoothAdapter::getKnownDevices(JSContextRef context, JSObjectRef
                        
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
-               cbm->setObject(thisObject);
 
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
                EventBTGetKnownDevicesPtr event(new EventBTGetKnownDevices);
@@ -972,7 +965,6 @@ JSValueRef JSBluetoothAdapter::getDevice(JSContextRef context, JSObjectRef objec
                        
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
-               cbm->setObject(thisObject);
 
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
                EventBTGetDevicePtr event(new EventBTGetDevice);
@@ -1013,8 +1005,7 @@ JSValueRef JSBluetoothAdapter::getDevice(JSContextRef context, JSObjectRef objec
 
        }
 
-       return JSValueMakeUndefined(context);
-}
+       return JSValueMakeUndefined(context);}
 
 
 JSValueRef JSBluetoothAdapter::createBonding(JSContextRef context, JSObjectRef object,
@@ -1069,7 +1060,6 @@ JSValueRef JSBluetoothAdapter::createBonding(JSContextRef context, JSObjectRef o
                        
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
-               cbm->setObject(thisObject);
 
 
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
@@ -1164,7 +1154,6 @@ JSValueRef JSBluetoothAdapter::destroyBonding(JSContextRef context, JSObjectRef
                        
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
-               cbm->setObject(thisObject);
                
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
                EventBTCreateDestroyBondingPtr event(new EventBTCreateDestroyBonding);
@@ -1216,15 +1205,17 @@ JSValueRef JSBluetoothAdapter::registerRFCOMMServiceByUUID(JSContextRef context,
 {
        LogDebug("registerRFCOMMServiceByUUID");
 
-       JSBluetoothAdapterPriv *priv = static_cast<JSBluetoothAdapterPriv*>(JSObjectGetPrivate(thisObject));
-       
+       JSBluetoothAdapterPriv *priv = static_cast<JSBluetoothAdapterPriv*>(JSObjectGetPrivate(thisObject));    
+       JSValueRef successCallback = NULL;
+       JSValueRef errorCallBack = NULL;
+
        Try     
        {
                std::string serviceName, uuid;
                unsigned short securityLevel= SECURITY_LEVEL_HIGH_VALUE_INT;
                Validator validator(context);           
-               int serviceSocketFd = -1;
                
+               LogDebug("context address" << context << "priv-context" << priv->getContext());
                                
                if (priv == NULL)
                {
@@ -1245,8 +1236,6 @@ JSValueRef JSBluetoothAdapter::registerRFCOMMServiceByUUID(JSContextRef context,
                        Throw(InvalidArgumentException);
                }
 
-               
-               JSValueRef errorArgument = JSValueMakeNull(context);
                BluetoothConverter converter(priv->getContext());
                uuid = converter.toBluetoothUUIDString(arguments[0]);
 
@@ -1254,145 +1243,47 @@ JSValueRef JSBluetoothAdapter::registerRFCOMMServiceByUUID(JSContextRef context,
                {
                        ThrowMsg(ConversionException, "Not a string");
                }
-               
                serviceName = converter.toString(arguments[1]);
-
+               successCallback = converter.toFunction(arguments[2]);
+               
                if (argumentCount >= 4)
                {
-                       errorArgument = arguments[3];
+                       errorCallBack = converter.toFunctionOrNull(arguments[3]);
                }
                
                if (argumentCount >= 5)
                {
                        securityLevel = converter.toBluetoothSecurityLevelInt(arguments[4]);
                }
-
-
-               BluetoothRegisterServiceSuccessCallbackPrivateDataPtr privData(
-                       converter.toBluetoothRegisterServiceSuccessCallbackPrivateData(thisObject, arguments[2], errorArgument));
-
-               IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
-               EventBTRegisterRFCOMMEmitterPtr emitter(new EventBTRegisterRFCOMMEmitter);
-
-               if (BluetoothAdapterManager == NULL || emitter == NULL || privData == NULL)
-               {
-                       LogError("BluetoothAdapterManager or event or listener NULL");
-                       Throw(UnknownException);        
-               }
-               LogDebug("UUid:" << uuid << " serviceName:" << serviceName);
-               
-               emitter->setListener(&BluetoothAdapterListener::getInstance());
-               emitter->setEventPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privData));
-               serviceSocketFd = BluetoothAdapterManager->registerRFCOMMServiceByUUID(emitter, uuid, serviceName, securityLevel);
-
-               return converter.toJSValueRef(serviceSocketFd);
-       }
-       Catch (WrtDeviceApis::Commons::ConversionException)
-       {
-               LogError("ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                                       JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
-
-       }               
-       Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
-       {
-               LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                       JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
-
-       }
-       Catch (WrtDeviceApis::Commons::UnsupportedException)
-       {
-               LogError("NotsupportedException");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                       JSTizenException::NOT_SUPPORTED_ERROR, "not support error");
-
-       }
-       Catch (WrtDeviceApis::Commons::Exception) 
-       {
-               LogError("Exception");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                       JSTizenException::UNKNOWN_ERROR, "unknown error");
-
-       }       
-       return JSValueMakeUndefined(context);
-
-}
-
-JSValueRef JSBluetoothAdapter::unregisterRFCOMMService(JSContextRef context, JSObjectRef object,
-               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
-               JSValueRef* exception) 
-{
-
-       LogDebug("unregisterRFCOMMService");
        
-       JSBluetoothAdapterPriv *priv = static_cast<JSBluetoothAdapterPriv*>(JSObjectGetPrivate(thisObject));
-       JSValueRef successCallback = NULL;
-       JSValueRef errorCallBack = NULL;
-       
-       Try     
-       {
-
-               if (priv == NULL)
-               {
-                       LogError("priv null");
-                       Throw(UnknownException);        
-               }
-
-               if (argumentCount < 2  || argumentCount > 3)
-               {
-                       LogError("Wrong parameter count passed");
-                       Throw(InvalidArgumentException);
-               }
-
-               AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                               priv->getContext(),
-                               bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADPATER_UNREGISTER_RFCOMM]);
-               
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               
-               if (JSValueIsNull(context, arguments[0]) == true || JSValueIsNumber(context, arguments[0]) == false)
-               {
-                       LogError("Wrong parameter passed, type mismatch");
-                       ThrowMsg(ConversionException, "not a number");          
-               }
-
-               BluetoothConverter converter(priv->getContext());
-               int serviceSocketFd = converter.toInt(arguments[0]);
-               successCallback = converter.toFunction(arguments[1]);
-               
-               if (argumentCount >= 3)
-               {
-                       errorCallBack = converter.toFunctionOrNull(arguments[2]);
-               }
-
                JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
                
                if (cbm == NULL)
                {
                        Throw(UnknownException);        
                }
-                       
+
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
-               cbm->setObject(thisObject);
                
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
-               EventBTUnregisterRFCOMMServicePtr event(new EventBTUnregisterRFCOMMService);
-               event->setUnregisterSocket(serviceSocketFd);
+               EventBTRegisterRFCOMMPtr event(new EventBTRegisterRFCOMM);
 
                if (BluetoothAdapterManager == NULL || event == NULL)
                {
                        LogError("BluetoothAdapterManager or event or listener NULL");
                        Throw(UnknownException);        
                }
+               LogDebug("UUid:" << uuid << " serviceName:" << serviceName);
 
-               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
-               BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance();
+               BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance();           
                event->setForAsynchronousCall(&listener);
-               BluetoothAdapterManager->unregisterRFCOMMService(event);
-               
+               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+               event->setUuid(uuid);
+               event->setSecurityLevel(securityLevel); 
+               event->setName(serviceName);
+               BluetoothAdapterManager->registerRFCOMMServiceByUUID(event);
+
                return JSValueMakeNull(context);
        }
        Catch (WrtDeviceApis::Commons::ConversionException)
@@ -1409,6 +1300,13 @@ JSValueRef JSBluetoothAdapter::unregisterRFCOMMService(JSContextRef context, JSO
                        JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
 
        }
+       Catch (WrtDeviceApis::Commons::UnsupportedException)
+       {
+               LogError("NotsupportedException");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                       JSTizenException::NOT_SUPPORTED_ERROR, "not support error");
+
+       }
        Catch (WrtDeviceApis::Commons::Exception) 
        {
                LogError("Exception");
@@ -1417,6 +1315,9 @@ JSValueRef JSBluetoothAdapter::unregisterRFCOMMService(JSContextRef context, JSO
 
        }       
        return JSValueMakeUndefined(context);
+
 }
+
+
 }
 }
old mode 100755 (executable)
new mode 100644 (file)
index c1faf00..e21350c
@@ -108,11 +108,6 @@ private:
                JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
                JSValueRef* exception);
 
-       static JSValueRef unregisterRFCOMMService(
-               JSContextRef context, JSObjectRef object,
-                       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
-                       JSValueRef* exception);
-
        static JSValueRef getAddress(
                JSContextRef context, JSObjectRef object, 
                JSStringRef propertyName, JSValueRef* exception);
index 251f3f4..557d064 100644 (file)
  */
 
  
-/**
-* @file                 JSBluetoothClassDeviceMinor.h
-* @author       Kangsoo Lee (wpeter.lee@samsung.com)
-* @version      0.1
-*/
 
 #ifndef TIZENAPIS_TIZEN_JS_BLUETOOTH_CLASS_H_
 #define TIZENAPIS_TIZEN_JS_BLUETOOTH_CLASS_H_
old mode 100755 (executable)
new mode 100644 (file)
index 773d178..13eb7be
@@ -534,7 +534,6 @@ JSValueRef JSBluetoothDevice::connectToServiceByUUID(JSContextRef context, JSObj
                }
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
-               cbm->setObject(thisObject);
 
                IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject());
                EventBTConnectToServiceByUUIDPtr event(new EventBTConnectToServiceByUUID);
diff --git a/src/standards/Tizen/Bluetooth/JSBluetoothServiceHandler.cpp b/src/standards/Tizen/Bluetooth/JSBluetoothServiceHandler.cpp
new file mode 100644 (file)
index 0000000..5df0b6c
--- /dev/null
@@ -0,0 +1,455 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "JSBluetoothServiceHandler.h"
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <CommonsJavaScript/Utils.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include <API/Bluetooth/BluetoothProperty.h>
+#include "BluetoothConverter.h"
+#include "BluetoothAdapterListener.h"
+#include <API/Bluetooth/BluetoothFactory.h>
+#include <bluetooth.h>
+#include "plugin_config.h"
+
+using namespace std;
+using namespace DPL;
+using namespace WrtDeviceApis;
+using namespace TizenApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+JSClassRef JSBluetoothServiceHandler::m_jsClassRef = NULL;
+
+JSClassDefinition JSBluetoothServiceHandler::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       "BluetoothServiceHandler",
+       NULL,
+       m_properties,
+       m_function,
+       initialize,
+       finalize,
+       NULL, 
+       NULL, 
+       NULL, 
+       NULL, 
+       NULL, 
+       NULL,
+       NULL,
+       NULL,
+       NULL
+};
+
+
+
+
+JSStaticValue JSBluetoothServiceHandler::m_properties[] = 
+{
+       {"uuid", getUuid, NULL, kJSPropertyAttributeReadOnly},
+       {"onConnect", NULL, setOnConnect, kJSPropertyAttributeNone},
+       {"name", getName, NULL, kJSPropertyAttributeReadOnly},                  
+       {"isConnected", getIsConnected, NULL, kJSPropertyAttributeReadOnly},                    
+       {0, 0, 0, 0}
+};
+
+JSStaticFunction JSBluetoothServiceHandler::m_function[] =
+{
+       {"unRegister", JSBluetoothServiceHandler::unregisterRFCOMMService, kJSPropertyAttributeNone},
+       { 0, 0, 0 }
+};
+
+void JSBluetoothServiceHandler::initialize(JSContextRef context, JSObjectRef object) 
+{
+       LogDebug("JSBluetoothServiceHandler::initialize");
+}
+
+JSObjectRef JSBluetoothServiceHandler::createJSObject(JSContextRef context, std::string name, std::string uuid, int registerSock)
+{
+       IBluetoothServiceHandlerManagerPtr BluetoothServiceHandlerManager(BluetoothFactory::getInstance().getBluetoothServiceHandlerManager());
+       BluetoothServiceHandlerManager->setRegisterSocket(registerSock);
+       BluetoothServiceHandlerManager->setUUID(uuid);
+       BluetoothServiceHandlerManager->setIsConnected(false);
+       BluetoothServiceHandlerManager->setName(name);
+
+       JSBluetoothServiceHandlerPriv* priv = new JSBluetoothServiceHandlerPriv( context, BluetoothServiceHandlerManager);
+
+       return JSObjectMake(context, getClassRef(), priv);
+
+}
+
+
+
+const JSClassRef JSBluetoothServiceHandler::getClassRef() 
+{
+       if (!m_jsClassRef) 
+       {
+               m_jsClassRef = JSClassCreate(&m_classInfo);
+       }
+       return m_jsClassRef;
+}
+
+
+void JSBluetoothServiceHandler::getPropertyNames(JSContextRef context,
+                                       JSObjectRef object,
+                                       JSPropertyNameAccumulatorRef propertyNames)
+{
+}
+
+
+bool JSBluetoothServiceHandler::setOnConnect(JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef value,
+                                       JSValueRef* exception)
+
+{
+       LogDebug("OK");
+       
+       try 
+       {
+               JSBluetoothServiceHandlerPriv *priv = static_cast<JSBluetoothServiceHandlerPriv*>(JSObjectGetPrivate(object));
+               BluetoothConverter converter(priv->getContext());
+               JSValueRef successCallback = NULL;
+               JSValueRef errorCallback = NULL;
+
+               if (priv == NULL)
+               {
+                       ThrowMsg(UnknownException, "private object null");
+               }
+
+               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
+
+               if (cbm == NULL)
+               {
+                       ThrowMsg(ConversionException, "callback manager creation fail");
+               }
+
+               successCallback = converter.toFunction(value);
+               
+               cbm->setOnSuccess(successCallback);
+               cbm->setOnError(errorCallback);
+               //cbm->setObject(object);
+
+               IBluetoothServiceHandlerManagerPtr BluetoothServiceHandlerManager(priv->getObject());
+               EventBTServiceOnConnectEmitterPtr emitter(new EventBTServiceOnConnectEmitter);
+
+               emitter->setListener(&BluetoothAdapterListener::getInstance());
+               emitter->setEventPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(cbm));
+               if (BluetoothServiceHandlerManager->setServiceHandlerListener(emitter) != BT_ERROR_NONE)
+               {
+                       ThrowMsg(UnknownException, "private object null");
+               }
+                               
+               return true;
+       }
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               LogError("Exception: " << ex.GetMessage());
+
+               switch (ex.getCode())
+               {
+               case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
+                       JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+                       break;
+               case WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException:
+                       JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
+                       break;
+               case WrtDeviceApis::Commons::ExceptionCodes::Exception:
+               default:
+                       JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::UNKNOWN_ERROR, "Unkown error");
+               }
+       }       
+       return false;
+
+}
+
+
+       
+
+JSValueRef JSBluetoothServiceHandler::getUuid(JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception)
+{
+       LogDebug("OK"); 
+       
+       try 
+       {
+               JSBluetoothServiceHandlerPriv *priv = static_cast<JSBluetoothServiceHandlerPriv*>(JSObjectGetPrivate(object));
+               BluetoothConverter converter(priv->getContext());
+
+               if (priv == NULL)
+               {
+                       ThrowMsg(UnknownException, "private object null");
+               }
+
+               IBluetoothServiceHandlerManagerPtr BluetoothServiceHandlerManager(priv->getObject());
+               std::string uuid = BluetoothServiceHandlerManager->getUUID();
+               return converter.toJSValueRef(uuid);
+
+       }
+       
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               LogError("Exception: " << ex.GetMessage());
+
+               switch (ex.getCode())
+               {
+               case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
+                       return JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+               case WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException:
+                       return JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
+               case WrtDeviceApis::Commons::ExceptionCodes::Exception:
+               default:
+                       return JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::UNKNOWN_ERROR, "Unkown error");
+               }
+       }       
+       
+       return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef JSBluetoothServiceHandler::getName(JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception)
+{
+       LogDebug("OK"); 
+       
+       try 
+       {
+               JSBluetoothServiceHandlerPriv *priv = static_cast<JSBluetoothServiceHandlerPriv*>(JSObjectGetPrivate(object));
+               BluetoothConverter converter(priv->getContext());
+
+               if (priv == NULL)
+               {
+                       ThrowMsg(UnknownException, "private object null");
+               }
+
+               IBluetoothServiceHandlerManagerPtr BluetoothServiceHandlerManager(priv->getObject());
+               std::string name = BluetoothServiceHandlerManager->getName();
+               return converter.toJSValueRef(name);
+
+       }
+       
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               LogError("Exception: " << ex.GetMessage());
+
+               switch (ex.getCode())
+               {
+               case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
+                       return JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+               case WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException:
+                       return JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
+               case WrtDeviceApis::Commons::ExceptionCodes::Exception:
+               default:
+                       return JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::UNKNOWN_ERROR, "Unkown error");
+               }
+       }       
+       
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSBluetoothServiceHandler::getIsConnected(JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception)
+{
+       LogDebug("OK"); 
+       
+       try 
+       {
+               JSBluetoothServiceHandlerPriv *priv = static_cast<JSBluetoothServiceHandlerPriv*>(JSObjectGetPrivate(object));
+               BluetoothConverter converter(priv->getContext());
+
+               if (priv == NULL)
+               {
+                       ThrowMsg(UnknownException, "private object null");
+               }
+
+               IBluetoothServiceHandlerManagerPtr BluetoothServiceHandlerManager(priv->getObject());
+               bool connected = BluetoothServiceHandlerManager->getIsConnected();
+               return converter.toJSValueRef(connected);
+
+       }
+       
+       catch (const WrtDeviceApis::Commons::Exception& ex) 
+       {
+               LogError("Exception: " << ex.GetMessage());
+
+               switch (ex.getCode())
+               {
+               case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
+                       return JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+               case WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException:
+                       return JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
+               case WrtDeviceApis::Commons::ExceptionCodes::Exception:
+               default:
+                       return JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::UNKNOWN_ERROR, "Unkown error");
+               }
+       }       
+       
+       return JSValueMakeUndefined(context);
+}
+
+const JSClassDefinition* JSBluetoothServiceHandler::getClassInfo() 
+{
+       return &m_classInfo;
+}
+
+
+
+
+
+void JSBluetoothServiceHandler::finalize(JSObjectRef object) 
+{
+       JSBluetoothServiceHandlerPriv* priv = static_cast<JSBluetoothServiceHandlerPriv*>(JSObjectGetPrivate(object));
+       LogDebug("JSBluetoothServiceHandler::Finalrize");
+
+       if (priv != NULL)
+       {
+               JSObjectSetPrivate(object, NULL);
+               LogDebug("Deleting BluetoothManager");
+               delete priv;
+       }
+}
+
+bool JSBluetoothServiceHandler::hasInstance(JSContextRef context, JSObjectRef constructor,
+               JSValueRef possibleInstance, JSValueRef* exception) 
+{
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+JSValueRef JSBluetoothServiceHandler::unregisterRFCOMMService(JSContextRef context, JSObjectRef object,
+               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+               JSValueRef* exception) 
+{
+
+       LogDebug("unregisterRFCOMMService");
+       
+       JSValueRef successCallback = NULL;
+       JSValueRef errorCallBack = NULL;
+       
+       Try     
+       {
+               JSBluetoothServiceHandlerPriv *priv = static_cast<JSBluetoothServiceHandlerPriv*>(JSObjectGetPrivate(thisObject));
+
+               if (priv == NULL)
+               {
+                       LogError("priv null");
+                       Throw(UnknownException);        
+               }
+
+               if (argumentCount < 1 || argumentCount > 2)
+               {
+                       LogError("Wrong parameter count passed");
+                       Throw(InvalidArgumentException);
+               }
+
+               AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
+                               priv->getContext(),
+                               bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADPATER_UNREGISTER_RFCOMM]);
+               
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);  
+       
+
+               BluetoothConverter converter(priv->getContext());
+
+               successCallback = converter.toFunction(arguments[0]);
+               
+               if (argumentCount >= 2)
+               {
+                       errorCallBack = converter.toFunctionOrNull(arguments[1]);
+               }
+
+               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
+               
+               if (cbm == NULL)
+               {
+                       Throw(UnknownException);        
+               }
+                       
+               cbm->setOnSuccess(successCallback);
+               cbm->setOnError(errorCallBack);
+//             cbm->setObject(thisObject);
+               
+               IBluetoothServiceHandlerManagerPtr BluetoothServiceHandlerManager(priv->getObject());
+               EventBTUnregisterRFCOMMServicePtr event(new EventBTUnregisterRFCOMMService);
+
+               if (BluetoothServiceHandlerManager == NULL || event == NULL)
+               {
+                       LogError("BluetoothAdapterManager or event or listener NULL");
+                       Throw(UnknownException);        
+               }
+
+               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+               BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance();
+               event->setForAsynchronousCall(&listener);
+               BluetoothServiceHandlerManager->unRegister(event);
+               
+               return JSValueMakeNull(context);
+       }
+       Catch (WrtDeviceApis::Commons::ConversionException)
+       {
+               LogError("ConversionException");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+
+       }               
+       Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
+       {
+               LogError("InvalidArgumentException");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                       JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
+
+       }
+       Catch (WrtDeviceApis::Commons::Exception) 
+       {
+               LogError("Exception");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                       JSTizenException::UNKNOWN_ERROR, "unknown error");
+
+       }       
+       return JSValueMakeUndefined(context);
+}
+
+
+}
+}
+
diff --git a/src/standards/Tizen/Bluetooth/JSBluetoothServiceHandler.h b/src/standards/Tizen/Bluetooth/JSBluetoothServiceHandler.h
new file mode 100644 (file)
index 0000000..f3571bf
--- /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_TIZEN_JS_BLUETOOTH_SERVICE_HANDLER_H_
+#define TIZENAPIS_TIZEN_JS_BLUETOOTH_SERVICE_HANDLER_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Bluetooth/IBluetoothServiceHandlerManager.h>
+
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+typedef PrivateObjectT<Api::Bluetooth::IBluetoothServiceHandlerManagerPtr>::Type JSBluetoothServiceHandlerPriv;
+
+class JSBluetoothServiceHandler 
+{
+public:
+       static const JSClassDefinition* getClassInfo();
+       static const JSClassRef getClassRef();
+
+       static JSObjectRef createJSObject(JSContextRef context, std::string name, std::string uuid, int registerSock);
+
+private:
+       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 getUuid(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+       static bool setOnConnect(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
+       static void getPropertyNames(JSContextRef context, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
+       static JSValueRef unregisterRFCOMMService(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, 
+               const JSValueRef arguments[], JSValueRef* exception);
+       static JSValueRef getName(JSContextRef context, JSObjectRef object, JSStringRef propertyName,JSValueRef* exception);
+       static JSValueRef getIsConnected(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+               
+       static JSClassDefinition m_classInfo;
+       static JSStaticValue m_properties[];
+       static JSStaticFunction m_function[];
+       static JSClassRef m_jsClassRef;
+};
+}
+} 
+
+#endif
+
old mode 100755 (executable)
new mode 100644 (file)
index bf154f2..7602a6b
@@ -72,16 +72,18 @@ JSStaticValue JSBluetoothSocket::m_properties[] =
        {"protocol", getProperty, NULL, kJSPropertyAttributeReadOnly},
        {"state", getProperty, NULL, kJSPropertyAttributeReadOnly},
        {"peer", getProperty, NULL, kJSPropertyAttributeReadOnly},
+       {"onError", NULL, setProperty, kJSPropertyAttributeNone},
+       {"onMessage", NULL, setProperty, kJSPropertyAttributeNone},
+       {"onClose", NULL, setProperty, kJSPropertyAttributeNone},
        {0, 0, 0, 0}
 };
 
 
 JSStaticFunction JSBluetoothSocket::m_function[] =
 {
-       { "setSocketNotifyListener",  JSBluetoothSocket::setSocketNotifier, kJSPropertyAttributeNone },
-       { "writeData",                  JSBluetoothSocket::writeData, kJSPropertyAttributeNone },
-       { "readData",                   JSBluetoothSocket::readData, kJSPropertyAttributeNone },
-       { "close",                              JSBluetoothSocket::close, kJSPropertyAttributeNone },   
+       { "writeData", JSBluetoothSocket::writeData, kJSPropertyAttributeNone },
+       { "readData", JSBluetoothSocket::readData, kJSPropertyAttributeNone },
+       { "close", JSBluetoothSocket::close, kJSPropertyAttributeNone },        
        { 0, 0, 0 }
 };
 
@@ -101,6 +103,72 @@ const JSClassDefinition* JSBluetoothSocket::getClassInfo()
 
 JSClassRef JSBluetoothSocket::m_jsClassRef = JSClassCreate(JSBluetoothSocket::getClassInfo());
 
+bool JSBluetoothSocket::setProperty(JSContextRef context, 
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef value,
+                                       JSValueRef* exception)
+{
+       LogDebug("OK");
+       
+       try 
+       {
+               JSBluetoothSocketPriv *priv = static_cast<JSBluetoothSocketPriv*>(JSObjectGetPrivate(object));
+               IBluetoothSocketManagerPtr BluetoothSocketManager(priv->getObject());
+               BluetoothConverter converter(priv->getContext());
+               
+               if (priv == NULL)
+               {
+                       ThrowMsg(ConversionException, "private object null");
+               }
+
+               EventBTSocketNotificationEmitterPtr emitter = BluetoothSocketManager->getSocketNotifier();
+       
+               if (BluetoothSocketManager == NULL || emitter == NULL)
+               {
+                       LogError("BluetoothManager or event or listener NULL");
+                       Throw(WrtDeviceApis::Commons::UnknownException);        
+               }
+               
+               BluetoothSocketNotifierPrivateDataPtr privData = 
+                               DPL::DynamicPointerCast<BluetoothSocketNotifierPrivateData>(emitter->getEventPrivateData());
+
+               if (privData == NULL)
+               {
+                       LogError("privData NULL");
+                       Throw(WrtDeviceApis::Commons::UnknownException);        
+               }
+               
+               converter.setBluetoothSocketNotifierCallback(propertyName, value, object, privData);
+               emitter->setListener(&BluetoothSocketListener::getInstance());
+               emitter->setEventPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privData));
+
+               return true;
+       }
+       catch (WrtDeviceApis::Commons::Exception& ex) 
+       {
+               LogError("Exception: " << ex.GetMessage());
+
+               switch (ex.getCode())
+               {
+               case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
+                       JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+                       break;
+               case WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException:
+                       JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
+                       break;
+               case WrtDeviceApis::Commons::ExceptionCodes::Exception:
+               default:
+                       JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::UNKNOWN_ERROR, "Unkown error");
+               }
+       }       
+       return false;
+
+}
+
 void JSBluetoothSocket::initialize(JSContextRef context, JSObjectRef object) 
 {
        LogDebug("JSBluetoothSocket::initialize ");
@@ -131,7 +199,50 @@ JSObjectRef JSBluetoothSocket::createJSObject(JSContextRef context, BluetoothSoc
        IBluetoothSocketManagerPtr BluetoothSocketManager(BluetoothFactory::getInstance().getBluetoothSocketManager());
        JSBluetoothSocketPriv* priv = new JSBluetoothSocketPriv( context, BluetoothSocketManager);
        BluetoothSocketManager->setSocketData(socketData);
-       return JSObjectMake(context, getClassRef(), priv);
+
+       try 
+       {
+               if (BluetoothSocketManager == NULL || priv == NULL)
+               {
+                       LogError("BluetoothManager or event or listener NULL");
+                       Throw(WrtDeviceApis::Commons::UnknownException);        
+               }
+
+               BluetoothConverter converter(priv->getContext());
+               EventBTSocketNotificationEmitterPtr emitter(new EventBTSocketNotificationEmitter);
+
+               BluetoothSocketNotifierPrivateDataPtr privData(converter.getInitalBluetoothSocketNotifierPrivateData());
+               emitter->setListener(&BluetoothSocketListener::getInstance());
+               emitter->setEventPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privData));
+               
+               if (BluetoothSocketManager->setSocketNotifier(emitter) != BT_ERROR_NONE)
+               {
+                       LogError("callback set error");
+                       Throw(WrtDeviceApis::Commons::UnknownException);        
+               }
+               
+               return JSObjectMake(context, getClassRef(), priv);
+       }
+       catch (WrtDeviceApis::Commons::Exception& ex) 
+       {
+               LogError("Exception: " << ex.GetMessage());
+
+               switch (ex.getCode())
+               {
+               case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
+                       return JSTizenExceptionFactory::makeErrorObject(context,
+                               JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+               case WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException:
+                       return JSTizenExceptionFactory::makeErrorObject(context,
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
+               case WrtDeviceApis::Commons::ExceptionCodes::Exception:
+               default:
+                       return JSTizenExceptionFactory::makeErrorObject(context,
+                               JSTizenException::UNKNOWN_ERROR, "Unkown error");
+               }
+       }               
+
+       
 }
 
 JSObjectRef JSBluetoothSocket::createJSObject(JSContextRef context, BluetoothSocketData socketData, EventBTReadDataType readData)
@@ -221,95 +332,6 @@ JSValueRef JSBluetoothSocket::getProperty(JSContextRef context,
 }
 
 
-
-JSValueRef JSBluetoothSocket::setSocketNotifier(JSContextRef context, JSObjectRef object,
-               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
-               JSValueRef* exception) 
-{
-
-       LogDebug("JSBluetoothSocket");
-
-       Try     
-       {
-               JSBluetoothSocketPriv *priv = static_cast<JSBluetoothSocketPriv*>(JSObjectGetPrivate(thisObject));
-
-               if (priv == NULL)
-               {
-                       LogError("priv null");
-                       Throw(WrtDeviceApis::Commons::UnknownException);        
-               }
-
-               AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                       priv->getContext(),
-                       bluetoothExportedNames[BLUETOOTH_FUNCTION_API_SOCKET_SET_SOCKETNOTIFIER]);
-
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-               
-               if (argumentCount < 1)
-               {
-                       LogError("Wrong parameter passed");
-                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);
-               }
-               
-               BluetoothConverter converter(priv->getContext());
-               
-               BluetoothSocketNotifierPrivateDataPtr privData(
-                       converter.toBluetoothSocketNotifierPrivateData(thisObject, arguments[0]));
-               
-               IBluetoothSocketManagerPtr BluetoothSocketManager(priv->getObject());
-               EventBTSocketNotificationEmitterPtr emitter(new EventBTSocketNotificationEmitter);
-
-               if (BluetoothSocketManager == NULL || emitter == NULL || privData == NULL)
-               {
-                       LogError("BluetoothManager or event or listener NULL");
-                       Throw(WrtDeviceApis::Commons::UnknownException);        
-               }
-               emitter->setListener(&BluetoothSocketListener::getInstance());
-               emitter->setEventPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privData));
-               
-               if (BluetoothSocketManager->setSocketNotifier(emitter) != BT_ERROR_NONE)
-               {
-                       LogError("callback set error");
-                       Throw(WrtDeviceApis::Commons::UnknownException);        
-               }
-               
-               return JSValueMakeNull(context);
-       }
-       Catch (WrtDeviceApis::Commons::SecurityException) 
-       {
-               LogError("permission denied error");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                       JSTizenException::PERMISSION_DENIED_ERROR, "permission denied error");  
-
-       }
-       Catch (WrtDeviceApis::Commons::ConversionException)
-       {
-               LogError("ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
-       }
-       Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
-       {
-               LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
-       }
-       Catch (WrtDeviceApis::Commons::UnknownException) 
-       {
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::UNKNOWN_ERROR, "Unkown error");
-       }
-       Catch(WrtDeviceApis::Commons::Exception) 
-       {
-               LogError("UnkownException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::UNKNOWN_ERROR, "Unkown error");
-       }       
-
-       return JSValueMakeUndefined(context);
-
-}
-
 JSValueRef JSBluetoothSocket::writeData(JSContextRef context, JSObjectRef object,
                JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
                JSValueRef* exception) 
@@ -409,10 +431,18 @@ JSValueRef JSBluetoothSocket::readData(JSContextRef context, JSObjectRef object,
        Try     
        {
                JSBluetoothSocketPriv *priv = static_cast<JSBluetoothSocketPriv*>(JSObjectGetPrivate(thisObject));
-               
                IBluetoothSocketManagerPtr BluetoothSocketManager(priv->getObject());
+
+               AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
+                       priv->getContext(),
+                       bluetoothExportedNames[BLUETOOTH_FUNCTION_API_SOCKET_READ_DATA]);
+               
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+               
+
                EventBTReadDataType     data = BluetoothSocketManager->readData();
                int length = data.size();
+               LogDebug("size" << length);
                BluetoothConverter converter(priv->getContext());
 
                if (length == 0)
@@ -421,11 +451,6 @@ JSValueRef JSBluetoothSocket::readData(JSContextRef context, JSObjectRef object,
                        Throw(WrtDeviceApis::Commons::InvalidArgumentException);        
                }
 
-               AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                       priv->getContext(),
-                       bluetoothExportedNames[BLUETOOTH_FUNCTION_API_SOCKET_READ_DATA]);
-               
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                JSObjectRef result = converter.toBluetoothByteArray(data);
                return result;
index 3223bba..0fa6e29 100644 (file)
@@ -41,7 +41,18 @@ private:
        static void initialize(JSContextRef context, JSObjectRef object);
        static void finalize(JSObjectRef object);
        static bool hasInstance(JSContextRef context, JSObjectRef constructor,
-       JSValueRef possibleInstance, JSValueRef* exception);
+               JSValueRef possibleInstance, JSValueRef* exception);
+
+       static bool setProperty(JSContextRef context, 
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                               JSValueRef value,
+                                               JSValueRef* exception);
+
+       static bool setOnConnect(JSContextRef context, JSObjectRef object,
+                                               JSStringRef propertyName, JSValueRef value,
+                                               JSValueRef* exception);
+
 
        static JSValueRef setSocketNotifier(JSContextRef context, JSObjectRef object,
                JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index a5283ef..772998f 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License. 
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
 #include <Commons/WrtWrapper/WrtWrappersMgr.h>
 
index db4b4a7..8a039a4 100755 (executable)
@@ -1,6 +1,9 @@
 SET( CMAKE_INSTALL_RPATH
   ${wrt-deviceapis-commons_LIBRARY_DIRS})
 
+pkg_search_module(wrt-plugins-widgetdb REQUIRED wrt-plugins-widgetdb)
+set(LIBS_WIDGETDB ${wrt-plugins-widgetdb_LIBRARIES})
+
 add_subdir(Tizen)
 add_subdir(Calendar)
 add_subdir(Contact)
@@ -14,12 +17,12 @@ add_subdir(Systeminfo)
 add_subdir(NFC)
 add_subdir(Sensors)
 #add_subdir(Log)
+add_subdir(Filesystem)
+add_subdir(Account)
 
-#add_subdir(Account)
 #add_subdir(DeviceInteraction)
 #add_subdir(Accelerometer)
 #add_subdir(Orientation)
-#add_subdir(Filesystem)
 #add_subdir(Gyroscope)
 #add_subdir(Light)
 #add_subdir(Magnetic)
index 07e8ebf..41f9158 100755 (executable)
@@ -13,10 +13,10 @@ set(SRCS
   JSEventId.cpp
   JSCalendar.cpp
   JSCalendarManager.cpp
-  JSCategoryArray.cpp
   JSAttendee.cpp
   JSRecurrenceRule.cpp
   JSEventAlarm.cpp
+  JSCalendarItemGeo.cpp
   plugin_initializer.cpp
   plugin_config.cpp
   ../Tizen/FilterConverter.cpp
@@ -27,6 +27,7 @@ set(SRCS
   ${SRCS_PLATFORM_IMPLEMENTATION_TIMEUTIL}
   ../TimeUtil/JSTimeUtil.cpp
   ../TimeUtil/JSTZDate.cpp
+  ../TimeUtil/JSTimeDuration.cpp
   ../TimeUtil/TimeUtilConverter.cpp
   ../TimeUtil/plugin_config.cpp
 )
index 09ff82b..36dd0df 100755 (executable)
  */
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Validator.h>
 #include <CommonsJavaScript/JSUtils.h>
 #include "JSCalendarItem.h"
 #include "JSCalendarItemProperties.h"
 #include "JSEventId.h"
+#include "JSCalendarItemGeo.h"
 #include "CalendarConverter.h"
 #include "JSCalendar.h"
 #include "JSCalendarManager.h"
-#include "JSCategoryArray.h"
 #include "JSAttendee.h"
 #include "JSRecurrenceRule.h"
+#include "JSEventAlarm.h"
 #include <Tizen/TimeUtil/TimeUtilConverter.h>
+#include "API/TimeUtil/DurationProperties.h"
 
 using namespace TizenApis::Api::Calendar;
 using namespace WrtDeviceApis::Commons;
@@ -42,7 +44,6 @@ namespace Tizen1_0 {
 namespace Calendar {
 
 std::vector<std::string> CalendarConverter::m_allowedAttributes;
-std::vector<std::string> CalendarConverter::m_allowedCreateProperties;
 
 CalendarConverter::CalendarConverter(JSContextRef context, CalendarEvent::CalendarType calendarType) : Converter(context)
 {
@@ -50,36 +51,17 @@ CalendarConverter::CalendarConverter(JSContextRef context, CalendarEvent::Calend
 
     m_calendarType = calendarType;
 
-    if (m_allowedAttributes.size() == 0) { // for search filter
-        m_allowedAttributes.push_back("id");
-        m_allowedAttributes.push_back("summary");
-        m_allowedAttributes.push_back("description");
-        m_allowedAttributes.push_back("location");
+    // for WAC style search filter
+    if (m_allowedAttributes.size() == 0) {
+        m_allowedAttributes.push_back(TIZEN_CALENDAR_ITEM_ID);
+        m_allowedAttributes.push_back(TIZEN_CALENDAR_ITEM_SUMMARY);
+        m_allowedAttributes.push_back(TIZEN_CALENDAR_ITEM_DESCRIPTION);
+        m_allowedAttributes.push_back(TIZEN_CALENDAR_ITEM_LOCATION);
         m_allowedAttributes.push_back("category");
-        m_allowedAttributes.push_back("status");
+        m_allowedAttributes.push_back(TIZEN_CALENDAR_ITEM_STATUS);
         m_allowedAttributes.push_back("initialStartDate");
         m_allowedAttributes.push_back("endStartDate");
     }
-    if (m_allowedCreateProperties.size() == 0) {
-        m_allowedCreateProperties.push_back("description");
-        m_allowedCreateProperties.push_back("summary");
-        m_allowedCreateProperties.push_back("startDate");
-        m_allowedCreateProperties.push_back("duration");
-        m_allowedCreateProperties.push_back("location");
-        m_allowedCreateProperties.push_back("categories");
-        m_allowedCreateProperties.push_back("status");
-        m_allowedCreateProperties.push_back("alarms");
-        m_allowedCreateProperties.push_back("isAllDay");
-        m_allowedCreateProperties.push_back("organizer");
-        m_allowedCreateProperties.push_back("attendees");
-        m_allowedCreateProperties.push_back("position");
-        m_allowedCreateProperties.push_back("visibility");
-        m_allowedCreateProperties.push_back("lastModifiedDate");
-        m_allowedCreateProperties.push_back("availability");
-        m_allowedCreateProperties.push_back("recurrenceRule");
-        m_allowedCreateProperties.push_back("isDetached");
-        m_allowedCreateProperties.push_back("attributesOfInterest");
-    }
 }
 
 CalendarConverter::~CalendarConverter()
@@ -118,32 +100,31 @@ JSValueRef CalendarConverter::toJSValueRef(const EventIdPtr& arg)
     return JSUtils::makeObject(m_context, JSEventId::getClassRef(), arg);
 }
 
-CalendarEvent::EventAlarmType CalendarConverter::toEventAlarmType(int tizenValue)
+JSValueRef CalendarConverter::toJSValueRef(const CalendarItemGeoPtr& arg)
+{
+    return JSUtils::makeObject(m_context, JSCalendarItemGeo::getClassRef(), arg);
+}
+
+CalendarEvent::EventAlarmType CalendarConverter::toEventAlarmType(std::string alarmMethod)
 const
 {
-    switch (tizenValue) {
-    case JSCalendarManager::NO_ALARM:
-        return CalendarEvent::NO_ALARM;
-    case JSCalendarManager::SILENT_ALARM:
+    if (!alarmMethod.compare(TIZEN_CALENDAR_PROPERTY_SILENT_ALARM))
         return CalendarEvent::SILENT_ALARM;
-    case JSCalendarManager::SOUND_ALARM:
+    else if (!alarmMethod.compare(TIZEN_CALENDAR_PROPERTY_SOUND_ALARM))
         return CalendarEvent::SOUND_ALARM;
-    default:
-        break;
-    }
-    ThrowMsg(InvalidArgumentException, "Alarm type has wrong value");
+    else
+        Throw(ConversionException);
+
+    return CalendarEvent::SOUND_ALARM;
 }
 
-int CalendarConverter::toTizenValue(
-        CalendarEvent::EventAlarmType abstractValue) const
+std::string CalendarConverter::toTizenValue(CalendarEvent::EventAlarmType abstractValue) const
 {
     switch (abstractValue) {
-    case CalendarEvent::NO_ALARM:
-        return JSCalendarManager::NO_ALARM;
     case CalendarEvent::SILENT_ALARM:
-        return JSCalendarManager::SILENT_ALARM;
+        return TIZEN_CALENDAR_PROPERTY_SILENT_ALARM;
     case CalendarEvent::SOUND_ALARM:
-        return JSCalendarManager::SOUND_ALARM;
+        return TIZEN_CALENDAR_PROPERTY_SOUND_ALARM;
     default:
         break;
     }
@@ -199,9 +180,7 @@ const
 EventRecurrenceRule::EventRecurrence CalendarConverter::toRecurrenceFrequency(
         std::string tizenValue) const
 {
-    if(!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_NO_RECURRENCE))
-        return EventRecurrenceRule::NO_RECURRENCE;
-    else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_DAILY_RECURRENCE))
+    if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_DAILY_RECURRENCE))
         return EventRecurrenceRule::DAILY_RECURRENCE;
     else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_WEEKLY_RECURRENCE))
         return EventRecurrenceRule::WEEKLY_RECURRENCE;
@@ -217,8 +196,6 @@ std::string CalendarConverter::toTizenValue(
         EventRecurrenceRule::EventRecurrence abstractValue) const
 {
     switch (abstractValue) {
-    case EventRecurrenceRule::NO_RECURRENCE:
-        return TIZEN_CALENDAR_PROPERTY_NO_RECURRENCE;
     case EventRecurrenceRule::DAILY_RECURRENCE:
         return TIZEN_CALENDAR_PROPERTY_DAILY_RECURRENCE;
     case EventRecurrenceRule::WEEKLY_RECURRENCE:
@@ -229,11 +206,11 @@ std::string CalendarConverter::toTizenValue(
         return TIZEN_CALENDAR_PROPERTY_MONTHLY_RECURRENCE;
     case EventRecurrenceRule::YEARLY_RECURRENCE:
         return TIZEN_CALENDAR_PROPERTY_YEARLY_RECURRENCE;
+    case EventRecurrenceRule::NO_RECURRENCE:
     default:
+        return "";
         break;
     }
-    
-    return TIZEN_CALENDAR_PROPERTY_NO_RECURRENCE;
 }
 
 EventRecurrenceRulePtr CalendarConverter::toEventRecurrenceRule(JSValueRef rrule)
@@ -242,7 +219,7 @@ EventRecurrenceRulePtr CalendarConverter::toEventRecurrenceRule(JSValueRef rrule
     EventRecurrenceRulePtr result(new EventRecurrenceRule());
     const ScopedJSStringRef frequencyStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_FREQUENCY));
     const ScopedJSStringRef intervalStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_INTERVAL));
-    const ScopedJSStringRef endDateStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_END_DATE));
+    const ScopedJSStringRef untilDateStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_UNTIL_DATE));
     const ScopedJSStringRef occurrenceCountStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_OCCURRENCE_COUNT));
 //    const ScopedJSStringRef daysOfTheMonthStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_DAYS_OF_THE_MONTH));
     const ScopedJSStringRef daysOfTheWeekStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_DAYS_OF_THE_WEEK));
@@ -255,7 +232,7 @@ EventRecurrenceRulePtr CalendarConverter::toEventRecurrenceRule(JSValueRef rrule
 
     JSValueRef frequencyData = JSObjectGetProperty(m_context, arg, frequencyStr.get(), NULL);
     JSValueRef intervalData = JSObjectGetProperty(m_context, arg, intervalStr.get(), NULL);
-    JSValueRef endDateData = JSObjectGetProperty(m_context, arg, endDateStr.get(), NULL);
+    JSValueRef untilDateData = JSObjectGetProperty(m_context, arg, untilDateStr.get(), NULL);
     JSValueRef occurrenceCountData = JSObjectGetProperty(m_context, arg, occurrenceCountStr.get(), NULL);
 //    JSValueRef daysOfTheMonthData = JSObjectGetProperty(m_context, arg, daysOfTheMonthStr.get(), NULL);
     JSValueRef daysOfTheWeekData = JSObjectGetProperty(m_context, arg, daysOfTheWeekStr.get(), NULL);
@@ -272,9 +249,9 @@ EventRecurrenceRulePtr CalendarConverter::toEventRecurrenceRule(JSValueRef rrule
     } else {
         result->setInterval(DEFAULT_EVENT_INTERVAL);
     }
-    if (!JSValueIsUndefined(m_context, endDateData)) {
-        if (!JSValueIsNull(m_context, endDateData)) {
-            result->setEndDate(toDateTimeT(endDateData));
+    if (!JSValueIsUndefined(m_context, untilDateData)) {
+        if (!JSValueIsNull(m_context, untilDateData)) {
+            result->setEndDate(toDateTimeT(untilDateData));
         } else {
             result->resetEndDate();
         }
@@ -511,7 +488,7 @@ void CalendarConverter::toEventFilterConvertId(
         const EventFilterPtr &result,
         const JSValueRef &filters)
 {
-    const ScopedJSStringRef idStr(JSStringCreateWithUTF8CString("id"));
+    const ScopedJSStringRef idStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_ID));
     JSObjectRef filterObj = toJSObjectRef(filters);
     if (JSObjectHasProperty(m_context, filterObj, idStr.get())) {
         LogDebug("converting id");
@@ -525,7 +502,7 @@ void CalendarConverter::toEventFilterConvertSummary(
         const EventFilterPtr &result,
         const JSValueRef &filters)
 {
-    const ScopedJSStringRef summaryStr(JSStringCreateWithUTF8CString("summary"));
+    const ScopedJSStringRef summaryStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_SUMMARY));
     JSObjectRef filterObj = toJSObjectRef(filters);
     if (JSObjectHasProperty(m_context, filterObj, summaryStr.get())) {
         LogDebug("converting summary");
@@ -542,7 +519,7 @@ void CalendarConverter::toEventFilterConvertDescription(
         const JSValueRef &filters)
 {
     const ScopedJSStringRef descriptionStr(JSStringCreateWithUTF8CString(
-                                               "description"));
+                                               TIZEN_CALENDAR_ITEM_DESCRIPTION));
     JSObjectRef filterObj = toJSObjectRef(filters);
     if (JSObjectHasProperty(m_context, filterObj, descriptionStr.get())) {
         LogDebug("converting description");
@@ -559,7 +536,7 @@ void CalendarConverter::toEventFilterConvertLocation(
         const JSValueRef &filters)
 {
     const ScopedJSStringRef locationStr(JSStringCreateWithUTF8CString(
-                                            "location"));
+                                            TIZEN_CALENDAR_ITEM_LOCATION));
     JSObjectRef filterObj = toJSObjectRef(filters);
     if (JSObjectHasProperty(m_context, filterObj, locationStr.get())) {
         LogDebug("converting location");
@@ -592,7 +569,7 @@ void CalendarConverter::toEventFilterConvertStatus(
         const EventFilterPtr &result,
         const JSValueRef &filters)
 {
-    const ScopedJSStringRef statusStr(JSStringCreateWithUTF8CString("status"));
+    const ScopedJSStringRef statusStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_STATUS));
     JSObjectRef filterObj = toJSObjectRef(filters);
     if (JSObjectHasProperty(m_context, filterObj, statusStr.get())) {
         LogDebug("converting status");
@@ -680,11 +657,6 @@ EventFilterPtr CalendarConverter::toEventFilter(const JSValueRef &filters)
 CategoryListPtr CalendarConverter::toCategories(JSValueRef categories)
 {
     LogDebug("entered");
-    if (JSValueIsObjectOfClass(m_context, categories,
-                               JSCategoryArray::getClassRef())) {
-        return JSCategoryArray::getCategories(m_context,
-                                              toJSObjectRef(categories));
-    }
     CategoryListPtr result(new CategoryList());
     *result = toVectorOfStrings(categories);
     return result;
@@ -694,16 +666,16 @@ EventAttendeePtr CalendarConverter::toAttendee(JSValueRef attendee)
 {
     LogDebug("entered");
     EventAttendeePtr result(new EventAttendee());
-    const ScopedJSStringRef nameStr(JSStringCreateWithUTF8CString("name"));
-    const ScopedJSStringRef uriStr(JSStringCreateWithUTF8CString("uri"));
-    const ScopedJSStringRef roleStr(JSStringCreateWithUTF8CString("role"));
-    const ScopedJSStringRef statusStr(JSStringCreateWithUTF8CString("status"));
-    const ScopedJSStringRef RSVPStr(JSStringCreateWithUTF8CString("RSVP"));
-    const ScopedJSStringRef typeStr(JSStringCreateWithUTF8CString("type"));
-    const ScopedJSStringRef groupStr(JSStringCreateWithUTF8CString("group"));
-    const ScopedJSStringRef delegatorURIStr(JSStringCreateWithUTF8CString("delegatorURI"));
-    const ScopedJSStringRef delegateURIStr(JSStringCreateWithUTF8CString("delegateURI"));
-    const ScopedJSStringRef uidStr(JSStringCreateWithUTF8CString("uid"));
+    const ScopedJSStringRef nameStr(JSStringCreateWithUTF8CString(TIZEN_ATTENDEE_NAME));
+    const ScopedJSStringRef uriStr(JSStringCreateWithUTF8CString(TIZEN_ATTENDEE_URI));
+    const ScopedJSStringRef roleStr(JSStringCreateWithUTF8CString(TIZEN_ATTENDEE_ROLE));
+    const ScopedJSStringRef statusStr(JSStringCreateWithUTF8CString(TIZEN_ATTENDEE_STATUS));
+    const ScopedJSStringRef RSVPStr(JSStringCreateWithUTF8CString(TIZEN_ATTENDEE_RSVP));
+    const ScopedJSStringRef typeStr(JSStringCreateWithUTF8CString(TIZEN_ATTENDEE_TYPE));
+    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));
 
     JSObjectRef arg = toJSObjectRef(attendee);
 
@@ -773,29 +745,31 @@ EventAlarmPtr CalendarConverter::toEventAlarm(JSValueRef alarm)
 {
     LogDebug("entered");
     EventAlarmPtr result(new EventAlarm());
-    const ScopedJSStringRef absoluteDateStr(JSStringCreateWithUTF8CString("absoluteDate"));
-    const ScopedJSStringRef minutesStr(JSStringCreateWithUTF8CString("minutes"));
-    const ScopedJSStringRef daysStr(JSStringCreateWithUTF8CString("days"));
-    const ScopedJSStringRef methodsStr(JSStringCreateWithUTF8CString("methods"));
+    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));
 
     JSObjectRef arg = toJSObjectRef(alarm);
 
     JSValueRef absoluteDateData = JSObjectGetProperty(m_context, arg, absoluteDateStr.get(), NULL);
-    JSValueRef minutesData = JSObjectGetProperty(m_context, arg, minutesStr.get(), NULL);
-    JSValueRef daysData = JSObjectGetProperty(m_context, arg, daysStr.get(), NULL);
+    JSValueRef beforeData = JSObjectGetProperty(m_context, arg, beforeStr.get(), NULL);
     JSValueRef methodsData = JSObjectGetProperty(m_context, arg, methodsStr.get(), NULL);
 
     if (!JSValueIsUndefined(m_context, absoluteDateData)) {
-        result->setAbsoluteDate(toDateTimeT(absoluteDateData));
+        TimeUtilConverter timeConverter(m_context);
+        result->setAbsoluteDate(timeConverter.toTZDateTimeT(absoluteDateData));
     }
-    if (!JSValueIsUndefined(m_context, minutesData)) {
-        result->setMinutes(toLong(minutesData));
-    }
-    if (!JSValueIsUndefined(m_context, daysData)) {
-        result->setDays(toLong(daysData));
+    if (!JSValueIsUndefined(m_context, beforeData)) {
+        TimeUtilConverter timeConverter(m_context);
+        result->setDuration(timeConverter.getDurationPropertis(beforeData));
     }
     if (!JSValueIsUndefined(m_context, methodsData)) {
-        result->setMethods(toVectorOfInts(methodsData));
+        std::vector<std::string> methods = toVectorOfStrings(methodsData);
+        std::vector<CalendarEvent::EventAlarmType> convertedMethods;
+        for (unsigned int i=0; i<methods.size(); i++) {
+            convertedMethods.push_back(toEventAlarmType(methods[i]));
+        }
+        result->setMethods(convertedMethods);
     }
 
     return result;
@@ -822,29 +796,25 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
 {
     LogDebug("entered");
     CalendarEventPtr result(new CalendarEvent());
-    const ScopedJSStringRef descriptionStr(JSStringCreateWithUTF8CString("description"));
-    const ScopedJSStringRef summaryStr(JSStringCreateWithUTF8CString("summary"));
-    const ScopedJSStringRef startTimeStr(JSStringCreateWithUTF8CString("startDate"));
-    const ScopedJSStringRef durationStr(JSStringCreateWithUTF8CString("duration"));
-    const ScopedJSStringRef locationStr(JSStringCreateWithUTF8CString("location"));
-    const ScopedJSStringRef categoriesStr(JSStringCreateWithUTF8CString("categories"));
-    const ScopedJSStringRef statusStr(JSStringCreateWithUTF8CString("status"));
-    const ScopedJSStringRef alarmsStr(JSStringCreateWithUTF8CString("alarms"));
-    const ScopedJSStringRef isAllDayStr(JSStringCreateWithUTF8CString("isAllDay"));
-    const ScopedJSStringRef organizerStr(JSStringCreateWithUTF8CString("organizer"));
-    const ScopedJSStringRef attendeesStr(JSStringCreateWithUTF8CString("attendees"));
-    const ScopedJSStringRef latitudeStr(JSStringCreateWithUTF8CString("latitude"));
-    const ScopedJSStringRef longitudeStr(JSStringCreateWithUTF8CString("longitude"));
-    const ScopedJSStringRef visibilityStr(JSStringCreateWithUTF8CString("visibility"));
-    //const ScopedJSStringRef lastModifiedDateStr(JSStringCreateWithUTF8CString("lastModifiedDate")); // read only
-    const ScopedJSStringRef availabilityStr(JSStringCreateWithUTF8CString("availability"));
-    const ScopedJSStringRef recurrenceRuleStr(JSStringCreateWithUTF8CString("recurrenceRule"));
-    //const ScopedJSStringRef isDetachedStr(JSStringCreateWithUTF8CString("isDetached")); //read only
-    //const ScopedJSStringRef attributesOfInterestStr(JSStringCreateWithUTF8CString("attributesOfInterest"));
-    const ScopedJSStringRef priorityStr(JSStringCreateWithUTF8CString("priority"));
-    const ScopedJSStringRef dueDateStr(JSStringCreateWithUTF8CString("dueDate"));
-    const ScopedJSStringRef completedDateStr(JSStringCreateWithUTF8CString("completedDate"));
-    const ScopedJSStringRef progressStr(JSStringCreateWithUTF8CString("progress"));
+    const ScopedJSStringRef descriptionStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_DESCRIPTION));
+    const ScopedJSStringRef summaryStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_SUMMARY));
+    const ScopedJSStringRef startTimeStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_START_DATE));
+    const ScopedJSStringRef durationStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_DURATION));
+    const ScopedJSStringRef locationStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_LOCATION));
+    const ScopedJSStringRef categoriesStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_CATEGORIES));
+    const ScopedJSStringRef statusStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_STATUS));
+    const ScopedJSStringRef alarmsStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_ALARMS));
+    const ScopedJSStringRef isAllDayStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_IS_ALL_DAY));
+    const ScopedJSStringRef organizerStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_ORGANIZER));
+    const ScopedJSStringRef attendeesStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_ATTENDEES));
+    const ScopedJSStringRef geolocationStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_GEOLOCATION));
+    const ScopedJSStringRef visibilityStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_VISIBILITY));
+    const ScopedJSStringRef availabilityStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_EVENT_AVAILABILITY));
+    const ScopedJSStringRef recurrenceRuleStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_EVENT_RECURRENCE_RULE));
+    const ScopedJSStringRef priorityStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_PRIORITY));
+    const ScopedJSStringRef dueDateStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_TASK_DUE_DATE));
+    const ScopedJSStringRef completedDateStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_TASK_COMPLETED_DATE));
+    const ScopedJSStringRef progressStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_TASK_PROGRESS));
 
     JSObjectRef arg = toJSObjectRef(event);
 
@@ -859,14 +829,10 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
     JSValueRef isAllDayData = JSObjectGetProperty(m_context, arg, isAllDayStr.get(), NULL);
     JSValueRef organizerData = JSObjectGetProperty(m_context, arg, organizerStr.get(), NULL);
     JSValueRef attendeesData = JSObjectGetProperty(m_context, arg, attendeesStr.get(), NULL);
-    JSValueRef latitudeData = JSObjectGetProperty(m_context, arg, latitudeStr.get(), NULL);
-    JSValueRef longitudeData = JSObjectGetProperty(m_context, arg, longitudeStr.get(), NULL);
+    JSValueRef geolocationData = JSObjectGetProperty(m_context, arg, geolocationStr.get(), NULL);
     JSValueRef visibilityData = JSObjectGetProperty(m_context, arg, visibilityStr.get(), NULL);
-    //JSValueRef lastModifiedDateData = JSObjectGetProperty(m_context, arg, lastModifiedDateStr.get(), NULL); // read only
     JSValueRef availabilityData = JSObjectGetProperty(m_context, arg, availabilityStr.get(), NULL);
     JSValueRef recurrenceRuleData = JSObjectGetProperty(m_context, arg, recurrenceRuleStr.get(), NULL);
-    //JSValueRef isDetachedData = JSObjectGetProperty(m_context, arg, isDetachedStr.get(), NULL); // read only
-    //JSValueRef attributesOfInterestData = JSObjectGetProperty(m_context, arg, attributesOfInterestStr.get(), NULL);
     JSValueRef priorityData = JSObjectGetProperty(m_context, arg, priorityStr.get(), NULL);
     JSValueRef dueDateData = JSObjectGetProperty(m_context, arg, dueDateStr.get(), NULL);
     JSValueRef completedDateData = JSObjectGetProperty(m_context, arg, completedDateStr.get(), NULL);
@@ -884,15 +850,16 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
     if (!JSValueIsUndefined(m_context, startTimeData)) {
         result->setStartTime(timeUtilConverter.toTZDateTimeT(startTimeData));
         result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(startTimeData).timezone);
+        LogInfo("start time converted from TZDate: "<<result->getStartTime()<<", time zone: "<<result->getTimeZone());
     } else {
         //set default value, current local time.
         if(m_calendarType == CalendarEvent::EVENT_TYPE) {
-            result->setStartTime(std::time(NULL));
+            //result->setStartTime(std::time(NULL));
         }
     }
     if (!JSValueIsUndefined(m_context, durationData)) {
-        long length = timeUtilConverter.getDurationLength(durationData, NULL);
-        int unit = timeUtilConverter.getDurationUnit(durationData, NULL);
+        long length = timeUtilConverter.getDurationLength(durationData);
+        int unit = timeUtilConverter.getDurationUnit(durationData);
         LogInfo("duration length: "<<length<<", unit "<<unit);
         if (length < 0) {
             Throw(ConversionException);
@@ -908,10 +875,6 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
         } else {
             Throw(ConversionException);
         }
-    } else {
-        //default duration is 3600 seconds, or 1 hour.
-        LogInfo("duration length is 3600");
-        result->setEndTime(result->getStartTime() + 3600);
     }
     if (!JSValueIsUndefined(m_context, locationData)) {
         result->setLocation(toString(locationData));
@@ -930,14 +893,35 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
         EventAlarmListPtr alarms = toVectorOfEventAlarms(alarmsData);
         std::vector<CalendarEvent::EventAlarmType> alarmsType;
         std::vector<long> alarmsTick;
-        // Set the multiple alarms.
         for( unsigned int i=0; i<alarms->size(); i++) {
             EventAlarmPtr theAlarm = alarms->at(i);
-            alarmsType.push_back(toEventAlarmType(theAlarm->getMethods().at(0)));
+            alarmsType.push_back(theAlarm->getMethods().at(0));
             if( 0 < theAlarm->getAbsoluteDate() ) {
                 alarmsTick.push_back(theAlarm->getAbsoluteDate()/60); // minutes only in platform.
             } else {
-                alarmsTick.push_back(theAlarm->getMinutes() + theAlarm->getDays()*24*60);
+                long tick;
+                long length = theAlarm->getDuration().length;
+                switch(theAlarm->getDuration().unit) {
+                case TizenApis::Api::TimeUtil::MSECS_UNIT:
+                    tick = length/(1000*60);
+                    break;
+                case TizenApis::Api::TimeUtil::SECONDS_UNIT:
+                    tick = length/60;
+                    break;
+                case TizenApis::Api::TimeUtil::MINUTES_UNIT:
+                    tick = length;
+                    break;
+                case TizenApis::Api::TimeUtil::HOURS_UNIT:
+                    tick = length*60;
+                    break;
+                case TizenApis::Api::TimeUtil::DAYS_UNIT:
+                    tick = length*60*24;
+                    break;
+                default:
+                    ThrowMsg(ConversionException, "Wrong alarm unit type.");
+                }
+
+                alarmsTick.push_back(tick);
             }
         }
         result->setAlarmsType(alarmsType);
@@ -953,32 +937,18 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
         EventAttendeeListPtr attendees = toVectorOfAttendees(attendeesData);
         result->setAttendees(attendees);
     }
-    if (!JSValueIsUndefined(m_context, latitudeData)) {
-        result->setLatitude(toDouble(latitudeData));
-    }
-    if (!JSValueIsUndefined(m_context, longitudeData)) {
-        result->setLongitude(toDouble(longitudeData));
+    if (!JSValueIsUndefined(m_context, geolocationData)) {
+        result->setGeolocation(toGeolocation(geolocationData));
     }
     if (!JSValueIsUndefined(m_context, visibilityData)) {
         result->setVisibility(toEventVisibility(toString(visibilityData)));
     }
-    /* This feature is read only.
-    if (!JSValueIsUndefined(m_context, lastModifiedDateData)) {
-        result->setLastModifiedDate(toDateTimeT(lastModifiedDateData));
-    } */
     if (!JSValueIsUndefined(m_context, availabilityData)) {
         result->setAvailability(toEventAvailability(toString(availabilityData)));
     }
     if (!JSValueIsUndefined(m_context, recurrenceRuleData)) {
         result->setRecurrenceRule(toEventRecurrenceRule(recurrenceRuleData));
     }
-    /* attributesOfInterest is not supported
-    if (!JSValueIsUndefined(m_context, attributesOfInterestData)) {
-        AttributeList alist = toVectorOfStrings(attributesOfInterestData);
-        AttributeListPtr attributesOfInterest = AttributeListPtr(new AttributeList());
-        *attributesOfInterest = alist;
-        result->setAttributesOfInterest(attributesOfInterest);
-    }*/
     if (!JSValueIsUndefined(m_context, priorityData)) {
         result->setPriority(toTaskPriority(toString(priorityData)));
     }
@@ -1052,6 +1022,28 @@ EventIdPtr CalendarConverter::toEventId(JSValueRef eventId)
     return result;
 }
 
+CalendarItemGeoPtr CalendarConverter::toGeolocation(JSValueRef geoInfo)
+{
+    LogDebug("entered");
+    CalendarItemGeoPtr result(new CalendarItemGeo());
+    const ScopedJSStringRef latStr(JSStringCreateWithUTF8CString("latitude"));
+    const ScopedJSStringRef lonStr(JSStringCreateWithUTF8CString("longitude"));
+
+    JSObjectRef arg = toJSObjectRef(geoInfo);
+
+    JSValueRef latData = JSObjectGetProperty(m_context, arg, latStr.get(), NULL);
+    JSValueRef lonData = JSObjectGetProperty(m_context, arg, lonStr.get(), NULL);
+
+    if (!JSValueIsUndefined(m_context, latData)) {
+        result->setLatitude(toDouble(latData));
+    }
+    if (!JSValueIsUndefined(m_context, lonData)) {
+        result->setLongitude(toDouble(lonData));
+   }
+
+    return result;
+}
+
 EventIdListPtr CalendarConverter::toVectorOfEventIds(JSValueRef eventIds)
 {
     LogDebug("entered");
@@ -1108,6 +1100,8 @@ CalendarEvent::TaskPriority CalendarConverter::toTaskPriority(std::string priori
         return CalendarEvent::MEDIUM_PRIORITY;
     else if (!priority.compare(TIZEN_CALENDAR_PROPERTY_LOW_PRIORITY))
         return CalendarEvent::LOW_PRIORITY;
+    else
+        Throw(ConversionException);
 
     return CalendarEvent::LOW_PRIORITY;
 }
index 7aad2b9..611e5b3 100755 (executable)
@@ -24,6 +24,7 @@
 #include <API/Calendar/ICalendar.h>
 #include <API/Calendar/EventAttendee.h>
 #include <API/Calendar/EventAlarm.h>
+#include <API/Calendar/CalendarItemGeo.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/ScopedJSStringRef.h>
 
@@ -46,7 +47,7 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
     TizenApis::Api::Calendar::EventAttendeePtr toAttendee(JSValueRef attendee);
     TizenApis::Api::Calendar::EventAttendeeListPtr toVectorOfAttendees(JSValueRef attendees);
 
-    TizenApis::Api::Calendar::CalendarEvent::EventAlarmType toEventAlarmType(int tizenValue) const;
+    TizenApis::Api::Calendar::CalendarEvent::EventAlarmType toEventAlarmType(std::string tizenValue) const;
     TizenApis::Api::Calendar::CalendarEvent::EventStatus toEventStatus(std::string tizenValue) const;
     TizenApis::Api::Calendar::EventRecurrenceRule::EventRecurrence toRecurrenceFrequency(std::string tizenValue) const;
     TizenApis::Api::Calendar::EventRecurrenceRulePtr toEventRecurrenceRule(JSValueRef rrule);
@@ -57,7 +58,7 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
     TizenApis::Api::Calendar::EventAttendee::EventAttendeeStatus toEventAttendeeStatus(std::string tizenValue) const;
     TizenApis::Api::Calendar::EventAttendee::EventAttendeeType toEventAttendeeType(std::string tizenValue) const;
 
-    int toTizenValue(TizenApis::Api::Calendar::CalendarEvent::EventAlarmType abstractValue) const;
+    std::string toTizenValue(TizenApis::Api::Calendar::CalendarEvent::EventAlarmType abstractValue) const;
     std::string toTizenValue(TizenApis::Api::Calendar::CalendarEvent::EventStatus abstractValue) const;
     std::string toTizenValue(TizenApis::Api::Calendar::EventRecurrenceRule::EventRecurrence abstractValue) const;
     std::string toTizenValue(TizenApis::Api::Calendar::CalendarEvent::EventVisibility abstractValue) const;
@@ -73,11 +74,13 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
     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::EventIdPtr toEventId(JSValueRef eventId);
     TizenApis::Api::Calendar::EventIdListPtr toVectorOfEventIds(JSValueRef eventIds);
+    TizenApis::Api::Calendar::CalendarItemGeoPtr toGeolocation(JSValueRef geoInfo);
     std::vector<time_t> toVectorOfTimeTFromTZDate(JSValueRef dates);
     TizenApis::Api::Calendar::CalendarEvent::TaskPriority toTaskPriority(std::string priority) const;
        TizenApis::Api::Calendar::CalendarEvent::CalendarType toCalendarType(std::string type) const;
@@ -111,7 +114,6 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
             const JSValueRef &filters);
 
     static std::vector<std::string> m_allowedAttributes;
-    static std::vector<std::string> m_allowedCreateProperties;
     TizenApis::Api::Calendar::CalendarEvent::CalendarType m_calendarType;
 };
 
index ae3da9d..aff4703 100755 (executable)
@@ -16,7 +16,7 @@
 
 
 #include "CalendarResponseDispatcher.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
 #include <Tizen/Common/JSTizenException.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
@@ -302,8 +302,10 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventFindEventsPtr &eve
             return;
         } else {
             JSValueRef errorObject;
-            if (event->getExceptionCode() ==
-                ExceptionCodes::NotFoundException) {
+            if (event->getExceptionCode() == ExceptionCodes::InvalidArgumentException) {
+                errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
+                        cbm->getContext(), TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+            } else if (event->getExceptionCode() == ExceptionCodes::NotFoundException) {
                 errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
                         cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
             } else {
@@ -311,15 +313,16 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventFindEventsPtr &eve
                         cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
             }
             cbm->callOnError(errorObject);
+            return;
         }
     }
     Catch(Exception)
     {
         LogError("error during processing answer");
+        JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
+                cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+        cbm->callOnError(errorObject);
     }
-    JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
-            cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
-    cbm->callOnError(errorObject);
 }
 
 void CalendarResponseDispatcher::OnAnswerReceived(const IEventExpandEventRecurrencePtr &event)
@@ -349,16 +352,17 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventExpandEventRecurre
                         cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
             }
             cbm->callOnError(errorObject);
+            return;
         }
         LogDebug("result fail");
     }
-    Catch(ConversionException)
+    Catch(Exception)
     {
-        LogError("cannot convert event");
+        LogError("error during processing answer");
+        JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
+                cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+        cbm->callOnError(errorObject);
     }
-    JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
-            cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
-    cbm->callOnError(errorObject);
 }
 
 void CalendarResponseDispatcher::onAnswerReceived(const OnEventsChangedPtr& event)
index 1db4ed7..56cb3e9 100755 (executable)
@@ -16,7 +16,7 @@
 
 
 #include "JSAttendee.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Tizen/Common/JSTizenException.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <CommonsJavaScript/Converter.h>
@@ -31,16 +31,6 @@ namespace Tizen1_0 {
 namespace Calendar {
 
 #define TIZEN_ATTENDEE_ATTRIBUTENAME "Attendee"
-#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_UID "uid"
 
 JSClassDefinition JSAttendee::m_classInfo = {
     0,
@@ -179,42 +169,72 @@ bool JSAttendee::setProperty(JSContextRef context,
         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_UID)) {
+            if (!JSValueIsString(context, value)) {
+                Throw(InvalidArgumentException);
+            }
             std::string uid = converter->toString(value);
             attendee->setPersonId(uid);
             return true;
index 54ea2a9..f75ec0a 100755 (executable)
@@ -33,6 +33,17 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
+#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_UID "uid"
+
 typedef PrivateObject<Api::Calendar::EventAttendeePtr,
                                NoOwnership> AttendeePrivateObject;
 
index cb5e79f..656aefd 100755 (executable)
@@ -15,7 +15,7 @@
  */
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <API/Calendar/ICalendar.h>
 #include <API/Calendar/EventId.h>
 #include <API/Calendar/CalendarFactory.h>
@@ -79,8 +79,6 @@ JSValueRef getFunctionOrNull(JSContextRef ctx,
 }
 
 #define TIZEN_CALENDAR_ATTRIBUTENAME "Calendar"
-#define TIZEN_CALENDAR_PROPERTY_NAME "name"
-#define TIZEN_CALENDAR_PROPERTY_ACCOUNT_ID "accountId"
 
 namespace TizenApis {
 namespace Tizen1_0 { 
@@ -111,6 +109,8 @@ JSStaticValue JSCalendar::m_property[] = {
       NULL, kJSPropertyAttributeReadOnly },
     { TIZEN_CALENDAR_PROPERTY_ACCOUNT_ID, JSCalendar::getPropertyAccountId,
       NULL, kJSPropertyAttributeReadOnly },
+    { TIZEN_CALENDAR_PROPERTY_ID, JSCalendar::getPropertyId,
+      NULL, kJSPropertyAttributeReadOnly },
     { 0, 0, 0, 0 }
 };
 
@@ -140,7 +140,6 @@ void JSCalendar::initialize(JSContextRef context,
     CalendarPrivObject *priv =
         static_cast<CalendarPrivObject*>(JSObjectGetPrivate(object));
     if (!priv) {
-        //create default instance
         LogWarning("create default instance");
         ICalendarPtr calendar =
             Api::Calendar::CalendarFactory::getInstance().createCalendarObject();
@@ -196,22 +195,19 @@ JSValueRef JSCalendar::add(JSContextRef context,
     {
         ICalendarPtr calendar = getCalendar(context, thisObject, NULL);
 
-        if (argumentCount > 1) {
-            LogError("Wrong number of parameters.");
-            Throw(InvalidArgumentException);
+        if (argumentCount!=1) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
-        if (JSValueIsUndefined(context, arguments[0]) ||
-            JSValueIsNull(context, arguments[0])) {
-            Throw(InvalidArgumentException);
+        if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
         CalendarConverterFactory::ConverterType converter =
             CalendarConverterFactory::getConverter(privateObject->getContext());
         CalendarEventPtr event = converter->toEvent(arguments[0]);
         if (!event) {
-            LogError("Failed to get an event.");
-            Throw(UnknownException);
+            ThrowMsg(ConversionException, "Parameter conversion failed.");
         }
 
         IEventAddEventPtr dplEvent(new IEventAddEvent());
@@ -222,24 +218,28 @@ JSValueRef JSCalendar::add(JSContextRef context,
         if (dplEvent->getResult()) {
             return converter->toJSValueRefItem(dplEvent->getEvent());
         } else {
-            return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+            ThrowMsg(UnknownException, "Adding failed by unkown reason.");
         }
     }
     Catch(UnsupportedException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::NOT_SUPPORTED_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(InvalidArgumentException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(ConversionException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(Exception)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
     return JSValueMakeNull(context);
@@ -268,21 +268,20 @@ JSValueRef JSCalendar::addBatch(JSContextRef context,
     {
         ICalendarPtr calendar = getCalendar(context, thisObject, NULL);
 
-        if (argumentCount > 3) {
-            LogError("Wrong number of parameters");
-            Throw(InvalidArgumentException);
+        if (argumentCount>3 || argumentCount<1) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
         CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
 
         CalendarEventListPtr events;
         if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
-            Throw(InvalidArgumentException);
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         }
         events = converter->toVectorOfEventsFromProperty(arguments[0]);
         if (!events) {
             LogError("Failed to create events.");
-            Throw(InvalidArgumentException);
+            ThrowMsg(ConversionException, "Parameter conversion failed.");
         }
 
         JSValueRef onError = NULL;
@@ -292,17 +291,10 @@ JSValueRef JSCalendar::addBatch(JSContextRef context,
         JSContextRef globalContext = privateObject->getContext();
         JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, NULL, onError);
         CalendarEventsSuccessCallback result;
-        //result.onSuccess = JSUtils::getJSPropertyOrUndefined(context, objectCallbacks, "onSuccess");
-        result.onSuccess = arguments[1];
-        Validator validator(context);
-        if ((!validator.isNullOrUndefined(result.onSuccess) && !validator.isCallback(result.onSuccess)))
-        {
-           LogError("Calendar callback set error.");
-           Throw(InvalidArgumentException);
+        if (argumentCount > 1) {
+            result.onSuccess = getFunctionOrNull(context, arguments[1]);
         }
         cbm->setOnSuccess(result.onSuccess);
-        //JSCallbackManagerPtr onAddEventCbm = JSCallbackManager::createObject(globalContext, result.onEventSuccess, result.onEventError);
-        //onAddEventCbm->setObject(thisObject);
 
         LogDebug("Proceed the event to the platform.");
 
@@ -322,24 +314,23 @@ JSValueRef JSCalendar::addBatch(JSContextRef context,
     }
     Catch(UnsupportedException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::NOT_SUPPORTED_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(InvalidArgumentException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(ConversionException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(Exception)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
-    }
-
-    if (NULL != cbm) {
-        cbm->callOnError(TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
-                    cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR));
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
     return JSValueMakeNull(context);
@@ -366,28 +357,23 @@ JSValueRef JSCalendar::update(JSContextRef context,
     {
         ICalendarPtr calendar = getCalendar(context, thisObject, exception);
 
-        if (argumentCount>2) {
-            LogError("Wrong number of parameters.");
-            Throw(InvalidArgumentException);
+        if (argumentCount>2 || argumentCount<1) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
-        if (JSValueIsUndefined(context, arguments[0]) ||
-            JSValueIsNull(context, arguments[0])) {
-            Throw(ConversionException);
+        if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         } else if (!JSValueIsObjectOfClass(context, arguments[0], JSCalendarItem::getClassRef())) {
-            LogError("Item parameter is not a type of item class.");
-            Throw(InvalidArgumentException);
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
         JSObjectRef arg = JSValueToObject(context, arguments[0], exception);
         CalendarEventPtr event = JSCalendarItem::getPrivateObject(arg);
         if (!JSCalendarItem::validate(context, arg, exception)) {
-            LogError("Event parameter contains errors.");
-            Throw(ConversionException);
+            ThrowMsg(InvalidArgumentException, "Wrong parameter value.");
         }
         if (!event) {
-            LogError("Failed to get event.");
-            Throw(UnknownException);
+            ThrowMsg(ConversionException, "Parameter conversion failed.");
         }
 
         bool updateAllInstances = true;
@@ -396,8 +382,7 @@ JSValueRef JSCalendar::update(JSContextRef context,
             if (JSValueIsBoolean(context, arguments[1])) {
                 updateAllInstances = converter->toBool(arguments[1]);
             } else {
-                LogInfo("updateAllInstances is wrong!");
-                Throw(InvalidArgumentException);
+                ThrowMsg(ConversionException, "Wrong parameter type.");
             }
         }
 
@@ -410,21 +395,33 @@ JSValueRef JSCalendar::update(JSContextRef context,
         if (dplEvent->getResult()) {
             return JSValueMakeNull(context);
         } else {
-            LogError("Unknow error occured.");
-            Throw(UnknownException);
+            ThrowMsg(UnknownException, "Updating 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)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(ConversionException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch (NotFoundException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(Exception)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
     return JSValueMakeNull(context);
@@ -453,22 +450,20 @@ JSValueRef JSCalendar::updateBatch(JSContextRef context,
     {
         ICalendarPtr calendar = getCalendar(context, thisObject, exception);
 
-        if (argumentCount > 4) {
-            LogError("Wrong callbacks parameters");
-            Throw(InvalidArgumentException);
+        if (argumentCount>4 || argumentCount<1) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
         CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
 
         if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
-            Throw(InvalidArgumentException);
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
         CalendarEventListPtr events;
         events = converter->toVectorOfEvents(arguments[0]);
         if (!events) {
-            LogError("Failed to get events");
-            Throw(UnknownException);
+            ThrowMsg(ConversionException, "Parameter conversion failed.");
         }
 
         JSValueRef onError = NULL;
@@ -478,12 +473,8 @@ JSValueRef JSCalendar::updateBatch(JSContextRef context,
         JSContextRef globalContext = privateObject->getContext();
         JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, NULL, onError);
         CalendarEventsSuccessCallback result;
-        result.onSuccess = arguments[1];
-        Validator validator(context);
-        if ((!validator.isNullOrUndefined(result.onSuccess) && !validator.isCallback(result.onSuccess)))
-        {
-           LogError("Calendar callback set error.");
-           Throw(InvalidArgumentException);
+        if (argumentCount > 1) {
+            result.onSuccess = getFunctionOrNull(context, arguments[1]);
         }
         cbm->setOnSuccess(result.onSuccess);
 
@@ -492,8 +483,7 @@ JSValueRef JSCalendar::updateBatch(JSContextRef context,
             if (JSValueIsBoolean(context, arguments[3])) {
                 updateAllInstances = converter->toBool(arguments[3]);
             } else {
-                LogInfo("updateAllInstances is wrong!");
-                Throw(InvalidArgumentException);
+                ThrowMsg(ConversionException, "Wrong parameter type.");
             }
         }
 
@@ -508,22 +498,30 @@ JSValueRef JSCalendar::updateBatch(JSContextRef context,
 
         return makePendingOperation(cbm->getContext(), dplEvent);
     }
+    Catch(UnsupportedException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    }
     Catch(InvalidArgumentException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(ConversionException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
     }
-    Catch(Exception)
+    Catch (NotFoundException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
-
-    if (NULL != cbm) {
-        cbm->callOnError(TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
-                    cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR));
+    Catch(Exception)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
     return JSValueMakeNull(context);
@@ -549,24 +547,24 @@ JSValueRef JSCalendar::remove(JSContextRef context,
     {
         ICalendarPtr calendar = getCalendar(context, thisObject, exception);
 
-        if (argumentCount>1) {
-            LogError("Wrong number of parameters.");
-            Throw(InvalidArgumentException);
+        if (argumentCount!=1) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
-        if (JSValueIsUndefined(context, arguments[0]) ||
-            JSValueIsNull(context, arguments[0])) {
-            Throw(InvalidArgumentException);
+        if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
         if (!JSValueIsObjectOfClass(context, arguments[0], JSEventId::getClassRef())) {
-            LogError("Wrong event id parameter.");
-            Throw(InvalidArgumentException);
+            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.");
+        }
 
         IEventDeleteEventPtr dplEvent(new IEventDeleteEvent());
         dplEvent->setEventId(itemId);
@@ -578,29 +576,36 @@ JSValueRef JSCalendar::remove(JSContextRef context,
             return JSValueMakeNull(context);
         } else {
             if (dplEvent->getExceptionCode() == ExceptionCodes::NotFoundException) {
-                LogError("Not found exception.");
-                Throw(NotFoundException);
+                ThrowMsg(ConversionException, "Item not found.");
             } else {
-                LogError("Unknow error occured.");
-                Throw(UnknownException);
+                ThrowMsg(UnknownException, "Removing 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)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(ConversionException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
     }
     Catch (NotFoundException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::NOT_FOUND_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(Exception)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
     return JSValueMakeNull(context);
@@ -628,19 +633,21 @@ JSValueRef JSCalendar::removeBatch(JSContextRef context,
     {
         ICalendarPtr calendar = getCalendar(context, thisObject, exception);
 
-        if (argumentCount > 3) {
-            LogError("No callback parameters");
-            Throw(InvalidArgumentException);
+        if (argumentCount>3 || argumentCount<1) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
         CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
 
         if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
-            Throw(InvalidArgumentException);
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
         EventIdListPtr itemIds;
         itemIds = converter->toVectorOfEventIds(arguments[0]);
+        if (!itemIds) {
+            ThrowMsg(ConversionException, "Parameter conversion failed.");
+        }
 
         JSValueRef onError = NULL;
         if (argumentCount > 2) {
@@ -649,12 +656,8 @@ JSValueRef JSCalendar::removeBatch(JSContextRef context,
         JSContextRef globalContext = privateObject->getContext();
         JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, NULL, onError);
         CalendarEventsSuccessCallback result;
-        result.onSuccess = arguments[1];
-        Validator validator(context);
-        if ((!validator.isNullOrUndefined(result.onSuccess) && !validator.isCallback(result.onSuccess)))
-        {
-           LogError("Calendar callback set error.");
-           Throw(InvalidArgumentException);
+        if (argumentCount > 1) {
+            result.onSuccess = getFunctionOrNull(context, arguments[1]);
         }
         cbm->setOnSuccess(result.onSuccess);
 
@@ -668,28 +671,36 @@ JSValueRef JSCalendar::removeBatch(JSContextRef context,
 
         return makePendingOperation(cbm->getContext(), dplEvent);
     }
+    Catch(UnsupportedException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    }
     Catch(InvalidArgumentException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(ConversionException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
     }
-    Catch(Exception)
+    Catch (NotFoundException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
-
-    if (NULL != cbm) {
-        cbm->callOnError(TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
-                    cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR));
+    Catch(Exception)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
     return JSValueMakeNull(context);
 }
 
-JSValueRef JSCalendar::find(JSContextRef context,
+JSValueRef JSCalendar::findWithWACFilter(JSContextRef context,
         JSObjectRef object,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -709,43 +720,28 @@ JSValueRef JSCalendar::find(JSContextRef context,
     Try
     {
         ICalendarPtr calendar = getCalendar(context, thisObject, exception);
-        if (argumentCount < 1) {
-            LogError("No callback parameters");
-            Throw(InvalidArgumentException);
+        if (argumentCount<1 || argumentCount>4) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
-        JSValueRef onError =
-            (argumentCount >
-             1 ? getFunctionOrNull(context, arguments[1]) : NULL);
+        JSValueRef onError = (argumentCount > 1 ? getFunctionOrNull(context, arguments[1]) : NULL);
         JSContextRef globalContext = privateObject->getContext();
         cbm = JSCallbackManager::createObject(globalContext, NULL, onError);
 
         Validator validator(context);
         if (validator.isCallback(arguments[0])) {
             cbm->setOnSuccess(arguments[0]);
-        } else if (JSValueIsNull(context,
-                                 arguments[0]) ||
-                   JSValueIsUndefined(context, arguments[0])) {
-            Throw(ConversionException);
+        } else if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])) {
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         } else {
-            Throw(InvalidArgumentException);
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         }
         //setup filters
         EventFilterPtr filter(NULL);
         if (argumentCount >= 3) {
             LogDebug("setting some filters");
-            CalendarConverterFactory::ConverterType converter =
-                CalendarConverterFactory::getConverter(context);
-            Try
-            {
-                if (!JSValueIsUndefined(context, arguments[2]) &&
-                    !JSValueIsNull(context, arguments[2])) {
-                    filter = converter->toEventFilter(arguments[2]);
-                }
-            }
-            Catch(InvalidArgumentException)
-            {
-                LogError("Invalid argument");
-                filter.Reset();
+            CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
+            if (!JSValueIsUndefined(context, arguments[2]) && !JSValueIsNull(context, arguments[2])) {
+                filter = converter->toEventFilter(arguments[2]);
             }
         }
         IEventFindEventsPtr dplEvent(new IEventFindEvents());
@@ -756,23 +752,36 @@ JSValueRef JSCalendar::find(JSContextRef context,
 
         return JSValueMakeNull(context);
     }
+    Catch(UnsupportedException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    }
     Catch(InvalidArgumentException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(ConversionException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch (NotFoundException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(Exception)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
     return JSValueMakeNull(context);
 }
 
-JSValueRef JSCalendar::findEventsGeneric(JSContextRef context,
+JSValueRef JSCalendar::find(JSContextRef context,
         JSObjectRef object,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -789,69 +798,83 @@ JSValueRef JSCalendar::findEventsGeneric(JSContextRef context,
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-    JSCallbackManagerPtr cbm(NULL);
+    Try
+    {
+        if (argumentCount<1 || argumentCount>4) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        }
 
-    Validator validator(context, exception);
-    CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
-    TizenApis::Tizen1_0::Tizen::FilterConverterFactory::ConverterType filterConverter = TizenApis::Tizen1_0::Tizen::FilterConverterFactory::getConverter(context);
-    ICalendarPtr calendar = getCalendar(context, thisObject, exception);
+        JSCallbackManagerPtr cbm(NULL);
 
-    JSContextRef globalContext = privateObject->getContext();
-    cbm = JSCallbackManager::createObject(globalContext);
+        Validator validator(context, exception);
+        CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
+        TizenApis::Tizen1_0::Tizen::FilterConverterFactory::ConverterType filterConverter = TizenApis::Tizen1_0::Tizen::FilterConverterFactory::getConverter(context);
+        ICalendarPtr calendar = getCalendar(context, thisObject, exception);
 
-    Try
-    {
-        if (argumentCount == 0 ||
-            (!validator.isCallback(arguments[0])) ||
+        JSContextRef globalContext = privateObject->getContext();
+        cbm = JSCallbackManager::createObject(globalContext);
+
+        if ((!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 && (!JSIsArrayValue(context, arguments[4]) && !validator.isNullOrUndefined(arguments[4])))) {
-            LogDebug("Argument type mismatch");
-            Throw(InvalidArgumentException);
+            (argumentCount >= 5 && (!JSValueIsObject(context, arguments[4]) && !validator.isNullOrUndefined(arguments[4])))) {
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
-            if (cbm) {
-                JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-                onSuccessForCbm = arguments[0];
-                if (argumentCount >= 2) {
-                    onErrorForCbm = arguments[1];
-                }
-                cbm->setObject(thisObject);
-                cbm->setOnSuccess(onSuccessForCbm);
-                cbm->setOnError(onErrorForCbm);
+        if (cbm) {
+            JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
+            onSuccessForCbm = arguments[0];
+            if (argumentCount >= 2) {
+                onErrorForCbm = arguments[1];
             }
+            cbm->setOnSuccess(onSuccessForCbm);
+            cbm->setOnError(onErrorForCbm);
+        }
 
         IEventFindEventsPtr dplEvent(new IEventFindEvents());
         dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
         dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance());
 
-            if (argumentCount >= 3 && !validator.isNullOrUndefined(arguments[2])) {
-                dplEvent->setGenericFilter(filterConverter->toFilter(arguments[2]));
-            }
-            if (argumentCount >= 4 && !validator.isNullOrUndefined(arguments[3])) {
-    //          dplEvent->setSortModes(filterConverter->toSortModeArray(arguments[3]));
-                TizenApis::Api::Tizen::SortModeArrayPtr sortModes(new TizenApis::Api::Tizen::SortModeArray());
-                sortModes->push_back(filterConverter->toSortMode(arguments[3]));
-                dplEvent->setSortModes(sortModes);
-            }
-            if (argumentCount >= 5 && !validator.isNullOrUndefined(arguments[4])) {
-                dplEvent->setAttributesOfInterest(converter->toVectorOfStrings(arguments[4]));
-            }
+        if (argumentCount >= 3 && !validator.isNullOrUndefined(arguments[2])) {
+            dplEvent->setGenericFilter(filterConverter->toFilter(arguments[2]));
+        }
+        if (argumentCount >= 4 && !validator.isNullOrUndefined(arguments[3])) {
+            // Though the sortMode is a single type, we save it in an array internally.
+            TizenApis::Api::Tizen::SortModeArrayPtr sortModes(new TizenApis::Api::Tizen::SortModeArray());
+            sortModes->push_back(filterConverter->toSortMode(arguments[3]));
+            dplEvent->setSortModes(sortModes);
+        }
+        /*if (argumentCount >= 5 && !validator.isNullOrUndefined(arguments[4])) {
+            dplEvent->setAttributesOfInterest(converter->toVectorOfStrings(arguments[4]));
+        }*/
 
         calendar->findEvents(dplEvent);
     }
+    Catch(UnsupportedException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    }
     Catch(InvalidArgumentException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(ConversionException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch (NotFoundException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(Exception)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
     return JSValueMakeNull(context);
@@ -878,9 +901,8 @@ JSValueRef JSCalendar::expandEventRecurrence(JSContextRef context,
     Try
     {
         ICalendarPtr calendar = getCalendar(context, thisObject, exception);
-        if (argumentCount>5) {
-            LogError("Wrong number of parameters.");
-            Throw(InvalidArgumentException);
+        if (argumentCount>5 || argumentCount<4) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
         JSValueRef onError =(argumentCount > 4 ? getFunctionOrNull(context, arguments[4]) : NULL);
@@ -890,19 +912,16 @@ JSValueRef JSCalendar::expandEventRecurrence(JSContextRef context,
         Validator validator(context);
         if (validator.isCallback(arguments[3])) {
             cbm->setOnSuccess(arguments[3]);
-        } else if (JSValueIsNull(context,
-                                 arguments[3]) ||
-                   JSValueIsUndefined(context, arguments[3])) {
-            Throw(InvalidArgumentException);
+        } else if (JSValueIsNull(context, arguments[3]) || JSValueIsUndefined(context, arguments[3])) {
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         } else {
-            Throw(InvalidArgumentException);
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
         JSObjectRef arg = JSValueToObject(context, arguments[0], exception);
         CalendarEventPtr event = JSCalendarItem::getPrivateObject(arg);
         if (!event) {
-            LogError("Failed to get an event.");
-            Throw(UnknownException);
+            ThrowMsg(ConversionException, "Parameter conversion failed.");
         }
 
         std::time_t startDate = 0;
@@ -926,17 +945,30 @@ JSValueRef JSCalendar::expandEventRecurrence(JSContextRef context,
 
         return JSValueMakeNull(context);
     }
+    Catch(UnsupportedException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    }
     Catch(InvalidArgumentException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(ConversionException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch (NotFoundException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(Exception)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
     return JSValueMakeNull(context);
@@ -964,40 +996,38 @@ JSValueRef JSCalendar::convertFromString(JSContextRef context,
     Try
     {
         ICalendarPtr calendar = getCalendar(context, thisObject, NULL);
-        if (argumentCount>2 || argumentCount<1) {
-            LogError("Wrong count of parameters");
-            Throw(InvalidArgumentException);
+        if (argumentCount!=2) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
-        if (JSValueIsUndefined(context, arguments[0]) ||
-            JSValueIsNull(context, arguments[0])) {
-            Throw(InvalidArgumentException);
+        if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         }
         else if (!JSValueIsString(context, arguments[0])) {
-            LogError("invalid type of id parameter");
-            Throw(InvalidArgumentException);
+            ThrowMsg(ConversionException, "First parameter is not a string type.");
+        }
+
+        if (JSValueIsUndefined(context, arguments[1]) || JSValueIsNull(context, arguments[1])) {
+            ThrowMsg(ConversionException, "Wrong parameter type.");
+        }
+        else if (!JSValueIsString(context, arguments[1])) {
+            ThrowMsg(ConversionException, "Second parameter is not a CalendarTextFormat type.");
         }
 
         CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
+            CalendarConverterFactory::getConverter(globalContext);
 
         std::string eventStr;
         CalendarEvent::VObjectFormat format = CalendarEvent::ICALENDAR_20;
 
-        if (JSValueIsString(context, arguments[0])) {
-            eventStr = converter->toString(arguments[0]);
-        } else {
-            LogError("Wrong type of itemStr.");
-            Throw(InvalidArgumentException);
-        }
+        eventStr = converter->toString(arguments[0]);
 
         if( argumentCount>1 )
         {
             if (JSValueIsString(context, arguments[1])) {
                 format = converter->toVObjectFormat(converter->toString(arguments[1]));
             } else {
-                LogError("Wrong type of format.");
-                Throw(InvalidArgumentException);
+                ThrowMsg(ConversionException, "Second parameter is not a CalendarTextFormat type.");
             }
         }
 
@@ -1011,21 +1041,28 @@ JSValueRef JSCalendar::convertFromString(JSContextRef context,
             LogInfo("Successfully created an event.");
             return converter->toJSValueRefItemProperties(dplEvent->getEvent());
         } else {
-            LogError("Unexpected error.");
-            Throw(UnknownException);
+            ThrowMsg(UnknownException, "Converting from 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)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(ConversionException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(Exception)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
     return JSValueMakeNull(context);
@@ -1052,43 +1089,34 @@ JSValueRef JSCalendar::convertToString(JSContextRef context,
     Try
     {
         ICalendarPtr calendar = getCalendar(context, thisObject, NULL);
-        if (argumentCount>2 || argumentCount<1) {
-            LogError("Wrong number of parameters.");
-            Throw(InvalidArgumentException);
+        if (argumentCount!=2) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
-        if (JSValueIsUndefined(context, arguments[0]) ||
-            JSValueIsNull(context, arguments[0])) {
-            Throw(ConversionException);
+        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())) {
-                LogError("Wrong event argument.");
-                Throw(InvalidArgumentException);
+            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)) {
-                Throw(ConversionException);
+            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())) {
-                LogError("Wrong task argument.");
-                Throw(InvalidArgumentException);
+            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)) {
-                Throw(ConversionException);
+            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) {
-            LogError("Failed to get an event.");
-            Throw(UnknownException);
+            ThrowMsg(ConversionException, "Parameter conversion failed.");
         }
 
         CalendarEvent::VObjectFormat format = CalendarEvent::ICALENDAR_20;
@@ -1096,7 +1124,7 @@ JSValueRef JSCalendar::convertToString(JSContextRef context,
         if( argumentCount>1 )
         {
             if (JSValueIsString(context, arguments[1])) {
-                    format = converter.toVObjectFormat(converter.toString(arguments[1]));
+                format = converter.toVObjectFormat(converter.toString(arguments[1]));
             }
         }
 
@@ -1109,20 +1137,33 @@ JSValueRef JSCalendar::convertToString(JSContextRef context,
         if (dplEvent->getResult()) {
             return converter.toJSValueRef(dplEvent->getEventString());
         } else {
-            Throw(UnknownException);
+            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)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(ConversionException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch (NotFoundException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(Exception)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
     return JSValueMakeNull(context);
@@ -1148,9 +1189,8 @@ JSValueRef JSCalendar::addChangeListener(JSContextRef context,
     Try
     {
         ICalendarPtr calendar = getCalendar(context, thisObject, exception);
-        if (argumentCount > 2) {
-            LogError("No callback parameters");
-            Throw(InvalidArgumentException);
+        if (argumentCount>2 || argumentCount<1) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
         CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
@@ -1170,15 +1210,11 @@ JSValueRef JSCalendar::addChangeListener(JSContextRef context,
            (!validator.isNullOrUndefined(result.onUpdated) && !validator.isCallback(result.onUpdated)) ||
            (!validator.isNullOrUndefined(result.onDeleted) && !validator.isCallback(result.onDeleted)))
         {
-           LogError("Calendar multi calback set error!");
-           Throw(InvalidArgumentException);
+            ThrowMsg(InvalidArgumentException, "Wrong successCallback parameter value.");
         }
         JSCallbackManagerPtr onAddedCbm = JSCallbackManager::createObject(globalContext, result.onAdded, NULL);
         JSCallbackManagerPtr onUpdatedCbm = JSCallbackManager::createObject(globalContext, result.onUpdated, NULL);
         JSCallbackManagerPtr onDeletedCbm = JSCallbackManager::createObject(globalContext, result.onDeleted, NULL);
-        onAddedCbm->setObject(thisObject);
-        onUpdatedCbm->setObject(thisObject);
-        onDeletedCbm->setObject(thisObject);
 
         /* The interested attributes are not supported in platform.
         AttributeListPtr attributes;
@@ -1208,7 +1244,6 @@ JSValueRef JSCalendar::addChangeListener(JSContextRef context,
 
         // return sync operation and process the events and emit results while processing them
         IEventWatchChangesPtr dplEvent(new IEventWatchChanges());
-        //dplEvent->setAttributes(attributes);
         dplEvent->setEmitter(emitter);
         dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
         dplEvent->setForSynchronousCall();
@@ -1220,22 +1255,29 @@ JSValueRef JSCalendar::addChangeListener(JSContextRef context,
             LogDebug("Returning the watchId "<<watchId);
             return converter->toJSValueRefLong(watchId);
         } else {
-            LogDebug("Watch failed!");
-            Throw(UnknownException);
+            ThrowMsg(UnknownException, "Adding change listener failed by unkown reason.");
         }
         return JSValueMakeNull(context);
     }
+    Catch(UnsupportedException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    }
     Catch(InvalidArgumentException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(ConversionException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(Exception)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
     return JSValueMakeNull(context);
@@ -1260,15 +1302,15 @@ JSValueRef JSCalendar::removeChangeListener(JSContextRef context,
     Try
     {
         ICalendarPtr calendar = getCalendar(context, thisObject, exception);
-        if (argumentCount > 1) {
-            LogError("Wrong number of parameter.");
-            Throw(InvalidArgumentException);
+        if (argumentCount!=1) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
         long watchId = -1;
             CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
-            if (JSValueIsNumber(context, arguments[0]))
+            if (JSValueIsNumber(context, arguments[0])) {
                 watchId = converter->toLong(arguments[0]);
+            }
 
         LogDebug("Make sync operation");
 
@@ -1279,17 +1321,30 @@ JSValueRef JSCalendar::removeChangeListener(JSContextRef context,
 
         return JSValueMakeNull(context);
     }
+    Catch(UnsupportedException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    }
     Catch(InvalidArgumentException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(ConversionException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch (NotFoundException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(Exception)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
     return JSValueMakeNull(context);
@@ -1331,6 +1386,24 @@ JSValueRef JSCalendar::getPropertyAccountId(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
+JSValueRef JSCalendar::getPropertyId(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+    Try
+    {
+        ICalendarPtr calendar = getCalendar(context, object, exception);
+        Converter converter(context);
+        return converter.toJSValueRef(calendar->getId());
+    }
+    Catch(Exception)
+    {
+        LogError("error during executing a function");
+    }
+    return JSValueMakeUndefined(context);
+}
+
 ICalendarPtr JSCalendar::getCalendar(JSContextRef ctx,
         const JSObjectRef object,
         JSValueRef* exception)
index 4e504f1..72d9c1d 100755 (executable)
@@ -29,6 +29,10 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
+#define TIZEN_CALENDAR_PROPERTY_NAME "name"
+#define TIZEN_CALENDAR_PROPERTY_ACCOUNT_ID "accountId"
+#define TIZEN_CALENDAR_PROPERTY_ID "id"
+
 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::ICalendarPtr,
                                WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarPrivObject;
 
@@ -82,6 +86,11 @@ class JSCalendar
             JSStringRef propertyName,
             JSValueRef* exception);
 
+    static JSValueRef getPropertyId(JSContextRef context,
+            JSObjectRef object,
+            JSStringRef propertyName,
+            JSValueRef* exception);
+
     /**
      * Add a calendar item.
      */
@@ -143,9 +152,9 @@ class JSCalendar
             JSValueRef* exception);
 
     /**
-     * Search for calendar events.
+     * Search for calendar items using old wac2.0 stype filter.
      */
-    static JSValueRef find(JSContextRef context,
+    static JSValueRef findWithWACFilter(JSContextRef context,
             JSObjectRef object,
             JSObjectRef thisObject,
             size_t argumentCount,
@@ -153,9 +162,9 @@ class JSCalendar
             JSValueRef* exception);
 
     /**
-     * Search for calendar events.
+     * Search for calendar items using tizen generic filter.
      */
-    static JSValueRef findEventsGeneric(JSContextRef context,
+    static JSValueRef find(JSContextRef context,
             JSObjectRef object,
             JSObjectRef thisObject,
             size_t argumentCount,
index e8610ec..c922426 100755 (executable)
@@ -16,7 +16,7 @@
 
 
 #include <ctime>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSUtils.h>
@@ -39,10 +39,6 @@ namespace Calendar {
 
 #define TIZEN_CALENDAR_EVENT_ATTRIBUTENAME "CalendarEvent"
 
-#define TIZEN_CALENDAR_EVENT_ID "id"
-#define TIZEN_CALENDAR_EVENT_LASTMODIFIEDDATE "lastModificationDate"
-#define TIZEN_CALENDAR_EVENT_IS_DETACHED "isDetached"
-
 JSClassDefinition JSCalendarEvent::m_classInfo = {
     0,
     kJSClassAttributeNone,
@@ -66,7 +62,7 @@ JSClassDefinition JSCalendarEvent::m_classInfo = {
 JSStaticValue JSCalendarEvent::m_property[] = {
     { TIZEN_CALENDAR_EVENT_ID, getPropertyId,
       NULL, kJSPropertyAttributeReadOnly },
-    { TIZEN_CALENDAR_EVENT_LASTMODIFIEDDATE, getPropertyLastModifiedDate,
+    { TIZEN_CALENDAR_EVENT_LAST_MODIFICATION_DATE, getPropertyLastModificationDate,
       NULL, kJSPropertyAttributeReadOnly },
     { TIZEN_CALENDAR_EVENT_IS_DETACHED, getPropertyIsDetached,
       NULL, kJSPropertyAttributeReadOnly },
@@ -171,7 +167,7 @@ JSValueRef JSCalendarEvent::getPropertyId(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSCalendarEvent::getPropertyLastModifiedDate(JSContextRef context,
+JSValueRef JSCalendarEvent::getPropertyLastModificationDate(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName,
         JSValueRef* exception)
@@ -208,8 +204,12 @@ JSValueRef JSCalendarEvent::getPropertyIsDetached(JSContextRef context,
     LogDebug("entered");
     Try
     {
-        Converter converter(context);
         CalendarEventPtr event = getPrivateObject(object);
+        if(CalendarEvent::EVENT_TYPE != event->getCalendarType()) {
+            return JSValueMakeUndefined(context);
+        }
+
+        Converter converter(context);
         return converter.toJSValueRef(event->getIsDetached());
     }
     Catch(Exception)
index aba8a6e..6229943 100755 (executable)
@@ -26,6 +26,10 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
+#define TIZEN_CALENDAR_EVENT_ID "id"
+#define TIZEN_CALENDAR_EVENT_LAST_MODIFICATION_DATE "lastModificationDate"
+#define TIZEN_CALENDAR_EVENT_IS_DETACHED "isDetached"
+
 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::CalendarEventPtr,
        WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarEventPrivObject;
 
@@ -86,7 +90,7 @@ class JSCalendarEvent
             JSObjectRef object,
             JSStringRef propertyName,
             JSValueRef* exception);
-    static JSValueRef getPropertyLastModifiedDate(JSContextRef context,
+    static JSValueRef getPropertyLastModificationDate(JSContextRef context,
             JSObjectRef object,
             JSStringRef propertyName,
             JSValueRef* exception);
index f01f38e..29f5974 100755 (executable)
@@ -16,7 +16,7 @@
 
 
 #include <ctime>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSUtils.h>
@@ -39,9 +39,6 @@ namespace Calendar {
 
 #define TIZEN_CALENDAR_ITEM_ATTRIBUTENAME "CalendarItem"
 
-#define TIZEN_CALENDAR_ITEM_ID "id"
-#define TIZEN_CALENDAR_ITEM_LASTMODIFIEDDATE "lastModificationDate"
-
 JSClassDefinition JSCalendarItem::m_classInfo = {
     0,
     kJSClassAttributeNone,
@@ -66,7 +63,7 @@ JSStaticValue JSCalendarItem::m_property[] = {
     //EventProperties
     { TIZEN_CALENDAR_ITEM_ID, getPropertyId,
       NULL, kJSPropertyAttributeReadOnly },
-    { TIZEN_CALENDAR_ITEM_LASTMODIFIEDDATE, getPropertyLastModifiedDate,
+    { TIZEN_CALENDAR_ITEM_LAST_MODIFICATION_DATE, getPropertyLastModificationDate,
       NULL, kJSPropertyAttributeReadOnly },
 
     { 0, 0, 0, 0 }
@@ -170,7 +167,7 @@ JSValueRef JSCalendarItem::getPropertyId(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSCalendarItem::getPropertyLastModifiedDate(JSContextRef context,
+JSValueRef JSCalendarItem::getPropertyLastModificationDate(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName,
         JSValueRef* exception)
index c736778..902de1b 100755 (executable)
@@ -26,6 +26,9 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
+#define TIZEN_CALENDAR_ITEM_ID "id"
+#define TIZEN_CALENDAR_ITEM_LAST_MODIFICATION_DATE "lastModificationDate"
+
 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::CalendarEventPtr,
        WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarItemPrivObject;
 
@@ -86,7 +89,7 @@ class JSCalendarItem
             JSObjectRef object,
             JSStringRef propertyName,
             JSValueRef* exception);
-    static JSValueRef getPropertyLastModifiedDate(JSContextRef context,
+    static JSValueRef getPropertyLastModificationDate(JSContextRef context,
             JSObjectRef object,
             JSStringRef propertyName,
             JSValueRef* exception);
diff --git a/src/standards/Tizen/Calendar/JSCalendarItemGeo.cpp b/src/standards/Tizen/Calendar/JSCalendarItemGeo.cpp
new file mode 100755 (executable)
index 0000000..facaba6
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "JSCalendarItemGeo.h"
+#include <dpl/log/log.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <CommonsJavaScript/Converter.h>
+
+using namespace TizenApis::Api::Calendar;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Calendar {
+
+#define TIZEN_CALENDAR_ITEM_GEO_ATTRIBUTENAME "CalendarItemGeo"
+
+JSClassDefinition JSCalendarItemGeo::m_classInfo = {
+    0,
+    kJSClassAttributeNone,
+    TIZEN_CALENDAR_ITEM_GEO_ATTRIBUTENAME,
+    0,
+    m_property,
+    NULL, //m_function,
+    initialize,
+    finalize,
+    NULL, //hasProperty,
+    NULL, //getProperty,
+    NULL, //setProperty,
+    NULL, //deleteProperty,
+    NULL, //getPropertyNames,
+    NULL, //callAsFunction,
+    NULL, //callAsConstructor,
+    NULL, //hasInstance,
+    NULL, //convertToType,
+};
+
+JSStaticValue JSCalendarItemGeo::m_property[] = {
+    { TIZEN_CALENDAR_ITEM_GEO_LATITUDE, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_CALENDAR_ITEM_GEO_LONGITUDE, getProperty, setProperty, kJSPropertyAttributeNone },
+    { 0, 0, 0, 0 }
+};
+
+JSClassRef JSCalendarItemGeo::m_jsClassRef = JSClassCreate(
+        JSCalendarItemGeo::getClassInfo());
+
+const JSClassDefinition* JSCalendarItemGeo::getClassInfo()
+{
+    return &(m_classInfo);
+}
+
+JSClassRef JSCalendarItemGeo::getClassRef()
+{
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+CalendarItemGeoPtr JSCalendarItemGeo::getPrivateObject(JSObjectRef object)
+{
+    LogDebug("entered");
+    CalendarItemGeoPrivateObject *priv =
+        static_cast<CalendarItemGeoPrivateObject*>(JSObjectGetPrivate(object));
+    if (!priv) {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    CalendarItemGeoPtr result = priv->getObject();
+    if (!result) {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    return result;
+}
+
+void JSCalendarItemGeo::initialize(JSContextRef context,
+        JSObjectRef object)
+{
+    LogDebug("enter");
+}
+
+void JSCalendarItemGeo::finalize(JSObjectRef object)
+{
+    LogDebug("enter");
+    CalendarItemGeoPrivateObject* priv =
+        static_cast<CalendarItemGeoPrivateObject*>(JSObjectGetPrivate(object));
+    delete priv;
+    JSObjectSetPrivate(object, NULL);
+}
+
+JSValueRef JSCalendarItemGeo::getProperty(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+    LogDebug("enter");
+    Converter converter(context);
+    Try
+    {
+        CalendarItemGeoPrivateObject* priv =
+            static_cast<CalendarItemGeoPrivateObject*>(JSObjectGetPrivate(object));
+        if (!priv) {
+            Throw(NullPointerException);
+        }
+        CalendarItemGeoPtr geoInfo = priv->getObject();
+
+        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ITEM_GEO_LATITUDE)) {
+            double latitude = geoInfo->getLatitude();
+            if( latitude==CalendarItemGeo::GEO_UNDEFINED ) {
+                return JSValueMakeUndefined(context);
+            } else {
+                return converter.toJSValueRef(geoInfo->getLatitude());
+            }
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ITEM_GEO_LONGITUDE)) {
+            double longitude = geoInfo->getLongitude();
+            if( longitude==CalendarItemGeo::GEO_UNDEFINED ) {
+                return JSValueMakeUndefined(context);
+            } else {
+                return converter.toJSValueRef(geoInfo->getLongitude());
+            }
+        }
+    }
+    Catch(Exception)
+    {
+        LogError("invalid property");
+    }
+
+    return JSValueMakeUndefined(context);
+}
+
+bool JSCalendarItemGeo::setProperty(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef value,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    Converter converter(context);
+    Try
+    {
+        CalendarItemGeoPrivateObject* priv =
+            static_cast<CalendarItemGeoPrivateObject*>(JSObjectGetPrivate(object));
+        if (!priv) {
+            Throw(NullPointerException);
+        }
+        CalendarItemGeoPtr geoInfo = priv->getObject();
+
+        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ITEM_GEO_LATITUDE)) {
+            if (!JSValueIsNumber(context, value)) {
+                Throw(InvalidArgumentException);
+            }
+            double latitude = converter.toDouble(value);
+            if( latitude>CalendarItemGeo::GEO_LATITUDE_MAX ) {
+                geoInfo->setLatitude(CalendarItemGeo::GEO_LATITUDE_MAX);
+            } else if( latitude<CalendarItemGeo::GEO_LATITUDE_MIN ) {
+                geoInfo->setLatitude(CalendarItemGeo::GEO_LATITUDE_MIN);
+            } else {
+                geoInfo->setLatitude(latitude);
+            }
+            return true;
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ITEM_GEO_LONGITUDE)) {
+            if (!JSValueIsNumber(context, value)) {
+                Throw(InvalidArgumentException);
+            }
+            double longitude = converter.toDouble(value);
+            if( longitude>CalendarItemGeo::GEO_LONGITUDE_MAX ) {
+                geoInfo->setLongitude(CalendarItemGeo::GEO_LONGITUDE_MAX);
+            } else if( longitude<CalendarItemGeo::GEO_LONGITUDE_MIN ) {
+                geoInfo->setLongitude(CalendarItemGeo::GEO_LONGITUDE_MIN);
+            } else {
+                geoInfo->setLongitude(longitude);
+            }
+            return true;
+        }
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to set incorrect value");
+    }
+
+    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+    return false;
+}
+
+}
+}
+}
diff --git a/src/standards/Tizen/Calendar/JSCalendarItemGeo.h b/src/standards/Tizen/Calendar/JSCalendarItemGeo.h
new file mode 100755 (executable)
index 0000000..6b13f24
--- /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 _JS_CALENDAR_ITEM_GEO_H_
+#define _JS_CALENDAR_ITEM_GEO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Calendar/CalendarItemGeo.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Calendar {
+
+#define TIZEN_CALENDAR_ITEM_GEO_LATITUDE "latitude"
+#define TIZEN_CALENDAR_ITEM_GEO_LONGITUDE "longitude"
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::CalendarItemGeoPtr,
+                               WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarItemGeoPrivateObject;
+
+class JSCalendarItemGeo
+{
+  public:
+
+    static const JSClassDefinition* getClassInfo();
+
+    static JSClassRef getClassRef();
+
+    static TizenApis::Api::Calendar::CalendarItemGeoPtr getPrivateObject(JSObjectRef object);
+
+  private:
+
+    /**
+     * The callback invoked when an object is first created.
+     */
+    static void initialize(JSContextRef context, JSObjectRef object);
+
+    /**
+     * The callback invoked when an object is finalized.
+     */
+    static void finalize(JSObjectRef object);
+
+    static JSValueRef getProperty(JSContextRef context,
+            JSObjectRef object,
+            JSStringRef propertyName,
+            JSValueRef* exception);
+
+    static bool setProperty(JSContextRef context,
+            JSObjectRef object,
+            JSStringRef propertyName,
+            JSValueRef value,
+            JSValueRef* exception);
+
+    static JSClassRef m_jsClassRef;
+
+    /**
+     * This structure describes a statically declared function property.
+     */
+    static JSStaticFunction m_function[];
+
+    /**
+     * This structure contains properties and callbacks that define a type of object.
+     */
+    static JSClassDefinition m_classInfo;
+
+    /**
+     * This member variable contains the initialization values for the static properties of this class.
+     * The values are given according to the data structure JSPropertySpec
+     */
+    static JSStaticValue m_property[];
+};
+
+}
+}
+}
+
+#endif /* _JS_CALENDAR_ITEM_GEO_H_ */
index 963d669..79636d4 100755 (executable)
@@ -16,7 +16,7 @@
 
 
 #include <ctime>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSUtils.h>
@@ -26,9 +26,9 @@
 #include <Tizen/TimeUtil/JSTZDate.h>
 #include <API/Calendar/EventAlarm.h>
 #include <API/Calendar/EventId.h>
+#include "API/TimeUtil/DurationProperties.h"
 #include "JSCalendarItemProperties.h"
 #include "CalendarConverter.h"
-#include "JSCategoryArray.h"
 #include "JSEventId.h"
 #include "JSEventAlarm.h"
 #include "JSRecurrenceRule.h"
@@ -44,27 +44,6 @@ namespace Calendar {
 
 #define TIZEN_CALENDAR_ITEM_PROPERTIES_ATTRIBUTENAME "CalendarItemProperties"
 
-#define TIZEN_CALENDAR_ITEM_DESCRIPTION "description"
-#define TIZEN_CALENDAR_ITEM_SUMMARY "summary"
-#define TIZEN_CALENDAR_ITEM_STARTTIME "startDate"
-#define TIZEN_CALENDAR_ITEM_LOCATION "location"
-#define TIZEN_CALENDAR_ITEM_LATITUDE "latitude"
-#define TIZEN_CALENDAR_ITEM_LONGITUDE "longitude"
-#define TIZEN_CALENDAR_ITEM_ORGANIZER "organizer"
-#define TIZEN_CALENDAR_ITEM_VISIBILITY "visibility"
-#define TIZEN_CALENDAR_ITEM_STATUS "status"
-#define TIZEN_CALENDAR_ITEM_ALARMS "alarms"
-#define TIZEN_CALENDAR_ITEM_CATEGORIES "categories"
-
-#define TIZEN_CALENDAR_EVENT_DURATION "duration"
-#define TIZEN_CALENDAR_EVENT_IS_ALL_DAY "isAllDay"
-#define TIZEN_CALENDAR_EVENT_ATTENDEES "attendees"
-#define TIZEN_CALENDAR_EVENT_RECURRENCE_RULE "recurrenceRule"
-#define TIZEN_CALENDAR_EVENT_AVAILABILITY "availability"
-
-#define TIZEN_CALENDAR_TASK_DUEDATE  "dueDate"
-#define TIZEN_CALENDAR_TASK_PRIORITY  "priority"
-
 JSClassDefinition JSCalendarItemProperties::m_classInfo = {
     0,
     kJSClassAttributeNone,
@@ -91,14 +70,12 @@ JSStaticValue JSCalendarItemProperties::m_property[] = {
       setPropertyDescription, kJSPropertyAttributeNone },
     { TIZEN_CALENDAR_ITEM_SUMMARY, getPropertySummary,
       setPropertySummary, kJSPropertyAttributeNone },
-    { TIZEN_CALENDAR_ITEM_STARTTIME, getPropertyStartTime,
+    { TIZEN_CALENDAR_ITEM_START_DATE, getPropertyStartTime,
       setPropertyStartTime, kJSPropertyAttributeNone },
     { TIZEN_CALENDAR_ITEM_LOCATION, getPropertyLocation,
       setPropertyLocation, kJSPropertyAttributeNone },
-    { TIZEN_CALENDAR_ITEM_LATITUDE, getPropertyLatitude,
-      setPropertyLatitude, kJSPropertyAttributeNone },
-    { TIZEN_CALENDAR_ITEM_LONGITUDE, getPropertyLongitude,
-      setPropertyLongitude, kJSPropertyAttributeNone },
+    { TIZEN_CALENDAR_ITEM_GEOLOCATION, getPropertyGeolocation,
+      setPropertyGeolocation, kJSPropertyAttributeNone },
     { TIZEN_CALENDAR_ITEM_ORGANIZER, getPropertyOrganizer,
       setPropertyOrganizer, kJSPropertyAttributeNone },
     { TIZEN_CALENDAR_ITEM_VISIBILITY, getPropertyVisibility,
@@ -109,22 +86,26 @@ JSStaticValue JSCalendarItemProperties::m_property[] = {
       setPropertyAlarms, kJSPropertyAttributeNone },
     { TIZEN_CALENDAR_ITEM_CATEGORIES, getPropertyCategories,
       setPropertyCategories, kJSPropertyAttributeNone },
-    // Event Properties
-    { TIZEN_CALENDAR_EVENT_DURATION, getPropertyDuration,
+    { TIZEN_CALENDAR_ITEM_DURATION, getPropertyDuration,
       setPropertyDuration, kJSPropertyAttributeNone },
-    { TIZEN_CALENDAR_EVENT_IS_ALL_DAY, getPropertyIsAllDay,
+    { TIZEN_CALENDAR_ITEM_IS_ALL_DAY, getPropertyIsAllDay,
       setPropertyIsAllDay, kJSPropertyAttributeNone },
-    { TIZEN_CALENDAR_EVENT_ATTENDEES, getPropertyAttendees,
+    { TIZEN_CALENDAR_ITEM_ATTENDEES, getPropertyAttendees,
       setPropertyAttendees, kJSPropertyAttributeNone },
     { TIZEN_CALENDAR_EVENT_RECURRENCE_RULE, getPropertyRecurrenceRule,
       setPropertyRecurrenceRule, kJSPropertyAttributeNone },
     { TIZEN_CALENDAR_EVENT_AVAILABILITY, getPropertyAvailability,
       setPropertyAvailability, kJSPropertyAttributeNone },
-    // Task Properties
-    { TIZEN_CALENDAR_TASK_DUEDATE, getPropertyDueDate,
+    { TIZEN_CALENDAR_TASK_DUE_DATE, getPropertyDueDate,
       setPropertyDueDate, kJSPropertyAttributeNone },
-    { TIZEN_CALENDAR_TASK_PRIORITY, getPropertyPriority,
+    { TIZEN_CALENDAR_TASK_COMPLETED_DATE, getPropertyCompletedDate,
+      setPropertyCompletedDate, kJSPropertyAttributeNone },
+    { TIZEN_CALENDAR_TASK_PROGRESS, getPropertyProgress,
+      setPropertyProgress, kJSPropertyAttributeNone },
+    { TIZEN_CALENDAR_ITEM_PRIORITY, getPropertyPriority,
       setPropertyPriority, kJSPropertyAttributeNone },
+    { TIZEN_CALENDAR_EVENT_END_DATE, getPropertyEndDate,
+      setPropertyEndDate, kJSPropertyAttributeNone },
 
     { 0, 0, 0, 0 }
 };
@@ -232,6 +213,10 @@ bool JSCalendarItemProperties::setPropertyDescription(JSContextRef context,
     LogDebug("entered");
     Try
     {
+        if (!JSValueIsString(context, value)) {
+            Throw(InvalidArgumentException);
+        }
+
         Converter converter(context);
         CalendarEventPtr event = getPrivateObject(object);
         std::string description = converter.toString(value);
@@ -241,8 +226,9 @@ bool JSCalendarItemProperties::setPropertyDescription(JSContextRef context,
     Catch(Exception)
     {
         LogWarning("trying to set incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+
     return false;
 }
 
@@ -274,6 +260,10 @@ bool JSCalendarItemProperties::setPropertySummary(JSContextRef context,
     LogDebug("entered");
     Try
     {
+        if (!JSValueIsString(context, value)) {
+            Throw(InvalidArgumentException);
+        }
+
         Converter converter(context);
         CalendarEventPtr event = getPrivateObject(object);
         std::string subject = converter.toString(value);
@@ -283,8 +273,9 @@ bool JSCalendarItemProperties::setPropertySummary(JSContextRef context,
     Catch(Exception)
     {
         LogWarning("trying to set incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+
     return false;
 }
 
@@ -298,11 +289,11 @@ JSValueRef JSCalendarItemProperties::getPropertyStartTime(JSContextRef context,
     {
         CalendarItemPropertiesPrivObject *privateObject =
             static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
-        Converter converter(context);
+        TimeUtilConverter timeConverter(privateObject->getContext());
         CalendarEventPtr event = privateObject->getObject();
 
-        // Use the global context saved in the event struct.
-        return JSTZDate::createJSObject(privateObject->getContext(), event->getStartTime(), event->getTimeZone());
+        LogInfo("start time before converted to TZDate: "<<event->getStartTime()<<", time zone: "<<event->getTimeZone());
+        return timeConverter.FromUTCTimeTToTZDate(event->getStartTime(), event->getTimeZone());
     }
     Catch(Exception)
     {
@@ -320,15 +311,20 @@ bool JSCalendarItemProperties::setPropertyStartTime(JSContextRef context,
     LogDebug("entered");
     Try
     {
+        if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
+            Throw(InvalidArgumentException);
+        }
+
         CalendarEventPtr event = getPrivateObject(object);
         TimeUtilConverter converter(context);
+        std::time_t duration = event->getEndTime() - event->getStartTime();
+        if (duration<0) {
+            duration = 0;
+        }
+
         std::time_t startTime = converter.toTZDateTimeT(value);
-        std::time_t duration = 0;
-        duration = (event->getEndTime() - event->getStartTime());
-        if (duration<0)
-            duration = 3600; // default 1 hour.
-        event->setEndTime(startTime + duration);
         event->setStartTime(startTime);
+        event->setEndTime(startTime + duration);
 
         std::string timeZone = converter.getPropertiesInTZDate(value).timezone;
         event->setTimeZone(timeZone);
@@ -337,8 +333,9 @@ bool JSCalendarItemProperties::setPropertyStartTime(JSContextRef context,
     Catch(Exception)
     {
         LogWarning("trying to set incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+
     return false;
 }
 
@@ -370,6 +367,10 @@ bool JSCalendarItemProperties::setPropertyLocation(JSContextRef context,
     LogDebug("entered");
     Try
     {
+        if (!JSValueIsString(context, value)) {
+            Throw(InvalidArgumentException);
+        }
+
         Converter converter(context);
         CalendarEventPtr event = getPrivateObject(object);
         std::string location = converter.toString(value);
@@ -379,8 +380,9 @@ bool JSCalendarItemProperties::setPropertyLocation(JSContextRef context,
     Catch(Exception)
     {
         LogWarning("trying to set incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+
     return false;
 }
 
@@ -392,10 +394,11 @@ JSValueRef JSCalendarItemProperties::getPropertyCategories(JSContextRef context,
     LogDebug("entered");
     Try
     {
+        Converter converter(context);
         CalendarEventPtr event = getPrivateObject(object);
         CategoryListPtr categories = event->getCategories();
         if (categories) {
-            return JSCategoryArray::createArray(context, categories);
+            return converter.toJSValueRef(*categories);
         }
     }
     Catch(Exception)
@@ -423,8 +426,9 @@ bool JSCalendarItemProperties::setPropertyCategories(JSContextRef context,
     Catch(Exception)
     {
         LogWarning("trying to set incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+
     return false;
 }
 
@@ -459,10 +463,10 @@ bool JSCalendarItemProperties::setPropertyStatus(JSContextRef context,
     CalendarEventPtr event(NULL);
     Try
     {
-        if (!JSValueIsNumber(context, value)) {
-            TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
-            return false;
+        if (!JSValueIsString(context, value)) {
+            Throw(InvalidArgumentException);
         }
+
         event = getPrivateObject(object);
         CalendarConverterFactory::ConverterType converter =
             CalendarConverterFactory::getConverter(context);
@@ -471,23 +475,13 @@ bool JSCalendarItemProperties::setPropertyStatus(JSContextRef context,
         event->setStatus(status);
         return true;
     }
-    Catch(ConversionException)
-    {
-        LogWarning("trying to set incorrect value");
-        event->setStatus(CalendarEvent::INVALID_STATUS);
-        return true;
-    }
-    Catch(InvalidArgumentException)
-    {
-        LogWarning("trying to set incorrect value");
-        event->setStatus(CalendarEvent::INVALID_STATUS);
-        return true;
-    }
     Catch(Exception)
     {
         LogWarning("trying to set incorrect value");
+        event->setStatus(CalendarEvent::INVALID_STATUS);
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+
     return false;
 }
 
@@ -509,9 +503,11 @@ JSValueRef JSCalendarItemProperties::getPropertyAlarms(JSContextRef context,
         }
         for( unsigned int i=0; i<event->getAlarmsTick().size(); i++) {
             EventAlarmPtr alarm(new EventAlarm());
-            alarm->setMinutes( event->getAlarmsTick().at(i) ); // Default unit is minute.
-            alarm->setDays(0);
-            std::vector<int> methodVector;
+            TizenApis::Api::TimeUtil::DurationProperties duration;
+            duration.unit = TizenApis::Api::TimeUtil::MINUTES_UNIT;
+            duration.length = event->getAlarmsTick().at(i);
+            alarm->setDuration(duration); // Default unit is minute.
+            std::vector<CalendarEvent::EventAlarmType> methodVector;
             methodVector.push_back(event->getAlarmsType().at(i)); // Only one alarm type is saved.
             alarm->setMethods(methodVector);
             alarm->setTimeZone(event->getTimeZone());
@@ -549,32 +545,45 @@ bool JSCalendarItemProperties::setPropertyAlarms(JSContextRef context,
         // Set the multiple alarms.
         for( unsigned int i=0; i<alarms->size(); i++) {
             EventAlarmPtr theAlarm = alarms->at(i);
-            alarmsType.push_back(converter->toEventAlarmType(theAlarm->getMethods().at(0)));
+            alarmsType.push_back(theAlarm->getMethods().at(0));
             if( 0 < theAlarm->getAbsoluteDate() ) {
-                alarmsTick.push_back(theAlarm->getAbsoluteDate()/60); //
+                alarmsTick.push_back(theAlarm->getAbsoluteDate()/60);
             } else {
-                alarmsTick.push_back(theAlarm->getMinutes() + theAlarm->getDays()*24*60);
+                long tick;
+                long length = theAlarm->getDuration().length;
+                switch(theAlarm->getDuration().unit) {
+                case TizenApis::Api::TimeUtil::MSECS_UNIT:
+                    tick = length/(1000*60);
+                    break;
+                case TizenApis::Api::TimeUtil::SECONDS_UNIT:
+                    tick = length/60;
+                    break;
+                case TizenApis::Api::TimeUtil::MINUTES_UNIT:
+                    tick = length;
+                    break;
+                case TizenApis::Api::TimeUtil::HOURS_UNIT:
+                    tick = length*60;
+                    break;
+                case TizenApis::Api::TimeUtil::DAYS_UNIT:
+                    tick = length*60*24;
+                    break;
+                default:
+                    ThrowMsg(ConversionException, "Wrong alarm unit type.");
+                }
+
+                alarmsTick.push_back(tick);
             }
         }
         event->setAlarmsType(alarmsType);
         event->setAlarmsTick(alarmsTick);
         return true;
     }
-    Catch(ConversionException)
-    {
-        LogWarning("trying to set incorrect value");
-        return true;
-    }
-    Catch(InvalidArgumentException)
-    {
-        LogWarning("trying to set incorrect value");
-        return true;
-    }
     Catch(Exception)
     {
-        LogError("Error during setting a value");
+        LogWarning("trying to set incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+
     return false;
 }
 
@@ -606,6 +615,10 @@ bool JSCalendarItemProperties::setPropertyOrganizer(JSContextRef context,
     LogDebug("entered");
     Try
     {
+        if (!JSValueIsString(context, value)) {
+            Throw(InvalidArgumentException);
+        }
+
         Converter converter(context);
         CalendarEventPtr event = getPrivateObject(object);
         std::string organizer = converter.toString(value);
@@ -615,8 +628,9 @@ bool JSCalendarItemProperties::setPropertyOrganizer(JSContextRef context,
     Catch(Exception)
     {
         LogWarning("trying to set incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+
     return false;
 }
 
@@ -651,10 +665,10 @@ bool JSCalendarItemProperties::setPropertyVisibility(JSContextRef context,
     CalendarEventPtr event(NULL);
     Try
     {
-        if (!JSValueIsNumber(context, value)) {
+        if (!JSValueIsString(context, value)) {
             Throw(InvalidArgumentException);
-            return false;
         }
+
         event = getPrivateObject(object);
         CalendarConverterFactory::ConverterType converter =
             CalendarConverterFactory::getConverter(context);
@@ -663,71 +677,17 @@ bool JSCalendarItemProperties::setPropertyVisibility(JSContextRef context,
         event->setVisibility(visibility);
         return true;
     }
-    Catch(ConversionException)
-    {
-        LogWarning("trying to set incorrect value");
-        event->setVisibility(CalendarEvent::INVALID_VISIBILITY);
-        return true;
-    }
-    Catch(InvalidArgumentException)
-    {
-        LogWarning("trying to set incorrect value");
-        event->setVisibility(CalendarEvent::INVALID_VISIBILITY);
-        return true;
-    }
     Catch(Exception)
     {
         LogError("Error during setting a value");
+        event->setVisibility(CalendarEvent::INVALID_VISIBILITY);
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
-    return false;
-}
-
-JSValueRef JSCalendarItemProperties::getPropertyLatitude(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    Try
-    {
-        Converter converter(context);
-        CalendarEventPtr event = getPrivateObject(object);
-        double latitude = event->getLatitude();
-        return converter.toJSValueRef(latitude);
-    }
-    Catch(Exception)
-    {
-        LogWarning("trying to get incorrect value");
-    }
-    return JSValueMakeUndefined(context);
 
-}
-
-bool JSCalendarItemProperties::setPropertyLatitude(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef value,
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    Try
-    {
-        Converter converter(context);
-        CalendarEventPtr event = getPrivateObject(object);
-        double latitude = converter.toDouble(value);
-        event->setLatitude(latitude);
-        return true;
-    }
-    Catch(Exception)
-    {
-        LogWarning("trying to set incorrect value");
-    }
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     return false;
 }
 
-JSValueRef JSCalendarItemProperties::getPropertyLongitude(JSContextRef context,
+JSValueRef JSCalendarItemProperties::getPropertyGeolocation(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName,
         JSValueRef* exception)
@@ -735,43 +695,44 @@ JSValueRef JSCalendarItemProperties::getPropertyLongitude(JSContextRef context,
     LogDebug("entered");
     Try
     {
-        Converter converter(context);
+        CalendarConverter converter(context);
         CalendarEventPtr event = getPrivateObject(object);
-        double longitude = event->getLongitude();
-        return converter.toJSValueRef(longitude);
+        CalendarItemGeoPtr geoInfo = event->getGeolocation();
+
+        return converter.toJSValueRef(geoInfo);
     }
     Catch(Exception)
     {
         LogWarning("trying to get incorrect value");
     }
-    return JSValueMakeUndefined(context);
 
+    return JSValueMakeUndefined(context);
 }
 
-bool JSCalendarItemProperties::setPropertyLongitude(JSContextRef context,
+bool JSCalendarItemProperties::setPropertyGeolocation(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName,
         JSValueRef value,
         JSValueRef* exception)
 {
     LogDebug("entered");
+    CalendarEventPtr event(NULL);
     Try
     {
-        Converter converter(context);
-        CalendarEventPtr event = getPrivateObject(object);
-        double longitude = converter.toDouble(value);
-        event->setLongitude(longitude);
+        event = getPrivateObject(object);
+        CalendarConverter converter(context);
+        event->setGeolocation(converter.toGeolocation(value));
         return true;
     }
     Catch(Exception)
     {
         LogWarning("trying to set incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+
     return false;
 }
 
-// event properties
 JSValueRef JSCalendarItemProperties::getPropertyDuration(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName,
@@ -788,9 +749,6 @@ JSValueRef JSCalendarItemProperties::getPropertyDuration(JSContextRef context,
         TimeUtilConverter converter(priv->getContext());
         long length = event->getEndTime() - event->getStartTime(); // in seconds only
         LogDebug("event->getStartTime():"<< event->getStartTime() << ", length:" << length);
-        JSValueRef temp = converter.makeMillisecondDurationObject( length*1000 );
-        LogDebug("1");
-        LogDebug("temp : " << temp);
         return converter.makeMillisecondDurationObject( length*1000 );
     }
     Catch(Exception)
@@ -811,8 +769,8 @@ bool JSCalendarItemProperties::setPropertyDuration(JSContextRef context,
     {
         CalendarEventPtr event = getPrivateObject(object);
         TimeUtilConverter converter(context);
-        long length = converter.getDurationLength(value, exception);
-        int unit = converter.getDurationUnit(value, exception);
+        long length = converter.getDurationLength(value);
+        int unit = converter.getDurationUnit(value);
         if (length < 0) {
             TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
             return false;
@@ -837,8 +795,9 @@ bool JSCalendarItemProperties::setPropertyDuration(JSContextRef context,
     Catch(Exception)
     {
         LogWarning("trying to set incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+
     return false;
 }
 
@@ -885,9 +844,9 @@ bool JSCalendarItemProperties::setPropertyRecurrenceRule(JSContextRef context,
     Catch(Exception)
     {
         LogWarning("trying to set incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     return false;
 }
 
@@ -919,6 +878,10 @@ bool JSCalendarItemProperties::setPropertyIsAllDay(JSContextRef context,
 {
     Try
     {
+        if (!JSValueIsBoolean(context, value)) {
+            Throw(InvalidArgumentException);
+        }
+
         CalendarEventPtr event = getPrivateObject(object);
         Converter converter(context);
         event->setIsAllDay(converter.toBool(value));
@@ -927,7 +890,9 @@ bool JSCalendarItemProperties::setPropertyIsAllDay(JSContextRef context,
     Catch(Exception)
     {
         LogWarning("trying to get incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
+
     return false;
 }
 
@@ -962,10 +927,10 @@ bool JSCalendarItemProperties::setPropertyAvailability(JSContextRef context,
     CalendarEventPtr event(NULL);
     Try
     {
-        if (!JSValueIsNumber(context, value)) {
-            TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
-            return false;
+        if (!JSValueIsString(context, value)) {
+            Throw(InvalidArgumentException);
         }
+
         event = getPrivateObject(object);
         CalendarConverterFactory::ConverterType converter =
             CalendarConverterFactory::getConverter(context);
@@ -974,23 +939,13 @@ bool JSCalendarItemProperties::setPropertyAvailability(JSContextRef context,
         event->setAvailability(availability);
         return true;
     }
-    Catch(ConversionException)
-    {
-        LogWarning("trying to set incorrect value");
-        event->setAvailability(CalendarEvent::INVALID_AVAILABILITY);
-        return true;
-    }
-    Catch(InvalidArgumentException)
-    {
-        LogWarning("trying to set incorrect value");
-        event->setAvailability(CalendarEvent::INVALID_AVAILABILITY);
-        return true;
-    }
     Catch(Exception)
     {
         LogError("Error during setting a value");
+        event->setAvailability(CalendarEvent::INVALID_AVAILABILITY);
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+
     return false;
 }
 
@@ -1041,13 +996,13 @@ bool JSCalendarItemProperties::setPropertyAttendees(JSContextRef context,
     }
     Catch(Exception)
     {
-        LogWarning("trying to set incorrect value");
+        LogWarning("trying to set incorrect attendee value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+
     return false;
 }
 
-// task properties
 JSValueRef JSCalendarItemProperties::getPropertyDueDate(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName,
@@ -1062,7 +1017,6 @@ JSValueRef JSCalendarItemProperties::getPropertyDueDate(JSContextRef context,
         if(CalendarEvent::TASK_TYPE != task->getCalendarType()) {
             return JSValueMakeUndefined(context);
         }
-
         if (!task) {
             Throw(NullPointerException);
         }
@@ -1087,12 +1041,18 @@ bool JSCalendarItemProperties::setPropertyDueDate(JSContextRef context,
         JSValueRef* exception)
 {
     LogDebug("entered");
-    CalendarEventPtr task = getPrivateObject(object);
     Try
     {
+        CalendarEventPtr task = getPrivateObject(object);
         if (!task) {
             Throw(NullPointerException);
         }
+        if(CalendarEvent::TASK_TYPE != task->getCalendarType()) {
+            Throw(InvalidArgumentException);
+        }
+        if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
+            Throw(InvalidArgumentException);
+        }
 
         TimeUtilConverter converter(context);
         std::time_t dueDate = converter.toTZDateTimeT(value);
@@ -1108,10 +1068,135 @@ bool JSCalendarItemProperties::setPropertyDueDate(JSContextRef context,
     Catch(Exception)
     {
         LogWarning("trying to set incorrect value");
-        if (task) {
-            task->setEndTime(0);
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+    }
+
+    return false;
+}
+
+JSValueRef JSCalendarItemProperties::getPropertyCompletedDate(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        CalendarItemPropertiesPrivObject *privateObject =
+            static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
+        CalendarEventPtr task = privateObject->getObject();
+        if(CalendarEvent::TASK_TYPE != task->getCalendarType()) {
+            return JSValueMakeUndefined(context);
+        }
+        if (!task) {
+            Throw(NullPointerException);
+        }
+        if (task->getEndTime() != 0) {
+            // Use the global context saved in the event struct.
+            return JSTZDate::createJSObject(privateObject->getContext(), task->getEndTime(), task->getTimeZone());
+        } else {
+            return JSValueMakeUndefined(context);
+        }
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+bool JSCalendarItemProperties::setPropertyCompletedDate(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef value,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        CalendarEventPtr task = getPrivateObject(object);
+        if (!task) {
+            Throw(NullPointerException);
+        }
+        if(CalendarEvent::TASK_TYPE != task->getCalendarType()) {
+            Throw(InvalidArgumentException);
+        }
+        if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
+            Throw(InvalidArgumentException);
+        }
+
+        TimeUtilConverter converter(context);
+        std::time_t completedDate = converter.toTZDateTimeT(value);
+
+        task->setEndTime(completedDate);
+
+        if( task->getTimeZone().empty() ) {
+            std::string timeZone = converter.getPropertiesInTZDate(value).timezone;
+            task->setTimeZone(timeZone);
+        }
+        return true;
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to set incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+    }
+
+    return false;
+}
+
+JSValueRef JSCalendarItemProperties::getPropertyProgress(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        CalendarEventPtr task = getPrivateObject(object);
+        if(CalendarEvent::TASK_TYPE != task->getCalendarType()) {
+            return JSValueMakeUndefined(context);
+        }
+
+        Converter converter(context);
+        return converter.toJSValueRef(task->getProgress());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+bool JSCalendarItemProperties::setPropertyProgress(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef value,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        if (!JSValueIsNumber(context, value)) {
+            Throw(InvalidArgumentException);
         }
+
+        CalendarEventPtr task = getPrivateObject(object);
+        if(CalendarEvent::TASK_TYPE != task->getCalendarType()) {
+            return JSValueMakeUndefined(context);
+        }
+
+        Converter converter(context);
+        int progress = converter.toInt(value);
+        task->setProgress(progress);
+        return true;
     }
+    Catch(Exception)
+    {
+        LogWarning("trying to set incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+    }
+
     return false;
 }
 
@@ -1125,16 +1210,16 @@ JSValueRef JSCalendarItemProperties::getPropertyPriority(JSContextRef context,
     {
         CalendarConverterFactory::ConverterType converter =
             CalendarConverterFactory::getConverter(context);
-        CalendarEventPtr task = getPrivateObject(object);
-        if (!task) {
+        CalendarEventPtr item = getPrivateObject(object);
+        if (!item) {
             Throw(NullPointerException);
         }
-        if(CalendarEvent::LOW_PRIORITY <= task->getPriority() || 
-            CalendarEvent::HIGH_PRIORITY >= task->getPriority()) {
+        if(CalendarEvent::LOW_PRIORITY <= item->getPriority() ||
+            CalendarEvent::HIGH_PRIORITY >= item->getPriority()) {
             return JSValueMakeUndefined(context);
         }   
             
-        std::string priority = converter->toTizenValue(task->getPriority());
+        std::string priority = converter->toTizenValue(item->getPriority());
         return converter->toJSValueRef(priority);
     }
     Catch(Exception)
@@ -1151,26 +1236,101 @@ bool JSCalendarItemProperties::setPropertyPriority(JSContextRef context,
         JSValueRef* exception)
 {
     LogDebug("entered");
-    CalendarEventPtr task = getPrivateObject(object);
+    CalendarEventPtr item = getPrivateObject(object);
     Try
     {
+
+        if (!JSValueIsString(context, value)) {
+            Throw(InvalidArgumentException);
+        }
+
         CalendarConverterFactory::ConverterType converter =
             CalendarConverterFactory::getConverter(context);
-        if (!task) {
-            Throw(NullPointerException);
-        }
         CalendarEvent::TaskPriority priority =
             converter->toTaskPriority(converter->toString(value));
-        task->setPriority(priority);
+        item->setPriority(priority);
         return true;
     }
     Catch(Exception)
     {
         LogWarning("trying to set incorrect value");
-        if (task) {
-            task->setPriority(CalendarEvent::INVALID_PRIORITY);
+        if (item) {
+            item->setPriority(CalendarEvent::INVALID_PRIORITY);
+        }
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+    }
+
+    return false;
+}
+
+JSValueRef JSCalendarItemProperties::getPropertyEndDate(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        CalendarItemPropertiesPrivObject *privateObject =
+            static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
+        CalendarEventPtr event = privateObject->getObject();
+        if(CalendarEvent::EVENT_TYPE != event->getCalendarType()) {
+            return JSValueMakeUndefined(context);
+        }
+        if (!event) {
+            Throw(NullPointerException);
+        }
+        if (event->getEndTime() != 0) {
+            // Use the global context saved in the event struct.
+            return JSTZDate::createJSObject(privateObject->getContext(), event->getEndTime(), event->getTimeZone());
+        } else {
+            return JSValueMakeUndefined(context);
         }
     }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+bool JSCalendarItemProperties::setPropertyEndDate(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef value,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        CalendarEventPtr event = getPrivateObject(object);
+        if (!event) {
+            Throw(NullPointerException);
+        }
+        if(CalendarEvent::EVENT_TYPE != event->getCalendarType()) {
+            Throw(InvalidArgumentException);
+        }
+        if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
+            Throw(InvalidArgumentException);
+        }
+
+        TimeUtilConverter converter(context);
+        std::time_t endDate = converter.toTZDateTimeT(value);
+
+        event->setEndTime(endDate);
+
+        if( event->getTimeZone().empty() ) {
+            std::string timeZone = converter.getPropertiesInTZDate(value).timezone;
+            event->setTimeZone(timeZone);
+        }
+        return true;
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to set incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+    }
+
     return false;
 }
 
index 944d04d..5eff397 100755 (executable)
@@ -26,6 +26,32 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
+// Common CalendarItemProperties
+#define TIZEN_CALENDAR_ITEM_DESCRIPTION "description"
+#define TIZEN_CALENDAR_ITEM_SUMMARY "summary"
+#define TIZEN_CALENDAR_ITEM_IS_ALL_DAY "isAllDay"
+#define TIZEN_CALENDAR_ITEM_START_DATE "startDate"
+#define TIZEN_CALENDAR_ITEM_DURATION "duration"
+#define TIZEN_CALENDAR_ITEM_LOCATION "location"
+#define TIZEN_CALENDAR_ITEM_GEOLOCATION "geolocation"
+#define TIZEN_CALENDAR_ITEM_ORGANIZER "organizer"
+#define TIZEN_CALENDAR_ITEM_VISIBILITY "visibility"
+#define TIZEN_CALENDAR_ITEM_STATUS "status"
+#define TIZEN_CALENDAR_ITEM_PRIORITY  "priority"
+#define TIZEN_CALENDAR_ITEM_ALARMS "alarms"
+#define TIZEN_CALENDAR_ITEM_CATEGORIES "categories"
+#define TIZEN_CALENDAR_ITEM_ATTENDEES "attendees"
+
+// CalendarTaskProperties
+#define TIZEN_CALENDAR_TASK_DUE_DATE  "dueDate"
+#define TIZEN_CALENDAR_TASK_COMPLETED_DATE  "completedDate"
+#define TIZEN_CALENDAR_TASK_PROGRESS "progress"
+
+// CalendarEventProperties
+#define TIZEN_CALENDAR_EVENT_END_DATE  "endDate"
+#define TIZEN_CALENDAR_EVENT_AVAILABILITY "availability"
+#define TIZEN_CALENDAR_EVENT_RECURRENCE_RULE "recurrenceRule"
+
 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::CalendarEventPtr, 
        WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarItemPropertiesPrivObject;
 
@@ -118,20 +144,11 @@ class JSCalendarItemProperties
             JSStringRef propertyName,
             JSValueRef value,
             JSValueRef* exception);
-    static JSValueRef getPropertyLatitude(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName,
-            JSValueRef* exception);
-    static bool setPropertyLatitude(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName,
-            JSValueRef value,
-            JSValueRef* exception);
-    static JSValueRef getPropertyLongitude(JSContextRef context,
+    static JSValueRef getPropertyGeolocation(JSContextRef context,
             JSObjectRef object,
             JSStringRef propertyName,
             JSValueRef* exception);
-    static bool setPropertyLongitude(JSContextRef context,
+    static bool setPropertyGeolocation(JSContextRef context,
             JSObjectRef object,
             JSStringRef propertyName,
             JSValueRef value,
@@ -181,7 +198,6 @@ class JSCalendarItemProperties
             JSStringRef propertyName,
             JSValueRef value,
             JSValueRef* exception);
-    // event properties
     static JSValueRef getPropertyIsAllDay(JSContextRef context,
             JSObjectRef object,
             JSStringRef propertyName,
@@ -227,7 +243,6 @@ class JSCalendarItemProperties
             JSStringRef propertyName,
             JSValueRef value,
             JSValueRef* exception);
-    // Task properties
     static JSValueRef getPropertyDueDate(JSContextRef context,
             JSObjectRef object,
             JSStringRef propertyName,
@@ -237,6 +252,24 @@ class JSCalendarItemProperties
             JSStringRef propertyName,
             JSValueRef value,
             JSValueRef* exception);
+    static JSValueRef getPropertyCompletedDate(JSContextRef context,
+            JSObjectRef object,
+            JSStringRef propertyName,
+            JSValueRef* exception);
+    static bool setPropertyCompletedDate(JSContextRef context,
+            JSObjectRef object,
+            JSStringRef propertyName,
+            JSValueRef value,
+            JSValueRef* exception);
+    static JSValueRef getPropertyProgress(JSContextRef context,
+            JSObjectRef object,
+            JSStringRef propertyName,
+            JSValueRef* exception);
+    static bool setPropertyProgress(JSContextRef context,
+            JSObjectRef object,
+            JSStringRef propertyName,
+            JSValueRef value,
+            JSValueRef* exception);
     static JSValueRef getPropertyPriority(JSContextRef context,
             JSObjectRef object,
             JSStringRef propertyName,
@@ -246,6 +279,15 @@ class JSCalendarItemProperties
             JSStringRef propertyName,
             JSValueRef value,
             JSValueRef* exception);
+    static JSValueRef getPropertyEndDate(JSContextRef context,
+            JSObjectRef object,
+            JSStringRef propertyName,
+            JSValueRef* exception);
+    static bool setPropertyEndDate(JSContextRef context,
+            JSObjectRef object,
+            JSStringRef propertyName,
+            JSValueRef value,
+            JSValueRef* exception);
 };
 
 }
index 2333469..d57df1c 100755 (executable)
@@ -39,9 +39,9 @@ using namespace WrtDeviceApis::Commons;
 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"
-#define TIZEN_CALENDAR_MANAGER_ATTRIBUTENAME "calendar"
 
 namespace TizenApis {
 namespace Tizen1_0 {
@@ -115,7 +115,7 @@ JSValueRef JSCalendarManager::getCalendars(JSContextRef context,
         static_cast<CalendarManagerPrivObject*>(JSObjectGetPrivate(thisObject));
     if (NULL == privateObject) {
         LogError("private object is null");
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR);
     }
 
     JSContextRef globalContext = privateObject->getContext();
@@ -124,16 +124,15 @@ JSValueRef JSCalendarManager::getCalendars(JSContextRef context,
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-    if (argumentCount < 2) {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
-    }
-
-    JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
-    cbm->setObject(thisObject);
-
     CalendarConverter converter(context);
 
     Try {
+        if (argumentCount<2 || argumentCount>3) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        }
+
+        JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+
         if (argumentCount > 2) {
             cbm->setOnError(converter.toFunctionOrNull(arguments[2]));
         }
@@ -141,8 +140,7 @@ JSValueRef JSCalendarManager::getCalendars(JSContextRef context,
 
         CalendarEvent::CalendarType calendarType = CalendarEvent::EVENT_TYPE;
         if (!JSValueIsString(context, arguments[0])) {
-            LogError("Invalid type of type parameter.");
-            Throw(InvalidArgumentException);
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         } else {
             calendarType = converter.toCalendarType(converter.toString(arguments[0]));
         }
@@ -154,14 +152,25 @@ JSValueRef JSCalendarManager::getCalendars(JSContextRef context,
         privateObject->getObject()->getCalendars(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(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(Exception) {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+    Catch(ConversionException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(Exception)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
     return JSValueMakeNull(context);
@@ -178,7 +187,7 @@ JSValueRef JSCalendarManager::getDefaultCalendar(JSContextRef context,
         static_cast<CalendarManagerPrivObject*>(JSObjectGetPrivate(thisObject));
     if (NULL == privateObject) {
         LogError("private object is null");
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR);
     }
 
     JSContextRef globalContext = privateObject->getContext();
@@ -187,16 +196,15 @@ JSValueRef JSCalendarManager::getDefaultCalendar(JSContextRef context,
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-    if (argumentCount == 0) {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
-    }
-
     Try {
+        if (argumentCount!=1) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        }
+
         CalendarConverter converter(context);
         CalendarEvent::CalendarType calendarType = CalendarEvent::EVENT_TYPE;
         if (!JSValueIsString(context, arguments[0])) {
-            LogError("Invalid type of type parameter.");
-            Throw(InvalidArgumentException);
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         } else {
             calendarType = converter.toCalendarType(converter.toString(arguments[0]));
         }
@@ -211,18 +219,35 @@ JSValueRef JSCalendarManager::getDefaultCalendar(JSContextRef context,
                 CalendarConverterFactory::getConverter(globalContext); // should be global!
             return converter->toJSValueRefCalendar(dplEvent->getCalendar());
         } else {
-            Throw(UnknownException);
+            ThrowMsg(UnknownException, "Updating failed by unkown reason.");
         }
     }
-    Catch(ConversionException) {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+    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(InvalidArgumentException) {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+    Catch(ConversionException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
     }
-    Catch(Exception) {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+    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);
 }
 
index 8fb639a..aafe67f 100755 (executable)
@@ -72,13 +72,13 @@ typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar
 #define TIZEN_CALENDAR_PROPERTY_ROOM_TYPE           "ROOM"
 #define TIZEN_CALENDAR_PROPERTY_UNKNOWN_TYPE        "UNKNOWN"
 
-#define TIZEN_CALENDAR_PROPERTY_NO_RECURRENCE       "NO_RECURRENCE"
+//#define TIZEN_CALENDAR_PROPERTY_NO_RECURRENCE       "NO_RECURRENCE"
 #define TIZEN_CALENDAR_PROPERTY_DAILY_RECURRENCE    "DAILY"
 #define TIZEN_CALENDAR_PROPERTY_WEEKLY_RECURRENCE   "WEEKLY"
 #define TIZEN_CALENDAR_PROPERTY_MONTHLY_RECURRENCE  "MONTHLY"
 #define TIZEN_CALENDAR_PROPERTY_YEARLY_RECURRENCE   "YEARLY"
 
-#define TIZEN_CALENDAR_PROPERTY_NO_ALARM            "NO_ALARM"
+//#define TIZEN_CALENDAR_PROPERTY_NO_ALARM            "NO_ALARM"
 #define TIZEN_CALENDAR_PROPERTY_SILENT_ALARM        "SILENT"
 #define TIZEN_CALENDAR_PROPERTY_SOUND_ALARM         "SOUND"
 
index 5564a63..76158ba 100755 (executable)
@@ -16,7 +16,7 @@
 
 
 #include <ctime>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSUtils.h>
@@ -39,10 +39,6 @@ namespace Calendar {
 
 #define TIZEN_CALENDAR_TASK_ATTRIBUTENAME "CalendarTask"
 
-#define TIZEN_CALENDAR_TASK_ID "id"
-#define TIZEN_CALENDAR_TASK_LASTMODIFIEDDATE "lastModificationDate"
-
-
 JSClassDefinition JSCalendarTask::m_classInfo = {
     0,
     kJSClassAttributeNone,
@@ -67,7 +63,7 @@ JSStaticValue JSCalendarTask::m_property[] = {
     //EventProperties
     { TIZEN_CALENDAR_TASK_ID, getPropertyId,
       NULL, kJSPropertyAttributeReadOnly },
-    { TIZEN_CALENDAR_TASK_LASTMODIFIEDDATE, getPropertyLastModifiedDate,
+    { TIZEN_CALENDAR_TASK_LAST_MODIFICATION_DATE, getPropertyLastModificationDate,
       NULL, kJSPropertyAttributeReadOnly },
 
     { 0, 0, 0, 0 }
@@ -170,7 +166,7 @@ JSValueRef JSCalendarTask::getPropertyId(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSCalendarTask::getPropertyLastModifiedDate(JSContextRef context,
+JSValueRef JSCalendarTask::getPropertyLastModificationDate(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName,
         JSValueRef* exception)
index 8ac4d36..7bfcf35 100755 (executable)
@@ -26,6 +26,9 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
+#define TIZEN_CALENDAR_TASK_ID "id"
+#define TIZEN_CALENDAR_TASK_LAST_MODIFICATION_DATE "lastModificationDate"
+
 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::CalendarEventPtr,
        WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarTaskPrivObject;
 
@@ -86,7 +89,7 @@ class JSCalendarTask
             JSObjectRef object,
             JSStringRef propertyName,
             JSValueRef* exception);
-    static JSValueRef getPropertyLastModifiedDate(JSContextRef context,
+    static JSValueRef getPropertyLastModificationDate(JSContextRef context,
             JSObjectRef object,
             JSStringRef propertyName,
             JSValueRef* exception);
index fee4c81..1d0509c 100755 (executable)
 
 
 #include "JSEventAlarm.h"
-#include <dpl/log.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;
 
 namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
-#define TIZEN_ALARM_ATTRIBUTENAME "Alarm"
-#define TIZEN_ABSOLUTE_DATE "absoluteDate"
-#define TIZEN_MINUTES "minutes"
-#define TIZEN_DAYS "days"
-#define TIZEN_METHODS "methods"
+#define TIZEN_CALENDAR_ALARM_ATTRIBUTENAME "CalendarAlarm"
 
 JSClassDefinition JSEventAlarm::m_classInfo = {
     0,
     kJSClassAttributeNone,
-    TIZEN_ALARM_ATTRIBUTENAME,
+    TIZEN_CALENDAR_ALARM_ATTRIBUTENAME,
     0,
     m_property,
     NULL, //m_function,
@@ -56,10 +56,9 @@ JSClassDefinition JSEventAlarm::m_classInfo = {
 };
 
 JSStaticValue JSEventAlarm::m_property[] = {
-    { TIZEN_ABSOLUTE_DATE, getProperty, setProperty, kJSPropertyAttributeNone },
-    { TIZEN_MINUTES, getProperty, setProperty, kJSPropertyAttributeNone },
-    { TIZEN_DAYS, getProperty, setProperty, kJSPropertyAttributeNone },
-    { TIZEN_METHODS, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_CALENDAR_ALARM_ABSOLUTE_DATE, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_CALENDAR_ALARM_BEFORE, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_CALENDAR_ALARM_METHODS, getProperty, setProperty, kJSPropertyAttributeNone },
     { 0, 0, 0, 0 }
 };
 
@@ -131,7 +130,7 @@ JSValueRef JSEventAlarm::getProperty(JSContextRef context,
         }
         EventAlarmPtr alarm = priv->getObject();
 
-        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ABSOLUTE_DATE)) {
+        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_ABSOLUTE_DATE)) {
             if (!alarm) {
                 Throw(WrtDeviceApis::Commons::NullPointerException);
             }
@@ -141,14 +140,12 @@ JSValueRef JSEventAlarm::getProperty(JSContextRef context,
             } else {
                 return JSValueMakeUndefined(context);
             }
-        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_MINUTES)) {
-            return converter.toJSValueRef(alarm->getMinutes());
-        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_DAYS)) {
-            return converter.toJSValueRef(alarm->getDays());
-        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_METHODS)) {
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_BEFORE)) {
+            return JSTimeDuration::createJSObject(priv->getContext(), alarm->getDuration());
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_METHODS)) {
             std::vector<JSValueRef> result;
-            std::vector<int> methods = alarm->getMethods();
-            for(std::vector<int>::iterator i = methods.begin(); i != methods.end(); i++)
+            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);
         }
@@ -167,7 +164,7 @@ bool JSEventAlarm::setProperty(JSContextRef context,
         JSValueRef* exception)
 {
     LogDebug("entered");
-    WrtDeviceApis::CommonsJavaScript::Converter converter(context);
+    CalendarConverter converter(context);
     Try
     {
         EventAlarmPrivateObject* priv =
@@ -177,7 +174,10 @@ bool JSEventAlarm::setProperty(JSContextRef context,
         }
         EventAlarmPtr alarm = priv->getObject();
 
-        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ABSOLUTE_DATE)) {
+        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);
@@ -187,17 +187,20 @@ bool JSEventAlarm::setProperty(JSContextRef context,
                 alarm->setTimeZone(timeZone);
             }
             return true;
-        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_MINUTES)) {
-            long minutes = converter.toLong(value);
-            alarm->setMinutes(minutes);
-            return true;
-        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_DAYS)) {
-            long days = converter.toLong(value);
-            alarm->setDays(days);
+        } 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_METHODS)) {
-            std::vector<int> methods = converter.toVectorOfInts(value);
-            alarm->setMethods(methods);
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_METHODS)) {
+            std::vector<std::string> methods = converter.toVectorOfStrings(value);
+            std::vector<CalendarEvent::EventAlarmType> convertedMethods;
+            for (unsigned int i=0; i<methods.size(); i++) {
+                convertedMethods.push_back(converter.toEventAlarmType(methods[i]));
+            }
+            alarm->setMethods(convertedMethods);
             return true;
         }
     }
index ae843cc..8ec3078 100755 (executable)
@@ -28,8 +28,12 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
+#define TIZEN_CALENDAR_ALARM_ABSOLUTE_DATE "absoluteDate"
+#define TIZEN_CALENDAR_ALARM_BEFORE "before"
+#define TIZEN_CALENDAR_ALARM_METHODS "methods"
+
 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<EventAlarmPtr,
-                                                        WrtDeviceApis::CommonsJavaScript::NoOwnership> EventAlarmPrivateObject;
+            WrtDeviceApis::CommonsJavaScript::NoOwnership> EventAlarmPrivateObject;
 
 class JSEventAlarm
 {
index b4556bf..c35e8e6 100755 (executable)
@@ -16,7 +16,7 @@
 
 
 #include "JSEventId.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
 #include <CommonsJavaScript/Converter.h>
@@ -32,8 +32,6 @@ namespace Tizen1_0 {
 namespace Calendar {
 
 #define TIZEN_EVENTID_ATTRIBUTENAME "EventId"
-#define TIZEN_EVENTID_UID "uid"
-#define TIZEN_EVENTID_RECURRENCEID "recurrenceId"
 
 JSClassDefinition JSEventId::m_classInfo = {
     0,
@@ -162,10 +160,16 @@ bool JSEventId::setProperty(JSContextRef context,
         EventIdPtr eventId = priv->getObject();
 
         if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_EVENTID_UID)) {
+            if (!JSValueIsString(context, value)) {
+                Throw(InvalidArgumentException);
+            }
             std::string uid = converter.toString(value);
             eventId->setUId(uid);
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_EVENTID_RECURRENCEID)) {
+            if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
+                Throw(InvalidArgumentException);
+            }
             TimeUtilConverter timeConverter(context);
             std::time_t recurrenceId = timeConverter.toTZDateTimeT(value);
             eventId->setRecurrenceId(recurrenceId);
index 25c2f03..1dd6faf 100755 (executable)
 #ifndef _JS_EVENT_ID_H_
 #define _JS_EVENT_ID_H_
 
-#include <string>
-#include <vector>
 #include <JavaScriptCore/JavaScript.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <API/Calendar/EventId.h>
 
-using namespace TizenApis::Api::Calendar;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
 namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
-typedef PrivateObject<EventIdPtr,
-                               NoOwnership> EventIdPrivateObject;
+#define TIZEN_EVENTID_UID "uid"
+#define TIZEN_EVENTID_RECURRENCEID "recurrenceId"
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::EventIdPtr,
+                               WrtDeviceApis::CommonsJavaScript::NoOwnership> EventIdPrivateObject;
 
 class JSEventId
 {
@@ -43,7 +40,7 @@ class JSEventId
 
     static JSClassRef getClassRef();
 
-    static EventIdPtr getEventId(JSObjectRef object);
+    static TizenApis::Api::Calendar::EventIdPtr getEventId(JSObjectRef object);
 
   private:
 
index 5914264..91315b9 100755 (executable)
@@ -16,7 +16,7 @@
 
 
 #include "JSRecurrenceRule.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Tizen/Common/JSTizenException.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <CommonsJavaScript/Converter.h>
@@ -32,6 +32,8 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
+#define TIZEN_RECURRENCE_RULE_ATTRIBUTENAME "RecurrenceRule"
+
 JSClassDefinition JSRecurrenceRule::m_classInfo = {
     0,
     kJSClassAttributeNone,
@@ -55,7 +57,7 @@ JSClassDefinition JSRecurrenceRule::m_classInfo = {
 JSStaticValue JSRecurrenceRule::m_property[] = {
     { TIZEN_RECURRENCE_RULE_FREQUENCY, getProperty, setProperty, kJSPropertyAttributeNone },
     { TIZEN_RECURRENCE_RULE_INTERVAL, getProperty, setProperty, kJSPropertyAttributeNone },
-    { TIZEN_RECURRENCE_RULE_END_DATE, 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 },
@@ -124,7 +126,7 @@ JSValueRef JSRecurrenceRule::getProperty(JSContextRef context,
             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_END_DATE)) {
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_UNTIL_DATE)) {
             if (!rrule) {
                 Throw(NullPointerException);
             }
@@ -190,17 +192,26 @@ bool JSRecurrenceRule::setProperty(JSContextRef context,
         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_END_DATE)) {
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_UNTIL_DATE)) {
+            if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
+                Throw(InvalidArgumentException);
+            }
             TimeUtilConverter timeConverter(context);
-            std::time_t endDate = timeConverter.toTZDateTimeT(value);
-            rrule->setEndDate(endDate);
+            std::time_t untilDate = timeConverter.toTZDateTimeT(value);
+            rrule->setEndDate(untilDate);
 
             if( rrule->getTimeZone().empty() ) {
                 std::string timeZone = timeConverter.getPropertiesInTZDate(value).timezone;
@@ -208,10 +219,13 @@ bool JSRecurrenceRule::setProperty(JSContextRef context,
             }
             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)) {
+        /*} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_MONTH)) {
             std::vector<int> daysOfTheMonth = converter->toVectorOfInts(value);
             rrule->setDaysOfTheMonth(daysOfTheMonth);
             return true;*/
@@ -219,7 +233,7 @@ bool JSRecurrenceRule::setProperty(JSContextRef context,
             std::vector<std::string> daysOfTheWeek = converter->toVectorOfStrings(value);
             rrule->setDaysOfTheWeek(daysOfTheWeek);
             return true;
-/*        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR)) {
+        /*} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR)) {
             std::vector<int> daysOfTheYear = converter->toVectorOfInts(value);
             rrule->setDaysOfTheYear(daysOfTheYear);
             return true;
index d1b90fe..df22093 100755 (executable)
@@ -33,10 +33,9 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
-#define TIZEN_RECURRENCE_RULE_ATTRIBUTENAME "RecurrenceRule"
 #define TIZEN_RECURRENCE_RULE_FREQUENCY "frequency"
 #define TIZEN_RECURRENCE_RULE_INTERVAL "interval"
-#define TIZEN_RECURRENCE_RULE_END_DATE "endDate"
+#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"
index d3e5494..11e9c23 100755 (executable)
@@ -15,7 +15,7 @@
  */
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <Commons/plugin_initializer_def.h>
 #include <Commons/WrtWrapper/WrtWrappersMgr.h>
@@ -30,31 +30,12 @@ void on_widget_start_callback(int widgetId,
         JavaScriptContext context,
         const engine_interface_t *interface)
 {
-    LogDebug("[Tizen\\calendar] on_widget_start_callback (" << widgetId << ")");
-    Try
-    {
-        WrtDeviceApis::Commons::WrtWrappersMgr::getInstance().registerWrapper(
-            widgetId,
-            context,
-            interface);
-    }
-    Catch(WrtDeviceApis::Commons::Exception)
-    {
-        LogError("Wrt wrapper registration failed");
-    }
+    LogDebug("[Tizen\\Calendar] on_widget_start_callback (" << widgetId << ")");
 }
 
 void on_widget_stop_callback(int widgetId)
 {
-    LogDebug("[Tizen\\calendar] on_widget_stop_callback (" << widgetId << ")");
-    Try
-    {
-        WrtDeviceApis::Commons::WrtWrappersMgr::getInstance().removeWrapper(widgetId);
-    }
-    Catch(WrtDeviceApis::Commons::Exception)
-    {
-        LogError("Wrt wrapper removal failed");
-    }
+    LogDebug("[Tizen\\Calendar] on_widget_stop_callback (" << widgetId << ")");
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
index 0e1d4ea..9ee597c 100755 (executable)
@@ -16,7 +16,7 @@
 
  
 #include "Converter.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <Commons/Exception.h>
 #include <CommonsJavaScript/Validator.h>
index fe11429..2fc4dff 100755 (executable)
@@ -15,7 +15,7 @@
  */
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 
 #include <CommonsJavaScript/Validator.h>
index 61bf5a3..5aec320 100755 (executable)
@@ -155,7 +155,6 @@ JSValueRef JSCallHistory::find(JSContextRef context, JSObjectRef object, JSObjec
 
                JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext));
                if (cbm != NULL) {
-                       cbm->setObject(thisObject);
                }
 
                if (argumentCount >= 2) {
@@ -298,7 +297,6 @@ JSValueRef JSCallHistory::removeBatch(JSContextRef context, JSObjectRef object,
        try {
                JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext));
                if (cbm != NULL) {
-                       cbm->setObject(thisObject);
                }
 
                if (argumentCount >= 3) {
index a5a0595..9ee9874 100755 (executable)
@@ -17,7 +17,7 @@
 
 #include <cassert>
 #include <memory>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include <CommonsJavaScript/JSUtils.h>
 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
index 60fef9f..1f74f57 100755 (executable)
@@ -17,7 +17,7 @@
  
 #include "ResponseDispatcher.h"
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/assert.h>
 
 #include <Commons/Exception.h>
index ef042a6..aa17fe0 100755 (executable)
@@ -15,7 +15,7 @@
  */
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
 #include <Commons/WrtWrapper/WrtWrappersMgr.h>
 #include <Commons/Exception.h>
index 90502fd..9016725 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "JSTizenException.h"
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <CommonsJavaScript/Converter.h>
 
index 58e91bc..6311ae9 100644 (file)
@@ -17,7 +17,7 @@
 #include "JSTizenExceptionFactory.h"
 
 #include <dpl/assert.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <CommonsJavaScript/JSUtils.h>
 
index 7e027c2..8419b8b 100755 (executable)
@@ -24,8 +24,7 @@
 #ifndef _TIZEN_CONTACT_ADDRESS_BOOK_CONTROLLER_H_
 #define _TIZEN_CONTACT_ADDRESS_BOOK_CONTROLLER_H_
 
-#include <dpl/controller.h>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include <Commons/EventReceiver.h>
 #include <Commons/EventListener.h>
index 090fb85..722ae55 100755 (executable)
@@ -21,7 +21,7 @@
  * @brief
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Validator.h>
 #include <CommonsJavaScript/ScopedJSStringRef.h>
 #include <CommonsJavaScript/JSUtils.h>
index de348f2..68f583e 100755 (executable)
@@ -24,7 +24,6 @@
 #ifndef _TIZEN_CONTACT_MANAGER_CONTROLLER_H_
 #define _TIZEN_CONTACT_MANAGER_CONTROLLER_H_
 
-#include <dpl/controller.h>
 #include <dpl/shared_ptr.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/JSPendingOperationPrivateObject.h>
index af966d9..73e14ca 100755 (executable)
@@ -21,7 +21,7 @@
  * @brief       Implementation of the JSAddressBook class
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/assert.h>
 #include <CommonsJavaScript/Validator.h>
 #include <CommonsJavaScript/Converter.h>
index 3bbe48d..2de5b51 100755 (executable)
@@ -22,7 +22,7 @@
  */
 
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
 #include "ContactConverter.h"
index e3477ed..4fa99d6 100755 (executable)
@@ -22,7 +22,7 @@
  */
 
 #include "JSAddressBookChangeCallbackManager.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 namespace TizenApis {
 namespace Tizen1_0 {
index 2002567..a420d5e 100755 (executable)
@@ -22,7 +22,7 @@
  */
 
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
index 84bceff..9241c87 100755 (executable)
@@ -21,7 +21,7 @@
  * @brief       Implementation of the JSContact class
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include <CommonsJavaScript/Converter.h>
 #include "ContactConverter.h"
index f3e3733..280e38f 100755 (executable)
@@ -22,7 +22,7 @@
  */
 
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
 #include "ContactConverter.h"
index 456d770..84673d1 100755 (executable)
@@ -22,7 +22,7 @@
  */
 
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
index a7dc914..cd4b14f 100755 (executable)
@@ -22,7 +22,7 @@
  */
 
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
 #include "ContactConverter.h"
index 69c88ed..3535774 100755 (executable)
@@ -22,7 +22,7 @@
  */
 
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
 #include "ContactConverter.h"
index e59d3c1..e49a4d8 100755 (executable)
@@ -22,7 +22,7 @@
  */
 
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
 #include "ContactConverter.h"
index baf2cd9..3137b42 100755 (executable)
@@ -22,7 +22,7 @@
  */
 
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
index 7cb1739..566efa2 100755 (executable)
@@ -22,7 +22,7 @@
  */
 
 #include <string>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
 #include <CommonsJavaScript/Validator.h>
 #include <CommonsJavaScript/Converter.h>
index ea45286..2fe693d 100755 (executable)
@@ -21,7 +21,7 @@
  * @brief       Implementation of the JSContactName class
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include <CommonsJavaScript/Converter.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
index 6307a80..83aa7a6 100755 (executable)
@@ -22,7 +22,7 @@
  */
 
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
 #include "ContactConverter.h"
index 912f02d..50cd1e8 100755 (executable)
@@ -21,7 +21,7 @@
  * @brief       Implementation of the JSContactPhoneNumber class
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include <CommonsJavaScript/Converter.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
index 203bee6..b75fb5d 100755 (executable)
@@ -22,7 +22,7 @@
  */
 
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
 #include "ContactConverter.h"
index 7d6b1c6..d14cc17 100755 (executable)
@@ -22,7 +22,7 @@
  */
 
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
index dad006d..7710e88 100755 (executable)
@@ -21,7 +21,7 @@
  * @brief       Implementation of the JSContactProperties class
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include <CommonsJavaScript/Converter.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
index 9c2b5f6..a34068f 100755 (executable)
@@ -22,7 +22,7 @@
  */
 
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
 #include "ContactConverter.h"
index 5e97009..24e1f7c 100755 (executable)
@@ -22,7 +22,7 @@
  */
 
 #include <algorithm>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
index 41cc2d0..4493294 100755 (executable)
@@ -21,7 +21,7 @@
  * @brief
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <Commons/plugin_initializer_def.h>
 #include <Commons/WrtWrapper/WrtWrappersMgr.h>
diff --git a/src/standards/Tizen/Filesystem/CMakeLists.txt b/src/standards/Tizen/Filesystem/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..5a3b7b1
--- /dev/null
@@ -0,0 +1,35 @@
+set(TARGET_NAME "wrt-plugins-tizen-1.0-filesystem")
+set(DESTINATION_NAME "tizen-1.0-filesystem")
+
+include_directories(${INCLUDES_PLATFORM_IMPLEMENTATION_FILESYSTEM})
+
+set(SRCS
+  ${SRCS_PLATFORM_API_FILESYSTEM}
+  ${SRCS_PLATFORM_IMPLEMENTATION_FILESYSTEM}
+  JSFilesystemManager.cpp
+  JSFile.cpp
+  JSFilestream.cpp
+  JSStorage.cpp
+  Converter.cpp
+  EventGetNodeData.cpp
+  plugin_initializer.cpp
+  plugin_config.cpp
+  Encodings.cpp
+  StorageStaticController.cpp
+  FilesystemUtils.cpp
+  ResponseDispatcher.cpp
+  ../Common/JSTizenException.cpp
+  ../Common/TizenExceptionData.cpp
+  ../Common/JSTizenExceptionFactory.cpp
+)
+
+add_library(${TARGET_NAME} SHARED ${SRCS})
+target_link_libraries(${TARGET_NAME}
+  wrt-plugins-tizen-1.0-tizen
+  ${LIBS_COMMON}
+  ${LIBS_WIDGETDB}
+  ${LIBS_PLATFORM_IMPLEMENTATION_FILESYSTEM}
+)
+
+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/Filesystem/Converter.cpp b/src/standards/Tizen/Filesystem/Converter.cpp
new file mode 100755 (executable)
index 0000000..a46088c
--- /dev/null
@@ -0,0 +1,243 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "Converter.h"
+#include <dpl/log/log.h>
+
+#include <API/Filesystem/IManager.h>
+#include <API/Filesystem/IPath.h>
+#include <Commons/Exception.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include "FilesystemUtils.h"
+#include "JSFile.h"
+#include "Encodings.h"
+#include "JSStorage.h"
+
+namespace {
+const char* PROPERTY_FILEFILTER_NAME = "name";
+const char* PROPERTY_FILEFILTER_START_CREATED = "startCreated";
+const char* PROPERTY_FILEFILTER_END_CREATED = "endCreated";
+const char* PROPERTY_FILEFILTER_START_MODIFIED = "startModified";
+const char* PROPERTY_FILEFILTER_END_MODIFIED = "endModified";
+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* ENCODINGS[] = {
+    TizenApis::Tizen1_0::Encodings::UTF8,
+    TizenApis::Tizen1_0::Encodings::ISO88591,
+    NULL
+};
+} // namespace
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0{
+Converter::Converter(JSContextRef context) : WrtDeviceApis::CommonsJavaScript::Converter(context)
+{
+}
+
+JSValueRef Converter::toJSValueRef(
+        const Api::Filesystem::StoragePropertiesPtr &arg,
+        JSContextRef context)
+{
+       Api::Filesystem::StorageProperties tmpStorage;
+
+       tmpStorage.setLabel(arg->getLabel()); 
+       tmpStorage.setType(arg->getType());
+
+       switch (arg->getState()) {
+       case Api::Filesystem::StorageProperties::STATE_MOUNTED :
+               tmpStorage.setState(JSStorage::STATE_MOUNTED);
+               break;
+       case Api::Filesystem::StorageProperties::STATE_REMOVED:
+               tmpStorage.setState(JSStorage::STATE_REMOVED);
+               break;
+       case Api::Filesystem::StorageProperties::STATE_UNMOUNTABLE:
+               tmpStorage.setState(JSStorage::STATE_UNMOUNTABLE);
+               break;
+       }
+
+       JSObjectRef jsObject = JSStorage::createJSObject(context, tmpStorage);
+       if (!jsObject) {
+               ThrowMsg(Commons::ConversionException, "Could not create JS object.");
+       }
+
+       return toJSValueRef(jsObject);
+}
+
+JSValueRef Converter::toJSValueRef(
+        const std::vector<Api::Filesystem::StoragePropertiesPtr>& arg,
+        JSContextRef context)
+{
+       JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
+       if (!jsResult) {
+               ThrowMsg(Commons::ConversionException, "Could not create js array object");
+       }
+
+       Api::Filesystem::StorageProperties tmpStorage;
+
+       for (size_t i = 0; i < arg.size(); i++) {
+               tmpStorage.setLabel(arg[i]->getLabel()); 
+               tmpStorage.setType(arg[i]->getType());
+
+               switch (arg[i]->getState()) {
+               case Api::Filesystem::StorageProperties::STATE_MOUNTED :
+                       tmpStorage.setState(JSStorage::STATE_MOUNTED);
+                       break;
+               case Api::Filesystem::StorageProperties::STATE_REMOVED:
+                       tmpStorage.setState(JSStorage::STATE_REMOVED);
+                       break;
+               case Api::Filesystem::StorageProperties::STATE_UNMOUNTABLE:
+                       tmpStorage.setState(JSStorage::STATE_UNMOUNTABLE);
+                       break;
+               }
+
+               JSObjectRef jsObject = JSStorage::createJSObject(context, tmpStorage);
+               if (!jsObject) {
+                       ThrowMsg(Commons::ConversionException, "Could not create JS object.");
+               }
+
+               if (!JSSetArrayElement(m_context, jsResult, i, jsObject)) {
+                       ThrowMsg(Commons::ConversionException, "Could not insert value into js array");
+               }
+       }
+
+       return jsResult;
+}
+
+JSValueRef Converter::toJSValueRef(const Api::Filesystem::NodeList& arg,
+        JSContextRef context)
+{
+       JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
+       if (!jsResult) {
+               ThrowMsg(Commons::ConversionException, "Could not create js array object");
+       }
+
+       for (std::size_t i = 0; i < arg.size(); ++i) {
+               JSFile::PrivateObject* privateObject = new JSFile::PrivateObject(context, arg[i]);
+               JSObjectRef jsObject = JSObjectMake(m_context, JSFile::getClassRef(), privateObject);
+               if (!jsObject) {
+                       delete privateObject;
+                       ThrowMsg(Commons::ConversionException, "Could not create JS object.");
+               }
+               if (!JSSetArrayElement(m_context, jsResult, i, jsObject)) {
+                       ThrowMsg(Commons::ConversionException, "Could not insert value into js array");
+               }
+       }
+
+       return jsResult;
+}
+
+JSValueRef Converter::toJSValueRef(unsigned char* data, std::size_t num)
+{
+       JSObjectRef result = JSCreateArrayObject(m_context, 0, NULL);
+       if (!result) {
+               ThrowMsg(Commons::ConversionException, "Could not create array object.");
+       }
+
+       for (std::size_t i = 0; i < num; ++i) {
+               JSValueRef value = JSValueMakeNumber(m_context, data[i]);
+               if (!JSSetArrayElement(m_context, result, i, value)) {
+                       ThrowMsg(Commons::ConversionException, "Could not fill array.");
+               }
+       }
+
+       return result;
+}
+
+Api::Filesystem::IPathPtr Converter::toPath(const JSValueRef& arg)
+{
+       Try {
+               std::string path = toString(arg);
+               if (!Utils::isPathValid(path)) {
+                       ThrowMsg(Commons::ConversionException, "Invalid path component.");
+               }
+               return Api::Filesystem::IPath::create(path);
+       } Catch (Commons::InvalidArgumentException) {
+               ReThrowMsg(Commons::ConversionException, "Not a valid path.");
+       }
+}
+
+Api::Filesystem::NodeFilterPtr Converter::toNodeFilter(const JSValueRef& arg)
+{
+       JSObjectRef filter = toJSObjectRef(arg);
+
+       Api::Filesystem::NodeFilterPtr result(new Api::Filesystem::NodeFilter());
+       JSValueRef prop = NULL;
+       prop = JSUtils::getJSProperty(m_context, filter, PROPERTY_FILEFILTER_NAME);
+       if (prop) {
+               result->setName(toString(prop));
+       }
+
+       prop = JSUtils::getJSProperty(m_context, filter, PROPERTY_FILEFILTER_START_CREATED);
+       if (prop) {
+               result->setMinCreated(toDateTimeT(prop));
+       }
+
+       prop = JSUtils::getJSProperty(m_context, filter, PROPERTY_FILEFILTER_END_CREATED);
+       if (prop) {
+               result->setMaxCreated(toDateTimeT(prop));
+       }
+
+       prop = JSUtils::getJSProperty(m_context, filter, PROPERTY_FILEFILTER_START_MODIFIED);
+       if (prop) {
+               result->setMinModified(toDateTimeT(prop));
+       }
+
+       prop = JSUtils::getJSProperty(m_context, filter, PROPERTY_FILEFILTER_END_MODIFIED);
+       if (prop) {
+               result->setMaxModified(toDateTimeT(prop));
+       }
+
+       return result;
+}
+
+Api::Filesystem::AccessMode Converter::toAccessMode(const JSValueRef& arg)
+{
+       std::string mode = toString_(arg);
+       if (ACCESS_MODE_READ == mode) {
+               return Api::Filesystem::AM_READ;
+       } else if (ACCESS_MODE_APPEND == mode) {
+               return Api::Filesystem::AM_APPEND;
+       } else if (ACCESS_MODE_WRITE == mode) {
+               return Api::Filesystem::AM_WRITE;
+       } else if (ACCESS_MODE_READ_WRITE == mode) {
+               return Api::Filesystem::AM_WRITE;
+       }
+       
+       ThrowMsg(Commons::InvalidArgumentException, "Invalid mode.");
+}
+
+std::string Converter::toEncoding(const JSValueRef& arg)
+{
+       std::string result = toString_(arg);
+       const char** ptr = ENCODINGS;
+       while (*ptr) {
+               if (result == *ptr) {
+                       return result;
+               }
+               ++ptr;
+       }
+       ThrowMsg(Commons::InvalidArgumentException, "Invalid encoding");
+}
+}
+}
diff --git a/src/standards/Tizen/Filesystem/Converter.h b/src/standards/Tizen/Filesystem/Converter.h
new file mode 100755 (executable)
index 0000000..e54f924
--- /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. 
+ */
+
+#ifndef TIZENAPIS_TIZEN_FILESYSTEM_CONVERTER_H_
+#define TIZENAPIS_TIZEN_FILESYSTEM_CONVERTER_H_
+
+#include <vector>
+#include <string>
+#include <map>
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/Converter.h>
+#include <API/Filesystem/Enums.h>
+#include <API/Filesystem/IPath.h>
+#include <API/Filesystem/INodeTypes.h>
+#include <API/Filesystem/NodeFilter.h>
+#include <API/Filesystem/StorageProperties.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+class Converter : public WrtDeviceApis::CommonsJavaScript::Converter
+{
+public:
+       using WrtDeviceApis::CommonsJavaScript::Converter::toJSValueRef;
+
+public:
+       explicit Converter(JSContextRef context);
+
+       JSValueRef toJSValueRef(
+               const Api::Filesystem::StoragePropertiesPtr &arg,
+               JSContextRef context);
+
+       JSValueRef toJSValueRef(
+               const std::vector<Api::Filesystem::StoragePropertiesPtr>& arg,
+               JSContextRef context);
+
+       JSValueRef toJSValueRef(const Api::Filesystem::NodeList& arg,
+               JSContextRef context);
+
+       JSValueRef toJSValueRef(unsigned char* data,
+               std::size_t num);
+
+       Api::Filesystem::IPathPtr toPath(const JSValueRef& arg);
+
+       Api::Filesystem::NodeFilterPtr toNodeFilter(const JSValueRef& arg);
+
+       Api::Filesystem::AccessMode toAccessMode(const JSValueRef& arg);
+
+       std::string toEncoding(const JSValueRef& arg);
+};
+
+typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<Converter> ConverterFactory;
+typedef ConverterFactory::ConverterType ConverterPtr;
+}
+}
+
+#endif
\ No newline at end of file
diff --git a/src/standards/Tizen/Filesystem/Encodings.cpp b/src/standards/Tizen/Filesystem/Encodings.cpp
new file mode 100755 (executable)
index 0000000..a950ed8
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "Encodings.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Encodings {
+const char* UTF8 = "UTF-8";
+
+const char* ISO88591 = "ISO-8859-1";
+}
+}
+}
diff --git a/src/standards/Tizen/Filesystem/Encodings.h b/src/standards/Tizen/Filesystem/Encodings.h
new file mode 100755 (executable)
index 0000000..956a48d
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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_FILESYSTEM_ENCODINGS_H_
+#define TIZENAPIS_TIZEN_FILESYSTEM_ENCODINGS_H_
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Encodings {
+extern const char* UTF8;
+
+extern const char* ISO88591;
+}
+}
+}
+
+#endif
\ No newline at end of file
diff --git a/src/standards/Tizen/Filesystem/EventGetNodeData.cpp b/src/standards/Tizen/Filesystem/EventGetNodeData.cpp
new file mode 100755 (executable)
index 0000000..12b486b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "EventGetNodeData.h"
+
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+EventGetNodeData::EventGetNodeData(int perms, JSCallbackManagerPtr callbackManager) :
+               m_perms(perms),
+               m_callbackManager(callbackManager)
+{
+}
+
+int EventGetNodeData::getPerms() const
+{
+       return m_perms;
+}
+
+JSCallbackManagerPtr EventGetNodeData::getCallbackManager() const
+{
+       return m_callbackManager;
+}
+}
+}
diff --git a/src/standards/Tizen/Filesystem/EventGetNodeData.h b/src/standards/Tizen/Filesystem/EventGetNodeData.h
new file mode 100755 (executable)
index 0000000..a94cf6c
--- /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_EVENTGETNODEDATA_H_
+#define TIZENAPIS_TIZEN_EVENTGETNODEDATA_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+class EventGetNodeData : public WrtDeviceApis::Commons::IEventPrivateData
+{
+public:
+       EventGetNodeData(int perms,
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager);
+
+       int getPerms() const;
+
+       WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr getCallbackManager() const;
+
+private:
+       int m_perms;
+       WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr m_callbackManager;
+};
+
+typedef DPL::SharedPtr<EventGetNodeData> EventGetNodeDataPtr;
+}
+}
+
+#endif
\ No newline at end of file
diff --git a/src/standards/Tizen/Filesystem/FilesystemUtils.cpp b/src/standards/Tizen/Filesystem/FilesystemUtils.cpp
new file mode 100755 (executable)
index 0000000..38fdac1
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 <map>
+#include <string>
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+#include <Commons/Exception.h>
+#include <API/Filesystem/Enums.h>
+#include <API/Filesystem/IManager.h>
+#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <WidgetDB/WidgetDBMgr.h>
+#include "FilesystemUtils.h"
+
+using namespace TizenApis::Api::Filesystem;
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+namespace {
+const std::string PATH_INVALID_COMPONENT_PARENT_DIR("..");
+const std::string PATH_INVALID_COMPONENT_CURRENT_DIR(".");
+
+typedef std::map<std::string, std::string> RootToPathMap;
+typedef RootToPathMap::const_iterator RootToPathMapIterator;
+typedef std::map<std::string, std::string> PathToRootMap;
+typedef PathToRootMap::const_iterator PathToRootMapIterator;
+}
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Utils {
+const RootToPathMap& getRootToPathMap()
+{
+       static RootToPathMap result;
+       if (result.empty()) {
+        IManager& manager = IManager::getInstance();
+               std::map<std::string, Api::Filesystem::IPathPtr> locations = manager.getStorageList();
+
+               std::map<std::string, Api::Filesystem::IPathPtr>::const_iterator it;
+
+               for (it = locations.begin(); it != locations.end(); ++it) {
+                       result[it->first] = it->second->getFullPath();
+               }
+       }
+       return result;
+}
+
+const PathToRootMap& getPathToRootMap()
+{
+       static PathToRootMap result;
+       if (result.empty()) {
+               IManager& manager = IManager::getInstance();
+               std::map<std::string, Api::Filesystem::IPathPtr> locations = manager.getStorageList();
+
+               std::map<std::string, Api::Filesystem::IPathPtr>::const_iterator it;
+
+               for (it = locations.begin(); it != locations.end(); ++it) {
+                       result[it->second->getFullPath()] = it->first;
+               }
+       }
+       return result;
+}
+
+IPathPtr fromVirtualPath(JSContextRef context,
+                         const std::string& arg)
+{
+       IWrtWrapperPtr wrt = WrtWrappersMgr::getInstance().getWrtWrapper(context);
+       Assert(wrt && "WrtWrapper not found, not a GLOBAL context supplied?");
+
+       if (!isPathValid(arg)) {
+               ThrowMsg(Commons::NotFoundException, "Not found path component.");
+       }
+
+       std::string root;
+       std::string tail;
+       std::string::size_type separatorPosition = arg.find(IPath::getSeparator());
+       if (separatorPosition != std::string::npos) {
+               root = arg.substr(0, separatorPosition);
+               tail = arg.substr(separatorPosition + 1, arg.size() - 1);
+       } else {
+               root = arg;
+       }
+
+    WidgetDB::Api::IWidgetDBPtr widgetDB =
+        WidgetDB::Api::getWidgetDB(wrt->getWidgetId());
+
+       RootToPathMap rootToPath = getRootToPathMap();
+       rootToPath["wgt-package"] = widgetDB->getWidgetInstallationPath();
+       rootToPath["wgt-private"] = widgetDB->getWidgetPersistentStoragePath();
+       rootToPath["wgt-private-tmp"] = widgetDB->getWidgetTemporaryStoragePath();
+       RootToPathMapIterator it = rootToPath.find(root);
+       if (it == rootToPath.end()) {
+               ThrowMsg(Commons::NotFoundException, "Location not found.");
+       }
+       IPathPtr result = IPath::create(it->second);
+
+       if (!tail.empty()) {
+               result->append(tail);
+       }
+
+       return result;
+}
+
+std::string toVirtualPath(JSContextRef context, const std::string& arg) {
+       IWrtWrapperPtr wrt = WrtWrappersMgr::getInstance().getWrtWrapper(context);
+       Assert(wrt && "WrtWrapper not found, not a GLOBAL context supplied?");
+
+    WidgetDB::Api::IWidgetDBPtr widgetDB =
+        WidgetDB::Api::getWidgetDB(wrt->getWidgetId());
+
+       PathToRootMap pathToRoot = getPathToRootMap();
+       pathToRoot[widgetDB->getWidgetInstallationPath()] = "wgt-package";
+       pathToRoot[widgetDB->getWidgetPersistentStoragePath()] = "wgt-private";
+       pathToRoot[widgetDB->getWidgetTemporaryStoragePath()] = "wgt-private-tmp";
+
+       std::string path = arg;
+       std::string::size_type pos = path.size();
+       while (std::string::npos != (pos = path.rfind(IPath::getSeparator(), pos))) {
+               PathToRootMapIterator it = pathToRoot.find(path);
+               if (pathToRoot.end() != it) {
+                       return it->second + arg.substr(path.size());
+               }
+               path.erase(pos, path.size());
+       }
+       ThrowMsg(Commons::ConversionException, "Path doesn't contain a valid location type.");
+}
+
+bool isPathValid(const std::string& path) {
+       static const std::string currentDirBegin(
+               PATH_INVALID_COMPONENT_CURRENT_DIR +
+               Api::Filesystem::IPath::getSeparator());
+       static const std::string parentDirBegin(
+               PATH_INVALID_COMPONENT_PARENT_DIR +
+               Api::Filesystem::IPath::getSeparator());
+       static const std::string currentDirMiddle(
+               Api::Filesystem::IPath::getSeparator() +
+               PATH_INVALID_COMPONENT_CURRENT_DIR +
+               Api::Filesystem::IPath::getSeparator());
+       static const std::string parentDirMiddle(
+               Api::Filesystem::IPath::getSeparator() +
+               PATH_INVALID_COMPONENT_PARENT_DIR +
+               Api::Filesystem::IPath::getSeparator());
+
+       if (path.find(parentDirBegin) == 0 ||
+               path.find(currentDirBegin) == 0 ||
+               path.find(parentDirMiddle) != std::string::npos ||
+               path.find(currentDirMiddle) != std::string::npos) {
+               return false;
+       }
+       return true;
+}
+
+}
+}
+}
diff --git a/src/standards/Tizen/Filesystem/FilesystemUtils.h b/src/standards/Tizen/Filesystem/FilesystemUtils.h
new file mode 100755 (executable)
index 0000000..dbe8439
--- /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. 
+ */
+
+#ifndef TIZENAPIS_FILESYSTEM_UTILS_H_
+#define TIZENAPIS_FILESYSTEM_UTILS_H_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+#include <API/Filesystem/IPath.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Utils {
+
+Api::Filesystem::IPathPtr fromVirtualPath(JSContextRef context,
+                                          const std::string& arg);
+
+std::string toVirtualPath(JSContextRef context, const std::string& arg);
+
+bool isPathValid(const std::string& path);
+
+}
+}
+}
+
+#endif
diff --git a/src/standards/Tizen/Filesystem/JSFile.cpp b/src/standards/Tizen/Filesystem/JSFile.cpp
new file mode 100755 (executable)
index 0000000..6554b41
--- /dev/null
@@ -0,0 +1,956 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "JSFile.h"
+
+#include <string>
+#include <ctime>
+#include <dpl/log/log.h>
+
+#include <Commons/FunctionDeclaration.h>
+#include <Commons/Exception.h>
+#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtWrapper/IWrtWrapper.h>
+#include <API/Filesystem/Enums.h>
+#include <API/Filesystem/IManager.h>
+#include <API/Filesystem/EventCopy.h>
+#include <API/Filesystem/EventMove.h>
+#include <API/Filesystem/EventListNodes.h>
+#include <API/Filesystem/EventOpen.h>
+#include <API/Filesystem/EventReadText.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/Utils.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h> 
+#include <Tizen/Common/SecurityExceptions.h>
+#include "FilesystemUtils.h"
+#include "Converter.h"
+#include "plugin_config.h"
+#include "Encodings.h"
+#include "JSFilestream.h"
+#include "ResponseDispatcher.h"
+
+using namespace TizenApis::Api::Filesystem;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Commons;
+
+namespace {
+const char* PLUGIN_NAME = "File";
+const char* PROPERTY_PARENT = "parent";
+const char* PROPERTY_READ_ONLY = "readOnly";
+const char* PROPERTY_IS_FILE = "isFile";
+const char* PROPERTY_IS_DIRECTORY = "isDirectory";
+const char* PROPERTY_CREATED = "created";
+const char* PROPERTY_MODIFIED = "modified";
+const char* PROPERTY_PATH = "path";
+const char* PROPERTY_NAME = "name";
+const char* PROPERTY_FULL_PATH = "fullPath";
+const char* PROPERTY_FILE_SIZE = "fileSize";
+const char* PROPERTY_LENGTH = "length";
+
+JSValueRef getFunctionOrNull(JSContextRef ctx, JSValueRef arg)
+{
+       if (Validator(ctx).isCallback(arg)) {
+               return arg;
+       } else if (!JSValueIsNull(ctx, arg) && !JSValueIsUndefined(ctx, arg)) {
+               ThrowMsg(ConversionException, "Not a function nor JS null.");
+       }
+       return NULL;
+}
+
+
+JSValueRef getFunction(JSContextRef ctx, JSValueRef arg)
+{
+       if (Validator(ctx).isCallback(arg)) {
+               return arg;
+       } else if (JSValueIsNull(ctx, arg) || JSValueIsUndefined(ctx, arg)) {
+               ThrowMsg(InvalidArgumentException, "JS null passed as function.");
+       }
+       ThrowMsg(ConversionException, "Not a function nor JS null.");
+}
+}
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+JSClassRef JSFile::m_classRef = 0;
+
+JSClassDefinition JSFile::m_classInfo = {
+       0,
+       kJSClassAttributeNone,
+       PLUGIN_NAME,
+       0,
+       m_properties,
+       m_functions,
+       initialize,
+       finalize,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       getPropertyNames,
+       NULL,
+       NULL,
+       hasInstance,
+       NULL
+};
+
+JSStaticValue JSFile::m_properties[] = {
+       { PROPERTY_PARENT, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { PROPERTY_READ_ONLY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { PROPERTY_IS_FILE, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { PROPERTY_IS_DIRECTORY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { PROPERTY_CREATED, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { PROPERTY_MODIFIED, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { PROPERTY_PATH, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { PROPERTY_NAME, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { PROPERTY_FULL_PATH, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { PROPERTY_FILE_SIZE, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { PROPERTY_LENGTH, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSFile::m_functions[] = {
+       { "toURI", toUri, kJSPropertyAttributeNone },
+       { "listFiles", listFiles, kJSPropertyAttributeNone },
+       { "openStream", openStream, kJSPropertyAttributeNone },
+       { "readAsText", readAsText, kJSPropertyAttributeNone },
+       { "copyTo", copyTo, kJSPropertyAttributeNone },
+       { "moveTo", moveTo, kJSPropertyAttributeNone },
+       { "createDirectory", createDirectory, kJSPropertyAttributeNone },
+       { "createFile", createFile, kJSPropertyAttributeNone },
+       { "resolve", resolve, kJSPropertyAttributeNone },
+       { "deleteDirectory", deleteDirectory, kJSPropertyAttributeNone },
+       { "deleteFile", deleteFile, kJSPropertyAttributeNone },
+       { 0, 0, 0 }
+};
+
+void JSFile::initialize(JSContextRef context,
+               JSObjectRef object)
+{
+}
+
+void JSFile::finalize(JSObjectRef object)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(object));
+       if (privateObject) {
+               JSObjectSetPrivate(object, NULL);
+               delete privateObject;
+       }
+}
+
+const JSClassRef JSFile::getClassRef()
+{
+       if (!m_classRef) {
+               m_classRef = JSClassCreate(&m_classInfo);
+       }
+       return m_classRef;
+}
+
+const JSClassDefinition* JSFile::getClassInfo()
+{
+       return &m_classInfo;
+}
+
+JSValueRef JSFile::getProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(object));
+       if (!privateObject) {
+               return JSValueMakeUndefined(context);
+       }
+
+       JSContextRef globalContext = privateObject->getContext();
+       Converter converter(globalContext);
+
+       try {
+               if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_PARENT)) {
+                       INodePtr parent(privateObject->getObject()->getParent());
+                       if (parent) {
+                               return JSUtils::makeObject(privateObject->getContext(), getClassRef(), parent);
+                       }
+                       return JSValueMakeNull(context);
+               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_READ_ONLY)) {
+                       bool readOnly = ((privateObject->getObject()->getMode() & PERM_WRITE) == 0);
+                       return converter.toJSValueRef(readOnly);
+               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_IS_FILE)) {
+                       bool isFile = (privateObject->getObject()->getType() == NT_FILE);
+                       return converter.toJSValueRef(isFile);
+               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_IS_DIRECTORY)) {
+                       bool isDirectory =(privateObject->getObject()->getType() == NT_DIRECTORY);
+                       return converter.toJSValueRef(isDirectory);
+               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_CREATED)) {
+                       std::time_t created = privateObject->getObject()->getCreated();
+                       return converter.toJSValueRef(created);
+               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_MODIFIED)) {
+                       std::time_t modified = privateObject->getObject()->getModified();
+                       return converter.toJSValueRef(modified);
+               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_PATH)) {
+                       std::string fpath = privateObject->getObject()->getPath()->getFullPath();
+                       std::string vpath = Utils::toVirtualPath(globalContext, fpath);
+                       std::string::size_type pos = vpath.rfind(IPath::getSeparator());
+                       std::string path = (std::string::npos != pos ? vpath.substr(0, pos + 1) : vpath);
+                       return converter.toJSValueRef(path);
+               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NAME)) {
+                       std::string fpath = privateObject->getObject()->getPath()->getFullPath();
+                       std::string vpath = Utils::toVirtualPath(globalContext, fpath);
+                       std::string name;
+                       std::string::size_type pos = vpath.rfind(IPath::getSeparator());
+                       if (std::string::npos != pos) {
+                               name = vpath.substr(pos + 1);
+                       }
+                       return converter.toJSValueRef(name);
+               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_FULL_PATH)) {
+                       std::string path = privateObject->getObject()->getPath()->getFullPath();
+                       return converter.toJSValueRef(Utils::toVirtualPath(globalContext, path));
+               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_FILE_SIZE)) {
+                       if (privateObject->getObject()->getType() == NT_DIRECTORY) {
+                               return JSValueMakeUndefined(context);
+                       }
+                       return converter.toJSValueRef(privateObject->getObject()->getSize());
+               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_LENGTH)) {
+                       if (privateObject->getObject()->getType() == NT_FILE) {
+                               return JSValueMakeUndefined(context);
+                       }
+                       NodeList children = privateObject->getObject()->getChildNodes();
+                       return converter.toJSValueRef(children.size());
+               }
+       } catch (const WrtDeviceApis::Commons::Exception& ex) {
+               LogWarning("trying to get incorrect value");
+       }
+
+       return JSValueMakeUndefined(context);
+}
+
+void JSFile::getPropertyNames(JSContextRef context,
+               JSObjectRef object,
+               JSPropertyNameAccumulatorRef propertyNames)
+{
+}
+
+bool JSFile::hasInstance(JSContextRef context,
+               JSObjectRef constructor,
+               JSValueRef possibleInstance,
+               JSValueRef* exception)
+{
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+JSValueRef JSFile::toUri(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       Converter converter(context);
+       try {
+               IWrtWrapperPtr wrapper = WrtWrappersMgr::getInstance().getWrtWrapper(privateObject->getContext());
+               int widgetId = wrapper->getWidgetId();
+               return converter.toJSValueRef(privateObject->getObject()->toUri(widgetId));
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSFile::listFiles(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       if (argc < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+
+       LogDebug("OK");
+       JSContextRef globalContext = privateObject->getContext();
+
+       try {
+               
+               JSValueRef onSuccess = getFunction(globalContext, argv[0]);
+               JSValueRef onError = NULL;
+               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+                       
+               if (argc > 1) {
+                       onError = getFunctionOrNull(globalContext, argv[1]);
+               }
+
+               cbm->setOnSuccess(onSuccess);
+               cbm->setOnError(onError);
+
+               Converter converter(globalContext);
+
+               EventListNodesPtr event(new EventListNodes(privateObject->getObject()));
+               if (argc > 2) {
+                       if (!JSValueIsNull(context, argv[2]) && !JSValueIsUndefined(context, argv[2])) {
+                               try {
+                                       event->setFilter(converter.toNodeFilter(argv[2]));
+                               } catch(WrtDeviceApis::Commons::ConversionException) {
+                                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
+                               }
+                       }
+               }
+               event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
+               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+               privateObject->getObject()->getChildNodes(event);
+
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+
+       return JSValueMakeNull(context);
+}
+
+JSValueRef JSFile::openStream(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       if (argumentCount < 2) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+
+       JSContextRef globalContext = privateObject->getContext();
+
+       try {
+
+               JSValueRef onSuccess = getFunction(globalContext, arguments[1]);
+               JSValueRef onError = NULL;
+               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+                       
+               if (argumentCount > 2) {
+                       onError = getFunctionOrNull(globalContext, arguments[2]);
+               }
+
+               cbm->setOnSuccess(onSuccess);
+               cbm->setOnError(onError);
+
+               
+               Converter converter(globalContext);
+
+               AccessMode mode = converter.toAccessMode(arguments[0]);
+
+               std::string encoding = Encodings::UTF8;
+               if (argumentCount > 3) {
+                       encoding = converter.toEncoding(arguments[3]);
+               }
+
+               if ((AM_READ != mode) && (PERM_READ == privateObject->getObject()->getPermissions())) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
+               }
+
+               std::string path = privateObject->getObject()->getPath()->getFullPath();
+               std::string vpath = Utils::toVirtualPath(globalContext, path);
+
+               AccessModeInfo am = AccessModeInfo(mode, vpath);
+               AceSecurityStatus status = FILESYSTEM_ACCESSMODE_CHECK_ACCESS(
+                               globalContext,
+                               FILESYSTEM_FUNCTION_API_OPEN_STREAM,
+                               am);
+
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+               EventOpenPtr event(new EventOpen(mode));
+               event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
+               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+
+               privateObject->getObject()->open(event);
+
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+
+    return JSValueMakeNull(context);
+}
+
+JSValueRef JSFile::readAsText(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       if (argc < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+       
+       JSContextRef globalContext = privateObject->getContext();
+       AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(
+                       privateObject->getContext(),
+                       FILESYSTEM_FUNCTION_API_READ_AS_TEXT);
+
+       try {
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+               
+               JSValueRef onSuccess = getFunction(globalContext, argv[0]);
+               JSValueRef onError = NULL;
+               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+                       
+               if (argc > 1) {
+                       onError = getFunctionOrNull(globalContext, argv[1]);
+               }
+
+               cbm->setOnSuccess(onSuccess);
+               cbm->setOnError(onError);
+
+               Converter converter(context);
+               std::string src = Encodings::UTF8;
+               if (argc > 2) {
+                       if (!JSValueIsNull(context, argv[2]) && !JSValueIsUndefined(context, argv[2])) {
+                               src = converter.toEncoding(argv[2]);
+                       }
+               }
+
+               if (NT_FILE != privateObject->getObject()->getType()) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+               }
+
+               EventReadTextPtr event(new EventReadText());
+               event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
+               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData> (cbm));
+
+               privateObject->getObject()->read(event);
+
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+
+    return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSFile::copyTo(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       JSContextRef globalContext = privateObject->getContext();
+
+       if (argc < 3) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+
+       try {
+               Converter converter(globalContext);
+               IPathPtr src = Utils::fromVirtualPath(globalContext, converter.toString(argv[0]));
+               IPathPtr dest = Utils::fromVirtualPath(globalContext, converter.toString(argv[1]));
+               bool overwrite = converter.toBool(argv[2]);;
+
+               JSValueRef onSuccess = NULL;
+               JSValueRef onError = NULL;
+               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+
+               if (argc > 3) {
+                       onSuccess = getFunctionOrNull(globalContext, argv[3]);
+               }
+               
+               if (argc > 4) {
+                       onError = getFunctionOrNull(globalContext, argv[4]);
+               }
+
+               cbm->setOnSuccess(onSuccess);
+               cbm->setOnError(onError);
+               
+               if (NT_DIRECTORY != privateObject->getObject()->getType()) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+               }
+
+               std::string virtualDestPath = Utils::toVirtualPath(globalContext, dest->getFullPath());
+               AccessModeInfo amode = AccessModeInfo(Api::Filesystem::AM_WRITE, virtualDestPath);
+               AceSecurityStatus status = FILESYSTEM_ACCESSMODE_CHECK_ACCESS(
+                               globalContext,
+                               FILESYSTEM_FUNCTION_API_COPY_TO,
+                               amode);
+
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+               EventCopyPtr event(new EventCopy(src, dest));
+               if (overwrite) {
+                       event->setOptions(OPT_OVERWRITE);
+               }
+
+               event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
+               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+               IManager::getInstance().copy(event);
+               
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+
+    return JSValueMakeNull(context);
+}
+
+JSValueRef JSFile::moveTo(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       JSContextRef globalContext = privateObject->getContext();
+
+       if (argc < 3) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+
+       LogDebug("OK");
+       
+       try {
+
+               if ((privateObject->getObject()->getPermissions() & PERM_WRITE) == 0) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
+               }
+
+               if (NT_DIRECTORY != privateObject->getObject()->getType()) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+               }
+
+               Converter converter(context);
+               IPathPtr src = Utils::fromVirtualPath(globalContext, converter.toString(argv[0]));
+               IPathPtr dest = Utils::fromVirtualPath(globalContext, converter.toString(argv[1]));
+               bool overwrite = converter.toBool(argv[2]);
+
+               JSValueRef onSuccess = NULL;
+               JSValueRef onError = NULL;
+               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+
+               if (argc > 3) {
+                       onSuccess = getFunctionOrNull(globalContext, argv[3]);
+               }
+               
+               if (argc > 4) {
+                       onError = getFunctionOrNull(globalContext, argv[4]);
+               }
+
+               cbm->setOnSuccess(onSuccess);
+               cbm->setOnError(onError);
+
+               std::string virtualDestPath = Utils::toVirtualPath(globalContext, dest->getFullPath());
+
+               AccessModeInfo amode = AccessModeInfo(Api::Filesystem::AM_WRITE, virtualDestPath);
+               AceSecurityStatus status = FILESYSTEM_ACCESSMODE_CHECK_ACCESS(
+                               globalContext,
+                               FILESYSTEM_FUNCTION_API_MOVE_TO,
+                               amode);
+
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+               EventMovePtr event(new EventMove(src, dest));
+               if (overwrite) {
+                       event->setOptions(OPT_OVERWRITE);
+               }
+
+               event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
+               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+
+               IManager::getInstance().move(event);
+
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+       return JSValueMakeNull(context);
+}
+
+JSValueRef JSFile::createDirectory(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(
+                       privateObject->getContext(),
+                       FILESYSTEM_FUNCTION_API_CREATE_DIR);
+
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       if (argc < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+
+       Converter converter(context);
+       try {
+               IPathPtr path = converter.toPath(argv[0]);
+               INodePtr node(privateObject->getObject()->createChild(path, NT_DIRECTORY, OPT_RECURSIVE));
+               node->setPermissions(privateObject->getObject()->getPermissions());
+               return JSUtils::makeObject(privateObject->getContext(), getClassRef(), node);
+       } catch (const WrtDeviceApis::Commons::PlatformException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+}
+
+JSValueRef JSFile::createFile(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(
+                       privateObject->getContext(),
+                       FILESYSTEM_FUNCTION_API_CREATE_FILE);
+
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       if (argc < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+
+       Converter converter(context);
+       try {
+               IPathPtr path = converter.toPath(argv[0]);
+               INodePtr node = privateObject->getObject()->createChild(path, NT_FILE);
+               return JSUtils::makeObject(privateObject->getContext(), getClassRef(), node);
+       } catch (const WrtDeviceApis::Commons::PlatformException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSFile::resolve(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       if (argc < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+
+       if (!JSValueIsString(context, argv[0])) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+
+       if (privateObject->getObject()->getType() != NT_DIRECTORY) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+       }
+
+       Converter converter(context);
+       try {
+               IPathPtr path = converter.toPath(argv[0]);
+               INodePtr node = privateObject->getObject()->getChild(path);
+               node->setPermissions(privateObject->getObject()->getPermissions());
+               return JSUtils::makeObject(privateObject->getContext(), getClassRef(), node);
+       } catch (const WrtDeviceApis::Commons::PlatformException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSFile::deleteDirectory(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       if (argc < 2) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+
+       JSContextRef globalContext = privateObject->getContext();
+
+       LogDebug("OK");
+       
+       try {
+               AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(
+                               globalContext,
+                               FILESYSTEM_FUNCTION_API_DELETE_DIR);
+
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+               if ((privateObject->getObject()->getPermissions() & PERM_WRITE) == 0) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
+               }
+
+               if (privateObject->getObject()->getType() != NT_DIRECTORY) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+               }
+
+               Converter converter(context);
+               IPathPtr path = Utils::fromVirtualPath(globalContext, converter.toString(argv[0]));
+               bool recursive = recursive = converter.toBool(argv[1]);
+
+               if (*privateObject->getObject()->getPath() != path->getPath()) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+               }
+               JSValueRef onSuccess = NULL;
+               JSValueRef onError = NULL;
+               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+                       
+               if (argc > 2) {
+                       onSuccess = getFunctionOrNull(globalContext, argv[2]);
+               }
+               
+               if (argc > 3) {
+                       onError = getFunctionOrNull(globalContext, argv[3]);
+               }
+
+               cbm->setOnSuccess(onSuccess);
+               cbm->setOnError(onError);
+
+               EventResolvePtr eventResolve(new EventResolve(path));
+               if (eventResolve->setForSynchronousCall()) { 
+                       IManager::getInstance().getNode(eventResolve);
+                       if (!eventResolve->getResult() || (eventResolve->getExceptionCode() != WrtDeviceApis::Commons::ExceptionCodes::None)) {
+                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+                       }
+
+                       if (eventResolve->getResult()->getType() != NT_DIRECTORY) {
+                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
+                       }
+
+                       EventRemovePtr eventRemove(new EventRemove(path));
+
+                       if (recursive) {
+                               eventRemove->setOptions(OPT_RECURSIVE);
+                       }
+
+                       eventRemove->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
+                       eventRemove->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+                       IManager::getInstance().remove(eventRemove);
+               }
+       } catch (const WrtDeviceApis::Commons::PlatformException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+
+    return JSValueMakeNull(context);
+}
+
+JSValueRef JSFile::deleteFile(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       if (argc < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+
+       JSContextRef globalContext = privateObject->getContext();
+
+       LogDebug("OK");
+       
+       try {
+               AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(
+                               globalContext,
+                               FILESYSTEM_FUNCTION_API_DELETE_FILE);
+
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+               if ((privateObject->getObject()->getPermissions() & PERM_WRITE) == 0) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
+               }
+
+               if (privateObject->getObject()->getType() != NT_DIRECTORY) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+               }
+
+               Converter converter(context);
+               IPathPtr path = Utils::fromVirtualPath(globalContext, converter.toString(argv[0]));
+
+               JSValueRef onSuccess = NULL;
+               JSValueRef onError = NULL;
+               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+
+               if (argc > 1) {
+                       onSuccess = getFunctionOrNull(globalContext, argv[1]);
+               }
+               
+               if (argc > 2) {
+                       onError = getFunctionOrNull(globalContext, argv[2]);
+               }
+               
+               cbm->setOnSuccess(onSuccess);
+               cbm->setOnError(onError);
+
+               EventResolvePtr eventResolve(new EventResolve(path));
+               if (eventResolve->setForSynchronousCall()) { 
+                       IManager::getInstance().getNode(eventResolve);
+                       if (!eventResolve->getResult() ||(eventResolve->getExceptionCode() != WrtDeviceApis::Commons::ExceptionCodes::None)) {
+                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+                       }
+
+                       if (eventResolve->getResult()->getType() != NT_FILE) {
+                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
+                       }
+                       
+                       LogDebug("try to call async event");
+                       EventRemovePtr eventRemove(new EventRemove(path));
+                       eventRemove->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
+                       eventRemove->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+                       IManager::getInstance().remove(eventRemove);
+
+               }
+       } catch (const WrtDeviceApis::Commons::PlatformException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+
+       return JSValueMakeNull(context);
+}
+}
+}
+
diff --git a/src/standards/Tizen/Filesystem/JSFile.h b/src/standards/Tizen/Filesystem/JSFile.h
new file mode 100755 (executable)
index 0000000..e7b5d67
--- /dev/null
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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_JSFILE_H_
+#define TIZENAPIS_TIZEN_JSFILE_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Filesystem/INode.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+class JSFile
+{
+public:
+       typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Filesystem::INodePtr>::Type PrivateObject;
+
+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 collecting the names of an object's properties.
+       */
+       static void getPropertyNames(JSContextRef context,
+               JSObjectRef object,
+               JSPropertyNameAccumulatorRef propertyNames);
+
+       /**
+       * 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);
+
+       /**
+       * Returns a URI for the file.
+       */
+       static JSValueRef toUri(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * Returns list of all files of this directory.
+       */
+       static JSValueRef listFiles(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * WRT_GeneralError exception
+       */
+       static JSValueRef openStream(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * WRT_GeneralError exception
+       */
+       static JSValueRef readAsText(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * The operation is only for file except for directory.
+       * Make sure the dest directory already exists.
+       */
+       static JSValueRef copyTo(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * This operation is only for file not directory
+       * The dest directory should exists in local file system, or the operation fails.
+       */
+       static JSValueRef moveTo(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * create directory even through the parent directories do not  exist in local file system.
+       */
+       static JSValueRef createDirectory(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * Creates a new empty file in a specified location.
+       */
+       static JSValueRef createFile(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * Resolves an existing file or directory relative to
+       * the current directory this operation is performed on; and
+       * returns a file handle for it.
+       */
+       static JSValueRef resolve(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+        * Removes all files from specified directory if recursive is true, 
+        * or just remove the directory itself when there is no files or directories underneath it
+        */
+       static JSValueRef deleteDirectory(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * Deletes a specified file.
+       */
+       static JSValueRef deleteFile(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * This structure describes a statically declared function property.
+       */
+       static JSStaticFunction m_functions[];
+
+       /**
+       * This structure describes a statically declared value property.
+       */
+       static JSStaticValue m_properties[];
+
+       /**
+       * This structure contains properties and callbacks that define a type of object.
+       */
+       static JSClassDefinition m_classInfo;
+
+       static JSClassRef m_classRef;
+};
+}
+}
+
+#endif
\ No newline at end of file
diff --git a/src/standards/Tizen/Filesystem/JSFilestream.cpp b/src/standards/Tizen/Filesystem/JSFilestream.cpp
new file mode 100755 (executable)
index 0000000..eb44bfc
--- /dev/null
@@ -0,0 +1,404 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "JSFilestream.h"
+
+#include <dpl/scoped_array.h>
+#include <dpl/log/log.h>
+
+#include <Commons/Base64.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include "Converter.h"
+#include "plugin_config.h"
+
+namespace {
+const char* PLUGIN_NAME = "FileStream";
+const char* PROPERTY_EOF = "eof";
+const char* PROPERTY_POSITION = "position";
+const char* PROPERTY_BYTES_AVAILABLE = "bytesAvailable";
+}
+
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+JSClassRef JSFilestream::m_classRef = 0;
+
+JSClassDefinition JSFilestream::m_classInfo = {
+       0,
+       kJSClassAttributeNone,
+       PLUGIN_NAME,
+       0,
+       m_properties,
+       m_functions,
+       initialize,
+       finalize,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       getPropertyNames,
+       NULL,
+       NULL,
+       hasInstance,
+       NULL
+};
+
+JSStaticValue JSFilestream::m_properties[] = {
+       { PROPERTY_EOF, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { PROPERTY_POSITION, getProperty, setProperty, kJSPropertyAttributeNone },
+       { PROPERTY_BYTES_AVAILABLE, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSFilestream::m_functions[] = {
+       { "close", close, kJSPropertyAttributeNone },
+       { "read", read, kJSPropertyAttributeNone },
+       { "readBytes", readBytes, kJSPropertyAttributeNone },
+       { "readBase64", readBase64, kJSPropertyAttributeNone },
+       { "write", write, kJSPropertyAttributeNone },
+       { "writeBytes", writeBytes, kJSPropertyAttributeNone },
+       { "writeBase64", writeBase64, kJSPropertyAttributeNone },
+       { 0, 0, 0 }
+};
+
+void JSFilestream::initialize(JSContextRef context,
+       JSObjectRef object)
+{
+}
+
+void JSFilestream::finalize(JSObjectRef object)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(object));
+       delete privateObject;
+}
+
+const JSClassRef JSFilestream::getClassRef()
+{
+       if (!m_classRef) {
+               m_classRef = JSClassCreate(&m_classInfo);
+       }
+       return m_classRef;
+}
+
+const JSClassDefinition* JSFilestream::getClassInfo()
+{
+       return &m_classInfo;
+}
+
+JSValueRef JSFilestream::getProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(object));
+       if (!privateObject) {
+               return JSValueMakeUndefined(context);
+       }
+
+       PrivateObject::ObjectType stream = privateObject->getObject();
+       Converter converter(context);
+       try {
+               if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_EOF)) {
+                       return converter.toJSValueRef(stream->isEof());
+               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_POSITION)) {
+                       long pos = stream->getPosition();
+                       if (pos < 0) {
+                               return JSValueMakeUndefined(context);
+                       }
+                       return converter.toJSValueRef(static_cast<unsigned long>(pos));
+               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_BYTES_AVAILABLE)) {
+                       long bytes = stream->getSize() - stream->getPosition();
+                       return converter.toJSValueRef(static_cast<unsigned long>(bytes));
+               }
+       } catch (const WrtDeviceApis::Commons::ConversionException& ex) {
+               LogWarning("trying to get incorrect value");
+       }
+
+       return JSValueMakeUndefined(context);
+}
+
+bool JSFilestream::setProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject =  static_cast<PrivateObject*>(JSObjectGetPrivate(object));
+       if (!privateObject) {
+               return false;
+       }
+
+       Converter converter(context);
+       try {
+               if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_POSITION)) {
+                       privateObject->getObject()->setPosition(converter.toLong(value));
+                       return true;
+               }
+       } catch (const WrtDeviceApis::Commons::Exception& ex) {
+               LogWarning("trying to set incorrect value");
+       }
+
+       return false;
+}
+
+void JSFilestream::getPropertyNames(JSContextRef context,
+               JSObjectRef object,
+               JSPropertyNameAccumulatorRef propertyNames)
+{
+}
+
+bool JSFilestream::hasInstance(JSContextRef context,
+               JSObjectRef constructor,
+               JSValueRef instance,
+               JSValueRef* exception)
+{
+    return JSValueIsObjectOfClass(context, instance, JSFilestream::getClassRef());
+}
+
+JSValueRef JSFilestream::close(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject =  static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       Try {
+               privateObject->getObject()->close();
+       } Catch (WrtDeviceApis::Commons::PlatformException) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSFilestream::read(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       if (argc < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch error");
+       }
+
+       Converter converter(context);
+       try {
+               unsigned long count = converter.toULong(argv[0]);
+               DPL::ScopedArray<char> text(privateObject->getObject()->getChars(count));
+               return converter.toJSValueRef(std::string(text.Get()));
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       }
+       
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSFilestream::readBytes(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       if (argc < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch error");
+       }
+
+       Converter converter(context);
+       Try {
+               unsigned long count = converter.toULong(argv[0]);
+               DPL::ScopedArray<unsigned char> data(privateObject->getObject()->getBytes(count));
+               return converter.toJSValueRef(data.Get(), privateObject->getObject()->getCount());
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       }
+
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSFilestream::readBase64(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       if (argc < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch error");
+       }
+
+       Converter converter(context);
+       try {
+               unsigned long count = converter.toULong(argv[0]);
+               DPL::ScopedArray<unsigned char> data(privateObject->getObject()->getBytes(count));
+               std::string base64 = WrtDeviceApis::Commons::Base64::encode(data.Get(), privateObject->getObject()->getCount());
+               return converter.toJSValueRef(base64);
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       }
+
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSFilestream::write(JSContextRef context,
+       JSObjectRef object,
+       JSObjectRef thisObject,
+       size_t argc,
+       const JSValueRef argv[],
+       JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       if (argc < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch error");
+       }
+
+       Converter converter(context);
+       try {
+               privateObject->getObject()->write(converter.toString(argv[0]));
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       }
+
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSFilestream::writeBytes(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       if (argc < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch error");
+       }
+
+       Converter converter(context);
+       Try {
+               PrivateObject::ObjectType stream = privateObject->getObject();
+               std::vector<unsigned char> data = converter.toVectorOfUChars(argv[0]);
+               std::vector<unsigned char>::const_iterator it = data.begin();
+               for (; it != data.end(); ++it) {
+                       stream->write(*it);
+               }
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       }
+
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSFilestream::writeBase64(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       if (argc < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch error");
+       }
+
+       Converter converter(context);
+       try {
+               std::string base64 = WrtDeviceApis::Commons::Base64::decode(converter.toString(argv[0]));
+               privateObject->getObject()->write(base64);
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       }
+
+       return JSValueMakeUndefined(context);
+}
+} // Tizen1_0
+} // TizenApis
+
diff --git a/src/standards/Tizen/Filesystem/JSFilestream.h b/src/standards/Tizen/Filesystem/JSFilestream.h
new file mode 100755 (executable)
index 0000000..d68e1c3
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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_JSFILESTREAM_H_
+#define TIZENAPIS_TIZEN_JSFILESTREAM_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Filesystem/IStream.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+class JSFilestream
+{
+public:
+       typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Filesystem::IStreamPtr>::Type PrivateObject;
+
+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 setting a property's value.
+       */
+       static bool setProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception);
+
+       /**
+       * The callback invoked when collecting the names of an object's properties.
+       */
+       static void getPropertyNames(JSContextRef context,
+               JSObjectRef object,
+               JSPropertyNameAccumulatorRef propertyNames);
+
+       /**
+       * 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);
+
+       /**
+       * Closes this FileStream.
+       */
+       static JSValueRef close(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * Reads the specified number of characters from this FileStream.
+       */
+       static JSValueRef read(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * Reads the specified number of bytes from this FileStream.
+       */
+       static JSValueRef readBytes(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * Reads the specified number of bytes from this FileStream, encoding the result in base64.
+       */
+       static JSValueRef readBase64(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * Writes the specified DOMString to this FileStream.
+       */
+       static JSValueRef write(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * Writes the specified bytes to this FileStream.
+       */
+       static JSValueRef writeBytes(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * Converts the specified base64 DOMString to bytes and writes the result to this FileStream.
+       */
+       static JSValueRef writeBase64(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       /**
+       * This structure describes a statically declared function property.
+       */
+       static JSStaticFunction m_functions[];
+
+       /**
+       * This structure describes a statically declared value property.
+       */
+       static JSStaticValue m_properties[];
+
+       /**
+       * This structure contains properties and callbacks that define a type of object.
+       */
+       static JSClassDefinition m_classInfo;
+
+       static JSClassRef m_classRef;
+};
+}
+}
+
+#endif
\ No newline at end of file
diff --git a/src/standards/Tizen/Filesystem/JSFilesystemManager.cpp b/src/standards/Tizen/Filesystem/JSFilesystemManager.cpp
new file mode 100755 (executable)
index 0000000..bd4acdd
--- /dev/null
@@ -0,0 +1,441 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 "JSFilesystemManager.h"
+
+#include <dpl/log/log.h>
+
+#include <Commons/Exception.h>
+#include <API/Filesystem/EventResolve.h>
+#include <API/Filesystem/IManager.h>
+#include <API/Filesystem/IPath.h>
+#include <API/Filesystem/EventGetStorage.h>
+#include <API/Filesystem/EventListStorages.h>
+#include <API/Filesystem/EventStorageStateChanged.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <CommonsJavaScript/Utils.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/Validator.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h> 
+#include <Tizen/Common/SecurityExceptions.h>
+
+#include "JSFile.h"
+#include "FilesystemUtils.h"
+#include "Converter.h"
+#include "EventGetNodeData.h"
+#include "plugin_config.h"
+#include "StorageStaticController.h"
+#include "ResponseDispatcher.h"
+
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Commons;
+
+
+namespace {
+const char* PLUGIN_NAME = "filesystem";
+const char* PROPERTY_MAXPATHLENGTH = "maxPathLength";
+
+JSValueRef getFunctionOrNull(JSContextRef ctx, JSValueRef arg)
+{
+       if (Validator(ctx).isCallback(arg)) {
+               return arg;
+       } else if (!JSValueIsNull(ctx, arg) && !JSValueIsUndefined(ctx, arg)) {
+               ThrowMsg(ConversionException, "Not a function nor JS null.");
+       }
+       return NULL;
+}
+
+
+JSValueRef getFunction(JSContextRef ctx, JSValueRef arg)
+{
+       if (Validator(ctx).isCallback(arg)) {
+               return arg;
+       } else if (JSValueIsNull(ctx, arg) || JSValueIsUndefined(ctx, arg)) {
+               ThrowMsg(InvalidArgumentException, "JS null passed as function.");
+       }
+       ThrowMsg(ConversionException, "Not a function nor JS null.");
+}
+
+}
+
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+JSClassRef JSFilesystemManager::m_classRef = 0;
+
+JSClassDefinition JSFilesystemManager::m_classInfo = {
+       0,
+       kJSClassAttributeNone,
+       PLUGIN_NAME,
+       0,
+       m_properties,
+       m_functions,
+       initialize,
+       finalize,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+};
+
+JSStaticValue JSFilesystemManager::m_properties[] = {
+       { PROPERTY_MAXPATHLENGTH, getMaxPathLength, NULL, kJSPropertyAttributeReadOnly },
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSFilesystemManager::m_functions[] = {
+       { "resolve", JSFilesystemManager::resolve, kJSPropertyAttributeNone },
+       { "getStorage", JSFilesystemManager::getStorage, kJSPropertyAttributeNone },
+       { "listStorages", JSFilesystemManager::getStorageList, kJSPropertyAttributeNone },
+       { "addStorageStateChangeListener", JSFilesystemManager::addStorageStateListener, kJSPropertyAttributeNone },
+       { "removeStorageStateChangeListener", JSFilesystemManager::removeStorageStateListener, kJSPropertyAttributeNone },
+       { 0, 0, 0 }
+};
+
+const JSClassRef JSFilesystemManager::getClassRef()
+{
+       if (!m_classRef) {
+               m_classRef = JSClassCreate(&m_classInfo);
+       }
+       return m_classRef;
+}
+
+const JSClassDefinition* JSFilesystemManager::getClassInfo()
+{
+       return &m_classInfo;
+}
+
+void JSFilesystemManager::initialize(JSContextRef context,
+        JSObjectRef object)
+{
+       PrivateObject* privateObject = new PrivateObject(context);
+       if (!JSObjectSetPrivate(object, privateObject)) {
+               delete privateObject;
+       }
+}
+
+void JSFilesystemManager::finalize(JSObjectRef object)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(object));
+       if (privateObject) {
+               JSObjectSetPrivate(object, NULL);
+               delete privateObject;
+       }
+}
+
+JSValueRef JSFilesystemManager::getMaxPathLength(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       ConverterPtr converter = ConverterFactory::getConverter(context);
+       try {
+               return converter->toJSValueRef(Api::Filesystem::IManager::getInstance().getMaxPathLength());
+       } catch (const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSFilesystemManager::getStorage(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSValueMakeUndefined(context);
+       }
+
+       if (argc < 2) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+
+       JSContextRef globalContext = privateObject->getContext();
+       ConverterPtr converter = ConverterFactory::getConverter(globalContext);
+
+       try {
+
+               JSValueRef onSuccess = getFunction(globalContext, argv[1]);
+               JSValueRef onError = NULL;
+               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+                       
+               if (argc > 2) {
+                       onError = getFunctionOrNull(globalContext, argv[2]);
+               }
+
+               cbm->setOnSuccess(onSuccess);
+               cbm->setOnError(onError);
+               
+               if (JSValueIsNull(context, argv[0]) || JSValueIsUndefined(context, argv[0]) || !JSValueIsString(context, argv[0])) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
+               }
+
+               Api::Filesystem::EventGetStoragePtr event(new Api::Filesystem::EventGetStorage());
+               event->setLabel(converter->toString(argv[0]));
+               event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
+               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+
+
+               Api::Filesystem::IManager::getInstance().getStorage(event);
+
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+
+       return JSValueMakeNull(context);
+}
+
+JSValueRef JSFilesystemManager::getStorageList(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSValueMakeUndefined(context);
+       }
+
+       if (argc < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+               
+
+       JSContextRef globalContext = privateObject->getContext();
+       ConverterPtr converter = ConverterFactory::getConverter(globalContext);
+       
+       try {
+
+               JSValueRef onSuccess = getFunction(globalContext, argv[0]);
+               JSValueRef onError = NULL;
+               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+                       
+               if (argc > 1) {
+                       onError = getFunctionOrNull(globalContext, argv[1]);
+               }
+
+               cbm->setOnSuccess(onSuccess);
+               cbm->setOnError(onError);
+               
+
+               Api::Filesystem::EventListStoragesPtr event(new Api::Filesystem::EventListStorages());
+               event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
+               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+               Api::Filesystem::IManager::getInstance().listStorages(event);
+
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+
+       return JSValueMakeNull(context);
+}
+
+JSValueRef JSFilesystemManager::addStorageStateListener(JSContextRef context, 
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSValueMakeUndefined(context);
+       }
+
+       if (argc < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+
+       JSContextRef globalContext = privateObject->getContext();
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+       ConverterPtr converter = ConverterFactory::getConverter(globalContext);
+
+       try {
+               if (JSValueIsNull(context, argv[0]) || JSValueIsUndefined(context, argv[0])) {
+                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error"));
+                       return JSValueMakeNull(context);
+               } else if (!JSObjectIsFunction(context, converter->toJSObjectRef(argv[0]))) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+               }
+               cbm->setOnSuccess(argv[0]);
+
+               Api::Filesystem::EventStorageStateChangedEmitterPtr emitter(new Api::Filesystem::EventStorageStateChangedEmitter);
+               emitter->setListener(&StorageStaticController::getInstance());
+               emitter->setEventPrivateData(DPL::StaticPointerCast<Api::Filesystem::EventStorageStateChanged::PrivateDataType>(cbm));
+               long id = Api::Filesystem::IManager::getInstance().addStorageStateChangeListener(emitter);
+               return converter->toJSValueRefLong(id);
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSFilesystemManager::removeStorageStateListener(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSValueMakeUndefined(context);
+       }
+
+       if (argc < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+
+       if (!JSValueIsNumber(context, argv[0])) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+
+       JSContextRef globalContext = privateObject->getContext();
+       ConverterPtr converter = ConverterFactory::getConverter(globalContext);
+       
+       try {
+               long id = static_cast<long>(converter->toLong(argv[0]));
+
+               if (id >= 0) {
+                       Api::Filesystem::IManager::getInstance().removeStorageStateChangeListener(id);
+               }
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSFilesystemManager::resolve(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argc,
+               const JSValueRef argv[],
+               JSValueRef* exception)
+{
+       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSValueMakeUndefined(context);
+       }
+
+       if (argc < 2) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+       }
+
+       JSContextRef globalContext = privateObject->getContext();
+       ConverterPtr converter = ConverterFactory::getConverter(globalContext);
+       
+       try {
+
+               JSValueRef onSuccess = getFunction(globalContext, argv[1]);
+               JSValueRef onError = NULL;
+               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+                       
+               if (argc > 2) {
+                       onError = getFunctionOrNull(globalContext, argv[2]);
+               }
+
+               cbm->setOnSuccess(onSuccess);
+               cbm->setOnError(onError);
+               
+               Api::Filesystem::IPathPtr path = Utils::fromVirtualPath(globalContext, converter->toString(argv[0]));
+               std::string virtualPath = converter->toString(argv[0]);
+
+               int permissions = Api::Filesystem::PERM_READ;
+
+               if (argc > 3) {
+                       if (!JSValueIsNull(context, argv[3]) && !JSValueIsUndefined(context, argv[3])) {
+                               std::string perms = converter->toString(argv[3]);
+                               if (("r" != perms) && ("rw" != perms) && ("w" != perms) && ("a" != perms)) {
+                                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
+                               } else if ("r" == perms) {
+                                       permissions = Api::Filesystem::PERM_READ;
+                               } else {
+                                       permissions = Api::Filesystem::PERM_READ | Api::Filesystem::PERM_WRITE;
+                               }
+                               
+                       }
+               }
+
+               PermissionsAccessInfo perms(permissions, virtualPath);
+               AceSecurityStatus status = FILESYSTEM_PERMISSION_CHECK_ACCESS(
+                               privateObject->getContext(),
+                               FILESYSTEM_FUNCTION_API_MGR_RESOLVE_ID,
+                               perms);
+
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+               EventGetNodeDataPtr data(new EventGetNodeData(permissions, cbm));
+               Api::Filesystem::EventResolvePtr event(new Api::Filesystem::EventResolve(path));
+               event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
+               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (data));
+               Api::Filesystem::IManager::getInstance().getNode(event);
+               
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::NotFoundException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+
+       return JSValueMakeNull(context);
+}
+}
+}
diff --git a/src/standards/Tizen/Filesystem/JSFilesystemManager.h b/src/standards/Tizen/Filesystem/JSFilesystemManager.h
new file mode 100755 (executable)
index 0000000..8759677
--- /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. 
+ */
+
+#ifndef TIZENAPIS_TIZEN_JSFILESYSTEMMANAGER_H_
+#define TIZENAPIS_TIZEN_JSFILESYSTEMMANAGER_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+class JSFilesystemManager
+{
+  public:
+    typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<void>::Type PrivateObject;
+
+  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 getMaxPathLength(JSContextRef context,
+            JSObjectRef object,
+            JSStringRef propertyName,
+            JSValueRef* exception);
+
+    /**
+     * Resolves a location to a File handle.
+     */
+    static JSValueRef resolve(JSContextRef context,
+            JSObjectRef object,
+            JSObjectRef thisObject,
+            size_t argc,
+            const JSValueRef argv[],
+            JSValueRef* exception);
+
+    /**
+     * Get information about a storage based on it's label.
+     */
+    static JSValueRef getStorage(JSContextRef context,
+       JSObjectRef object,
+       JSObjectRef thisObject,
+       size_t argc,
+       const JSValueRef argv[],
+       JSValueRef* exception);
+
+    /**
+     * List the available storages on the device.
+     * Get the list of available internal and external storage devices.
+     */
+    static JSValueRef getStorageList(JSContextRef context,
+            JSObjectRef object,
+            JSObjectRef thisObject,
+            size_t argc,
+            const JSValueRef argv[],
+            JSValueRef* exception);
+
+    static JSValueRef addStorageStateListener(JSContextRef context, 
+       JSObjectRef object,
+       JSObjectRef thisObject,
+       size_t argc,
+       const JSValueRef argv[],
+       JSValueRef* exception) ;
+
+    static JSValueRef removeStorageStateListener(JSContextRef context, 
+       JSObjectRef object,
+       JSObjectRef thisObject,
+       size_t argc, 
+       const JSValueRef argv[],
+       JSValueRef* exception);
+
+  private:
+    /**
+     * This structure describes a statically declared function property.
+     */
+    static JSStaticFunction m_functions[];
+
+    /**
+     * This structure describes a statically declared value property.
+     */
+    static JSStaticValue m_properties[];
+
+    /**
+     * This structure contains properties and callbacks that define a type of object.
+     */
+    static JSClassDefinition m_classInfo;
+
+    static JSClassRef m_classRef;
+};
+}
+}
+
+#endif
\ No newline at end of file
diff --git a/src/standards/Tizen/Filesystem/JSStorage.cpp b/src/standards/Tizen/Filesystem/JSStorage.cpp
new file mode 100755 (executable)
index 0000000..5fa776d
--- /dev/null
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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/JSDOMExceptionFactory.h>
+#include <API/Filesystem/StorageProperties.h>
+#include "JSStorage.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace Api::Filesystem;
+
+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";
+} //private namespace
+
+JSClassDefinition JSStorage::m_classInfo = {
+       0,
+       kJSClassAttributeNone,
+       "FileSystemStorage",
+       0,
+       m_property,
+       0,
+       initialize,
+       finalize,
+       NULL,     //HasProperty,
+       getProperty,
+       NULL,     //SetProperty,
+       NULL,     //DeleteProperty,
+       NULL,     //GetPropertyNames,
+       NULL,     //CallAsFunction,
+       NULL,     //CallAsConstructor,
+       hasInstance,
+       NULL,     //ConvertToType
+};
+
+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_EXTERNAL, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { STR_STATE_MOUNTED, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { STR_STATE_REMOVED, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { STR_STATE_UNMOUNTABLE, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSStorage::getClassRef()
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_classInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSStorage::getClassInfo()
+{
+       return &m_classInfo;
+}
+
+JSClassRef JSStorage::m_jsClassRef = JSClassCreate(
+               JSStorage::getClassInfo());
+
+JSObjectRef JSStorage::createJSObject(JSContextRef context,
+               const StorageProperties &storages)
+{
+       std::auto_ptr<StorageProperties> storageProps(new StorageProperties());
+
+       storageProps->setLabel(storages.getLabel());
+       storageProps->setType(storages.getType());
+       storageProps->setState(storages.getState());
+
+       JSStoragePriv *priv = new JSStoragePriv(context, storageProps.get());
+       storageProps.release();
+       if (!priv) {
+               ThrowMsg(Commons::NullPointerException, "Can not new an object");
+       }
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
+void JSStorage::initialize(JSContextRef context,
+               JSObjectRef object)
+{
+}
+
+void JSStorage::finalize(JSObjectRef object)
+{
+       JSStoragePriv* priv = static_cast<JSStoragePriv*>(JSObjectGetPrivate(object));
+       JSObjectSetPrivate(object, NULL);
+       delete priv;
+}
+
+JSValueRef JSStorage::getProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       JSStoragePriv *priv = static_cast<JSStoragePriv*>(JSObjectGetPrivate(object));
+       assert(priv && "Private object not set.");
+
+       Try {
+               StorageProperties *storages = priv->getObject();
+               Converter convert(context);
+
+               if (JSStringIsEqualToUTF8CString(propertyName, STR_STORAGE_LABEL)) {
+                       return convert.toJSValueRef(storages->getLabel());
+               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_STORAGE_TYPE)) {
+                       return convert.toJSValueRef(storages->getType());
+               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_STORAGE_STATE)) {
+                       return convert.toJSValueRef(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);
+               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_STATE_MOUNTED)) {
+                       return convert.toJSValueRef(STATE_MOUNTED);
+               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_STATE_REMOVED)) {
+                       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");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSStorage::hasInstance(JSContextRef context,
+               JSObjectRef constructor,
+               JSValueRef possibleInstance,
+               JSValueRef* exception)
+{
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+}
+}
+
diff --git a/src/standards/Tizen/Filesystem/JSStorage.h b/src/standards/Tizen/Filesystem/JSStorage.h
new file mode 100755 (executable)
index 0000000..c961937
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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_STORAGE_H_
+#define TIZENAPIS_TIZEN_JS_STORAGE_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Filesystem/StorageProperties.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Filesystem::StorageProperties*>::Type JSStoragePriv;
+
+class JSStorage
+{
+public:
+       enum StorageType
+       {
+               TYPE_INTERNAL = 0,
+               TYPE_EXTERNAL,
+       };
+
+       enum StorageState
+       {
+               STATE_MOUNTED = 0,
+               STATE_REMOVED,
+               STATE_UNMOUNTABLE,
+       };
+               
+       static const JSClassDefinition* getClassInfo();
+
+       static const JSClassRef getClassRef();
+
+       /**
+       * create an JSObject for callback function(onAnswerReceived).
+       */
+       static JSObjectRef createJSObject(JSContextRef context,
+               const Api::Filesystem::StorageProperties &storages);
+
+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;
+};
+}
+}
+
+#endif
+
diff --git a/src/standards/Tizen/Filesystem/ResponseDispatcher.cpp b/src/standards/Tizen/Filesystem/ResponseDispatcher.cpp
new file mode 100755 (executable)
index 0000000..0719a5c
--- /dev/null
@@ -0,0 +1,239 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include "ResponseDispatcher.h"
+
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+
+#include <Commons/Exception.h>
+#include <Commons/IEvent.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h> 
+#include "JSFile.h"
+#include "JSFilestream.h"
+#include "EventGetNodeData.h"
+#include "Converter.h"
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+ResponseDispatcher& ResponseDispatcher::getInstance()
+{
+       static ResponseDispatcher dispatcher;
+       return dispatcher;
+}
+
+ResponseDispatcher::ResponseDispatcher() :
+       EventAnswerReceiver<Api::Filesystem::EventResolve>(ThreadEnum::NULL_THREAD),
+       EventAnswerReceiver<Api::Filesystem::EventGetStorage>(ThreadEnum::NULL_THREAD),
+       EventAnswerReceiver<Api::Filesystem::EventListStorages>(ThreadEnum::NULL_THREAD),
+       EventAnswerReceiver<Api::Filesystem::EventListNodes>(ThreadEnum::NULL_THREAD),
+       EventAnswerReceiver<Api::Filesystem::EventOpen>(ThreadEnum::NULL_THREAD),
+       EventAnswerReceiver<Api::Filesystem::EventCopy>(ThreadEnum::NULL_THREAD),
+       EventAnswerReceiver<Api::Filesystem::EventMove>(ThreadEnum::NULL_THREAD),
+       EventAnswerReceiver<Api::Filesystem::EventRemove>(ThreadEnum::NULL_THREAD),
+       EventAnswerReceiver<Api::Filesystem::EventReadText>(ThreadEnum::NULL_THREAD)
+{
+}
+
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventResolvePtr& event)
+{
+       EventGetNodeDataPtr data = DPL::DynamicPointerCast<EventGetNodeData>(event->getPrivateData());
+       Assert(NULL != data);
+
+       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+               event->getResult()->setPermissions(data->getPerms());
+               JSObjectRef object = JSUtils::makeObject(data->getCallbackManager()->getContext(), JSFile::getClassRef(), event->getResult());
+               data->getCallbackManager()->callOnSuccess(object);
+       } else {
+               JSObjectRef jsException =       JSTizenExceptionFactory::makeErrorObject(data->getCallbackManager()->getContext(), JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+               data->getCallbackManager()->callOnError(jsException);
+       }
+}
+
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventGetStoragePtr& event)
+{
+       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+       Assert(NULL != data);
+
+       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+               Converter converter(data->getContext());
+               Try {
+                       JSValueRef result = converter.toJSValueRef(event->getResult(), data->getContext());
+                       data->callOnSuccess(result);
+               } Catch (WrtDeviceApis::Commons::ConversionException) {
+                       data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error"));
+               }
+       } else {
+               JSObjectRef jsException = NULL;
+               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
+               } else {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
+               }
+               data->callOnError(jsException);
+       }
+}
+
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventListStoragesPtr& event)
+{
+       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+       Assert(NULL != data);
+
+       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+               Converter converter(data->getContext());
+               Try {
+                       JSValueRef result = converter.toJSValueRef(event->getResult(), data->getContext());
+                       data->callOnSuccess(result);
+               } Catch (WrtDeviceApis::Commons::ConversionException) {
+                       data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error"));
+               }
+       } else {
+               JSObjectRef jsException = NULL;
+               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
+               } else {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
+               }
+               data->callOnError(jsException);
+       }
+}
+
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventListNodesPtr& event)
+{
+       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+       Assert(NULL != data);
+
+       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+               Converter converter(data->getContext());
+               Try {
+                       JSValueRef result = converter.toJSValueRef(event->getResult(), data->getContext());
+                       data->callOnSuccess(result);
+               } Catch (WrtDeviceApis::Commons::ConversionException) {
+                       data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error"));
+               }
+       } else {
+               JSObjectRef jsException = NULL;
+               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
+               } else {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
+               }
+               data->callOnError(jsException);
+       }
+}
+
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventOpenPtr& event)
+{
+       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+       Assert(NULL != data);
+
+       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+               JSObjectRef object = JSUtils::makeObject(data->getContext(), JSFilestream::getClassRef(), event->getResult());
+               data->callOnSuccess(object);
+       } else {
+               JSObjectRef jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
+               data->callOnError(jsException);
+       }
+}
+
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventCopyPtr& event)
+{
+       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+       Assert(NULL != data);
+
+       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+               JSObjectRef object = JSUtils::makeObject(data->getContext(), JSFile::getClassRef(), event->getResult());
+               data->callOnSuccess(object);
+       } else {
+               JSObjectRef jsException = NULL;
+               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
+               } else {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
+               }
+               data->callOnError(jsException);
+       }
+}
+
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventMovePtr& event)
+{
+       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+       Assert(NULL != data);
+
+       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+               JSObjectRef object = JSUtils::makeObject(data->getContext(), JSFile::getClassRef(), event->getResult());
+               data->callOnSuccess(object);
+       } else {
+               JSObjectRef jsException = NULL;
+               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
+               } else {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
+               }
+               data->callOnError(jsException);
+       }
+}
+
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventRemovePtr& event)
+{
+       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+       Assert(NULL != data);
+
+       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+               data->callOnSuccess();
+       } else {
+               JSObjectRef jsException = NULL;
+               if (event->getExceptionCode() ==WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
+               } else {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
+               }
+               data->callOnError(jsException);
+       }
+}
+
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventReadTextPtr& event)
+{
+       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+       Assert(NULL != data);
+
+       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+               Converter converter(data->getContext());
+               Try {
+                       JSValueRef result = converter.toJSValueRef(event->getResult());
+                       data->callOnSuccess(result);
+               } Catch (WrtDeviceApis::Commons::ConversionException) {
+                       data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error"));
+               }
+       } else {
+               JSObjectRef jsException = NULL;
+               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
+               } else {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
+               }
+               data->callOnError(jsException);
+       }
+}
+}
+}
diff --git a/src/standards/Tizen/Filesystem/ResponseDispatcher.h b/src/standards/Tizen/Filesystem/ResponseDispatcher.h
new file mode 100755 (executable)
index 0000000..bbcd28e
--- /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_RESPONSEDISPATCHER_H_
+#define TIZENAPIS_TIZEN_RESPONSEDISPATCHER_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <Commons/EventReceiver.h>
+#include <API/Filesystem/EventResolve.h>
+#include <API/Filesystem/EventGetStorage.h>
+#include <API/Filesystem/EventListStorages.h>
+#include <API/Filesystem/EventListNodes.h>
+#include <API/Filesystem/EventOpen.h>
+#include <API/Filesystem/EventCopy.h>
+#include <API/Filesystem/EventMove.h>
+#include <API/Filesystem/EventRemove.h>
+#include <API/Filesystem/EventReadText.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+class ResponseDispatcher : 
+       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Filesystem::EventResolve>,
+       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Filesystem::EventGetStorage>,
+       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Filesystem::EventListStorages>,
+       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Filesystem::EventListNodes>,
+       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Filesystem::EventOpen>,
+       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Filesystem::EventCopy>,
+       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Filesystem::EventMove>,
+       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Filesystem::EventRemove>,
+       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Filesystem::EventReadText>
+{
+public:
+       static ResponseDispatcher& getInstance();
+
+       void OnAnswerReceived(const Api::Filesystem::EventResolvePtr& event);
+       void OnAnswerReceived(const Api::Filesystem::EventGetStoragePtr& event);
+       void OnAnswerReceived(const Api::Filesystem::EventListStoragesPtr& event);
+       void OnAnswerReceived(const Api::Filesystem::EventListNodesPtr& event);
+       void OnAnswerReceived(const Api::Filesystem::EventOpenPtr& event);
+       void OnAnswerReceived(const Api::Filesystem::EventCopyPtr& event);
+       void OnAnswerReceived(const Api::Filesystem::EventMovePtr& event);
+       void OnAnswerReceived(const Api::Filesystem::EventRemovePtr& event);
+       void OnAnswerReceived(const Api::Filesystem::EventReadTextPtr& event);
+
+protected:
+       ResponseDispatcher();
+};
+}
+}
+
+#endif
+
diff --git a/src/standards/Tizen/Filesystem/StorageStaticController.cpp b/src/standards/Tizen/Filesystem/StorageStaticController.cpp
new file mode 100755 (executable)
index 0000000..d62020b
--- /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 <JavaScriptCore/JavaScript.h>
+#include <dpl/log/log.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <CommonsJavaScript/Converter.h>
+#include <Commons/IEvent.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <API/Filesystem/EventStorageStateChanged.h>
+#include "StorageStaticController.h"
+#include "JSStorage.h"
+#include "Converter.h"
+
+using namespace TizenApis::Api::Filesystem;
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+StorageStaticController& StorageStaticController::getInstance()
+{
+       static StorageStaticController controller;
+       return controller;
+}
+
+StorageStaticController::StorageStaticController() :
+       EventListener<EventStorageStateChanged>(ThreadEnum::NULL_THREAD)
+{
+}
+
+void StorageStaticController::onAnswerReceived(
+       const EventStorageStateChangedPtr& event)
+{
+       JSCallbackManagerPtr callbackManager =
+               DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+
+       JSContextRef context = callbackManager->getContext();
+       Converter converter(context);
+       try {
+               JSValueRef result = converter.toJSValueRef(event->getResult(), context);
+               callbackManager->callOnSuccess(result);
+       } catch(Commons::ConversionException) {
+               LogError("Conversion exception while processing EventStorageStateChanged");
+       }
+}
+}
+}
\ No newline at end of file
diff --git a/src/standards/Tizen/Filesystem/StorageStaticController.h b/src/standards/Tizen/Filesystem/StorageStaticController.h
new file mode 100755 (executable)
index 0000000..ba54037
--- /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_TIZEN_FILESYSTEM_STORAGE_STATIC_CONTROLLER_H_
+#define TIZENAPIS_TIZEN_FILESYSTEM_STORAGE_STATIC_CONTROLLER_H_
+
+#include <Commons/EventReceiver.h>
+#include <Commons/EventListener.h>
+#include <API/Filesystem/EventStorageStateChanged.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+class StorageStaticController :
+    public WrtDeviceApis::Commons::EventListener<Api::Filesystem::EventStorageStateChanged>
+{
+public:
+       static StorageStaticController& getInstance();
+
+       void onAnswerReceived(
+       const Api::Filesystem::EventStorageStateChangedPtr& event);
+
+protected:
+       StorageStaticController();
+};
+}
+}
+
+#endif
+
diff --git a/src/standards/Tizen/Filesystem/config.xml b/src/standards/Tizen/Filesystem/config.xml
new file mode 100755 (executable)
index 0000000..aa7db21
--- /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-filesystem.so</library-name>
+  <feature-install-uri>filesystem.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/filesystem</name>
+      <device-capability>filesystem.read</device-capability>
+      <device-capability>filesystem.write</device-capability>
+  </api-feature>
+
+  <api-feature>
+      <name>http://tizen.org/api/filesystem.read</name>
+      <device-capability>filesystem.read</device-capability>
+  </api-feature>
+
+  <api-feature>
+      <name>http://tizen.org/api/filesystem.write</name>
+      <device-capability>filesystem.read</device-capability>
+      <device-capability>filesystem.write</device-capability>
+  </api-feature>
+
+</plugin-properties>
diff --git a/src/standards/Tizen/Filesystem/plugin_config.cpp b/src/standards/Tizen/Filesystem/plugin_config.cpp
new file mode 100755 (executable)
index 0000000..52115c7
--- /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. 
+ */
+
+
+#include <map>
+#include <utility>
+
+#include <dpl/assert.h>
+#include <Commons/FunctionDefinition.h>
+#include <Commons/FunctionDeclaration.h>
+#include <Commons/Exception.h>
+#include <API/Filesystem/Enums.h>
+
+#define FILESYSTEM_FEATURE_API "http://tizen.org/api/filesystem"
+#define FILESYSTEM_FEATURE_API_READ "http://tizen.org/api/filesystem.read"
+#define FILESYSTEM_FEATURE_API_WRITE "http://tizen.org/api/filesystem.write"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+const char* FILESYSTEM_PARAM_LOCATION = "param:location";
+const char* FILESYSTEM_DEVICE_CAP_READ = "filesystem.read";
+const char* FILESYSTEM_DEVICE_CAP_WRITE = "filesystem.write";
+
+const char* FILESYSTEM_FUNCTION_API_MGR_RESOLVE_ID = "manager_resolve";
+const char* FILESYSTEM_FUNCTION_API_MGR_RESOLVE = "resolve";
+
+const char* FILESYSTEM_FUNCTION_API_RESOLVE = "resolve";
+const char* FILESYSTEM_FUNCTION_API_TO_URI = "toURI";
+const char* FILESYSTEM_FUNCTION_API_LIST_FILES = "listFiles";
+const char* FILESYSTEM_FUNCTION_API_OPEN_STREAM = "openStream";
+const char* FILESYSTEM_FUNCTION_API_READ_AS_TEXT = "readAsText";
+const char* FILESYSTEM_FUNCTION_API_COPY_TO = "copyTo";
+const char* FILESYSTEM_FUNCTION_API_MOVE_TO = "moveTo";
+const char* FILESYSTEM_FUNCTION_API_CREATE_DIR = "createDirectory";
+const char* FILESYSTEM_FUNCTION_API_CREATE_FILE = "createFile";
+const char* FILESYSTEM_FUNCTION_API_DELETE_DIR = "deleteDirectory";
+const char* FILESYSTEM_FUNCTION_API_DELETE_FILE = "deleteFile";
+
+const char* FILESYSTEM_FUNCTION_API_CLOSE = "close";
+const char* FILESYSTEM_FUNCTION_API_READ = "read";
+const char* FILESYSTEM_FUNCTION_API_READ_BYTES = "readBytes";
+const char* FILESYSTEM_FUNCTION_API_READ_BASE64 = "readBase64";
+const char* FILESYSTEM_FUNCTION_API_WRITE = "write";
+const char* FILESYSTEM_FUNCTION_API_WRITE_BYTES = "writeBytes";
+const char* FILESYSTEM_FUNCTION_API_WRITE_BASE64 = "writeBase64";
+
+static WrtDeviceApis::Commons::FunctionMapping createFilesystemFunctions();
+
+static WrtDeviceApis::Commons::FunctionMapping FilesystemFunctions =
+    createFilesystemFunctions();
+
+DEFINE_FUNCTION_GETTER(Filesystem, FilesystemFunctions);
+
+static WrtDeviceApis::Commons::FunctionMapping createFilesystemFunctions()
+{
+       using namespace WrtDeviceApis::Commons;
+
+    /**
+     * Device capabilities
+     */
+
+    ACE_CREATE_DEVICE_CAP(DEVICE_CAP_FILESYSTEM_READ,
+                          FILESYSTEM_DEVICE_CAP_READ);
+    ACE_CREATE_DEVICE_CAP(DEVICE_CAP_FILESYSTEM_WRITE,
+                          FILESYSTEM_DEVICE_CAP_WRITE);
+
+    ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
+
+    ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_FILESYSTEM_READ);
+    ACE_ADD_DEVICE_CAP(DEVICE_LIST_FILESYSTEM_READ, DEVICE_CAP_FILESYSTEM_READ);
+
+    ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_FILESYSTEM_WRITE);
+    ACE_ADD_DEVICE_CAP(DEVICE_LIST_FILESYSTEM_WRITE,
+                       DEVICE_CAP_FILESYSTEM_WRITE);
+
+    /**
+     * Api Features
+     */
+    ACE_CREATE_FEATURE(FEATURE_FILESYSTEM, FILESYSTEM_FEATURE_API);
+    ACE_CREATE_FEATURE(FEATURE_READ, FILESYSTEM_FEATURE_API_READ);
+    ACE_CREATE_FEATURE(FEATURE_WRITE, FILESYSTEM_FEATURE_API_WRITE);
+
+    ACE_CREATE_FEATURE_LIST(FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE);
+    ACE_ADD_API_FEATURE(FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE,
+                        FEATURE_FILESYSTEM);
+    ACE_ADD_API_FEATURE(FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE,
+                        FEATURE_READ);
+    ACE_ADD_API_FEATURE(FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE,
+                        FEATURE_WRITE);
+
+    ACE_CREATE_FEATURE_LIST(FILESYSTEM_FEATURES_FILESYSTEM_READ);
+    ACE_ADD_API_FEATURE(FILESYSTEM_FEATURES_FILESYSTEM_READ,
+                        FEATURE_FILESYSTEM);
+    ACE_ADD_API_FEATURE(FILESYSTEM_FEATURES_FILESYSTEM_READ,
+                        FEATURE_READ);
+
+    ACE_CREATE_FEATURE_LIST(FILESYSTEM_FEATURES_FILESYSTEM_WRITE);
+    ACE_ADD_API_FEATURE(FILESYSTEM_FEATURES_FILESYSTEM_WRITE,
+                        FEATURE_FILESYSTEM);
+    ACE_ADD_API_FEATURE(FILESYSTEM_FEATURES_FILESYSTEM_WRITE,
+                        FEATURE_WRITE);
+
+    /**
+     * Functions
+     */
+
+    FunctionMapping FilesystemMapping;
+
+    AceFunction mgrResolveFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_MGR_RESOLVE,
+            FILESYSTEM_FUNCTION_API_MGR_RESOLVE,
+            FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE,
+            EMPTY_DEVICE_LIST); // check of device-cap will be done inside resolve()
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_MGR_RESOLVE_ID,
+                                 mgrResolveFunc));
+
+    AceFunction resolveFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_RESOLVE,
+            FILESYSTEM_FUNCTION_API_RESOLVE,
+            FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_RESOLVE,
+                                 resolveFunc));
+
+    AceFunction toUriFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_TO_URI,
+            FILESYSTEM_FUNCTION_API_TO_URI,
+            FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_TO_URI,
+                                 toUriFunc));
+
+    AceFunction listFilesFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_LIST_FILES,
+            FILESYSTEM_FUNCTION_API_LIST_FILES,
+            FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_LIST_FILES,
+                                 listFilesFunc));
+
+    AceFunction openStreamFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_OPEN_STREAM,
+            FILESYSTEM_FUNCTION_API_OPEN_STREAM,
+            FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE,
+            EMPTY_DEVICE_LIST); 
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_OPEN_STREAM,
+                                 openStreamFunc));
+
+    AceFunction readAsTextFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_READ_AS_TEXT,
+            FILESYSTEM_FUNCTION_API_READ_AS_TEXT,
+            FILESYSTEM_FEATURES_FILESYSTEM_READ,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_READ_AS_TEXT,
+                                 readAsTextFunc));
+
+    AceFunction copyToFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_COPY_TO,
+            FILESYSTEM_FUNCTION_API_COPY_TO,
+            FILESYSTEM_FEATURES_FILESYSTEM_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_COPY_TO,
+                                 copyToFunc));
+
+    AceFunction moveToFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_MOVE_TO,
+            FILESYSTEM_FUNCTION_API_MOVE_TO,
+            FILESYSTEM_FEATURES_FILESYSTEM_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_MOVE_TO,
+                                 moveToFunc));
+
+    AceFunction createDirFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_CREATE_DIR,
+            FILESYSTEM_FUNCTION_API_CREATE_DIR,
+            FILESYSTEM_FEATURES_FILESYSTEM_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_CREATE_DIR,
+                                 createDirFunc));
+
+    AceFunction createFileFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_CREATE_FILE,
+            FILESYSTEM_FUNCTION_API_CREATE_FILE,
+            FILESYSTEM_FEATURES_FILESYSTEM_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_CREATE_FILE,
+                                 createFileFunc));
+
+    AceFunction deleteDirFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_DELETE_DIR,
+            FILESYSTEM_FUNCTION_API_DELETE_DIR,
+            FILESYSTEM_FEATURES_FILESYSTEM_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_DELETE_DIR,
+                                 deleteDirFunc));
+
+    AceFunction deleteFileFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_DELETE_FILE,
+            FILESYSTEM_FUNCTION_API_DELETE_FILE,
+            FILESYSTEM_FEATURES_FILESYSTEM_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_DELETE_FILE,
+                                 deleteFileFunc));
+
+    AceFunction closeFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_CLOSE,
+            FILESYSTEM_FUNCTION_API_CLOSE,
+            FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_CLOSE,
+                                 closeFunc));
+
+    AceFunction readFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_READ,
+            FILESYSTEM_FUNCTION_API_READ,
+            FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_READ,
+                                 readFunc));
+
+    AceFunction readBytesFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_READ_BYTES,
+            FILESYSTEM_FUNCTION_API_READ_BYTES,
+            FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_READ_BYTES,
+                                 readBytesFunc));
+
+    AceFunction readBase64Func = ACE_CREATE_FUNCTION(
+            FUNCTION_READ_BASE64,
+            FILESYSTEM_FUNCTION_API_READ_BASE64,
+            FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_READ_BASE64,
+                                 readBase64Func));
+
+    AceFunction writeFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_WRITE,
+            FILESYSTEM_FUNCTION_API_WRITE,
+            FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_WRITE,
+                                 writeFunc));
+
+    AceFunction writeBytesFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_WRITE_BYTES,
+            FILESYSTEM_FUNCTION_API_WRITE_BYTES,
+            FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_WRITE_BYTES,
+                                 writeBytesFunc));
+
+    AceFunction writeBase64Func = ACE_CREATE_FUNCTION(
+            FUNCTION_WRITE_BASE64,
+            FILESYSTEM_FUNCTION_API_WRITE_BASE64,
+            FILESYSTEM_FEATURES_FILESYSTEM_READ_WRITE,
+            EMPTY_DEVICE_LIST);
+
+    FilesystemMapping.insert(std::make_pair(
+                                 FILESYSTEM_FUNCTION_API_WRITE_BASE64,
+                                 writeBase64Func));
+
+    return FilesystemMapping;
+}
+
+void setFilesystemPermDevCaps(int permissions,
+        const std::string& path,
+        WrtDeviceApis::Commons::AceFunction* outFunction)
+{
+    using namespace TizenApis::Api;
+    using namespace WrtDeviceApis::Commons;
+
+    Assert(outFunction && (permissions != Filesystem::PERM_NONE));
+
+    AceDeviceCapParam paramLocation = AceDeviceCapParam(
+            FILESYSTEM_PARAM_LOCATION, path);
+
+    AceDeviceCaps devCaps;
+
+    if (permissions && Filesystem::PERM_READ) {
+        AceDeviceCapability devCapRead = AceDeviceCapability(
+                FILESYSTEM_DEVICE_CAP_READ,
+                AceDeviceCapParams());
+        devCaps.push_back(devCapRead);
+
+        ACE_ADD_DEV_CAP_PARAM(
+            devCaps,
+            FILESYSTEM_DEVICE_CAP_READ,
+            paramLocation);
+    }
+
+    if (permissions && Filesystem::PERM_WRITE) {
+        AceDeviceCapability devCapWrite = AceDeviceCapability(
+                FILESYSTEM_DEVICE_CAP_WRITE,
+                AceDeviceCapParams());
+
+        devCaps.push_back(devCapWrite);
+
+        ACE_ADD_DEV_CAP_PARAM(
+            devCaps,
+            FILESYSTEM_DEVICE_CAP_WRITE,
+            paramLocation);
+    }
+
+    outFunction->deviceCapabilities = devCaps;
+}
+
+void setFilesystemAccessModeDevCaps(int accessMode,
+        const std::string& path,
+        WrtDeviceApis::Commons::AceFunction
+        *outFunction)
+{
+    using namespace TizenApis::Api;
+    using namespace WrtDeviceApis::Commons;
+
+    Assert(outFunction);
+
+    AceDeviceCapParam paramLocation = AceDeviceCapParam(
+            FILESYSTEM_PARAM_LOCATION,
+            path);
+    AceDeviceCaps devCaps;
+
+    if (accessMode && Filesystem::AM_READ) {
+        AceDeviceCapability devCapRead = AceDeviceCapability(
+                FILESYSTEM_DEVICE_CAP_READ,
+                AceDeviceCapParams());
+
+        devCaps.push_back(devCapRead);
+
+        ACE_ADD_DEV_CAP_PARAM(
+            devCaps,
+            FILESYSTEM_DEVICE_CAP_READ,
+            paramLocation);
+    }
+
+    if ((accessMode && Filesystem::AM_WRITE) ||
+        (accessMode && Filesystem::AM_APPEND)) {
+        AceDeviceCapability devCapWrite = AceDeviceCapability(
+                FILESYSTEM_DEVICE_CAP_WRITE,
+                AceDeviceCapParams());
+
+        devCaps.push_back(devCapWrite);
+
+        ACE_ADD_DEV_CAP_PARAM(
+            devCaps,
+            FILESYSTEM_DEVICE_CAP_WRITE,
+            paramLocation);
+    }
+    outFunction->deviceCapabilities = devCaps;
+}
+}
+}
diff --git a/src/standards/Tizen/Filesystem/plugin_config.h b/src/standards/Tizen/Filesystem/plugin_config.h
new file mode 100755 (executable)
index 0000000..dc3d817
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _FILESYSTEM_PLUGIN_CONFIG_H_
+#define _FILESYSTEM_PLUGIN_CONFIG_H_
+
+#include <Commons/FunctionDeclaration.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+extern const char* FILESYSTEM_FUNCTION_API_MGR_RESOLVE_ID;
+
+extern const char* FILESYSTEM_FUNCTION_API_RESOLVE;
+extern const char* FILESYSTEM_FUNCTION_API_TO_URI;
+extern const char* FILESYSTEM_FUNCTION_API_LIST_FILES;
+extern const char* FILESYSTEM_FUNCTION_API_OPEN_STREAM;
+extern const char* FILESYSTEM_FUNCTION_API_READ_AS_TEXT;
+extern const char* FILESYSTEM_FUNCTION_API_COPY_TO;
+extern const char* FILESYSTEM_FUNCTION_API_MOVE_TO;
+extern const char* FILESYSTEM_FUNCTION_API_CREATE_DIR;
+extern const char* FILESYSTEM_FUNCTION_API_CREATE_FILE;
+extern const char* FILESYSTEM_FUNCTION_API_DELETE_DIR;
+extern const char* FILESYSTEM_FUNCTION_API_DELETE_FILE;
+
+extern const char* FILESYSTEM_FUNCTION_API_CLOSE;
+extern const char* FILESYSTEM_FUNCTION_API_READ;
+extern const char* FILESYSTEM_FUNCTION_API_READ_BYTES;
+extern const char* FILESYSTEM_FUNCTION_API_READ_BASE64;
+extern const char* FILESYSTEM_FUNCTION_API_WRITE;
+extern const char* FILESYSTEM_FUNCTION_API_WRITE_BYTES;
+extern const char* FILESYSTEM_FUNCTION_API_WRITE_BASE64;
+
+DECLARE_FUNCTION_GETTER(Filesystem);
+
+void setFilesystemPermDevCaps(int permissions,
+        const std::string& path,
+        WrtDeviceApis::Commons::AceFunction* outFunction);
+
+void setFilesystemAccessModeDevCaps(int accessMode,
+        const std::string& path,
+        WrtDeviceApis::Commons::AceFunction*
+        outFunction);
+
+struct PermissionsAccessInfo
+{
+    PermissionsAccessInfo(int perms,
+            const std::string& fpath) :
+        permissions(perms),
+        path(fpath)
+    {
+    }
+
+    int permissions;
+    const std::string path;
+};
+
+struct AccessModeInfo
+{
+    AccessModeInfo(int amode,
+            const std::string& fpath) :
+        accessMode(amode),
+        path(fpath)
+    {
+    }
+
+    int accessMode;
+    const std::string path;
+};
+
+}
+}
+
+namespace WrtDeviceApis {
+namespace Commons {
+
+/**
+ * template specialization for security access basing on permissions
+ */
+template <>
+class DefaultArgsVerifier <TizenApis::Tizen1_0::PermissionsAccessInfo>
+{
+  public:
+    void operator()(AceFunction& aceFunction,
+            const TizenApis::Tizen1_0::PermissionsAccessInfo& permInfo) const
+    {
+        TizenApis::Tizen1_0::setFilesystemPermDevCaps(permInfo.permissions,
+                                 permInfo.path,
+                                 &aceFunction);
+    }
+};
+
+/**
+ * template specialization for security access basing on access mode
+ */
+template <>
+class DefaultArgsVerifier <TizenApis::Tizen1_0::AccessModeInfo>
+{
+  public:
+    void operator()(AceFunction& aceFunction,
+            const TizenApis::Tizen1_0::AccessModeInfo& accessInfo) const
+    {
+        TizenApis::Tizen1_0::setFilesystemAccessModeDevCaps(accessInfo.accessMode,
+                                       accessInfo.path,
+                                       &aceFunction);
+    }
+};
+
+#define FILESYSTEM_CHECK_ACCESS(globalContext, functionName) \
+    WrtDeviceApis::Commons::aceCheckAccess<AceFunctionGetter, \
+    WrtDeviceApis::Commons::DefaultArgsVerifier<> >(                \
+        globalContext,                     \
+        getFilesystemFunctionData,         \
+        functionName)
+
+#define FILESYSTEM_PERMISSION_CHECK_ACCESS(globalContext, functionName, perm)  \
+    WrtDeviceApis::Commons::aceCheckAccess<AceFunctionGetter,                  \
+    WrtDeviceApis::Commons::DefaultArgsVerifier <TizenApis::Tizen1_0::PermissionsAccessInfo> >(             \
+        globalContext,                     \
+        getFilesystemFunctionData,         \
+        functionName,                      \
+        perm)
+
+#define FILESYSTEM_ACCESSMODE_CHECK_ACCESS(globalContext, functionName, amode) \
+    WrtDeviceApis::Commons::aceCheckAccess<AceFunctionGetter,                  \
+    WrtDeviceApis::Commons::DefaultArgsVerifier <TizenApis::Tizen1_0::AccessModeInfo> >(                    \
+        globalContext,                     \
+        getFilesystemFunctionData,         \
+        functionName,                      \
+        amode)
+}
+}
+
+#endif
old mode 100644 (file)
new mode 100755 (executable)
similarity index 50%
rename from src/standards/Tizen/Log/plugin_initializer.cpp
rename to src/standards/Tizen/Filesystem/plugin_initializer.cpp
index eeab032..cac5f03
  * limitations under the License. 
  */
 
-#include <dpl/log.h>
+
+#include <dpl/log/log.h>
+#include <Commons/WrtWrapper/WrtWrappersMgr.h>
 #include <Commons/plugin_initializer_def.h>
-#include "JSTizenLog.h"
+#include "JSFilesystemManager.h"
+#include "JSFile.h"
+#include "JSFilestream.h"
 
-#define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
+using namespace WrtDeviceApis::Commons;
 
-void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface)
+void on_widget_start_callback(int widgetId,
+        JavaScriptContext context,
+        const engine_interface_t *interface)
 {
-    LogDebug("[TizenLog] on_widget_start_callback ("<<widgetId<<")");
+       Try {
+               WrtWrappersMgr::getInstance().registerWrapper(widgetId, context, interface);
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Wrt wrapper registration failed");
+       }
 }
 
 void on_widget_stop_callback(int widgetId)
 {
-    LogDebug("[TizenLog] on_widget_stop_callback ("<<widgetId<<")");
+       Try {
+               WrtWrappersMgr::getInstance().removeWrapper(widgetId);
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Wrt wrapper removal failed");
+       }
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
 
+#define FILESYSTEM ".filesystem"
+
 PLUGIN_CLASS_MAP_BEGIN
-    PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "log",
-      TizenApis::Tizen1_0::JSTizenLog::getClassRef(), NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+        "filesystem",
+        TizenApis::Tizen1_0::JSFilesystemManager::getClassRef(),
+        NULL)
 PLUGIN_CLASS_MAP_END
+
+#undef FILESYSTEM
+
index 4c9a613..4b0d42a 100644 (file)
@@ -11,7 +11,7 @@
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License. 
+ * limitations under the License.
  */
 
 
@@ -27,8 +27,8 @@
 #ifndef WRTPLUGINS_TIZEN_GEOCODER_CONTROLLER_H_
 #define WRTPLUGINS_TIZEN_GEOCODER_CONTROLLER_H_
 
-#include <dpl/controller.h>
-#include <dpl/log.h>
+#include <dpl/event/controller.h>
+#include <dpl/log/log.h>
 
 #include <CommonsJavaScript/JSCallbackManager.h>
 #include <API/Geocoder/EventGeocoder.h>
@@ -54,7 +54,7 @@ class GeocoderController :
         JSCallbackManagerPtr m_callbackManager;
 };
 
-} 
+}
 } // WrtPlugins
 
 #endif //WRTPLUGINS_TIZEN_GEOCODER_CONTROLLER_H_
index 80c152c..753897d 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <cassert>
 #include <memory>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/JSUtils.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
index 17b7fc3..586814d 100644 (file)
@@ -29,7 +29,7 @@
 
 #include <cassert>
 #include <memory>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
 //#include <Tizen/commons/JSDOMExceptionFactory.h>
index 15e6edc..0c4c58c 100644 (file)
@@ -221,7 +221,6 @@ JSValueRef JSGeocoder::getAddressInternal(JSContextRef context, double latitude,
                assert(priv && "Invalid private pointer.");
 
                JSCallbackManagerPtr cbm(JSCallbackManager::createObject(priv->getContext(), onSuccess, onError));
-               cbm->setObject(thisObject);
 
                EventGeocoderPtr event(new EventGeocoder());
                SharedPtr < IEventController > eventContr = StaticPointerCast<IEventController> (event);
@@ -411,7 +410,6 @@ JSValueRef JSGeocoder::geocode(JSContextRef context, JSObjectRef object, JSObjec
                }       //else
 
                JSCallbackManagerPtr cbm(JSCallbackManager::createObject(priv->getContext(), onSuccess, onError));
-               cbm->setObject(thisObject);
 
                SharedPtr < IEventController > eventContr = StaticPointerCast<IEventController> (event);
                JSObjectRef pendingOperation = CommonsJavaScript::makePendingOperation(context, event);
index 4a9d67c..8db9a30 100644 (file)
@@ -17,7 +17,7 @@
 
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
 #include "JSGeocoder.h"
 
diff --git a/src/standards/Tizen/Log/CMakeLists.txt b/src/standards/Tizen/Log/CMakeLists.txt
deleted file mode 100644 (file)
index 0d361f0..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-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
deleted file mode 100755 (executable)
index 56bc60b..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-/**
- * @file        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
deleted file mode 100644 (file)
index aa18dd4..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-/**
- * @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
deleted file mode 100644 (file)
index fe6fa61..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" ?>
-<!DOCTYPE plugin-properties SYSTEM "/usr/etc/tizen-apis/config.dtd">
-<plugin-properties>
-    <library-name>libwrt-plugins-tizen-1.0-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>
index 9a824f9..98a84ff 100755 (executable)
@@ -20,7 +20,7 @@ set(SRCS_MESSAGING
   JSConversation.cpp  
   JSMessageFolder.cpp  
   JSMessageBody.cpp
-  #JSMessageAttachment.cpp
+  JSMessageAttachment.cpp
   
   #../Filesystem/Converter.cpp
   #../Filesystem/EventGetNodeData.cpp
@@ -62,6 +62,7 @@ target_link_libraries(${TARGET_NAME}
   ${LIBS_PLATFORM_IMPLEMENTATION_FILESYSTEM}
   ${wrt-deviceapis-filesystem_LDFLAGS}
   ${LIBS_COMMON}
+  ${LIBS_WIDGETDB}
 )
 
 INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION ${DESTINATION_NAME})
index 9e14b66..dd549e0 100755 (executable)
@@ -242,7 +242,6 @@ Api::Messaging::IMessagePtr ConverterMessage::toIMessage(JSObjectRef arg)
     return retVal;
 }
 
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
 Api::Messaging::IAttachmentPtr ConverterMessage::toIAttachment(JSValueRef arg)
 {
        return toIAttachment(toJSObjectRef(arg));
@@ -274,7 +273,6 @@ Api::Messaging::IAttachmentPtr ConverterMessage::toIAttachment(JSObjectRef arg)
        }
        return retVal;
 }
-#endif
 
 Api::Messaging::IMessageFolderPtr ConverterMessage::toIMessageFolder(JSValueRef arg)
 {
@@ -402,22 +400,18 @@ Api::Messaging::MessageType ConverterMessage::toMessageType(JSObjectRef arg)
        std::string strMsgType = toString(arg);
        LogDebug("Messasge Type : " << strMsgType);
 
-       if ( strMsgType.compare("SMS") == 0 ) 
+       if ( strMsgType.compare("tizen.sms") == 0 ) 
        {
                return Api::Messaging::SMS;
        }
-       else if ( strMsgType.compare("MMS") == 0 ) 
+       else if ( strMsgType.compare("tizen.mms") == 0 ) 
        {
                return Api::Messaging::MMS;
        }
-       else if ( strMsgType.compare("EMAIL") == 0 )
+       else if ( strMsgType.compare("tizen.email") == 0 )
        {
                return Api::Messaging::EMAIL;
        }
-       else if ( strMsgType.compare("CHAT") == 0 )
-       {
-               return Api::Messaging::CHAT;
-       }
        else
        {
                ThrowMsg(WrtDeviceApis::Commons::ConversionException, "message type not supported");
@@ -432,18 +426,35 @@ std::string ConverterMessage::toMessageType( long msgtype )
        switch (msgtype)
        {
                case Api::Messaging::SMS:
-                       return "SMS";
+                       return "tizen.sms";
                case Api::Messaging::MMS:
-                       return "MMS";
+                       return "tizen.mms";
                case Api::Messaging::EMAIL:
-                       return "EMAIL";
-               case Api::Messaging::CHAT:
-                       return "CHAT";
+                       return "tizen.email";
                default :
                        ThrowMsg(WrtDeviceApis::Commons::ConversionException, "message type not supported");
        }
 }
 
+std::string ConverterMessage::toMessageStatusType( long msgstatus )
+{
+       LogDebug("Messasge Status : " << msgstatus);
+
+       switch (msgstatus)
+       {
+               case Api::Messaging::MESSAGE_STATUS_SENT:
+                       return "SENT";
+               case Api::Messaging::MESSAGE_STATUS_SENDING:
+                       return "SENDING";
+               case Api::Messaging::MESSAGE_STATUS_FAILED:
+                       return "FAILED";
+               case Api::Messaging::MESSAGE_STATUS_DRAFT:
+                       return "DRAFT";
+               default :
+                       ThrowMsg(WrtDeviceApis::Commons::ConversionException, "message status not supported");
+       }
+}
+
 Api::Messaging::IConversationPtr ConverterMessage::toConversation(const JSValueRef& arg)
 {
        return JSConversation::getConversation(m_context, arg);
index f05ab45..e4b3e19 100755 (executable)
@@ -24,7 +24,7 @@
  * @version    0.1
  * @brief
  */
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include <API/Messaging/IMessagingTypes.h>
 #include <API/Messaging/MessageFactory.h>
@@ -103,12 +103,10 @@ class ConverterMessage : public WrtDeviceApis::CommonsJavaScript::Converter
 
     Api::Messaging::IMessagePtr toIMessage(JSObjectRef arg);
 
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
     Api::Messaging::IAttachmentPtr toIAttachment(JSValueRef arg);
 
     Api::Messaging::IAttachmentPtr toIAttachment(JSObjectRef arg);
-#endif
-
+       
     Api::Messaging::Recipients toRecipients(JSValueRef arg);
 
     std::vector<Api::Messaging::FolderType> toVectorOfFolderTypes(JSValueRef arg);
@@ -125,6 +123,8 @@ class ConverterMessage : public WrtDeviceApis::CommonsJavaScript::Converter
 
     std::string toMessageType( long msgtype );
 
+    std::string toMessageStatusType( long msgstatus );
+
     Api::Messaging::AddressType toAddressType(JSValueRef arg);
 
     Api::Messaging::MessagePriority::Priority toMessagePriority(JSValueRef arg);
index 777fd5e..781331d 100755 (executable)
 * limitations under the License. 
 */
 
-/**
-* @file                 JSConversation.cpp
-* @author       Kangsoo Lee (wpeter.lee@samsung.com)
-* @version      0.1
-*/
 
 
 #include <CommonsJavaScript/Converter.h>
@@ -47,7 +41,7 @@ JSClassDefinition JSConversation::m_classInfo =
 {
        0,
        kJSClassAttributeNone,
-       "Conversation",
+       "MessageConversation",
        NULL,
        m_properties,
        NULL,
@@ -71,16 +65,16 @@ const char* JSConversation::MESSAGECOUNT = "messageCount";
 const char* JSConversation::UNREADMESSAGES = "unreadMessages";
 const char* JSConversation::PREVIEW = "preview";
 const char* JSConversation::SUBJECT = "subject";
-const char* JSConversation::READ = "read";
+const char* JSConversation::ISREAD = "isRead";
 const char* JSConversation::FROM = "from";
 const char* JSConversation::TO = "to";
 const char* JSConversation::CC = "cc"; 
 const char* JSConversation::BCC = "bcc"; 
 const char* JSConversation::LASTMESSAGEID = "lastMessageId";   
 
-const std::string JSConversation::TYPE_SMS              = "SMS";
-const std::string JSConversation::TYPE_MMS              = "MMS";
-const std::string JSConversation::TYPE_EMAIL    = "EMAIL";
+const std::string JSConversation::TYPE_SMS              = "tizen.sms";
+const std::string JSConversation::TYPE_MMS              = "tizen.mms";
+const std::string JSConversation::TYPE_EMAIL    = "tizen.email";
 
 JSStaticValue JSConversation::m_properties[] = {
        {"id", JSConversation::getProperty, NULL, kJSPropertyAttributeReadOnly },
@@ -90,7 +84,7 @@ JSStaticValue JSConversation::m_properties[] = {
        {"unreadMessages", JSConversation::getProperty, NULL, kJSPropertyAttributeReadOnly },
        {"preview", JSConversation::getProperty, NULL, kJSPropertyAttributeReadOnly },
        {"subject", JSConversation::getProperty, NULL, kJSPropertyAttributeReadOnly },
-       {"read", JSConversation::getProperty, NULL, kJSPropertyAttributeReadOnly },
+       {"isRead", JSConversation::getProperty, NULL, kJSPropertyAttributeReadOnly },
        {"from", JSConversation::getProperty, NULL, kJSPropertyAttributeReadOnly },
        {"to", JSConversation::getProperty, NULL, kJSPropertyAttributeReadOnly },
        {"cc", JSConversation::getProperty, NULL, kJSPropertyAttributeReadOnly },
@@ -203,7 +197,7 @@ JSValueRef JSConversation::getProperty(JSContextRef context,
                {
                        return converter.toJSValueRef(conversation->getSubject());      
                }
-               else if(JSStringIsEqualToUTF8CString(propertyName, READ)) 
+               else if(JSStringIsEqualToUTF8CString(propertyName, ISREAD)) 
                {
                        return converter.toJSValueRef(conversation->getRead());                         
                }
index 0776826..b21baf7 100755 (executable)
 */
 
 
-/*
- * @file        JSConversation.h
- * @author      Kangsoo Lee (wpeter.lee@samsung.com)
- * @version     0.1
- * @brief       Declaration of the Templete class
- */
 
 #ifndef WRTPLUGINS_TIZEN_JS_CONVERSATION_H_
 #define WRTPLUGINS_TIZEN_JS_CONVERSATION_H_
@@ -99,7 +93,7 @@ private:
        static const char* UNREADMESSAGES;
        static const char* PREVIEW;
        static const char* SUBJECT;
-       static const char* READ;
+       static const char* ISREAD;
        static const char* FROM;
        static const char* TO;
        static const char* CC;  
index 46b4063..8ac4798 100755 (executable)
@@ -24,8 +24,6 @@
  * @brief
  */
 
-#define PLUGIN_CONFIG_BLOCKING // milkelf.choi, 2011 10 10 - temporary :
-
 #include <dpl/assert.h>
 #include <API/Messaging/MessageFactory.h>
 #include <API/Messaging/MessagePriority.h>
 #include <Tizen/Common/SecurityExceptions.h>
 
 #include "MessagingErrorMsg.h"
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
 #include "JSMessageAttachment.h"
-#endif
-
-#ifndef PLUGIN_CONFIG_BLOCKING
 #include "plugin_config.h"
-#endif
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
-// filesystem
-#include <Tizen/Filesystem/JSFile.h>
-#endif
+
 using namespace std;
 using namespace TizenApis::Api::Messaging;
 using namespace TizenApis::Commons;
@@ -68,7 +58,7 @@ JSClassRef JSMessage::m_jsClassRef = NULL;
 JSClassDefinition JSMessage::m_classInfo = {
     0,
     kJSClassAttributeNone,
-    "MessagingMessage",
+    "Message",
     0,
     m_property,
     NULL,              //m_function
@@ -87,27 +77,25 @@ JSClassDefinition JSMessage::m_classInfo = {
 
 // JSMessage properties
 JSStaticValue JSMessage::m_property[] = {
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
-    { "attachments", getAttachments, setAttachments, kJSPropertyAttributeNone },
-#endif
+    { "id", getMessageId, NULL, kJSPropertyAttributeReadOnly },
+    { "serviceId", getAccountID, NULL, kJSPropertyAttributeReadOnly},
+    { "conversationId", getConversationId, NULL, kJSPropertyAttributeReadOnly },
+    { "folderId", getFolder, NULL, kJSPropertyAttributeReadOnly },
+    { "type", getMessageType, NULL, kJSPropertyAttributeReadOnly },
+    { "timestamp", getTime, NULL, kJSPropertyAttributeReadOnly },
+    { "from", getSourceAddress, NULL, kJSPropertyAttributeReadOnly },
+    { "to", getDestinationAddress, setDestinationAddress, kJSPropertyAttributeNone },
+    { "cc", getCcAddress, setCcAddress, kJSPropertyAttributeNone },
     { "bcc", getBccAddress, setBccAddress, kJSPropertyAttributeNone },
-    { "accountId", getAccountID, NULL, kJSPropertyAttributeReadOnly},
-//    { "uid", getUID, NULL, kJSPropertyAttributeReadOnly},
-    { "messageStatus", getMessageStatus, NULL, kJSPropertyAttributeReadOnly},
     { "body", getMessageBody, setMessageBody, kJSPropertyAttributeNone },
-
-    { "cc", getCcAddress, setCcAddress, kJSPropertyAttributeNone },
-    { "to", getDestinationAddress, setDestinationAddress, kJSPropertyAttributeNone },
     { "isRead", getIsRead, setIsRead, kJSPropertyAttributeNone },
-    { "id", getMessageId, NULL, kJSPropertyAttributeReadOnly },
+    //{ "hasAttachment", getAttachmentExistence, NULL, kJSPropertyAttributeReadOnly },
     { "priority", getMessagePriority, setMessagePriority, kJSPropertyAttributeNone },
-    { "type", getMessageType, NULL, kJSPropertyAttributeReadOnly },
-    { "from", getSourceAddress, NULL, kJSPropertyAttributeReadOnly },
     { "subject", getSubject, setSubject, kJSPropertyAttributeNone },
-    { "timestamp", getTime, NULL, kJSPropertyAttributeReadOnly },
-    { "folderId", getFolder, NULL, kJSPropertyAttributeReadOnly },
-    { "conversationId", getConversationId, NULL, kJSPropertyAttributeReadOnly },
-    { "inResponseTo", getInResponseTo, NULL, kJSPropertyAttributeReadOnly },
+    { "inResponseTo", getInResponseTo, NULL, kJSPropertyAttributeNone },
+    { "messageStatus", getMessageStatus, NULL, kJSPropertyAttributeReadOnly},
+    { "attachments", getAttachments, NULL, kJSPropertyAttributeReadOnly },
+    //{ "uid", getUID, NULL, kJSPropertyAttributeReadOnly},
     { 0, 0, 0, 0 }
 };
 
@@ -315,7 +303,6 @@ JSValueRef JSMessage::convertToType(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
 JSValueRef JSMessage::getAttachments(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName,
@@ -343,7 +330,7 @@ JSValueRef JSMessage::getAttachments(JSContextRef context,
                        std::vector<IAttachmentPtr> attachments;
                        std::vector<IAttachmentPtr>::iterator it;
                        
-                       if (msgType == Api::Messaging::MMS )
+                       if ( msgType == Api::Messaging::MMS )
                        {
                                Api::Messaging::AttachmentsPtr mmsAttachments =
                                        DPL::StaticPointerCast<Api::Messaging::Attachments>(Api::Messaging::MessageFactory::convertToEmail(msg));
@@ -391,7 +378,7 @@ JSValueRef JSMessage::getAttachments(JSContextRef context,
     }
     return JSValueMakeUndefined(context);
 }
-#endif
+
 
 JSValueRef JSMessage::getBccAddress(JSContextRef context,
         JSObjectRef object,
@@ -1077,7 +1064,7 @@ bool JSMessage::setBccAddress(JSContextRef context,
          return JSTizenExceptionFactory::postException(context, exception, 
                 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
     }
-       
+
     return false;
 }
 
@@ -1347,7 +1334,7 @@ bool JSMessage::setMessageBody(JSContextRef context,
 {
     Try
     {
-        LogDebug("Set Message Body. ????");
+        LogDebug("Set Message Body.");
         return true;
     }
        Catch(WrtDeviceApis::Commons::ConversionException) {
@@ -1374,7 +1361,7 @@ JSValueRef JSMessage::getConversationId(JSContextRef context,
         JSStringRef propertyName,
         JSValueRef* exception)
 {
-       LogDebug("OK");
+       LogDebug("getConversationId");
 
     Try
     {
@@ -1414,7 +1401,7 @@ JSValueRef JSMessage::getInResponseTo(JSContextRef context,
         JSStringRef propertyName,
         JSValueRef* exception)
 {
-       LogDebug("OK");
+    LogDebug("getInResponseTo");
 
     Try
     {
@@ -1459,11 +1446,9 @@ JSValueRef JSMessage::getInResponseTo(JSContextRef context,
                 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
        }
 
-
     return JSValueMakeUndefined(context);
 }
 
-
 JSValueRef JSMessage::getMessageStatus(JSContextRef context,
                        JSObjectRef object,
                        JSStringRef propertyName,
@@ -1483,7 +1468,7 @@ JSValueRef JSMessage::getMessageStatus(JSContextRef context,
          Api::Messaging::IMessagePtr msg = converter->toIMessage(object); //get message point
 
          LogInfo("create JS");
-         return converter->toJSValueRef(msg->getMessageStatus());
+         return converter->toJSValueRef(converter->toMessageStatusType(msg->getMessageStatus()));
 
        }
        Catch(WrtDeviceApis::Commons::ConversionException) {
@@ -1500,6 +1485,43 @@ JSValueRef JSMessage::getMessageStatus(JSContextRef context,
        return JSValueMakeUndefined(context);
 }
 
+#if 0
+JSValueRef JSMessage::getAttachmentExistence(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception)
+{
+       LogInfo("getAttachmentExistence");
+
+       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
+
+         LogInfo("create JS");
+         return converter->toJSValueRef(converter->toMessageStatusType(msg->getMessageStatus()));
+
+       }
+       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);
+       }
+       
+       return JSValueMakeUndefined(context);
+}
+#endif
 
 }
 }
index 014cd12..7ea5d93 100755 (executable)
@@ -27,7 +27,7 @@
 #ifndef JSMESSAGE_H
 #define JSMESSAGE_H
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <API/Messaging/IMessagingTypes.h>
@@ -164,12 +164,10 @@ class JSMessage
             JSObjectRef object,
             JSType type,
             JSValueRef* exception);
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
     static JSValueRef getAttachments(JSContextRef context,
             JSObjectRef object,
             JSStringRef propertyName,
             JSValueRef* exception);
-#endif
     static JSValueRef getBccAddress(JSContextRef context,
             JSObjectRef object,
             JSStringRef propertyName,
index 7a24fa0..44bc12a 100755 (executable)
  * @version     0.1
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSUtils.h>
 #include "ConverterMessage.h"
 #include "JSMessageAttachment.h"
-#include "JSAttachmentArray.h"         //attachment array
 #include <Tizen/Filesystem/JSFile.h>
 #include <Tizen/Filesystem/EventGetNodeData.h>
 #include <API/Filesystem/IManager.h>
@@ -244,6 +243,7 @@ JSValueRef JSMessageAttachment::getFile(JSContextRef context,
           JSStringRef propertyName,
           JSValueRef* exception)
 {
+#if 0 // MESSAGING ATTACHMENT IS BLOCKED
                LogDebug("enter");
                Try
                {
@@ -311,7 +311,9 @@ JSValueRef JSMessageAttachment::getFile(JSContextRef context,
                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
                }
                return JSValueMakeUndefined(context);
-               
+#endif
+return JSValueMakeUndefined(context);
+
 }
 
 Api::Messaging::IAttachmentPtr JSMessageAttachment::getAttachment(JSContextRef context,
index 54ba0a6..060d842 100755 (executable)
@@ -21,7 +21,7 @@
  * @version     0.1
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSUtils.h>
 #include "ConverterMessage.h"
@@ -47,7 +47,7 @@ JSClassRef JSMessageBody::m_jsClassRef = NULL;
 JSClassDefinition JSMessageBody::m_classInfo = {
     0,
     kJSClassAttributeNone,
-    "MessagingMessageBody",
+    "MessageBody",
     0,
     m_property,
     NULL,
index 582ceaf..1d0c080 100755 (executable)
 */
 
  
-/**
-* @file                 JSMessageFolder.cpp
-* @author       Oy Kwon (sirot.kwon@samsung.com)
-* @version      0.1
-*/
 
 
 #include <CommonsJavaScript/Converter.h>
@@ -71,17 +66,17 @@ JSClassDefinition JSMessageFolder::m_classInfo =
 };
 
 const char* JSMessageFolder::FOLDERID = "id";
-const char* JSMessageFolder::PARENTID = "parentid";
-const char* JSMessageFolder::ACCOUNTID = "accountid";
+const char* JSMessageFolder::PARENTID = "parentId";
+const char* JSMessageFolder::ACCOUNTID = "serviceId";
 const char* JSMessageFolder::CONTENTTYPE = "contentType";
 const char* JSMessageFolder::NAME = "name";
 const char* JSMessageFolder::PATH = "path";
 const char* JSMessageFolder::TYPE = "type";
 const char* JSMessageFolder::SYNCHRONIZABLE = "synchronizable";
 
-const std::string JSMessageFolder::TYPE_SMS             = "SMS";
-const std::string JSMessageFolder::TYPE_MMS             = "MMS";
-const std::string JSMessageFolder::TYPE_EMAIL   = "EMAIL";
+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::FOLDER_INBOX                 = "INBOX";
 const std::string JSMessageFolder::FOLDER_OUTBOX        = "OUTBOX";
@@ -93,8 +88,8 @@ const std::string JSMessageFolder::FOLDER_NOTSTANDARD  = "";
 
 JSStaticValue JSMessageFolder::m_properties[] = {
        {"id", JSMessageFolder::getProperty, NULL, kJSPropertyAttributeReadOnly },
-       {"parentid", JSMessageFolder::getProperty, NULL, kJSPropertyAttributeReadOnly },        
-       {"accountid", JSMessageFolder::getProperty, NULL, kJSPropertyAttributeReadOnly },       
+       {"parentId", JSMessageFolder::getProperty, NULL, kJSPropertyAttributeReadOnly },        
+       {"serviceId", JSMessageFolder::getProperty, NULL, kJSPropertyAttributeReadOnly },       
        {"contentType", JSMessageFolder::getProperty, NULL, kJSPropertyAttributeReadOnly },
        {"name", JSMessageFolder::getProperty, JSMessageFolder::setProperty, kJSPropertyAttributeNone },
        {"path", JSMessageFolder::getProperty, NULL, kJSPropertyAttributeReadOnly },
index 53114f3..1b2de18 100755 (executable)
 */
 
 
-/*
- * @file         JSMessageFolder.h
- * @author       Oy Kwon (sirot.kwon@samsung.com)
- * @version   0.1
- * @brief       Declaration of the Templete class
- */
 
 #ifndef WRTPLUGINS_TIZEN_JS_MESSAGEFOLDER_H_
 #define WRTPLUGINS_TIZEN_JS_MESSAGEFOLDER_H_
index 0185669..8aab02c 100755 (executable)
@@ -53,6 +53,7 @@ using namespace TizenApis::Commons;
 
 JSMessagingListener::JSMessagingListener(JSContextRef context) :
     WrtDeviceApis::CommonsJavaScript::PrivateObjectT<void>::Type(context),
+    EventAddDraftMessageAnswerReceiver(ThreadEnum::NULL_THREAD),
     EventSendMessageAnswerReceiver(ThreadEnum::NULL_THREAD),
     EventQueryMessagesAnswerReceiver(ThreadEnum::NULL_THREAD),
     EventDeleteMessagesAnswerReceiver(ThreadEnum::NULL_THREAD),
@@ -62,14 +63,60 @@ JSMessagingListener::JSMessagingListener(JSContextRef context) :
     EventQueryConversationsAnswerReceiver(ThreadEnum::NULL_THREAD),
     EventDeleteConversationsAnswerReceiver(ThreadEnum::NULL_THREAD),
     EventQueryFoldersAnswerReceiver(ThreadEnum::NULL_THREAD),    
-    m_nextHandle(1),
-    m_emiterMsgId(Api::Messaging::EmitterMessageReceived::emptyId),
-    m_emiterConvId(Api::Messaging::EmitterConversationReceived::emptyId),
-    m_emiterFolderId(Api::Messaging::EmitterFolderReceived::emptyId)
+    m_nextHandle(1)
+//    m_emiterMsgId(Api::Messaging::EmitterMessageReceived::emptyId),
+//    m_emiterConvId(Api::Messaging::EmitterConversationReceived::emptyId),
+//    m_emiterFolderId(Api::Messaging::EmitterFolderReceived::emptyId)
 {
 }
 
 void JSMessagingListener::OnAnswerReceived(
+        const Api::Messaging::EventAddDraftMessagePtr& event)
+{
+    WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager =
+        DPL::StaticPointerCast<JSCallbackManager >(event->getPrivateData());
+    Assert(NULL != callbackManager);
+    LogDebug("thread=" << DPL::Thread::GetCurrentThread());
+
+    Try
+    {
+        if (WrtDeviceApis::Commons::ExceptionCodes::None == event->getExceptionCode()) {
+            callbackManager->callOnSuccess();
+
+        } else {
+            switch (event->getExceptionCode()) {
+            case WrtDeviceApis::Commons::ExceptionCodes::PlatformException:
+                Throw(WrtDeviceApis::Commons::PlatformException);
+            case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
+                Throw(WrtDeviceApis::Commons::ConversionException);
+            default:
+                Throw(WrtDeviceApis::Commons::UnknownException);
+            }
+        }
+    }
+
+    Catch(WrtDeviceApis::Commons::PlatformException) {
+        LogError("platform error");
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+                                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
+    }
+
+    Catch(WrtDeviceApis::Commons::ConversionException) {
+        LogError("conversion error");
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+                                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
+    }
+
+    Catch(WrtDeviceApis::Commons::UnknownException) {
+        LogError("unknown error");
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+                                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
+    }
+
+}
+
+
+void JSMessagingListener::OnAnswerReceived(
         const Api::Messaging::EventSendMessagePtr& event)
 {
     LogDebug("ENTER");
@@ -139,6 +186,8 @@ void JSMessagingListener::OnAnswerReceived(
                 Throw(WrtDeviceApis::Commons::PlatformException);
             case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
                 Throw(WrtDeviceApis::Commons::ConversionException);
+            case WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException:
+                Throw(WrtDeviceApis::Commons::InvalidArgumentException);
             default:
                 Throw(WrtDeviceApis::Commons::UnknownException);
             }
@@ -156,6 +205,13 @@ void JSMessagingListener::OnAnswerReceived(
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
 
+    Catch(WrtDeviceApis::Commons::InvalidArgumentException) 
+    {
+        LogError("conversion error");
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+                                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
+    }
+
     Catch(WrtDeviceApis::Commons::UnknownException) {
         LogError("unknown error");
         callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
@@ -323,6 +379,8 @@ void JSMessagingListener::OnAnswerReceived(const Api::Messaging::EventQueryConve
                                        Throw(WrtDeviceApis::Commons::PlatformException);
                                case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
                                        Throw(WrtDeviceApis::Commons::ConversionException);
+                               case WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException:
+                                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);
                                default:
                                        Throw(WrtDeviceApis::Commons::UnknownException);
                        }
@@ -341,6 +399,12 @@ void JSMessagingListener::OnAnswerReceived(const Api::Messaging::EventQueryConve
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,                
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
        }
+       Catch(WrtDeviceApis::Commons::InvalidArgumentException)
+       {
+               LogError("conversion error");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,
+                                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
+       }       
        Catch(WrtDeviceApis::Commons::UnknownException) 
        {
                LogError("unknown error");
@@ -419,6 +483,8 @@ void JSMessagingListener::OnAnswerReceived(const Api::Messaging::EventQueryFolde
                                        Throw(WrtDeviceApis::Commons::PlatformException);
                                case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
                                        Throw(WrtDeviceApis::Commons::ConversionException);
+                               case WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException:
+                                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);
                                default:
                                        Throw(WrtDeviceApis::Commons::UnknownException);
                        }
@@ -437,6 +503,12 @@ void JSMessagingListener::OnAnswerReceived(const Api::Messaging::EventQueryFolde
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,                
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
        }
+       Catch(WrtDeviceApis::Commons::InvalidArgumentException) 
+       {
+               LogError("conversion error");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,                
+                                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
+       }       
        Catch(WrtDeviceApis::Commons::UnknownException) 
        {
                LogError("unknown error");
@@ -608,31 +680,28 @@ void JSMessagingListener::onAnswerReceived(
 long JSMessagingListener::addIncomingMsgCallback(const WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr& cbManager, int funtionIndex)
 {
        IncomingMsgCB* callbacks = NULL;
-       callbacks = &m_MessageCallbacks;
        long handle = 0;
        
-       if (NULL == callbacks) {
-           Throw(WrtDeviceApis::Commons::UnsupportedException);
-       }
-
-//   long handle = m_nextHandle;
        switch(funtionIndex)
        {
                case MESSAGES_MULTI_FUNCTION:
                {
-                       handle = static_cast<long>(m_emiterMsgId);
+                       callbacks = &m_MessageCallbacks;                        
+                       handle = static_cast<long>(m_emiterMsgId.back());
                        LogWarning("Message Emitter handle : " << handle);                      
                }
                break;
                case CONVERSATIONS_MULTI_FUNCTION:
                {
-                       handle = static_cast<long>(m_emiterConvId);
+                       callbacks = &m_ConversationCallbacks;                                           
+                       handle = static_cast<long>(m_emiterConvId.back());
                        LogWarning("Conversation Emitter handle : " << handle);                 
                }
                break;
                case FOLDERS_MULTI_FUNCTION:
                {
-                       handle = static_cast<long>(m_emiterFolderId);
+                       callbacks = &m_FolderCallbacks;                                         
+                       handle = static_cast<long>(m_emiterFolderId.back());
                        LogWarning("Folder Emitter handle : " << handle);                       
                }
                break;
@@ -642,7 +711,10 @@ long JSMessagingListener::addIncomingMsgCallback(const WrtDeviceApis::CommonsJav
                }
                break;
        }
-//    m_nextHandle++;
+
+       if (NULL == callbacks) {
+           Throw(WrtDeviceApis::Commons::UnsupportedException);
+       }
 
     // try to insert new callback
     if (!callbacks->insert(std::make_pair(handle, cbManager)).second) {
@@ -655,117 +727,61 @@ long JSMessagingListener::addIncomingMsgCallback(const WrtDeviceApis::CommonsJav
 
 void JSMessagingListener::removeIncomingMsgCallback(long handle)
 {
-    size_t removed = 0;
-    removed += m_MessageCallbacks.erase(handle);
+    size_t msgRemoved = 0;
+    size_t convRemoved = 0;
+    size_t folderRemoved = 0;  
+    msgRemoved += m_MessageCallbacks.erase(handle);
+    convRemoved += m_ConversationCallbacks.erase(handle);      
+    folderRemoved += m_FolderCallbacks.erase(handle);
 
     // there are duplicate handles
-    if (removed > 1) {
+    if (msgRemoved+msgRemoved+folderRemoved > 1) {
         LogError("Duplicate callback handles!");
     }
     Api::Messaging::EmitterMessageReceived::IdType temp_handle;
     temp_handle = static_cast<Api::Messaging::EmitterMessageReceived::IdType>(handle);
 
-    if (m_emiterMsgId == temp_handle) {
+    if (msgRemoved) {
         LogWarning("EmitterMessageReceived registered");
-        Api::Messaging::IMessaging::getInstance().removeOnMessageMsgReceived(m_emiterMsgId);
-        m_emiterMsgId = Api::Messaging::EmitterMessageReceived::emptyId;
+        Api::Messaging::IMessaging::getInstance().removeOnMessageMsgReceived(temp_handle);
     }
-    else if (m_emiterConvId == temp_handle) {
+    else if (convRemoved) {
         LogWarning("EmitterConversationReceived registered");
-        Api::Messaging::IMessaging::getInstance().removeOnMessageConvReceived(m_emiterConvId);
-        m_emiterConvId = Api::Messaging::EmitterConversationReceived::emptyId;
+        Api::Messaging::IMessaging::getInstance().removeOnMessageConvReceived(temp_handle);
     }
-    else if (m_emiterFolderId == temp_handle) {
+    else if (folderRemoved) {
         LogWarning("EmitterFolderReceived registered");
-        Api::Messaging::IMessaging::getInstance().removeOnMessageFolderReceived(m_emiterFolderId);
-        m_emiterFolderId = Api::Messaging::EmitterFolderReceived::emptyId;
+        Api::Messaging::IMessaging::getInstance().removeOnMessageFolderReceived(temp_handle);
     }
        
 }
 
-bool JSMessagingListener::checkMessageReceivedEmitter(int funtionIndex)
-{
-    bool retVal = FALSE;
-
-    switch(funtionIndex)
-    {
-        case MESSAGES_MULTI_FUNCTION:
-        {
-            if (m_emiterMsgId != Api::Messaging::EmitterMessageReceived::emptyId) {
-                LogWarning("Message Emitter Already registered");
-                retVal = TRUE;
-            }
-        }
-        break;
-        case CONVERSATIONS_MULTI_FUNCTION:
-        {
-            if (m_emiterConvId != Api::Messaging::EmitterMessageReceived::emptyId) {
-                LogWarning("Conversation Emitter Already registered");
-                retVal = TRUE;
-            }
-        }
-        break;
-        case FOLDERS_MULTI_FUNCTION:
-        {
-            if (m_emiterFolderId != Api::Messaging::EmitterMessageReceived::emptyId) {
-                LogWarning("MessageFolder Emitter Already registered");
-                retVal = TRUE;
-            }
-        }
-        break;
-        default:
-        {
-            LogWarning("Unexpected state");
-        }
-        break;
-       }
-    return retVal;
-}
-
-
 void JSMessagingListener::registerMessageReceivedEmitter(EventOnMessagingStorageChangesPrivateDataPtr privData)
 {
 
        if(privData->getFunctionIndex() == MESSAGES_MULTI_FUNCTION)
        {
 
-               if (m_emiterMsgId != Api::Messaging::EmitterMessageReceived::emptyId) {
-                       LogWarning("Already registered");
-                       return;
-               }
-       
            Api::Messaging::EmitterMessageReceivedPtr emitter(new Api::Messaging::EmitterMessageReceived());
            emitter->setListener(this);
                emitter->setEventPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privData));// <-registerMessageReceivedEmitter()
-           m_emiterMsgId = emitter->getId();
+           m_emiterMsgId.push_back(emitter->getId());
                Api::Messaging::IMessaging::getInstance().addOnMessageReceived(emitter, privData->getFilter(), privData->getFunctionIndex());           
        }
        else if(privData->getFunctionIndex() == CONVERSATIONS_MULTI_FUNCTION)
        {
-
-               if (m_emiterConvId != Api::Messaging::EmitterConversationReceived::emptyId) {
-                       LogWarning("Already registered");
-                       return;
-               }
-       
            Api::Messaging::EmitterConversationReceivedPtr emitter(new Api::Messaging::EmitterConversationReceived());
            emitter->setListener(this);
                emitter->setEventPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privData));// <-registerMessageReceivedEmitter()
-           m_emiterConvId = emitter->getId();
+           m_emiterConvId.push_back(emitter->getId());
                Api::Messaging::IMessaging::getInstance().addOnMessageReceived(emitter, privData->getFilter(), privData->getFunctionIndex());           
        }
        else// if(privData->getFunctionIndex() == FOLDERS_MULTI_FUNCTION)
        {
-
-               if (m_emiterFolderId != Api::Messaging::EmitterFolderReceived::emptyId) {
-                       LogWarning("Already registered");
-                       return;
-               }
-       
            Api::Messaging::EmitterFolderReceivedPtr emitter(new Api::Messaging::EmitterFolderReceived());
            emitter->setListener(this);
                emitter->setEventPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privData));// <-registerMessageReceivedEmitter()
-           m_emiterFolderId = emitter->getId();
+           m_emiterFolderId.push_back(emitter->getId());
                Api::Messaging::IMessaging::getInstance().addOnMessageReceived(emitter, privData->getFilter(), privData->getFunctionIndex());           
        }
        
@@ -774,22 +790,37 @@ void JSMessagingListener::registerMessageReceivedEmitter(EventOnMessagingStorage
 void JSMessagingListener::deregisterMessageReceivedEmitter()
 {
     LogDebug("enter");
-    if (m_emiterMsgId != Api::Messaging::EmitterMessageReceived::emptyId) {
+    if (m_emiterMsgId.size() > 0) {
         LogWarning("EmitterMessageReceived registered");
-               Api::Messaging::IMessaging::getInstance().removeOnMessageMsgReceived(m_emiterMsgId);
-               m_emiterMsgId = Api::Messaging::EmitterMessageReceived::emptyId;
+               Api::Messaging::EmitterMessageReceived::IdType  tempId;
+               while(m_emiterMsgId.size() > 0)
+               {
+                       tempId = m_emiterMsgId.back();
+                       Api::Messaging::IMessaging::getInstance().removeOnMessageMsgReceived(tempId);
+                       m_emiterMsgId.pop_back();
+               }
     }
 
-       if (m_emiterConvId != Api::Messaging::EmitterConversationReceived::emptyId) {
+       if (m_emiterConvId.size() > 0) {
                LogWarning("EmitterConversationReceived registered");
-               Api::Messaging::IMessaging::getInstance().removeOnMessageConvReceived(m_emiterConvId);
-               m_emiterConvId = Api::Messaging::EmitterConversationReceived::emptyId;
+               Api::Messaging::EmitterConversationReceived::IdType     tempId;
+               while(m_emiterConvId.size() > 0)
+               {
+                       tempId = m_emiterConvId.back();
+                       Api::Messaging::IMessaging::getInstance().removeOnMessageMsgReceived(tempId);
+                       m_emiterConvId.pop_back();
+               }
        }
 
-       if (m_emiterFolderId != Api::Messaging::EmitterFolderReceived::emptyId) {
+       if (m_emiterFolderId.size() > 0) {
                LogWarning("EmitterFolderReceived registered");
-               Api::Messaging::IMessaging::getInstance().removeOnMessageFolderReceived(m_emiterFolderId);
-               m_emiterFolderId = Api::Messaging::EmitterFolderReceived::emptyId;
+               Api::Messaging::EmitterFolderReceived::IdType   tempId;
+               while(m_emiterFolderId.size() > 0)
+               {
+                       tempId = m_emiterFolderId.back();
+                       Api::Messaging::IMessaging::getInstance().removeOnMessageMsgReceived(tempId);
+                       m_emiterFolderId.pop_back();
+               }
        }
     LogDebug("finish");
        return;
index 9c21470..5a3f602 100755 (executable)
@@ -11,7 +11,7 @@
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
-* limitations under the License. 
+* limitations under the License.
 */
 
 /**
@@ -25,7 +25,6 @@
 #define JSMESSAGINGLISTENER_H
 
 #include <map>
-#include <dpl/controller.h>
 #include <CommonsJavaScript/JSPendingOperation.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <API/Messaging/ReqReceiverMessage.h>
@@ -39,6 +38,8 @@
 
 namespace TizenApis {
 namespace Tizen1_0 {
+typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventAddDraftMessage>
+EventAddDraftMessageAnswerReceiver;    
 typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventSendMessage>
 EventSendMessageAnswerReceiver;
 typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventQueryMessages>
@@ -57,27 +58,29 @@ typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventQueryFo
 EventQueryFoldersAnswerReceiver;
 
 class JSMessagingListener : public WrtDeviceApis::CommonsJavaScript::PrivateObjectT<void>::Type,
+    public EventAddDraftMessageAnswerReceiver,
     public EventSendMessageAnswerReceiver,
     public EventQueryMessagesAnswerReceiver,
     public EventDeleteMessagesAnswerReceiver,
-    public EventUpdateMessagesAnswerReceiver,     
+    public EventUpdateMessagesAnswerReceiver,
     public Api::Messaging::EventUpdateMessageAnswerReceiver,
     public EventMessageReceivedListener,
     public EventQueryConversationsAnswerReceiver,
     public EventDeleteConversationsAnswerReceiver,
-    public EventQueryFoldersAnswerReceiver    
+    public EventQueryFoldersAnswerReceiver
 {
   public:
     explicit JSMessagingListener(JSContextRef context);
 
     long addIncomingMsgCallback(const WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr& cbManager, int funtionIndex);
     void removeIncomingMsgCallback(long handle);
-    bool checkMessageReceivedEmitter(int functionIndex);
     void registerMessageReceivedEmitter(EventOnMessagingStorageChangesPrivateDataPtr privData);
     void deregisterMessageReceivedEmitter();
 
   protected:
     virtual void OnAnswerReceived(
+            const DPL::SharedPtr<Api::Messaging::EventAddDraftMessage> &event);
+    virtual void OnAnswerReceived(
             const DPL::SharedPtr<Api::Messaging::EventSendMessage> &event);
     virtual void OnAnswerReceived(
             const DPL::SharedPtr<Api::Messaging::EventQueryMessages> &event);
@@ -95,12 +98,12 @@ class JSMessagingListener : public WrtDeviceApis::CommonsJavaScript::PrivateObje
   private:
     typedef std::map<long, WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr> IncomingMsgCB;
     IncomingMsgCB m_MessageCallbacks;
-//    IncomingMsgCB m_MessageUpdatedCallbacks;
-//    IncomingMsgCB m_MessageDeletedCallbacks;
+    IncomingMsgCB m_ConversationCallbacks;
+    IncomingMsgCB m_FolderCallbacks;
     long m_nextHandle;
-    Api::Messaging::EmitterMessageReceived::IdType m_emiterMsgId;
-    Api::Messaging::EmitterConversationReceived::IdType m_emiterConvId;
-    Api::Messaging::EmitterFolderReceived::IdType m_emiterFolderId;    
+    std::vector<Api::Messaging::EmitterMessageReceived::IdType> m_emiterMsgId;
+    std::vector<Api::Messaging::EmitterConversationReceived::IdType> m_emiterConvId;
+    std::vector<Api::Messaging::EmitterFolderReceived::IdType> m_emiterFolderId;
 };
 
 typedef DPL::SharedPtr<JSMessagingListener> JSMessagingListenerPtr;
index c70fcca..501921d 100755 (executable)
@@ -59,7 +59,7 @@ namespace Tizen1_0 {
        JSClassDefinition JSMessagingService::m_classInfo = {
                0,
                kJSClassAttributeNone,
-               "MessagingService",
+               "MessageService",
                NULL,
                m_property,
                m_function,
@@ -78,7 +78,7 @@ namespace Tizen1_0 {
 
        JSStaticValue JSMessagingService::m_property[] =
        {
-           {"accountId",                       getProperty, NULL, kJSPropertyAttributeReadOnly},
+           {"id",                      getProperty, NULL, kJSPropertyAttributeReadOnly},
            {"type",                            getProperty, NULL, kJSPropertyAttributeReadOnly},
            {"name",                            getProperty, NULL, kJSPropertyAttributeReadOnly},
            { 0, 0, 0, 0 }
@@ -88,9 +88,7 @@ namespace Tizen1_0 {
                        { "createMessage",        JSMessagingService::createMessage,       kJSPropertyAttributeNone },
                        { "sendMessage",          JSMessagingService::sendMessage,         kJSPropertyAttributeNone },
                        { "loadMessageBody",      JSMessagingService::loadMessageBody,     kJSPropertyAttributeNone },
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
                        { "loadMessageAttachment",        JSMessagingService::loadMessageAttachment,       kJSPropertyAttributeNone },
-#endif
                        { "sync",         JSMessagingService::sync,        kJSPropertyAttributeNone },
                        { "syncFolder",   JSMessagingService::syncFolder,          kJSPropertyAttributeNone },
                        { "cancelOperation",   JSMessagingService::cancelOperation,        kJSPropertyAttributeNone },
@@ -143,7 +141,7 @@ namespace Tizen1_0 {
                                } else if (JSStringIsEqualToUTF8CString(propertyName, "name")) {
                                        LogDebug("name" << ":" <<  imessagingService->getName());
                                        retVal = converter->toJSValueRef(imessagingService->getName());
-                               } else if (JSStringIsEqualToUTF8CString(propertyName, "accountId")) {
+                               } else if (JSStringIsEqualToUTF8CString(propertyName, "id")) {
                                        LogDebug("accountId" << ":" <<  imessagingService->getAccountID());
                                        
                                        std::stringstream stream;
@@ -460,7 +458,7 @@ JSValueRef JSMessagingService::loadMessageBody(JSContextRef context,
     JSContextRef globalContext = priv->getContext();           //create global Context
     LogInfo(">>> argument count : " << argumentCount);
 
-       if (argumentCount < 3) {
+       if (argumentCount < 2) {
                return JSTizenExceptionFactory::postException(context, exception, 
                        JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
        }
@@ -478,7 +476,7 @@ JSValueRef JSMessagingService::loadMessageBody(JSContextRef context,
                AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
                        priv->getContext(),
                        MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_BODY]);
-               TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager);
+                       TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager);
 
                if (JSValueIsObject(context, arguments[0]) && Validator(context).isCallback(arguments[0])) //check
                {
@@ -543,7 +541,6 @@ JSValueRef JSMessagingService::loadMessageBody(JSContextRef context,
 
 }
 
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
 JSValueRef JSMessagingService::loadMessageAttachment(JSContextRef context,
         JSObjectRef function,
         JSObjectRef thisObject,
@@ -555,19 +552,16 @@ JSValueRef JSMessagingService::loadMessageAttachment(JSContextRef context,
 
     JSMessagingServicePriv* priv = static_cast<JSMessagingServicePriv*>(JSObjectGetPrivate(thisObject));
 
-    if (!priv) {
-        LogError("Null pointer");
+       if (!priv) {
+               LogError("Private Object is Null pointer");
                return JSTizenExceptionFactory::postException(context, exception, 
-                  JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-
-
-    }
-
-    JSContextRef globalContext = priv->getContext();           //create global Context
-
+                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+       }
+       
+       JSContextRef globalContext = priv->getContext();                //create global Context
        LogInfo(">>> argument count : " << argumentCount);
 
-       if (argumentCount < 3) {
+       if (argumentCount < 2) {
                return JSTizenExceptionFactory::postException(context, exception, 
                        JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
        }
@@ -594,7 +588,8 @@ JSValueRef JSMessagingService::loadMessageAttachment(JSContextRef context,
                                priv->getContext(),
                                MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT]);
                        TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager);                       
-                       
+
+                       IMessagingServicePtr imessagingService = priv->getObject();
                        Api::Messaging::EventMessagingServicePtr event(new Api::Messaging::EventMessagingService());     //create event
 
                        LogInfo("event");
@@ -608,9 +603,10 @@ JSValueRef JSMessagingService::loadMessageAttachment(JSContextRef context,
                                Api::Messaging::IAttachmentPtr iAttchmentPtr = converter->toIAttachment(arguments[2]);
                                privateData->setMessageJSValueRef(arguments[2]);        //set Message JSValueRef.
                                if (iAttchmentPtr)
-                               {
+                               {       
                                        event->m_attachment = iAttchmentPtr;
                                        event->m_message = event->m_attachment->getMessage();
+                                                                               
                                        if (!event->m_message)
                                                return JSTizenExceptionFactory::postException(context, exception, 
                                                        JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
@@ -627,11 +623,17 @@ JSValueRef JSMessagingService::loadMessageAttachment(JSContextRef context,
                                                JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
                        }
 
+                       int opId = imessagingService->createOpId(MESSAGING_SERVICE_OP_DOWNLOAD_ATTACHMENT);
+                       LogDebug("Operation ID is = " << opId);
+
+                       event->opId = opId;
+                       imessagingService->setMessageToOpId(opId, event->m_message);
+                       
                        LogInfo("pendingOperation");
-                       JSValueRef pendingOperation = WrtDeviceApis::CommonsJavaScript::makePendingOperation(globalContext, event);     //create pendingOperation.
+                       //JSValueRef pendingOperation = WrtDeviceApis::CommonsJavaScript::makePendingOperation(globalContext, event);   //create pendingOperation.
                        Api::Messaging::ReqReceiverMessageSingleton::Instance().loadMessageAttachment(event);   //load message Body
 
-                       return pendingOperation;
+                       return converter->toJSValueRef(event->opId);
 
                }
                else
@@ -660,7 +662,6 @@ JSValueRef JSMessagingService::loadMessageAttachment(JSContextRef context,
 
        return JSValueMakeNull(context);
 }
-#endif
 
 JSValueRef JSMessagingService::sync(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
                        size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
index 32d8198..c6704b5 100755 (executable)
@@ -79,10 +79,10 @@ private :
        
        static JSValueRef loadMessageBody(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
                                size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
+
        static JSValueRef loadMessageAttachment(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
                                size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
-#endif         
+
        static JSValueRef sync(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
                                size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
 
index 27e2eb5..cc58cde 100755 (executable)
@@ -75,7 +75,7 @@ namespace Tizen1_0 {
        };
 
        JSStaticFunction JSMessagingServiceManager::m_function[] = {
-                       { "getMessagingServices",         JSMessagingServiceManager::getMessagingServices,         kJSPropertyAttributeNone },
+                       { "getMessageServices",   JSMessagingServiceManager::getMessagingServices,         kJSPropertyAttributeNone },
                        { 0, 0, 0 }
        };
 
@@ -216,8 +216,6 @@ JSValueRef JSMessagingServiceManager::getMessagingServices(JSContextRef context,
                        // JSCallbackManager contains function pointers of successCallback and errorCallback.
                        // The function pointers is be using to return results to Javascriptcore.  So JSCallbackManager should be executed by main thread.
        
-                       LogDebug("setObject");
-                       callbackManager->setObject(thisObject);
 
                   //check permission.
                        AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
@@ -306,7 +304,6 @@ JSValueRef JSMessagingServiceManager::getMessagingServices(JSContextRef context,
                // JSCallbackManager contains function pointers of successCallback and errorCallback.
                // The function pointers is be using to return results to Javascriptcore.  So JSCallbackManager should be executed by main thread.
                WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr cbm(JSCallbackManager::createObject(priv->getContext(), arguments[0], arguments[1]));
-               cbm->setObject(thisObject);
            //check permission.
                AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
                priv->getContext(),
index 68c1278..66a0248 100755 (executable)
@@ -63,7 +63,7 @@ namespace Tizen1_0 {
        JSClassDefinition JSMessagingStorage::m_classInfo = {
                0,
                kJSClassAttributeNone,
-               "messagingStorage",
+               "messageStorage",
                NULL,
                NULL,
                m_function,
@@ -81,6 +81,7 @@ namespace Tizen1_0 {
        };
 
        JSStaticFunction JSMessagingStorage::m_function[] = {
+                       { "addDraftMessage",                    JSMessagingStorage::addDraftMessage,                                     kJSPropertyAttributeNone },            
                        { "findMessages",                       JSMessagingStorage::findMessages,                                        kJSPropertyAttributeNone },
                        { "removeMessages",                     JSMessagingStorage::removeMessages,                      kJSPropertyAttributeNone },
                        { "updateMessages",                     JSMessagingStorage::updateMessages,                      kJSPropertyAttributeNone },
@@ -164,6 +165,91 @@ namespace Tizen1_0 {
                return retVal;
        }
 
+       JSValueRef JSMessagingStorage::addDraftMessage(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+               const JSValueRef arguments[], JSValueRef* exception) {
+
+       LogDebug("<<<");
+
+       JSMessagingListener* priv = static_cast<JSMessagingListener*>
+       (JSObjectGetPrivate(thisObject));
+
+       if (!priv) {
+               LogError(">>> Null pointer");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                  JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+
+       }
+
+       JSContextRef globalContext = priv->getContext();
+
+       if (argumentCount < 1) {
+               LogError(">>> TypeMismatchException");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                        JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+
+       }
+
+       WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
+
+       ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
+       Try {
+
+               //check permission.
+               AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
+                       priv->getContext(),
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_DRAFT_MESSAGE]);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);  
+
+               Api::Messaging::EventAddDraftMessagePtr event(new Api::Messaging::EventAddDraftMessage());
+
+                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+
+               if (argumentCount > 1) {
+                       callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
+               }
+               
+               if (argumentCount > 2) {
+                       callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
+               }
+               
+               event->msg = converter->toIMessage(arguments[0]);
+
+        event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(
+                                  callbackManager));
+        event->setForAsynchronousCall(priv);
+
+        Api::Messaging::ReqReceiverMessageSingleton::Instance().addDraftMessage(event);
+
+        return JSValueMakeNull(context);
+       }Catch(WrtDeviceApis::Commons::ConversionException) {
+               LogError(">>> TypeMismatchException");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+       }Catch(WrtDeviceApis::Commons::NullPointerException) {
+               LogError(">>> TypeMismatchException");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+       }Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
+               LogError(">>> InvalidValuesException");
+               if(argumentCount < 3)
+               {
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);                    
+               }                       
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
+                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
+       }Catch(WrtDeviceApis::Commons::PlatformException) {
+               LogError(">>> UnknownException");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+       }               
+
+       LogError(">>> JSValueMakeNull");
+       return JSValueMakeNull(context);
+       
+       }
+
+
                JSValueRef JSMessagingStorage::findMessages(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
                        const JSValueRef arguments[], JSValueRef* exception) {
 
@@ -767,7 +853,6 @@ namespace Tizen1_0 {
                WrtDeviceApis::CommonsJavaScript::JSCallbackManager::createObject(l_globalContext,
                                                                                                                NULL,
                                                                                                                NULL);
-               callbackManager->setObject(thisObject);
 
                OnMessagesChanged result = converter->toMessageMultifunctions(arguments[0]);
                int funtionIndex = result.functionIndex;
@@ -776,8 +861,6 @@ namespace Tizen1_0 {
                WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesUpdatedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesUpdated, NULL);
                WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesRemovedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesRemoved, NULL);
 
-               messagesUpdatedCbm->setObject(thisObject);
-               messagesRemovedCbm->setObject(thisObject);
 
                EventOnMessagingStorageChangesPrivateDataPtr privData(
                        new EventOnMessagingStorageChangesPrivateData(callbackManager, messagesUpdatedCbm, messagesRemovedCbm, funtionIndex));
@@ -789,13 +872,6 @@ namespace Tizen1_0 {
             privData->setFilter(filterConverter->toFilter(arguments[1]));
         }
 
-        if(listener->checkMessageReceivedEmitter(funtionIndex))
-        {
-            LogError("Already in use exception");
-                return JSTizenExceptionFactory::postException(context, exception, 
-                                        JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-               }
-
                listener->registerMessageReceivedEmitter(privData);
 
         // add to map and return index
@@ -877,7 +953,6 @@ namespace Tizen1_0 {
                WrtDeviceApis::CommonsJavaScript::JSCallbackManager::createObject(l_globalContext,
                                                                                                                NULL,
                                                                                                                NULL);
-               callbackManager->setObject(thisObject);
 
                OnMessagesChanged result = converter->toMessageMultifunctions(arguments[0]);
                int funtionIndex = result.functionIndex;
@@ -886,8 +961,6 @@ namespace Tizen1_0 {
                WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesUpdatedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesUpdated, NULL);
                WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesRemovedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesRemoved, NULL);
 
-               messagesUpdatedCbm->setObject(thisObject);
-               messagesRemovedCbm->setObject(thisObject);
 
                EventOnMessagingStorageChangesPrivateDataPtr privData(
                        new EventOnMessagingStorageChangesPrivateData(callbackManager, messagesUpdatedCbm, messagesRemovedCbm, funtionIndex));
@@ -899,13 +972,6 @@ namespace Tizen1_0 {
             privData->setFilter(filterConverter->toFilter(arguments[1]));
         }
 
-        if(listener->checkMessageReceivedEmitter(funtionIndex))
-        {
-            LogError("Already in use exception");
-                return JSTizenExceptionFactory::postException(context, exception, 
-                                        JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-               }
-
                listener->registerMessageReceivedEmitter(privData);
 
         // add to map and return index
@@ -988,7 +1054,6 @@ namespace Tizen1_0 {
                WrtDeviceApis::CommonsJavaScript::JSCallbackManager::createObject(l_globalContext,
                                                                                                                NULL,
                                                                                                                NULL);
-               callbackManager->setObject(thisObject);
 
                OnMessagesChanged result = converter->toMessageMultifunctions(arguments[0]);
                int funtionIndex = result.functionIndex;
@@ -997,8 +1062,6 @@ namespace Tizen1_0 {
                WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesUpdatedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesUpdated, NULL);
                WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesRemovedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesRemoved, NULL);
 
-               messagesUpdatedCbm->setObject(thisObject);
-               messagesRemovedCbm->setObject(thisObject);
 
                EventOnMessagingStorageChangesPrivateDataPtr privData(
                        new EventOnMessagingStorageChangesPrivateData(callbackManager, messagesUpdatedCbm, messagesRemovedCbm, funtionIndex));
@@ -1010,13 +1073,6 @@ namespace Tizen1_0 {
             privData->setFilter(filterConverter->toFilter(arguments[1]));
         }
 
-        if(listener->checkMessageReceivedEmitter(funtionIndex))
-        {
-            LogError("Already in use exception");
-                return JSTizenExceptionFactory::postException(context, exception, 
-                                        JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-               }
-
                listener->registerMessageReceivedEmitter(privData);
 
         // add to map and return index
index 91dd3d7..1fdc8fa 100755 (executable)
@@ -71,6 +71,9 @@ private:
                         JSStringRef propertyName,
                         JSValueRef* exception);
 
+       static JSValueRef addDraftMessage(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+        const JSValueRef arguments[], JSValueRef* exception);
+
        static JSValueRef findMessages(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
         const JSValueRef arguments[], JSValueRef* exception);
 
index 1670975..e9fcee2 100755 (executable)
@@ -21,7 +21,7 @@
  * @version     0.1
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "JSRecipientArray.h"
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/ScopedJSStringRef.h>
index 01d83cc..acc0c37 100755 (executable)
@@ -11,7 +11,7 @@
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
-* limitations under the License. 
+* limitations under the License.
 */
 
 
@@ -24,8 +24,7 @@
 #ifndef WRTPLUGINS_TIZEN_MESSAGING_CONTROLLER_H_
 #define WRTPLUGINS_TIZEN_MESSAGING_CONTROLLER_H_
 
-#include <dpl/log.h>
-#include <dpl/controller.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
 #include <API/Messaging/IMessagingServiceManager.h>
 #include <API/Messaging/IMessagingService.h>
@@ -48,21 +47,21 @@ class MessagingController :
 public:
        explicit MessagingController();
        virtual ~MessagingController();
-       
+
        static MessagingController& getInstance();
-       
+
 protected:
         void OnAnswerReceived(const Api::Messaging::EventGetMessagingServicePtr &event);
 
          void OnAnswerReceived(const Api::Messaging::EventMessagingServicePtr &event);
 
         void OnAnswerReceived(const Api::Messaging::EventSendMessagePtr &event);
-       
+
 };
 
 typedef DPL::Singleton<MessagingController> MessagingControllerSingleton;      //for singleton
 
-}  
+}
 } // WrtPlugins
 
 #endif //WRTPLUGINS_TIZEN_MESSAGING_CONTROLLER_H_
index 839d7c5..8a7104d 100755 (executable)
         <device-capability>messaging.send</device-capability>
         <device-capability>messaging.read</device-capability>
         <Object name="messaging">
-            <Function name="getMessagingServices"/>
+            <Function name="getMessageServices"/>
         </Object>
-    <Object name="messagingStorage">
+    <Object name="messageStorage">
+            <Function name="addDraftMessage"/>    
             <Function name="findMessages"/>
             <Function name="removeMessages"/>
             <Function name="updateMessages"/>
old mode 100644 (file)
new mode 100755 (executable)
index bb6e4c1..aa551c9
  */
 
  
-/**
-* @file                 plugin_config.cpp
-* @author       Kangsoo Lee (wpeter.lee@samsung.com)
-* @version      0.1
-*/
 
 #include <map>
 #include <utility>
@@ -44,7 +39,7 @@ using namespace WrtDeviceApis::Commons;
 
 const char* MessagingExportedNames[] = 
 {
-       "getMessagingService",
+       "getMessageServices",
        "createMessage",
        "sendMessage",
        "loadMessageBody",
@@ -52,6 +47,7 @@ const char* MessagingExportedNames[] =
        "sync",
        "syncFolder",
        "cancelOperation",
+       "addDraftMessage",
        "findMessages",
        "removeMessages",
        "updateMessages",
@@ -290,6 +286,16 @@ static WrtDeviceApis::Commons::FunctionMapping createMessagingFunctions()
                        sendMessageFunc));
        
       /**  Write  **/
+     AceFunction addDraftMessageFunc = ACE_CREATE_FUNCTION(
+                       FUNCTION_GET_MGR_SERVICE,
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_DRAFT_MESSAGE],
+                       MESSAGING_FEATURES_MESSAGING_WRITE,
+                       EMPTY_DEVICE_LIST);
+       
+       MessagingFunctions.insert( std::make_pair(
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_DRAFT_MESSAGE],
+                       addDraftMessageFunc));
+       
      AceFunction removeMessagesFunc = ACE_CREATE_FUNCTION(
                        FUNCTION_GET_MGR_SERVICE,
                        MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_MESSAGES],
old mode 100644 (file)
new mode 100755 (executable)
index ac6adb8..87979d5
@@ -32,6 +32,7 @@ MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT,
 MESSAGING_FUNCTION_API_SYNC,
 MESSAGING_FUNCTION_API_SYNC_FOLDER,
 MESSAGING_FUNCTION_API_CANCEL_OPERATION,
+MESSAGING_FUNCTION_API_ADD_DRAFT_MESSAGE,
 MESSAGING_FUNCTION_API_FIND_MESSAGES,
 MESSAGING_FUNCTION_API_REMOVE_MESSAGES,
 MESSAGING_FUNCTION_API_UPDATE_MESSAGES,
index 51a88cf..9eade7d 100755 (executable)
@@ -14,7 +14,7 @@
 * limitations under the License. 
 */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
 #include "JSMessagingServiceManager.h"
 #include "JSMessagingStorage.h"
@@ -43,7 +43,7 @@ PLUGIN_CLASS_MAP_BEGIN
 #if 1
        PLUGIN_CLASS_MAP_ADD_CLASS(
                WRT_JS_EXTENSION_OBJECT_TIZEN OBJECT_MESSAGING,
-               "messagingStorage",
+               "messageStorage",
                TizenApis::Tizen1_0::JSMessagingStorage::getClassRef(),
                NULL)
 #endif
index 7f9717c..5fec926 100755 (executable)
@@ -22,7 +22,7 @@
 #include "NFCStaticController.h"
 #include "EventNFCChangedPrivateData.h"
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <string>
 #include <CommonsJavaScript/Validator.h>
index 70619ff..56bdbd9 100755 (executable)
@@ -20,7 +20,7 @@
 #include "JSNFCManager.h"
 #include "NFCConverter.h"
 #include "ResponseDispatcher.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <CommonsJavaScript/Validator.h>
 #include <Commons/Exception.h>
@@ -235,7 +235,6 @@ JSValueRef JSNFCTag::readNDEF(JSContextRef context,
        INFCTagPtr NFCTag(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
                EventTagActionReadPtr event(new EventTagActionRead());
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
@@ -307,7 +306,6 @@ JSValueRef JSNFCTag::writeNDEF(JSContextRef context,
        INFCTagPtr NFCTag(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
                EventTagActionWritePtr event(new EventTagActionWrite());
                event->writeNdef(messageHandle);
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
@@ -386,7 +384,6 @@ JSValueRef JSNFCTag::transceive(JSContextRef context,
        INFCTagPtr NFCTag(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
                EventTagActionTransceivePtr event(new EventTagActionTransceive());
                event->transceive(data);
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
@@ -466,7 +463,6 @@ JSValueRef JSNFCTag::formatNDEF(JSContextRef context,
        INFCTagPtr NFCTag(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
                EventTagActionFormatPtr event(new EventTagActionFormat());
                event->format(key);
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
index 89fd2a3..a5fe44f 100755 (executable)
@@ -19,7 +19,7 @@
 #include "NFCConverter.h"
 #include "ResponseDispatcher.h"
 #include "JSNFCTag.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <CommonsJavaScript/Validator.h>
 #include <Commons/Exception.h>
@@ -179,7 +179,6 @@ JSValueRef JSNFCTagMifareClassic::authenticateWithKeyA(JSContextRef context,
        INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
                EventTagMifareClassicAuthenticateWithKeyAPtr event(new EventTagMifareClassicAuthenticateWithKeyA(convert.toVectorOfUChars(arguments[0]), convert.toInt(arguments[1])));
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
@@ -255,7 +254,6 @@ JSValueRef JSNFCTagMifareClassic::authenticateWithKeyB(JSContextRef context,
        INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
                EventTagMifareClassicAuthenticateWithKeyBPtr event(new EventTagMifareClassicAuthenticateWithKeyB(convert.toVectorOfUChars(arguments[0]), convert.toInt(arguments[1])));
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
@@ -330,7 +328,6 @@ JSValueRef JSNFCTagMifareClassic::readBlock(JSContextRef context,
        INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
                EventTagMifareClassicReadBlockPtr event(new EventTagMifareClassicReadBlock(convert.toInt(arguments[0])));
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
@@ -406,7 +403,6 @@ JSValueRef JSNFCTagMifareClassic::writeBlock(JSContextRef context,
        INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
                EventTagMifareClassicWriteBlockPtr event(new EventTagMifareClassicWriteBlock(convert.toInt(arguments[0]), convert.toVectorOfUChars(arguments[1])));
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
@@ -482,7 +478,6 @@ JSValueRef JSNFCTagMifareClassic::incrementBlockValue(JSContextRef context,
        INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
                EventTagMifareClassicIncrementBlockValuePtr event(new EventTagMifareClassicIncrementBlockValue(convert.toInt(arguments[0]), convert.toInt(arguments[1])));
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
@@ -558,7 +553,6 @@ JSValueRef JSNFCTagMifareClassic::decrementBlockValue(JSContextRef context,
        INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
                EventTagMifareClassicDecrementBlockValuePtr event(new EventTagMifareClassicDecrementBlockValue(convert.toInt(arguments[0]), convert.toInt(arguments[1])));
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
@@ -632,7 +626,6 @@ JSValueRef JSNFCTagMifareClassic::transfer(JSContextRef context,
        INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
                EventTagMifareClassicTransferPtr event(new EventTagMifareClassicTransfer(convert.toInt(arguments[0])));
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
@@ -706,7 +699,6 @@ JSValueRef JSNFCTagMifareClassic::restore(JSContextRef context,
        INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
                EventTagMifareClassicRestorePtr event(new EventTagMifareClassicRestore(convert.toInt(arguments[0])));
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
index 593efc8..103e994 100755 (executable)
@@ -19,7 +19,7 @@
 #include "NFCConverter.h"
 #include "ResponseDispatcher.h"
 #include "JSNFCTag.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <CommonsJavaScript/Validator.h>
 #include <Commons/Exception.h>
@@ -173,7 +173,6 @@ JSValueRef JSNFCTagMifareUltra::readPage(JSContextRef context,
        INFCTagMifareUltraPtr NFCTagMifareUltra(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
                EventTagMifareUltraReadPagePtr event(new EventTagMifareUltraReadPage(convert.toInt(arguments[0])));
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
@@ -249,7 +248,6 @@ JSValueRef JSNFCTagMifareUltra::writePage(JSContextRef context,
        INFCTagMifareUltraPtr NFCTagMifareUltra(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
                EventTagMifareUltraWritePagePtr event(new EventTagMifareUltraWritePage(convert.toInt(arguments[0]), convert.toVectorOfUChars(arguments[1])));
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
index 77b1275..bcfa492 100755 (executable)
@@ -19,7 +19,7 @@
 #include "JSNFCManager.h"
 #include "NFCConverter.h"
 #include "ResponseDispatcher.h"
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <CommonsJavaScript/Validator.h>
 #include <Commons/Exception.h>
@@ -212,7 +212,6 @@ JSValueRef JSNFCTarget::setReceiveNDEFListener(JSContextRef context,
        INFCTargetPtr NFCTarget(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
 
                EventTargetActionReceiveEmitterPtr emitter(new EventTargetActionReceiveEmitter);
                emitter->setListener(&NFCResponseDispatcher::getInstance());
@@ -320,7 +319,6 @@ JSValueRef JSNFCTarget::sendNDEF(JSContextRef context,
        INFCTargetPtr NFCTarget(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
        Try {
-               callbackManager->setObject( thisObject );
                EventTargetActionSendPtr event(new EventTargetActionSend(messageHandle));
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
index 5635d28..c16697f 100755 (executable)
@@ -19,7 +19,7 @@
 #include "JSNdefRecord.h"
 #include "NFCConverter.h"
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <Commons/Exception.h>
 #include <CommonsJavaScript/PrivateObject.h>
index 744fc2e..ecd143c 100755 (executable)
@@ -17,7 +17,7 @@
 
 #include <memory>
 #include <string>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/JSUtils.h>
 
 #include <Tizen/Common/JSTizenExceptionFactory.h>
index fb73b04..aa67e7a 100755 (executable)
@@ -16,7 +16,7 @@
 
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Validator.h>
 #include <CommonsJavaScript/ScopedJSStringRef.h>
 #include <CommonsJavaScript/JSUtils.h>
index 08a631c..6974827 100755 (executable)
@@ -15,7 +15,7 @@
  */
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 
 #include <JavaScriptCore/JavaScript.h>
index 6d5f76f..743bf14 100755 (executable)
@@ -15,7 +15,7 @@
  */
 
 #include <vector>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
index 5aae9e4..53c7d54 100755 (executable)
@@ -14,7 +14,7 @@
  * limitations under the License. 
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
 #include "JSNFCManager.h"
 
index a8537a2..4ca86fb 100755 (executable)
@@ -11,7 +11,6 @@ set(SRCS
   JSSensorManager.cpp
   JSSensorRequest.cpp
   JSSensorConnection.cpp
-  JSSensorData.cpp
   SensorType.cpp
   plugin_initializer.cpp
 )
index 9b8be6c..bf802d3 100755 (executable)
@@ -23,7 +23,6 @@
 #include <glib.h>
 #include "JSSensorManager.h"
 #include "JSSensorConnection.h"
-#include "JSSensorData.h"
 #include "JSSensorDataEvent.h"
 #include "JSSensorError.h"
 #include "SensorType.h"
@@ -495,10 +494,10 @@ static void sensor_cb_accelerometer(sensor_data_accuracy_e accuracy, float x, fl
         accuracy = SENSOR_DATA_ACCURACY_UNDEFINED;
     }
 
-    JSSensorDataEvent* data = new JSSensorDataEvent(JSSENSOR_REASON_WATCH, scon->type);
+    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, JSSENSOR_REASON_WATCH, scon->type);
     data->set(accuracy, g_get_monotonic_time(), x, y, z);
 
-    processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj(ctx));
+    processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj());
 }
 static void sensor_cb_magnetic(sensor_data_accuracy_e accuracy, float x, float y, float z, void* ud)
 {
@@ -508,9 +507,9 @@ static void sensor_cb_magnetic(sensor_data_accuracy_e accuracy, float x, float y
         accuracy = SENSOR_DATA_ACCURACY_UNDEFINED;
     }
 
-    JSSensorDataEvent* data = new JSSensorDataEvent(JSSENSOR_REASON_WATCH, scon->type);
+    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, JSSENSOR_REASON_WATCH, scon->type);
     data->set(accuracy, g_get_monotonic_time(), x, y, z);
-    processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj(ctx));
+    processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj());
 }
 static void sensor_cb_orientation(sensor_data_accuracy_e accuracy, float alpha, float beta, float gamma, void* ud)
 {
@@ -520,9 +519,9 @@ static void sensor_cb_orientation(sensor_data_accuracy_e accuracy, float alpha,
         accuracy = SENSOR_DATA_ACCURACY_UNDEFINED;
     }
 
-    JSSensorDataEvent* data = new JSSensorDataEvent(JSSENSOR_REASON_WATCH, scon->type);
+    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, JSSENSOR_REASON_WATCH, scon->type);
     data->set(accuracy, g_get_monotonic_time(), alpha, beta, gamma);
-    processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj(ctx));
+    processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj());
 }
 static void sensor_cb_gyroscope(sensor_data_accuracy_e accuracy, float x, float y, float z, void* ud)
 {
@@ -532,35 +531,35 @@ static void sensor_cb_gyroscope(sensor_data_accuracy_e accuracy, float x, float
         accuracy = SENSOR_DATA_ACCURACY_UNDEFINED;
     }
 
-    JSSensorDataEvent* data = new JSSensorDataEvent(JSSENSOR_REASON_WATCH, scon->type);
+    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, JSSENSOR_REASON_WATCH, scon->type);
     data->set(accuracy, g_get_monotonic_time(), x, y, z);
-    processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj(ctx));
+    processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj());
 }
-static void sensor_cb_light(sensor_data_accuracy_e accuracy, int level, void* ud)
+static void sensor_cb_light(sensor_data_accuracy_e accuracy, float lux, void* ud)
 {
     JSContextRef ctx = JSSensorManager::gCtx;
     struct SensorConnection* scon = (struct SensorConnection*) ud;
 
-    if(scon->threshold >= 0 && level != scon->threshold){
+    if(scon->threshold >= 0 && lux != scon->threshold){
         return;
     }
 
-    JSSensorDataEvent* data = new JSSensorDataEvent(JSSENSOR_REASON_WATCH, scon->type);
-    data->set(accuracy, g_get_monotonic_time(), level);
-    processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj(ctx));
+    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, JSSENSOR_REASON_WATCH, scon->type);
+    data->set(accuracy, g_get_monotonic_time(), lux);
+    processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj());
 }
-static void sensor_cb_proximity(bool is_near, void* ud)
+static void sensor_cb_proximity(sensor_data_accuracy_e accuracy, float distance, void *ud)
 {
     JSContextRef ctx = JSSensorManager::gCtx;
     struct SensorConnection* scon = (struct SensorConnection*) ud;
 
-    if(scon->threshold >= 0 && is_near != scon->threshold){
+    if(scon->threshold >= 0 && distance != scon->threshold){
         return;
     }
 
-    JSSensorDataEvent* data = new JSSensorDataEvent(JSSENSOR_REASON_WATCH, scon->type);
-    data->set(SENSOR_DATA_ACCURACY_UNDEFINED, g_get_monotonic_time(), is_near);
-    processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj(ctx));
+    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, JSSENSOR_REASON_WATCH, scon->type);
+    data->set(accuracy, g_get_monotonic_time(), distance);
+    processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj());
 }
 static void sensor_cb_calibration(void* ud)
 {
@@ -581,9 +580,9 @@ JSValueRef JSSensorConnection::read(JSContextRef ctx, JSObjectRef object, JSObje
 
     bool started = false;
     float x, y, z;
-    int level;
+    float lux, cm;
     sensor_data_accuracy_e acc;
-    JSSensorDataEvent* data = new JSSensorDataEvent(JSSENSOR_REASON_READ, scon->type);
+    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, JSSENSOR_REASON_READ, scon->type);
     if(scon->status != SENSOR_CON_WATCHING){
         sensor_start(scon->handle, scon->type);
         started = true;
@@ -607,11 +606,11 @@ JSValueRef JSSensorConnection::read(JSContextRef ctx, JSObjectRef object, JSObje
             data->set(acc, g_get_monotonic_time(), x, y, z);
             break;
         case SENSOR_LIGHT:
-            sensor_light_read_data(scon->handle, &acc, &level);
-            data->set(acc, g_get_monotonic_time(), level);
+            sensor_light_read_data(scon->handle, &acc, &lux);
+            data->set(acc, g_get_monotonic_time(), lux);
             break;
         case SENSOR_PROXIMITY:
-            return JSDOMExceptionFactory::NotSupportedException.make(ctx, exception);
+            sensor_proximity_read_data(scon->handle, &acc, &cm);
             break;
 
         default:
@@ -621,7 +620,7 @@ JSValueRef JSSensorConnection::read(JSContextRef ctx, JSObjectRef object, JSObje
         sensor_stop(scon->handle, scon->type);
         started = false;
     }
-    processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj(ctx));
+    processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj());
 
     return JSValueMakeUndefined(ctx);
 }
@@ -705,7 +704,7 @@ static gboolean registerAndStart(gpointer user_data)
             }
             break;
         case SENSOR_PROXIMITY:
-            err = sensor_proximity_set_cb(scon->handle, sensor_cb_proximity, scon);
+            err = sensor_proximity_set_cb(scon->handle, (int)scon->interval, sensor_cb_proximity, scon);
             if(err <0) {
                 throwError(scon, "Watching fail", JSSensorError::WATCH_ERROR);
                 return false;
diff --git a/src/standards/Tizen/Sensors/JSSensorData.cpp b/src/standards/Tizen/Sensors/JSSensorData.cpp
deleted file mode 100755 (executable)
index 698dae6..0000000
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-#include <vector>
-#include <CommonsJavaScript/Converter.h>
-#include <CommonsJavaScript/Validator.h>
-#include <CommonsJavaScript/JSUtils.h>
-#include <CommonsJavaScript/JSDOMExceptionFactory.h>
-#include "JSSensorData.h"
-
-#include <dlog.h>
-
-#undef LOG_TAG
-#define LOG_TAG "TIZEN_SENSOR"
-
-using namespace std;
-using namespace DPL;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-JSClassRef JSSensorData::m_jsClassRef = NULL;
-
-JSClassDefinition JSSensorData::m_jsClassInfo = {
-               0,
-               kJSClassAttributeNone,
-               "Sensor",
-               NULL,
-               NULL,
-        NULL,
-               initialize,
-               finalize,
-               hasProperty, //hasProperty
-        getProperty, //getProperty
-        setProperty, //setProperty
-               NULL, //deleteProperty
-               getPropertyNames, //getPropertyNames
-               NULL,
-               NULL, // constructor
-               hasInstance,
-               NULL
-};
-
-const JSClassRef JSSensorData::getClassRef() 
-{
-       if (!m_jsClassRef) {
-               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
-       }
-       return m_jsClassRef;
-}
-
-const JSClassDefinition* JSSensorData::getClassInfo() 
-{
-       return &m_jsClassInfo;
-}
-
-void JSSensorData::initialize(JSContextRef ctx, JSObjectRef object) 
-{
-}
-
-void JSSensorData::finalize(JSObjectRef object) 
-{
-}
-
-bool JSSensorData::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) 
-{
-       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
-}
-
-bool JSSensorData::hasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName)
-{
-    JSSensorData* data = (JSSensorData*)JSObjectGetPrivate(object);
-    if(data == NULL){
-        return false;
-    }
-    switch(data->mType){
-        case SENSOR_ACCELEROMETER:
-        case SENSOR_MAGNETIC:
-        case SENSOR_GYROSCOPE:
-            if(JSStringIsEqualToUTF8CString(propertyName, "x")){
-                return true;
-            }
-            else if(JSStringIsEqualToUTF8CString(propertyName, "y")){
-                return true;
-            }
-            else if(JSStringIsEqualToUTF8CString(propertyName, "z")){
-                return true;
-            }
-            break;
-        case SENSOR_ORIENTATION:
-            if(JSStringIsEqualToUTF8CString(propertyName, "alpha")){
-                return true;
-            }
-            else if(JSStringIsEqualToUTF8CString(propertyName, "beta")){
-                return true;
-            }
-            else if(JSStringIsEqualToUTF8CString(propertyName, "gamma")){
-                return true;
-            }
-            break;
-        case SENSOR_LIGHT:
-            if(JSStringIsEqualToUTF8CString(propertyName, "level")){
-                return true;
-            }
-            break;
-        case SENSOR_PROXIMITY:
-            if(JSStringIsEqualToUTF8CString(propertyName, "near")){
-                return true;
-            }
-            break;
-        default:
-            return false;
-    }
-
-    return false;
-}
-
-JSValueRef JSSensorData::getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
-{
-    JSSensorData* data = (JSSensorData*)JSObjectGetPrivate(object);
-    if(data == NULL){
-        *exception = JSDOMExceptionFactory::InvalidValuesException.make(ctx);
-        return NULL;
-    }
-
-    switch(data->mType){
-        case SENSOR_ACCELEROMETER:
-        case SENSOR_MAGNETIC:
-        case SENSOR_GYROSCOPE:
-            if(JSStringIsEqualToUTF8CString(propertyName, "x")){
-                return JSValueMakeNumber(ctx, data->mData.xyz[0]);
-            }
-            else if(JSStringIsEqualToUTF8CString(propertyName, "y")){
-                return JSValueMakeNumber(ctx, data->mData.xyz[1]);
-            }
-            else if(JSStringIsEqualToUTF8CString(propertyName, "z")){
-                return JSValueMakeNumber(ctx, data->mData.xyz[2]);
-            }
-            break;
-        case SENSOR_ORIENTATION:
-            if(JSStringIsEqualToUTF8CString(propertyName, "alpha")){
-                return JSValueMakeNumber(ctx, data->mData.xyz[0]);
-            }
-            else if(JSStringIsEqualToUTF8CString(propertyName, "beta")){
-                return JSValueMakeNumber(ctx, data->mData.xyz[1]);
-            }
-            else if(JSStringIsEqualToUTF8CString(propertyName, "gamma")){
-                return JSValueMakeNumber(ctx, data->mData.xyz[2]);
-            }
-            break;
-        case SENSOR_LIGHT:
-            if(JSStringIsEqualToUTF8CString(propertyName, "level")){
-                return JSValueMakeNumber(ctx, data->mData.level);
-            }
-            break;
-        case SENSOR_PROXIMITY:
-            if(JSStringIsEqualToUTF8CString(propertyName, "near")){
-                return JSValueMakeBoolean(ctx, data->mData.near);
-            }
-            break;
-        default:
-            return NULL;
-    }
-
-    return NULL;
-}
-
-bool JSSensorData::setProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
-{
-    JSSensorData* data = (JSSensorData*)JSObjectGetPrivate(object);
-    if(data == NULL){
-        *exception = JSDOMExceptionFactory::InvalidValuesException.make(ctx);
-        return NULL;
-    }
-    switch(data->mType){
-        case SENSOR_ACCELEROMETER:
-        case SENSOR_MAGNETIC:
-        case SENSOR_GYROSCOPE:
-            if(JSStringIsEqualToUTF8CString(propertyName, "x")){
-                return true;
-            }
-            else if(JSStringIsEqualToUTF8CString(propertyName, "y")){
-                return true;
-            }
-            else if(JSStringIsEqualToUTF8CString(propertyName, "z")){
-                return true;
-            }
-            break;
-        case SENSOR_ORIENTATION:
-            if(JSStringIsEqualToUTF8CString(propertyName, "alpha")){
-                return true;
-            }
-            else if(JSStringIsEqualToUTF8CString(propertyName, "beta")){
-                return true;
-            }
-            else if(JSStringIsEqualToUTF8CString(propertyName, "gamma")){
-                return true;
-            }
-            break;
-        case SENSOR_LIGHT:
-            if(JSStringIsEqualToUTF8CString(propertyName, "level")){
-                return true;
-            }
-            break;
-        case SENSOR_PROXIMITY:
-            if(JSStringIsEqualToUTF8CString(propertyName, "near")){
-                return true;
-            }
-            break;
-        default:
-            return false;
-    }
-    return false;
-}
-void JSSensorData::getPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames)
-{
-    JSStringRef pname_x = NULL;
-    JSStringRef pname_y = NULL;
-    JSStringRef pname_z = NULL;
-    JSStringRef pname_alpha = NULL;
-    JSStringRef pname_beta = NULL;
-    JSStringRef pname_gamma = NULL;
-    JSStringRef pname_level = NULL;
-    JSStringRef pname_near = NULL;
-    JSSensorData* data = (JSSensorData*)JSObjectGetPrivate(object);
-    switch(data->mType){
-        case SENSOR_ACCELEROMETER:
-        case SENSOR_MAGNETIC:
-        case SENSOR_GYROSCOPE:
-            pname_x = JSStringCreateWithUTF8CString("x");
-            pname_y = JSStringCreateWithUTF8CString("y");
-            pname_z = JSStringCreateWithUTF8CString("z");
-            JSPropertyNameAccumulatorAddName(propertyNames, pname_x);
-            JSPropertyNameAccumulatorAddName(propertyNames, pname_y);
-            JSPropertyNameAccumulatorAddName(propertyNames, pname_z);
-            JSStringRelease(pname_x);
-            JSStringRelease(pname_y);
-            JSStringRelease(pname_z);
-            break;
-        case SENSOR_ORIENTATION:
-            pname_alpha = JSStringCreateWithUTF8CString("alpha");
-            pname_beta = JSStringCreateWithUTF8CString("beta");
-            pname_gamma = JSStringCreateWithUTF8CString("gamma");
-            JSPropertyNameAccumulatorAddName(propertyNames, pname_alpha);
-            JSPropertyNameAccumulatorAddName(propertyNames, pname_beta);
-            JSPropertyNameAccumulatorAddName(propertyNames, pname_gamma);
-            JSStringRelease(pname_alpha);
-            JSStringRelease(pname_beta);
-            JSStringRelease(pname_gamma);
-            break;
-        case SENSOR_LIGHT:
-            pname_level = JSStringCreateWithUTF8CString("level");
-            JSPropertyNameAccumulatorAddName(propertyNames, pname_level);
-            JSStringRelease(pname_level);
-            break;
-        case SENSOR_PROXIMITY:
-            pname_near = JSStringCreateWithUTF8CString("near");
-            JSPropertyNameAccumulatorAddName(propertyNames, pname_near);
-            JSStringRelease(pname_near);
-            break;
-        default:
-            return;
-    }
-}
-
-} // Tizen1_0
-} // TizenApis
diff --git a/src/standards/Tizen/Sensors/JSSensorData.h b/src/standards/Tizen/Sensors/JSSensorData.h
deleted file mode 100755 (executable)
index 79b29d3..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-/**
-* @file                 JSSensorData.h
-* @author       Pius Lee (pius.lee@samsung.com)
-* @version      0.1
-*/
-
-#ifndef _WRTPLUGINS_TIZEN_JS_SENSORDATA_
-#define _WRTPLUGINS_TIZEN_JS_SENSORDATA_
-
-#include <JavaScriptCore/JavaScript.h>
-#include <sensors.h>
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-union SensorData {
-    float xyz[3];
-    int level;
-    bool near;
-};
-
-class JSSensorData {
-public:
-    static const JSClassDefinition* getClassInfo();
-    static const JSClassRef getClassRef();
-
-    JSSensorData(sensor_type_e type): mType(type){}
-    void set(float x, float y, float z)
-    {
-        mData.xyz[0] = x;
-        mData.xyz[1] = y;
-        mData.xyz[2] = z;
-    }
-    void set(int level){mData.level = level;}
-    void set(bool near){mData.near = near;}
-
-    JSObjectRef makeJSObj(JSContextRef ctx){
-        return JSObjectMake(ctx, getClassRef(), this);
-    }
-
-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 bool hasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
-    static JSValueRef getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
-    static bool setProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
-    static void getPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames); 
-
-private:
-    static JSClassDefinition m_jsClassInfo;
-    static JSClassRef m_jsClassRef;
-
-    sensor_type_e mType;
-    SensorData mData;
-};
-
-} // Tizen1_0
-} // TizenApis
-
-#endif
index f61ed73..c8efc3b 100644 (file)
@@ -22,7 +22,6 @@
 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
-#include "JSSensorData.h"
 #include "JSSensorDataEvent.h"
 
 #include <dlog.h>
@@ -71,46 +70,90 @@ static int accuracy_map(sensor_data_accuracy_e accuracy) {
     return JSSENSOR_DATA_ACCURACY_UNDEFINED;
 }
 
-JSSensorDataEvent::JSSensorDataEvent (int reason, sensor_type_e type)
-    : mType(type), mAccuracy(0), mTimestamp(0)
+JSSensorDataEvent::JSSensorDataEvent (JSContextRef ctx, int reason, sensor_type_e type)
+    : mType(type), mAccuracy(0), mTimestamp(0), mCtx(ctx)
 {
     setReason(reason);
-    mSensordata = new JSSensorData(type);
-    mExSensordata = NULL;
+
+    mData = NULL;
 }
 JSSensorDataEvent::~JSSensorDataEvent()
 {
-    if(mSensordata != NULL)
-        delete mSensordata;
 }
-                                                                                              
-void JSSensorDataEvent::set (sensor_data_accuracy_e accuracy, double timestamp)
+
+void JSSensorDataEvent::set (sensor_data_accuracy_e accuracy, double timestamp, float x, float y, float z)
 {
-    if(mType == SENSOR_LIGHT || mType == SENSOR_PROXIMITY){
-        mAccuracy = JSSENSOR_DATA_ACCURACY_HIGH;
+    JSStringRef pname_x;
+    JSStringRef pname_y;
+    JSStringRef pname_z;
+    JSValueRef pvalue_x;
+    JSValueRef pvalue_y;
+    JSValueRef pvalue_z;
+    JSObjectRef obj;
+
+    mTimestamp = timestamp;
+    mAccuracy = accuracy_map(accuracy);
+
+    if(mData != NULL){
+        JSValueUnprotect(mCtx, mData);
+        mData = NULL;
     }
-    else{
-        mAccuracy = accuracy_map(accuracy);
+    switch(mType)
+    {
+        case SENSOR_ACCELEROMETER:
+        case SENSOR_GYROSCOPE:
+        case SENSOR_MAGNETIC:
+            pname_x = JSStringCreateWithUTF8CString("x");
+            pname_y = JSStringCreateWithUTF8CString("y");
+            pname_z = JSStringCreateWithUTF8CString("z");
+            pvalue_x = JSValueMakeNumber(mCtx, x);
+            pvalue_y = JSValueMakeNumber(mCtx, y);
+            pvalue_z = JSValueMakeNumber(mCtx, z);
+            obj = JSObjectMake(mCtx, NULL, NULL);
+            JSObjectSetProperty(mCtx, obj, pname_x, pvalue_x, kJSPropertyAttributeNone, NULL); 
+            JSObjectSetProperty(mCtx, obj, pname_y, pvalue_y, kJSPropertyAttributeNone, NULL); 
+            JSObjectSetProperty(mCtx, obj, pname_z, pvalue_z, kJSPropertyAttributeNone, NULL); 
+            JSStringRelease(pname_x);
+            JSStringRelease(pname_y);
+            JSStringRelease(pname_z);
+            mData = obj;
+            break;
+        case SENSOR_ORIENTATION:
+            pname_x = JSStringCreateWithUTF8CString("alpha");
+            pname_y  = JSStringCreateWithUTF8CString("beta");
+            pname_z = JSStringCreateWithUTF8CString("gamma");
+            pvalue_x = JSValueMakeNumber(mCtx, x);
+            pvalue_y  = JSValueMakeNumber(mCtx, y);
+            pvalue_z = JSValueMakeNumber(mCtx, z);
+            obj = JSObjectMake(mCtx, NULL, NULL);
+            JSObjectSetProperty(mCtx, obj, pname_x, pvalue_x, kJSPropertyAttributeNone, NULL); 
+            JSObjectSetProperty(mCtx, obj, pname_y, pvalue_y, kJSPropertyAttributeNone, NULL); 
+            JSObjectSetProperty(mCtx, obj, pname_z, pvalue_z, kJSPropertyAttributeNone, NULL); 
+            JSStringRelease(pname_x);
+            JSStringRelease(pname_y);
+            JSStringRelease(pname_z);
+            mData = obj;
+            break;
+        case SENSOR_LIGHT:
+        case SENSOR_PROXIMITY:
+            mData = JSValueMakeNumber(mCtx, x);
+            break;
+    }
+    if(mData != NULL){
+        JSValueProtect(mCtx, mData);
     }
-    mTimestamp = timestamp;
-}
-void JSSensorDataEvent::set (sensor_data_accuracy_e accuracy, double timestamp, float x, float y, float z)
-{
-    set(accuracy, timestamp);
-    assert(mSensordata != NULL);
-    mSensordata->set(x, y, z);
-}
-void JSSensorDataEvent::set (sensor_data_accuracy_e accuracy, double timestamp, int level)
-{
-    set(accuracy, timestamp);
-    assert(mSensordata != NULL);
-    mSensordata->set(level);
 }
-void JSSensorDataEvent::set (sensor_data_accuracy_e accuracy, double timestamp, bool near)
+void JSSensorDataEvent::set (sensor_data_accuracy_e accuracy, double timestamp, float v)
 {
-    set(accuracy, timestamp);
-    assert(mSensordata != NULL);
-    mSensordata->set(near);
+    mTimestamp = timestamp;
+    mAccuracy = accuracy_map(accuracy);
+
+    if(mData != NULL){
+        JSValueUnprotect(mCtx, mData);
+        mData = NULL;
+    }
+    mData = JSValueMakeNumber(mCtx, v);
+    JSValueProtect(mCtx, mData);
 }
 
 void JSSensorDataEvent::setReason(int reason)
@@ -123,9 +166,9 @@ void JSSensorDataEvent::setReason(int reason)
     }
 }
 
-JSObjectRef JSSensorDataEvent::makeJSObj(JSContextRef ctx)
+JSObjectRef JSSensorDataEvent::makeJSObj()
 {
-    return JSObjectMake(ctx, getClassRef(), this);
+    return JSObjectMake(mCtx, getClassRef(), this);
 }
 
 JSClassRef JSSensorDataEvent::m_jsClassRef = NULL;
@@ -209,15 +252,11 @@ JSValueRef JSSensorDataEvent::getProperty(JSContextRef ctx, JSObjectRef object,
     JSSensorDataEvent* eventData = (JSSensorDataEvent*) JSObjectGetPrivate(object);
 
     assert(eventData != NULL);
-    assert(eventData->mSensordata != NULL);
 
     Converter convert(ctx);
 
     if(JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NAMES[PROPERTY_DATA])) {
-        if(eventData->mExSensordata != NULL)
-            return eventData->mExSensordata;
-        else
-            return eventData->mSensordata->makeJSObj(ctx);
+        return eventData->mData;
     }
     else if(JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NAMES[PROPERTY_ACCURACY])) {
         if(eventData->mAccuracy != JSSENSOR_DATA_ACCURACY_UNDEFINED)
@@ -279,7 +318,6 @@ JSValueRef JSSensorDataEvent::initSensorDataEvent(JSContextRef ctx, JSObjectRef
     if(eventData == NULL){
         return JSDOMExceptionFactory::InvalidValuesException.make(ctx, exception);
     }
-    assert(eventData->mSensordata != NULL);
 
     if(argumentCount < 7){
         // It will must be replace other error except DOMException
@@ -329,7 +367,7 @@ JSValueRef JSSensorDataEvent::initSensorDataEvent(JSContextRef ctx, JSObjectRef
     }
     eventData->mAccuracy = a;
 
-    eventData->mExSensordata = jsv_data;
+    eventData->mData = jsv_data;
 
     return JSValueMakeUndefined(ctx);
 }
index 775b314..39a82a3 100644 (file)
@@ -26,7 +26,6 @@
 
 #include <JavaScriptCore/JavaScript.h>
 #include <sensors.h>
-#include "JSSensorData.h"
 
 namespace TizenApis {
 namespace Tizen1_0 {
@@ -52,19 +51,15 @@ public:
     static const JSClassDefinition* getClassInfo();
     static const JSClassRef getClassRef();
 
-    JSSensorDataEvent ();
-    JSSensorDataEvent (int reason, sensor_type_e type);
+    JSSensorDataEvent (JSContextRef ctx, int reason, sensor_type_e type);
     ~JSSensorDataEvent();
                                                                                                   
     void set (sensor_data_accuracy_e accuracy, double timestamp, float x, float y, float z);
-    void set (sensor_data_accuracy_e accuracy, double timestamp, int level);
-    void set (sensor_data_accuracy_e accuracy, double timestamp, bool near);
-
-    void set (sensor_data_accuracy_e accuracy, double timestamp);
+    void set (sensor_data_accuracy_e accuracy, double timestamp, float v);
 
     void setReason(int reason);
 
-    JSObjectRef makeJSObj(JSContextRef ctx);
+    JSObjectRef makeJSObj();
 
 protected:
 
@@ -86,8 +81,8 @@ private:
     static JSStaticFunction m_function[];
     static JSObjectRef m_DOMEvent;
 
-    JSSensorData* mSensordata;
-    JSValueRef mExSensordata;
+    JSContextRef mCtx;
+    JSValueRef mData;
     sensor_type_e mType;
     int mAccuracy;
     double mTimestamp;
old mode 100755 (executable)
new mode 100644 (file)
index 08af0d9..2a5c6e0 100644 (file)
@@ -21,7 +21,7 @@
 * @version      0.1
 */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
 #include <Commons/WrtWrapper/WrtWrappersMgr.h>
 #include <Commons/Exception.h>
index 992e885..9ba7642 100755 (executable)
@@ -17,7 +17,7 @@
  */
 
 #include <memory>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "JSCellularNetworkInfo.h"
 
 namespace TizenApis {
index 9a9a92f..39b2cba 100755 (executable)
@@ -17,7 +17,7 @@
  */
 
 #include <memory>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "JSCpuInfo.h"
 
 namespace TizenApis {
index 508ad5c..5ec41e8 100755 (executable)
@@ -17,7 +17,7 @@
  */
 
 #include <memory>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "JSDeviceInfo.h"
 
 namespace TizenApis {
index 4b73136..ef9a941 100755 (executable)
@@ -17,7 +17,7 @@
  */
 
 #include <memory>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "JSDisplayInfo.h"
 
 namespace TizenApis {
index 419db88..a16e5fb 100755 (executable)
@@ -17,7 +17,7 @@
  */
 
 #include <memory>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "JSPowerInfo.h"
 
 namespace TizenApis {
index 5d51f80..1fea222 100755 (executable)
@@ -17,7 +17,7 @@
  */
 
 #include <memory>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "JSStorageInfo.h"
 
 namespace TizenApis {
old mode 100755 (executable)
new mode 100644 (file)
index b5a6ddb..5411d8e
@@ -42,7 +42,7 @@ using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace WrtDeviceApis::Commons;
 using namespace Api::Systeminfo;
 using namespace TizenApis::Commons;
-    
+
 JSClassDefinition JSSysteminfo::m_classInfo = {
     0,
     kJSClassAttributeNone,
@@ -66,8 +66,8 @@ JSClassDefinition JSSysteminfo::m_classInfo = {
 JSStaticFunction JSSysteminfo::m_function[] = {
     { "isSupported", JSSysteminfo::isSupported, kJSPropertyAttributeNone },    
     { "getPropertyValue", JSSysteminfo::getPropertyValue, kJSPropertyAttributeNone },
-    { "addPropertyValueChangedListener", JSSysteminfo::addPropertyValueChangedListener, kJSPropertyAttributeNone },
-    { "removePropertyChangedListener", JSSysteminfo::removePropertyChangedListener, kJSPropertyAttributeNone },
+    { "addPropertyValueChangeListener", JSSysteminfo::addPropertyValueChangeListener, kJSPropertyAttributeNone },
+    { "removePropertyValueChangeListener", JSSysteminfo::removePropertyValueChangeListener, kJSPropertyAttributeNone },
     { 0, 0, 0 }
 };
 
@@ -192,7 +192,6 @@ JSValueRef JSSysteminfo::getPropertyValue(JSContextRef context, JSObjectRef obje
     
     JSCallbackManagerPtr cbm(JSCallbackManager::createObject(priv->getContext(), onSuccessForCbm, onErrorForCbm, true, true));
 
-    cbm->setObject(thisObject);
 
     Try {
         if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])
@@ -236,7 +235,7 @@ JSValueRef JSSysteminfo::getPropertyValue(JSContextRef context, JSObjectRef obje
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSSysteminfo::addPropertyValueChangedListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+JSValueRef JSSysteminfo::addPropertyValueChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
         size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     LogDebug("enter");
@@ -245,7 +244,7 @@ JSValueRef JSSysteminfo::addPropertyValueChangedListener(JSContextRef context, J
     int failId = -1;    
     JSSysteminfoPriv *priv = static_cast<JSSysteminfoPriv*>(JSObjectGetPrivate(thisObject));
 
-       AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(priv->getContext(),SYSTEMINFO_FUNCTION_API_ADD_PROPERTY_VALUE_CHANGED_LISTENER);
+       AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(priv->getContext(),SYSTEMINFO_FUNCTION_API_ADD_PROPERTY_VALUE_CHANGE_LISTENER);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Converter converter(context);
@@ -283,7 +282,6 @@ JSValueRef JSSysteminfo::addPropertyValueChangedListener(JSContextRef context, J
         }
     }
     JSCallbackManagerPtr cbm(JSCallbackManager::createObject(priv->getContext(), onSuccessForCbm, onErrorForCbm, true, true));
-    cbm->setObject(thisObject);
 
     Try {
         if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])
@@ -299,22 +297,18 @@ JSValueRef JSSysteminfo::addPropertyValueChangedListener(JSContextRef context, J
         }
         ISysteminfoPtr Systeminfos(priv->getObject());
 
-        if(Systeminfos->isDuplicateWatch((const char *)converter.toString(property).c_str())) {
-            cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"invalid parameter"));
-            return converter.toJSValueRef(failId);
-        } else {
-            EventWatchSysteminfoPtr event(new EventWatchSysteminfo);
-            event->setWatchOption(option);
-            event->setBasePropertyPtr(Systeminfos->getBasePropertyPtr(priv->getContext(), property));
-            event->setPrivateData(StaticPointerCast<IEventPrivateData>(cbm));
-
-            SysteminfoListener& listener = SysteminfoListener::getInstance();
-            event->setForAsynchronousCall(&listener);        
+        EventWatchSysteminfoPtr event(new EventWatchSysteminfo);
+        event->setWatchOption(option);
+        event->setBasePropertyPtr(Systeminfos->getBasePropertyPtr(priv->getContext(), property));
+        event->setPrivateData(StaticPointerCast<IEventPrivateData>(cbm));
+
+        SysteminfoListener& listener = SysteminfoListener::getInstance();
+        event->setForAsynchronousCall(&listener);        
             
-            Systeminfos->watch(event);
-            return converter.toJSValueRef(event->getId());
+        Systeminfos->watch(event);
+        LogDebug("event->getId()" << event->getId());
+        return converter.toJSValueRef(event->getId());
         }
-    }
     
     Catch(PendingOperationException) {
         LogError("JSSysteminfo::get PendingOperationException");
@@ -335,13 +329,13 @@ JSValueRef JSSysteminfo::addPropertyValueChangedListener(JSContextRef context, J
     return JSValueMakeUndefined(context);    
 }
 
-JSValueRef JSSysteminfo::removePropertyChangedListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+JSValueRef JSSysteminfo::removePropertyValueChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
         size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     int id = 0;
     JSSysteminfoPriv *priv = static_cast<JSSysteminfoPriv*>(JSObjectGetPrivate(thisObject));    
 
-       AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(priv->getContext(),SYSTEMINFO_FUNCTION_API_REMOVE_PROPERTY_CHANGED_LISTENER);
+       AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(priv->getContext(),SYSTEMINFO_FUNCTION_API_REMOVE_PROPERTY_VALUE_CHANGE_LISTENER);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
     
     Converter converter(context);
index 8c67433..2c5c52e 100755 (executable)
@@ -44,10 +44,10 @@ class JSSysteminfo
     static JSValueRef getPropertyValue(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
                size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
 
-    static JSValueRef addPropertyValueChangedListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+    static JSValueRef addPropertyValueChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
             size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
 
-    static JSValueRef removePropertyChangedListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+    static JSValueRef removePropertyValueChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
                size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
 
     static JSClassDefinition m_classInfo;
index bab4245..8d7319e 100755 (executable)
@@ -17,7 +17,7 @@
  */
 
 #include <memory>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include "JSWifiNetworkInfo.h"
 
 namespace TizenApis {
index da440d3..ca2e574 100755 (executable)
@@ -13,8 +13,8 @@
         <Object name="systeminfo">
             <Function name="isSupported"/>
             <Function name="getPropertyValue"/>
-            <Function name="addPropertyValueChangedListener"/>
-            <Function name="removePropertyChangedListener"/>
+            <Function name="addPropertyValueChangeListener"/>
+            <Function name="removePropertyValueChangeListener"/>
         </Object>
     </api-feature>
 </plugin-properties>
index c244ecc..46b9606 100755 (executable)
@@ -30,8 +30,8 @@ namespace Tizen1_0 {
 
 const char* SYSTEMINFO_FUNCTION_API_IS_SUPPORTED = "isSupported";
 const char* SYSTEMINFO_FUNCTION_API_GET_PROPERTY_VALUE = "getPropertyValue";
-const char* SYSTEMINFO_FUNCTION_API_ADD_PROPERTY_VALUE_CHANGED_LISTENER = "addPropertyValueChangedListener";
-const char* SYSTEMINFO_FUNCTION_API_REMOVE_PROPERTY_CHANGED_LISTENER = "removePropertyChangedListener";
+const char* SYSTEMINFO_FUNCTION_API_ADD_PROPERTY_VALUE_CHANGE_LISTENER = "addPropertyValueChangeListener";
+const char* SYSTEMINFO_FUNCTION_API_REMOVE_PROPERTY_VALUE_CHANGE_LISTENER = "removePropertyValueChangeListener";
 
 static WrtDeviceApis::Commons::FunctionMapping createSysteminfoFunctions();
 
@@ -81,23 +81,23 @@ static WrtDeviceApis::Commons::FunctionMapping createSysteminfoFunctions()
 
     AceFunction addPropertyValueChangedListenerFunc = ACE_CREATE_FUNCTION(
         FUNCTION_ADD_PROPERTY_VALUE_CHANGED_LISTENER,
-        SYSTEMINFO_FUNCTION_API_ADD_PROPERTY_VALUE_CHANGED_LISTENER,
+        SYSTEMINFO_FUNCTION_API_ADD_PROPERTY_VALUE_CHANGE_LISTENER,
         SYSTEMINFO_FEATURES,
         DEVICE_LIST_SYSTEMINFO);
 
     SysteminfoFunctions.insert(std::make_pair(
-        SYSTEMINFO_FUNCTION_API_ADD_PROPERTY_VALUE_CHANGED_LISTENER,
+        SYSTEMINFO_FUNCTION_API_ADD_PROPERTY_VALUE_CHANGE_LISTENER,
         addPropertyValueChangedListenerFunc));
 
 
     AceFunction removePropertyChangedListenerFunc = ACE_CREATE_FUNCTION(
         FUNCTION_REMOVE_PROPERTY_CHANGED_LISTENER,
-        SYSTEMINFO_FUNCTION_API_REMOVE_PROPERTY_CHANGED_LISTENER,
+        SYSTEMINFO_FUNCTION_API_REMOVE_PROPERTY_VALUE_CHANGE_LISTENER,
         SYSTEMINFO_FEATURES,
         DEVICE_LIST_SYSTEMINFO);
 
     SysteminfoFunctions.insert(std::make_pair(
-        SYSTEMINFO_FUNCTION_API_REMOVE_PROPERTY_CHANGED_LISTENER,
+        SYSTEMINFO_FUNCTION_API_REMOVE_PROPERTY_VALUE_CHANGE_LISTENER,
         removePropertyChangedListenerFunc));
 
     return SysteminfoFunctions;
index 21fc071..20260f5 100755 (executable)
@@ -24,8 +24,8 @@ namespace Tizen1_0 {
 
 extern const char* SYSTEMINFO_FUNCTION_API_IS_SUPPORTED;
 extern const char* SYSTEMINFO_FUNCTION_API_GET_PROPERTY_VALUE;
-extern const char* SYSTEMINFO_FUNCTION_API_ADD_PROPERTY_VALUE_CHANGED_LISTENER;
-extern const char* SYSTEMINFO_FUNCTION_API_REMOVE_PROPERTY_CHANGED_LISTENER;
+extern const char* SYSTEMINFO_FUNCTION_API_ADD_PROPERTY_VALUE_CHANGE_LISTENER;
+extern const char* SYSTEMINFO_FUNCTION_API_REMOVE_PROPERTY_VALUE_CHANGE_LISTENER;
 
 DECLARE_FUNCTION_GETTER(Systeminfo);
 
index 6a6d34f..c036d88 100755 (executable)
@@ -16,7 +16,7 @@
  *  
  */
  
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
 #include "JSSysteminfo.h"
 
index 1c72204..5ec6fce 100755 (executable)
@@ -7,6 +7,7 @@ set(SRCS
   ${SRCS_PLATFORM_IMPLEMENTATION_TIMEUTIL}
   JSTimeUtil.cpp
        JSTZDate.cpp
+       JSTimeDuration.cpp
        TimeUtilConverter.cpp  
        plugin_initializer.cpp
        plugin_config.cpp
index 052c1b0..815d801 100755 (executable)
@@ -19,7 +19,7 @@
 
 #include <ctime>
 #include <string>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/JSUtils.h>
@@ -141,6 +141,20 @@ JSObjectRef JSTZDate::createJSObject(JSContextRef context) {
        return JSObjectMake(context, getClassRef(), priv);
 }
 
+JSObjectRef JSTZDate::createJSObject(JSContextRef context, const std::string &timezone) {
+       LogDebug("entered");
+       if (timezone == "")
+               return createJSObject(context);
+
+       ITZDatePtr TZDate = TimeUtilFactory::getInstance().createTZDateObject(timezone);
+       TZDatePrivObject *priv = new TZDatePrivObject(context, TZDate);
+       if (!priv) {
+               ThrowMsg(NullPointerException, "Can not new an object");
+       }
+
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
 JSObjectRef JSTZDate::createJSObject(JSContextRef context, const TZDateProperties &properties) {
        LogDebug("entered");
        ITZDatePtr TZDate = TimeUtilFactory::getInstance().createTZDateObject(properties);
@@ -153,7 +167,7 @@ JSObjectRef JSTZDate::createJSObject(JSContextRef context, const TZDatePropertie
        return JSObjectMake(context, getClassRef(), priv);
 }
 
-JSObjectRef JSTZDate::createJSObject(JSContextRef context, const long year, const long month,  const long day, const long hours, const long minutes, const long seconds, const std::string &timezone) {
+JSObjectRef JSTZDate::createJSObject(JSContextRef context, const long year, const long month,  const long day, const long hours, const long minutes, const long seconds, const long milliseconds, const std::string &timezone) {
        LogDebug("entered");
 
        TZDateProperties props;
@@ -163,6 +177,7 @@ JSObjectRef JSTZDate::createJSObject(JSContextRef context, const long year, cons
        props.hours = hours;
        props.minutes = minutes;
        props.seconds = seconds;
+       props.milliseconds = milliseconds;
        props.timezone = timezone;
 
        return createJSObject(context, props);
@@ -172,9 +187,15 @@ JSObjectRef JSTZDate::createJSObject(JSContextRef context, const long year, cons
 JSObjectRef JSTZDate::createJSObject(JSContextRef context, const time_t localTime, const std::string &timezone) {
        LogDebug("entered");
 
+       return createJSObject(context, localTime, 0, timezone);
+}
+
+JSObjectRef JSTZDate::createJSObject(JSContextRef context, const time_t localTime, const long msec, const std::string &timezone) {
+       LogDebug("entered");
+
        struct tm *tm = localtime(&localTime);
 
-       return createJSObject(context, tm->tm_year + 1900, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, timezone);
+       return createJSObject(context, tm->tm_year + 1900, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, msec, timezone);
 }
 
 void JSTZDate::initialize(JSContextRef context, JSObjectRef object)
@@ -208,18 +229,38 @@ JSObjectRef JSTZDate::constructor(JSContextRef ctx, JSObjectRef constructor, siz
        TZDatePrivObject* mainPriv = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(constructor));
        JSContextRef global_context = mainPriv ? mainPriv->getContext() : ctx;
        Try {
+               if (argumentCount > 8) {
+                       LogError("Wrong argument count");
+                       ThrowMsg(InvalidArgumentException, "Wrong TZDate argumentCount");
+               }
+
                if (argumentCount == 0) {
                        return createJSObject(global_context);
                } else if (argumentCount <= 2) {
-                       if (!JSValueIsNull(ctx, arguments[0]) && !JSValueIsUndefined(ctx, arguments[0])) {
-                               std::time_t date;
-                               date = converter.toDateTimeT(arguments[0]);
+                       if (!JSValueIsUndefined(ctx, arguments[0])) {
                                std::string timezone = "";
-                               if (argumentCount > 1) {
-                                       if ( JSValueIsNull(ctx, arguments[1]) || JSValueIsUndefined(ctx, arguments[1]) || !JSValueIsString(ctx, arguments[1]))
-                                               ThrowMsg(InvalidArgumentException, "Argument is invalid");
+                               if ((argumentCount == 2) && !JSValueIsNull(ctx, arguments[1])) {
+                                       if (JSValueIsUndefined(ctx, arguments[1]) || !JSValueIsString(ctx, arguments[1]))
+                                               ThrowMsg(ConversionException, "Argument is invalid");
                                        timezone = converter.toString(arguments[1]);
                                }
+
+                               if (JSValueIsNull(ctx, arguments[0]))
+                                       return createJSObject(global_context, timezone);
+                               
+                               std::time_t date;
+                               date = converter.toDateTimeT(arguments[0]);
+                               long msec = 0;
+                              JSStringRef getMillisecondsName = JSStringCreateWithUTF8CString("getMilliseconds");
+                               JSValueRef getMiliSecFuction = JSObjectGetProperty(ctx, converter.toJSObjectRef(arguments[0]), getMillisecondsName, exception);
+                               JSStringRelease(getMillisecondsName);
+                               if (getMiliSecFuction) {
+                                       JSObjectRef function = JSValueToObject(ctx, getMiliSecFuction, exception);
+                                       JSValueRef result = JSObjectCallAsFunction(ctx, function, converter.toJSObjectRef(arguments[0]), 0, NULL, exception);
+                                       msec = converter.toLong(result);
+                                       LogDebug("getMilliseconds = " << msec);
+                                       return createJSObject(global_context, date, msec, timezone);
+                               }
                                return createJSObject(global_context, date, timezone);
                        }
                } else {
@@ -227,31 +268,35 @@ JSObjectRef JSTZDate::constructor(JSContextRef ctx, JSObjectRef constructor, siz
                        prop.month = converter.FromJSValueReftolong(arguments[1]);
                        prop.day = converter.FromJSValueReftolong(arguments[2]);
                        if (argumentCount > 3) {
-                               if ((JSValueIsNull(ctx, arguments[3]) || JSValueIsUndefined(ctx, arguments[3]))
-                                       || !(JSValueIsNumber(ctx, arguments[3]))) {
-                                       ThrowMsg(InvalidArgumentException, "Argument is invalid");
+                               if (JSValueIsUndefined(ctx, arguments[3]) || !(JSValueIsNumber(ctx, arguments[3]))) {
+                                       ThrowMsg(ConversionException, "Argument is invalid");
                                }
-                               prop.hours = converter.FromJSValueReftolong(arguments[3]);
+                               if (!JSValueIsNull(ctx, arguments[3]))
+                                       prop.hours = converter.FromJSValueReftolong(arguments[3]);
                                if (argumentCount > 4) {
-                                       if (JSValueIsNull(ctx, arguments[4]) || JSValueIsUndefined(ctx, arguments[4]) || !JSValueIsNumber(ctx, arguments[4])) {
-                                               ThrowMsg(InvalidArgumentException, "Argument is invalid");
+                                       if (JSValueIsUndefined(ctx, arguments[4]) || !JSValueIsNumber(ctx, arguments[4])) {
+                                               ThrowMsg(ConversionException, "Argument is invalid");
                                        }
-                                       prop.minutes = converter.FromJSValueReftolong(arguments[4]);
+                                       if (!JSValueIsNull(ctx, arguments[4]))
+                                               prop.minutes = converter.FromJSValueReftolong(arguments[4]);
                                        if (argumentCount > 5) {
-                                               if (JSValueIsNull(ctx, arguments[5]) || JSValueIsUndefined(ctx, arguments[5]) || !JSValueIsNumber(ctx, arguments[5])) {
-                                                       ThrowMsg(InvalidArgumentException, "Argument is invalid");
+                                               if (JSValueIsUndefined(ctx, arguments[5]) || !JSValueIsNumber(ctx, arguments[5])) {
+                                                       ThrowMsg(ConversionException, "Argument is invalid");
                                                }
-                                               prop.seconds = converter.FromJSValueReftolong(arguments[5]);
+                                               if (!JSValueIsNull(ctx, arguments[5]))
+                                                       prop.seconds = converter.FromJSValueReftolong(arguments[5]);
                                                if (argumentCount > 6) {
-                                                       if (JSValueIsNull(ctx, arguments[6]) || JSValueIsUndefined(ctx, arguments[6]) || !JSValueIsNumber(ctx, arguments[6])) {
-                                                               ThrowMsg(InvalidArgumentException, "Argument is invalid");
+                                                       if (JSValueIsUndefined(ctx, arguments[6]) || !JSValueIsNumber(ctx, arguments[6])) {
+                                                               ThrowMsg(ConversionException, "Argument is invalid");
                                                        }
-                                                       prop.milliseconds= converter.FromJSValueReftolong(arguments[6]);
+                                                       if (!JSValueIsNull(ctx, arguments[6]))
+                                                               prop.milliseconds= converter.FromJSValueReftolong(arguments[6]);
                                                        if (argumentCount > 7) {
-                                                               if (JSValueIsNull(ctx, arguments[7]) || JSValueIsUndefined(ctx, arguments[7]) ||  !JSValueIsString(ctx, arguments[7])) {
-                                                                       ThrowMsg(InvalidArgumentException, "Argument is invalid");
+                                                               if (JSValueIsUndefined(ctx, arguments[7]) ||  !JSValueIsString(ctx, arguments[7])) {
+                                                                       ThrowMsg(ConversionException, "Argument is invalid");
                                                                }
-                                                               prop.timezone = converter.toString(arguments[7]);
+                                                               if (!JSValueIsNull(ctx, arguments[7]))
+                                                                       prop.timezone = converter.toString(arguments[7]);
                                                        }
                                                }
                                        }
@@ -262,16 +307,23 @@ JSObjectRef JSTZDate::constructor(JSContextRef ctx, JSObjectRef constructor, siz
                ThrowMsg(InvalidArgumentException, "Wrong TZDate argumentCount");
        } Catch(ConversionException) {
                LogDebug("Wrong conversion");
-               return converter.toJSObjectRef(JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch"));
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return NULL;
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return converter.toJSObjectRef(JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value"));
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               return NULL;
        } Catch (PlatformException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return NULL;
        } Catch (WrtDeviceApis::Commons::Exception) {
-           LogWarning("Trying to get incorrect value");
+               LogWarning("Trying to get incorrect value");
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return NULL;
        }
-       return converter.toJSObjectRef(JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error"));
+       *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       return NULL;
 }
 const JSClassRef JSTZDate::getClassRef()
 {
@@ -291,6 +343,11 @@ JSValueRef JSTZDate::getTimezone(JSContextRef context, JSObjectRef function,
        LogDebug("entered");
 
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -315,16 +372,13 @@ JSValueRef JSTZDate::getTimezone(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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 JSTZDate::toTimezone(JSContextRef context, JSObjectRef function,
@@ -334,10 +388,15 @@ JSValueRef JSTZDate::toTimezone(JSContextRef context, JSObjectRef function,
        TimeUtilConverter converter(context);
 
        Try {
-               if ((argumentCount < 1) ||(JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]))
-                       || (!JSValueIsString(context, arguments[0]))) {
+               if (argumentCount != 1) {
+                       LogError("Wrong TZDate parameters count");
+                       ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
+               }
+
+               if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])
+                       || !JSValueIsString(context, arguments[0])) {
                        LogError("Wrong TZDate parameters");
-                       ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters");
+                       ThrowMsg(ConversionException, "Wrong TZDate parameters");
                }
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
@@ -353,7 +412,7 @@ JSValueRef JSTZDate::toTimezone(JSContextRef context, JSObjectRef function,
 
                std::string timezone = converter.toString(arguments[0]);
                ITZDatePtr TZDate(privateObject->getObject());
-               return createJSObject(context, TZDate->toTimezone(timezone));
+               return createJSObject(privateObject->getContext(), TZDate->toTimezone(timezone));
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -362,7 +421,7 @@ JSValueRef JSTZDate::toTimezone(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -371,7 +430,7 @@ JSValueRef JSTZDate::toTimezone(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        }
 
-       return JSValueMakeUndefined(context);
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
 }
 
 JSValueRef JSTZDate::diffTZDate(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type) {
@@ -389,10 +448,15 @@ JSValueRef JSTZDate::diffTZDate(JSContextRef context, JSObjectRef thisObject, si
 
        TimeUtilConverter converter(context);
 
-       if ((argumentCount < 1) ||(JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]))
-               || (!JSValueIsObjectOfClass(context, arguments[0], getClassRef()))) {
+       if (argumentCount != 1) {
+               LogError("Wrong TZDate parameters count");
+               ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
+       }
+
+       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])
+               || !JSValueIsObjectOfClass(context, arguments[0], getClassRef())) {
                LogError("Wrong TZDate parameters");
-               ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters");
+               ThrowMsg(ConversionException, "Wrong TZDate parameters");
        }
 
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
@@ -435,7 +499,7 @@ JSValueRef JSTZDate::difference(JSContextRef context, JSObjectRef function,
                return diffTZDate(context, thisObject, argumentCount,  arguments, exception, DIFFERENCE);
        } Catch(InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -450,7 +514,7 @@ JSValueRef JSTZDate::difference(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        }
 
-       return JSValueMakeUndefined(context);
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
 }
 
 JSValueRef JSTZDate::equalsTo(JSContextRef context, JSObjectRef function,
@@ -467,7 +531,7 @@ JSValueRef JSTZDate::equalsTo(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -475,7 +539,7 @@ JSValueRef JSTZDate::equalsTo(JSContextRef context, JSObjectRef function,
                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 JSTZDate::earlierThan(JSContextRef context, JSObjectRef function,
@@ -492,7 +556,7 @@ JSValueRef JSTZDate::earlierThan(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -500,7 +564,7 @@ JSValueRef JSTZDate::earlierThan(JSContextRef context, JSObjectRef function,
                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");
 
 }
 
@@ -519,7 +583,7 @@ JSValueRef JSTZDate::laterThan(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -527,7 +591,7 @@ JSValueRef JSTZDate::laterThan(JSContextRef context, JSObjectRef function,
                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");
 
 }
 
@@ -536,6 +600,11 @@ JSValueRef JSTZDate::addDuration(JSContextRef context, JSObjectRef function,
 
        LogDebug("addDuration entered");
        Try {
+               if (argumentCount != 1) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -544,7 +613,7 @@ JSValueRef JSTZDate::addDuration(JSContextRef context, JSObjectRef function,
 
                TimeUtilConverter converter(context);
 
-               DurationProperties duration = converter.getDurationPropertis(arguments[0], exception);
+               DurationProperties duration = converter.getDurationPropertis(arguments[0]);
 
                AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
                        privateObject->getContext(),
@@ -562,7 +631,7 @@ JSValueRef JSTZDate::addDuration(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -570,7 +639,7 @@ JSValueRef JSTZDate::addDuration(JSContextRef context, JSObjectRef function,
                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 JSTZDate::toUTC(JSContextRef context, JSObjectRef function,
@@ -578,6 +647,11 @@ JSValueRef JSTZDate::toUTC(JSContextRef context, JSObjectRef function,
 
        LogDebug("toUTC entered");
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -600,15 +674,12 @@ JSValueRef JSTZDate::toUTC(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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");
 }
 
 
@@ -617,6 +688,11 @@ JSValueRef JSTZDate::toLocalTimezone(JSContextRef context, JSObjectRef function,
 
        LogDebug("toLocalTimezone entered");
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -639,21 +715,23 @@ JSValueRef JSTZDate::toLocalTimezone(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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 JSTZDate::toLocaleDateString(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -678,20 +756,24 @@ JSValueRef JSTZDate::toLocaleDateString(JSContextRef context, JSObjectRef functi
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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 JSTZDate::toLocaleTimeString(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -716,20 +798,24 @@ JSValueRef JSTZDate::toLocaleTimeString(JSContextRef context, JSObjectRef functi
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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 JSTZDate::toLocaleString(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -754,20 +840,24 @@ JSValueRef JSTZDate::toLocaleString(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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 JSTZDate::toDateString(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -792,20 +882,24 @@ JSValueRef JSTZDate::toDateString(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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 JSTZDate::toTimeString(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -830,14 +924,13 @@ JSValueRef JSTZDate::toTimeString(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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");
 }
 
 
@@ -845,6 +938,11 @@ JSValueRef JSTZDate::toString(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -869,14 +967,13 @@ JSValueRef JSTZDate::toString(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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 JSTZDate::getDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
@@ -945,6 +1042,11 @@ JSValueRef JSTZDate::getSeconds(JSContextRef context, JSObjectRef function, JSOb
 JSValueRef JSTZDate::getTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
         ITZDate::TZDateFields dateFields) {
        try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*> (JSObjectGetPrivate(thisObject));
 
                if (privateObject == NULL) {
@@ -971,27 +1073,23 @@ JSValueRef JSTZDate::getTZDateValue(JSContextRef context, JSObjectRef thisObject
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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 JSTZDate::setDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
         JSValueRef * exception) {
        LogDebug("<<<");
 
-       int minData = 1;
-       int maxData = 31;
        ITZDate::TZDateFields dateFields = ITZDate::TZDATE_DATE;
-       size_t argumentIndex = 0;
 
        try{
-               setTZDateValue(context, thisObject, argumentCount, arguments, argumentIndex, exception, dateFields, minData, maxData);
+               setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1000,7 +1098,7 @@ JSValueRef JSTZDate::setDate(JSContextRef context, JSObjectRef function, JSObjec
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -1009,20 +1107,17 @@ JSValueRef JSTZDate::setDate(JSContextRef context, JSObjectRef function, JSObjec
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        }
 
-       return JSValueMakeUndefined(context);
+       return JSValueMakeNull(context);
 } //setDate()
 
 JSValueRef JSTZDate::setFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
         JSValueRef * exception) {
        LogDebug("<<<");
 
-       int minData = 1000;
-       int maxData = 9999;
        ITZDate::TZDateFields dateFields = ITZDate::TZDATE_YEAR;
-       size_t argumentIndex = 0;
 
        try{
-               setTZDateValue(context, thisObject, argumentCount, arguments, argumentIndex, exception, dateFields, minData, maxData);
+               setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1031,7 +1126,7 @@ JSValueRef JSTZDate::setFullYear(JSContextRef context, JSObjectRef function, JSO
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -1040,20 +1135,17 @@ JSValueRef JSTZDate::setFullYear(JSContextRef context, JSObjectRef function, JSO
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        }
 
-       return JSValueMakeUndefined(context);
+       return JSValueMakeNull(context);
 } //setFullYear()
 
 JSValueRef JSTZDate::setHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
         JSValueRef * exception) {
        LogDebug("<<<");
 
-       int minData = 0;
-       int maxData = 23;
        ITZDate::TZDateFields dateFields = ITZDate::TZDATE_HOUR_OF_DAY;
-       size_t argumentIndex = 0;
 
        Try {
-                       setTZDateValue(context, thisObject, argumentCount, arguments, argumentIndex, exception, dateFields, minData, maxData);
+               setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1062,7 +1154,7 @@ JSValueRef JSTZDate::setHours(JSContextRef context, JSObjectRef function, JSObje
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -1071,20 +1163,17 @@ JSValueRef JSTZDate::setHours(JSContextRef context, JSObjectRef function, JSObje
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        }
 
-       return JSValueMakeUndefined(context);
+       return JSValueMakeNull(context);
 } //setHours()
 
 JSValueRef JSTZDate::setMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
         JSValueRef * exception) {
        LogDebug("<<<");
 
-       int minData = 0;
-       int maxData = 999;
        ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MILLISECOND;
-       size_t argumentIndex = 0;
        
        Try{
-               setTZDateValue(context, thisObject, argumentCount, arguments, argumentIndex, exception, dateFields, minData, maxData);
+               setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1093,7 +1182,7 @@ JSValueRef JSTZDate::setMilliseconds(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -1102,20 +1191,17 @@ JSValueRef JSTZDate::setMilliseconds(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        }
 
-       return JSValueMakeUndefined(context);
+       return JSValueMakeNull(context);
 } //setMilliseconds()
 
 JSValueRef JSTZDate::setMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
         JSValueRef * exception) {
        LogDebug("<<<");
 
-       int minData = 0;
-       int maxData = 23;
        ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MINUTE;
-       size_t argumentIndex = 0;
 
        Try {
-               setTZDateValue(context, thisObject, argumentCount, arguments, argumentIndex, exception, dateFields, minData, maxData);
+               setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1124,7 +1210,7 @@ JSValueRef JSTZDate::setMinutes(JSContextRef context, JSObjectRef function, JSOb
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -1133,20 +1219,17 @@ JSValueRef JSTZDate::setMinutes(JSContextRef context, JSObjectRef function, JSOb
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        }
 
-       return JSValueMakeUndefined(context);
+       return JSValueMakeNull(context);
 } //setMinutes()
 
 JSValueRef JSTZDate::setMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
         JSValueRef * exception) {
        LogDebug("<<<");
 
-       int minData = 0;
-       int maxData = 11;
        ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MONTH;
-       size_t argumentIndex = 0;
 
        Try {
-               setTZDateValue(context, thisObject, argumentCount, arguments, argumentIndex, exception, dateFields, minData, maxData);
+               setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1155,7 +1238,7 @@ JSValueRef JSTZDate::setMonth(JSContextRef context, JSObjectRef function, JSObje
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -1164,20 +1247,17 @@ JSValueRef JSTZDate::setMonth(JSContextRef context, JSObjectRef function, JSObje
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        }
 
-       return JSValueMakeUndefined(context);
+       return JSValueMakeNull(context);
 } //setMonth()
 
 JSValueRef JSTZDate::setSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
         JSValueRef * exception) {
        LogDebug("<<<");
 
-       int minData = 0;
-       int maxData = 23;
        ITZDate::TZDateFields dateFields = ITZDate::TZDATE_SECOND;
-       size_t argumentIndex = 0;
 
        Try {
-               setTZDateValue(context, thisObject, argumentCount, arguments, argumentIndex, exception, dateFields, minData, maxData);
+               setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1186,7 +1266,7 @@ JSValueRef JSTZDate::setSeconds(JSContextRef context, JSObjectRef function, JSOb
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -1195,27 +1275,28 @@ JSValueRef JSTZDate::setSeconds(JSContextRef context, JSObjectRef function, JSOb
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        }
 
-       return JSValueMakeUndefined(context);
+       return JSValueMakeNull(context);
 } //setSeconds()
 
 
-JSValueRef JSTZDate::setTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], size_t argumentIndex,
-        JSValueRef * exception, ITZDate::TZDateFields dateFields, int minData, int maxData) {
+JSValueRef JSTZDate::setTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+        JSValueRef * exception, ITZDate::TZDateFields dateFields) {
 
-       if (argumentCount - 1 < argumentIndex) {
+       if (argumentCount != 1) {
                LogError("Wrong parameters");
                ThrowMsg(InvalidArgumentException, "argumentIndex is bigger than argumentCount");
        }
 
        TimeUtilConverter converter(context);
 
-       int data = converter.toInt(arguments[argumentIndex]);
-       LogDebug("input data:" << data << ", minData:" << minData << ", maxData" << maxData);
+       if ((JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]))
+               || (!JSValueIsNumber(context, arguments[0])))
+               ThrowMsg(ConversionException, "Invalid Argument");
 
-       if (data < minData || data > maxData) {
-               LogError("Wrong parameters data:" << data);
-               ThrowMsg(InvalidArgumentException, "data range missmatch");
-       }
+       int data = converter.toInt(arguments[0]);
+
+       if ((dateFields == ITZDate::TZDATE_YEAR) && (data < 0))
+               ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
 
        TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*> (JSObjectGetPrivate(thisObject));
 
@@ -1232,60 +1313,65 @@ JSValueRef JSTZDate::setTZDateValue(JSContextRef context, JSObjectRef thisObject
        ITZDatePtr tzDate(privateObject->getObject());
        tzDate->set(dateFields, static_cast<long> (data));
 
-       return JSValueMakeUndefined(context);
+       return JSValueMakeNull(context);
 }      //setTZDateValue
 
 JSValueRef JSTZDate::getUTCDate(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
-       return getUTCTZDateValue(context, thisObject, ITZDate::TZDATE_DATE, exception);
+       return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_DATE, exception);
 }
 
 JSValueRef JSTZDate::getUTCDay(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
-       return getUTCTZDateValue(context, thisObject, ITZDate::TZDATE_DAY_OF_WEEK, exception);
+       return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_DAY_OF_WEEK, exception);
 }
 
 JSValueRef JSTZDate::getUTCFullYear(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
-       return getUTCTZDateValue(context, thisObject, ITZDate::TZDATE_YEAR, exception);
+       return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_YEAR, exception);
 }
 
 JSValueRef JSTZDate::getUTCHours(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
-       return getUTCTZDateValue(context, thisObject, ITZDate::TZDATE_HOUR_OF_DAY, exception);
+       return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_HOUR_OF_DAY, exception);
 }
 
 JSValueRef JSTZDate::getUTCMilliseconds(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
-       return getUTCTZDateValue(context, thisObject, ITZDate::TZDATE_MILLISECOND, exception);
+       return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_MILLISECOND, exception);
 }
 
 JSValueRef JSTZDate::getUTCMinutes(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
-       return getUTCTZDateValue(context, thisObject, ITZDate::TZDATE_MINUTE, exception);
+       return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_MINUTE, exception);
 }
 
 JSValueRef JSTZDate::getUTCMonth(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
-       return getUTCTZDateValue(context, thisObject, ITZDate::TZDATE_MONTH, exception);
+       return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_MONTH, exception);
 }
 
 JSValueRef JSTZDate::getUTCSeconds(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
-       return getUTCTZDateValue(context, thisObject, ITZDate::TZDATE_SECOND, exception);
+       return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_SECOND, exception);
 }
 
-JSValueRef JSTZDate::getUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, ITZDate::TZDateFields DateFields, JSValueRef * exception) {
+JSValueRef JSTZDate::getUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, ITZDate::TZDateFields DateFields, JSValueRef * exception) {
        LogDebug("Entered");
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -1311,67 +1397,66 @@ JSValueRef JSTZDate::getUTCTZDateValue(JSContextRef context, JSObjectRef thisObj
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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 JSTZDate::setUTCDate(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
 
-       return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_DATE, exception, 1, 31);
+       return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_DATE, exception);
 }
 
 JSValueRef JSTZDate::setUTCFullYear(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
 
-       return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_YEAR, exception, 1000, 9999);
+       return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_YEAR, exception);
 }
 
 JSValueRef JSTZDate::setUTCHours(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
 
-       return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_HOUR_OF_DAY, exception, 0, 23);
+       return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_HOUR_OF_DAY, exception);
 }
 
 JSValueRef JSTZDate::setUTCMilliseconds(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
 
-       return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MILLISECOND, exception, 0, 999);
+       return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MILLISECOND, exception);
 }
 
 JSValueRef JSTZDate::setUTCMinutes(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
 
-       return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MINUTE, exception, 0, 59);
+       return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MINUTE, exception);
 }
 
 JSValueRef JSTZDate::setUTCMonth(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
 
-       return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MONTH, exception, 0, 11);
+       return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MONTH, exception);
 }
 
 JSValueRef JSTZDate::setUTCSeconds(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
 
-       return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_SECOND, exception, 0, 59);
+       return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_SECOND, exception);
 }
 
 JSValueRef JSTZDate::setUTCTZDateValue(JSContextRef context, JSObjectRef thisObject,
-       size_t argumentCount, const JSValueRef arguments[], ITZDate::TZDateFields dateFields, JSValueRef * exception, int minData, int maxData) {
+       size_t argumentCount, const JSValueRef arguments[], ITZDate::TZDateFields dateFields, JSValueRef * exception) {
        LogDebug("Entered");
        Try {
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
@@ -1380,11 +1465,15 @@ JSValueRef JSTZDate::setUTCTZDateValue(JSContextRef context, JSObjectRef thisObj
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               if ((argumentCount < 1)
-                       || (!JSValueIsNumber(context, arguments[0])))
+               if (argumentCount != 1) {
+                       LogError("Wrong TZDate parameters count");
+                       ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
+               }
+                       
+               if (!JSValueIsNumber(context, arguments[0]))
                {
                        LogError("Wrong TZDate parameters");
-                       ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters");
+                       ThrowMsg(ConversionException, "Wrong TZDate parameters");
                }
 
                AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
@@ -1395,14 +1484,14 @@ JSValueRef JSTZDate::setUTCTZDateValue(JSContextRef context, JSObjectRef thisObj
                TimeUtilConverter converter(context);
                
                long data = converter.FromJSValueReftolong(arguments[0]);
-               if (data < minData || data > maxData) {
-                       LogError("Wrong parameters data:" << data);
-                       ThrowMsg(InvalidArgumentException, "data range missmatch");
-               }
+
+               if ((dateFields == ITZDate::TZDATE_YEAR) && (data < 0))
+                       ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
+       
                ITZDatePtr TZDate(privateObject->getObject());
                TZDate->setUTC(dateFields, data);
 
-               return JSValueMakeUndefined(context);
+               return JSValueMakeNull(context);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1411,7 +1500,7 @@ JSValueRef JSTZDate::setUTCTZDateValue(JSContextRef context, JSObjectRef thisObj
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -1419,11 +1508,18 @@ JSValueRef JSTZDate::setUTCTZDateValue(JSContextRef context, JSObjectRef thisObj
                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 JSTZDate::getTimezoneAbbreviation(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("entered");
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -1450,21 +1546,23 @@ JSValueRef JSTZDate::getTimezoneAbbreviation(JSContextRef context, JSObjectRef f
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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 JSTZDate::secondsFromUTC(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("entered");
 
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -1489,19 +1587,21 @@ JSValueRef JSTZDate::secondsFromUTC(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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 JSTZDate::isDST(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("entered");
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -1526,21 +1626,23 @@ JSValueRef JSTZDate::isDST(JSContextRef context, JSObjectRef function, JSObjectR
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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 JSTZDate::getPreviousDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("entered");
 
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -1565,21 +1667,23 @@ JSValueRef JSTZDate::getPreviousDSTTransition(JSContextRef context, JSObjectRef
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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 JSTZDate::getNextDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("entered");
 
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
@@ -1604,15 +1708,12 @@ JSValueRef JSTZDate::getNextDSTTransition(JSContextRef context, JSObjectRef func
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                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");
 }
 
 }              //Tizen1_0
index 71e9b48..4d15f27 100755 (executable)
@@ -37,9 +37,11 @@ public:
 
     static const JSClassRef getClassRef();
     static JSObjectRef createJSObject(JSContextRef context);
+    static JSObjectRef createJSObject(JSContextRef context, const std::string &timezone);
     static JSObjectRef createJSObject(JSContextRef context, const Api::TimeUtil::TZDateProperties &properties);
     static JSObjectRef createJSObject(JSContextRef context, const time_t localTime, const std::string &timezone);
-    static JSObjectRef createJSObject(JSContextRef context, const long year, const long month,  const long day, const long hours, const long minutes, const long seconds, const std::string &timezone);        
+       static JSObjectRef createJSObject(JSContextRef context, const time_t localTime, const long msec, const std::string &timezone);
+    static JSObjectRef createJSObject(JSContextRef context, const long year, const long month,  const long day, const long hours, const long minutes, const long seconds, const long milliseconds, const std::string &timezone);       
 private:
        enum CompareType {
                DIFFERENCE,
@@ -137,8 +139,8 @@ private:
        static JSValueRef getSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
                JSValueRef * exception);
 
-       static JSValueRef setTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], size_t argumentIndex, JSValueRef * exception,
-                       TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields, int minData, int maxData);
+       static JSValueRef setTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
+                       TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields);
 
        static JSValueRef getTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
                        TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields);
@@ -164,7 +166,7 @@ private:
        static JSValueRef setSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
                JSValueRef * exception);
 
-    static JSValueRef getUTCTZDateValue(JSContextRef context, JSObjectRef thisObject,
+    static JSValueRef getUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, 
                TizenApis::Api::TimeUtil::ITZDate::TZDateFields DateFields, JSValueRef * exception);    
     static JSValueRef getUTCDate(JSContextRef context, JSObjectRef function, 
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
@@ -184,7 +186,7 @@ private:
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
 
     static JSValueRef setUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, 
-               const JSValueRef arguments[], TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields, JSValueRef * exception, int minData, int maxData);
+               const JSValueRef arguments[], TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields, JSValueRef * exception);
     static JSValueRef setUTCDate(JSContextRef context, JSObjectRef function, 
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
     static JSValueRef setUTCFullYear(JSContextRef context, JSObjectRef function, 
diff --git a/src/standards/Tizen/TimeUtil/JSTimeDuration.cpp b/src/standards/Tizen/TimeUtil/JSTimeDuration.cpp
new file mode 100755 (executable)
index 0000000..1398b09
--- /dev/null
@@ -0,0 +1,310 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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>
+#include <memory>
+#include <dpl/log/log.h>
+
+#include <Commons/Exception.h>
+#include <CommonsJavaScript/Utils.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+
+#include <API/TimeUtil/TimeUtilFactory.h>
+
+#include "JSTimeDuration.h"
+#include "TimeUtilConverter.h"
+#include "plugin_config.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+using namespace DPL;
+using namespace TizenApis::Commons;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+#define TIZEN10_TIMEDURATION_LENGTH "length"
+#define TIZEN10_TIMEDURATION_UNIT "unit"
+
+JSClassDefinition JSTimeDuration::m_classInfo = {
+    0,
+    kJSClassAttributeNone,
+    "TimeDuration",
+    0,
+    m_property,
+    m_function,
+    initialize,
+    finalize,
+    NULL, //HasProperty,
+    NULL, //GetProperty,
+    NULL, //SetProperty,
+    NULL, //DeleteProperty,
+    NULL, //GetPropertyNames,
+    NULL, //CallAsFunction,
+    constructor, //CallAsConstructor,
+    NULL,
+    NULL, //ConvertToType
+};
+
+
+JSStaticFunction JSTimeDuration::m_function[] = {
+    {"difference",           JSTimeDuration::difference,            kJSPropertyAttributeNone},
+};
+
+JSStaticValue JSTimeDuration::m_property[] =
+{
+    //TimdDurationProperties
+       {TIZEN10_TIMEDURATION_LENGTH,  getProperty, setProperty, kJSPropertyAttributeNone},
+       {TIZEN10_TIMEDURATION_UNIT,  getProperty, setProperty, kJSPropertyAttributeNone},
+       { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSTimeDuration::getClassRef()
+{
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+const JSClassDefinition* JSTimeDuration::getClassInfo()
+{
+    return &m_classInfo;
+}
+
+JSClassRef JSTimeDuration::m_jsClassRef = JSClassCreate(JSTimeDuration::getClassInfo());
+
+void JSTimeDuration::initialize(JSContextRef context, JSObjectRef object)
+{
+       LogDebug("entered Nothing to do.");
+
+       if (!JSObjectGetPrivate(object)) {
+               LogDebug("Private object not set... setting it.");
+               DurationProperties durations;
+               std::auto_ptr<DurationProperties> durationProps(new DurationProperties(
+                                                                  durations));
+               TimeDurationPrivObject *priv = new TimeDurationPrivObject(context, durationProps.get());
+               durationProps.release();
+               if (!JSObjectSetPrivate(object, priv)) {
+                       delete priv;
+               }
+       }
+}
+
+void JSTimeDuration::finalize(JSObjectRef object)
+{
+       TimeDurationPrivObject* priv = static_cast<TimeDurationPrivObject*>(JSObjectGetPrivate(object));
+       JSObjectSetPrivate(object, NULL);
+       LogDebug("Deleting TimeDuration");
+       delete priv;
+}
+
+JSValueRef JSTimeDuration::getProperty(JSContextRef context, JSObjectRef object,
+        JSStringRef propertyName, JSValueRef* exception)
+{
+       LogDebug("Enter");
+
+       Try     {
+               TimeUtilConverter convert(context);
+
+               LogDebug("propertyName : " << convert.toString(propertyName));
+               if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_TIMEDURATION_LENGTH)) {
+                       return convert.toJSValueRef(static_cast<double>(convert.getDurationLength(object)));
+               } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_TIMEDURATION_UNIT)) {
+                       std::string strUnit = convert.toDurationUnitString(convert.getDurationUnit(object));
+                       if (strUnit == "")
+                               ThrowMsg(InvalidArgumentException, "unit string is invald.");
+                       return convert.toJSValueRef(strUnit);
+               }
+       } Catch (ConversionException) {
+               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+       } Catch (InvalidArgumentException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSTimeDuration::setProperty(JSContextRef context, JSObjectRef object,
+        JSStringRef propertyName, JSValueRef value,  JSValueRef* exception)
+{
+       LogDebug("Enter");
+
+       Try     {
+               TimeDurationPrivObject* privateObject = static_cast<TimeDurationPrivObject*>(JSObjectGetPrivate(object));
+               if (!privateObject) {
+                       LogError("Private object is not set.");
+                       ThrowMsg(NullPointerException, "Private object not initialized");
+               }
+
+               DurationProperties *duration = privateObject->getObject();
+               TimeUtilConverter convert(context);
+
+               if (JSValueIsNull(context, value) || JSValueIsUndefined(context, value)) {
+                       LogError("value is invald.");
+                       ThrowMsg(ConversionException, "value is invald.");
+               }
+               if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_TIMEDURATION_LENGTH)) {
+                       if (!JSValueIsNumber(context, value)) {
+                               LogError("value is invald.");
+                               ThrowMsg(ConversionException, "value is invald.");
+                       }
+                       duration->length = static_cast<long long>(convert.toDouble(value));
+               } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_TIMEDURATION_UNIT)) {
+                       if (!JSValueIsString(context, value)) {
+                               LogError("value is invald.");
+                               ThrowMsg(ConversionException, "value is invald.");
+                       }
+                       short unit = convert.toDurationUnit(convert.toString(value));
+                       if (unit == 0xff)
+                               ThrowMsg(InvalidArgumentException, "property doesn't exist.");
+                       duration->unit = unit;
+               } else
+                       ThrowMsg(InvalidArgumentException, "property doesn't exist.");
+
+               return true;
+       } Catch (NullPointerException) {
+               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
+       } Catch (ConversionException) {
+               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+       } Catch (InvalidArgumentException) {
+               LogError("InvalidArgumentException: " << _rethrown_exception.GetMessage());
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+       }
+       return false;
+}
+
+JSObjectRef JSTimeDuration::createJSObject(JSContextRef context,
+        const DurationProperties &durations)
+{
+    std::auto_ptr<DurationProperties> durationProps(new DurationProperties(
+                                                       durations));
+    TimeDurationPrivObject *priv = new TimeDurationPrivObject(context, durationProps.get());
+    durationProps.release();
+    if (!priv) {
+        ThrowMsg(NullPointerException, "Can not new an object");
+    }
+    return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSObjectRef JSTimeDuration::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
+       LogDebug("entered");
+       TimeUtilConverter convert(ctx);
+       Try {
+               if ((argumentCount < 1) || (argumentCount > 2)) {
+                       LogError("Wrong argument count");
+                       ThrowMsg(InvalidArgumentException, "Wrong TimeDuration argumentCount");
+               }
+
+               TimeDurationPrivObject* mainPriv = static_cast<TimeDurationPrivObject*>(JSObjectGetPrivate(constructor));
+               JSContextRef global_context = mainPriv ? mainPriv->getContext() : ctx;
+
+               DurationProperties duration;
+               if (JSValueIsNull(ctx, arguments[0]) || JSValueIsUndefined(ctx, arguments[0]) || !JSValueIsNumber(ctx, arguments[0])) {
+                       ThrowMsg(ConversionException, "Argument(length) is invalid");
+               }
+               duration.length = convert.toDouble(arguments[0]);
+               if (argumentCount == 2) {
+                       if (JSValueIsUndefined(ctx, arguments[1]) || !JSValueIsString(ctx, arguments[1])) {
+                               ThrowMsg(ConversionException, "Argument(unit) is invalid");
+                       } else if (!JSValueIsNull(ctx, arguments[1])) {
+                               std::string unit = convert.toString(arguments[1]);
+                               duration.unit = convert.toDurationUnit(unit);
+                               if (duration.unit == 0xff)
+                                       ThrowMsg(InvalidArgumentException, "Argument(unit) is invalid(wrong type unit)");
+                       }
+               }
+               return createJSObject(global_context, duration);
+       } Catch(NullPointerException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return NULL;
+       } Catch(UnknownException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return NULL;
+       } Catch(ConversionException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return NULL;
+       } Catch (InvalidArgumentException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               return NULL;
+       } Catch (WrtDeviceApis::Commons::Exception) {
+           LogWarning("Trying to get incorrect value");
+       }
+       *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       return NULL;
+}
+
+JSValueRef JSTimeDuration::difference(JSContextRef context, JSObjectRef function, 
+       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
+       LogDebug("Entered");
+       Try {
+               TimeDurationPrivObject* privateObject = static_cast<TimeDurationPrivObject*>(JSObjectGetPrivate(thisObject));
+
+               if (argumentCount != 1) {
+                       LogError("Wrong parameters");
+                       ThrowMsg(InvalidArgumentException, "Wrong parameters");
+               }
+
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       privateObject->getContext(),
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+               
+               TimeUtilConverter converter(privateObject->getContext());
+
+               DurationProperties first = converter.getDurationPropertis(thisObject);
+               DurationProperties second = converter.getDurationPropertis(arguments[0]);
+
+               DurationProperties diff;
+               if (first.unit > second.unit) {
+                       long long firstLength = converter.convertDurationLength(first, second.unit);
+                       diff.unit = second.unit;
+                       diff.length = firstLength - second.length;
+               } else {
+                       long long secondLength = converter.convertDurationLength(second, first.unit);
+                       diff.unit = first.unit;
+                       diff.length = first.length - secondLength;
+               }
+               return converter.makeDurationObject(diff);
+       } 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");
+}
+
+} //Tizen1_0
+} //TizenApis
diff --git a/src/standards/Tizen/TimeUtil/JSTimeDuration.h b/src/standards/Tizen/TimeUtil/JSTimeDuration.h
new file mode 100755 (executable)
index 0000000..14f588a
--- /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 WRT_PLUGINS_TIZEN_1_0_JS_TIMEDURATION_H_
+#define WRT_PLUGINS_TIZEN_1_0_JS_TIMEDURATION_H_
+
+#include <dpl/shared_ptr.h>
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/TimeUtil/DurationProperties.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<
+            TizenApis::Api::TimeUtil::DurationProperties*>::
+    Type TimeDurationPrivObject;
+
+/**
+ * @class JSTimeDuration
+ * @brief This class is javascript extension
+ *
+ */
+class JSTimeDuration
+{
+  public:
+    /**
+     * Gets object's class description.
+     */
+    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();
+    static JSObjectRef createJSObject(JSContextRef context, const Api::TimeUtil::DurationProperties &durations);
+  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);
+
+    /**
+     * Getters for properties
+     */
+    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 JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+    static JSValueRef difference(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.
+     */
+    static JSClassDefinition m_classInfo;
+
+    static JSClassRef m_jsClassRef;
+
+    /**
+     * 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[];
+};
+}
+}
+
+#endif //WRT_PLUGINS_TIZEN_1_0_JS_TIMEDURATION_H_
\ No newline at end of file
index c45cf2d..0f7d6bc 100755 (executable)
@@ -17,7 +17,7 @@
 
 #include <string>
 #include <ctime>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 
 #include <Commons/Exception.h>
 #include <CommonsJavaScript/Utils.h>
@@ -68,7 +68,6 @@ JSStaticFunction JSTimeUtil::m_function[] = {
     { "getDateFormat", JSTimeUtil::getDateFormat, kJSPropertyAttributeNone },
     { "getTimeFormat", JSTimeUtil::getTimeFormat, kJSPropertyAttributeNone },
     { "isLeapYear",      JSTimeUtil::isLeapYear,      kJSPropertyAttributeNone},
-    { "durationDifference",      JSTimeUtil::durationDifference,      kJSPropertyAttributeNone},
     { 0, 0, 0 }
 };
 
@@ -127,6 +126,11 @@ JSValueRef JSTimeUtil::getCurrentDateTime(JSContextRef context,
 {
        LogDebug("Entered ");
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TimeUtilPrivObject* privateObject = static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(thisObject));
                if (NULL == privateObject) {
                        LogError("private object is null");
@@ -150,7 +154,7 @@ JSValueRef JSTimeUtil::getCurrentDateTime(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 JSTimeUtil::setCurrentDateTime(JSContextRef context,
@@ -161,7 +165,12 @@ JSValueRef JSTimeUtil::setCurrentDateTime(JSContextRef context,
         JSValueRef* exception)
 {
        LogDebug("entered");
-               
+
+       if (argumentCount != 1) {
+               LogError("Wrong argument count");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+       }
+
        TimeUtilPrivObject* privateObject = static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(thisObject));
        if (NULL == privateObject) {
                LogError("private object is null");
@@ -173,16 +182,12 @@ JSValueRef JSTimeUtil::setCurrentDateTime(JSContextRef context,
                TIMEUTIL_FUNCTION_API_SET_CURRENT_DATE_TIME);
        
        Try {           
-               if (argumentCount < 1) {
-                       Throw(InvalidArgumentException);
-               }
-       
                TimeUtilConverter converter(context);   
                        
                if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0]) 
                        || (!JSValueIsObjectOfClass(context, arguments[0], JSTZDate::getClassRef()))) {
                        LogError("Wrong event argument");
-                       Throw(InvalidArgumentException);
+                       Throw(ConversionException);
                }
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
@@ -197,14 +202,14 @@ JSValueRef JSTimeUtil::setCurrentDateTime(JSContextRef context,
        } Catch(ConversionException) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (UnsupportedException) {
                LogError("JSTimeUtil::hasInstance NotSupportedException");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::PERMISSION_DENIED_ERROR , "Permission Denied");
        } Catch(WrtDeviceApis::Commons::Exception) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        }
-       return JSValueMakeNull(context);        
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
 }
 
 JSValueRef JSTimeUtil::getLocalTimezone(JSContextRef context,
@@ -216,6 +221,11 @@ JSValueRef JSTimeUtil::getLocalTimezone(JSContextRef context,
 {
        LogDebug("Entered ");
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TimeUtilPrivObject* privateObject = 
                        static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(
                                                               thisObject));
@@ -245,7 +255,7 @@ JSValueRef JSTimeUtil::getLocalTimezone(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 JSTimeUtil::getAvailableTimezones(JSContextRef context,
@@ -257,6 +267,11 @@ JSValueRef JSTimeUtil::getAvailableTimezones(JSContextRef context,
 {
        LogDebug("entered");
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TimeUtilPrivObject* privateObject = 
                        static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(
                                                               thisObject));
@@ -281,12 +296,9 @@ JSValueRef JSTimeUtil::getAvailableTimezones(JSContextRef context,
                }
                
                return converter.toJSValueRef(timezonesArray);
-       } 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 Value");;
+               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");
@@ -300,7 +312,7 @@ JSValueRef JSTimeUtil::getAvailableTimezones(JSContextRef context,
                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");    
 }
 
 JSValueRef JSTimeUtil::getDateFormat(JSContextRef context,
@@ -312,6 +324,11 @@ JSValueRef JSTimeUtil::getDateFormat(JSContextRef context,
 {
        LogDebug("entered");
        Try {
+               if (argumentCount > 1) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TimeUtilPrivObject* privateObject = 
                        static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(
                                                               thisObject));
@@ -325,20 +342,25 @@ JSValueRef JSTimeUtil::getDateFormat(JSContextRef context,
                        privateObject->getContext(),
                        TIMEUTIL_FUNCTION_API_READ_FUNCS);
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-               
+
+               TimeUtilConverter converter(context);   
                if ((argumentCount == 0) || (JSValueIsNull(context, arguments[0]))) {
                        b_shortFormat = false;
                } else if (JSValueIsUndefined(context, arguments[0]) || !JSValueIsBoolean(context, arguments[0]))
-                       Throw(InvalidArgumentException);
+                       Throw(ConversionException);
+               else
+                       b_shortFormat = converter.toBool(arguments[0]);
 
                ITimeUtilPtr TimeUtil(privateObject->getObject());
                std::string dateformat = TimeUtil->getDateFormat(b_shortFormat);        
-               TimeUtilConverter converter(context);
                
-               return converter.toJSValueRef(dateformat);      
+               return converter.toJSValueRef(dateformat);
+       } 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 Value");;
+               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");
@@ -348,7 +370,7 @@ JSValueRef JSTimeUtil::getDateFormat(JSContextRef context,
        } Catch (WrtDeviceApis::Commons::Exception) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");                    
        }
-       return JSValueMakeNull(context);        
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");    
 }
 
 JSValueRef JSTimeUtil::getTimeFormat(JSContextRef context,
@@ -360,6 +382,11 @@ JSValueRef JSTimeUtil::getTimeFormat(JSContextRef context,
 {
        LogDebug("entered");
        Try {
+               if (argumentCount != 0) {
+                       LogError("Wrong argument count");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               }
+
                TimeUtilPrivObject* privateObject = 
                        static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(
                                                               thisObject));
@@ -380,7 +407,7 @@ JSValueRef JSTimeUtil::getTimeFormat(JSContextRef context,
                return converter.toJSValueRef(dateformat);
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");;
+               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");
@@ -390,7 +417,7 @@ JSValueRef JSTimeUtil::getTimeFormat(JSContextRef context,
        } Catch (WrtDeviceApis::Commons::Exception) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");                    
        }
-       return JSValueMakeNull(context);
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
 }
 
 JSValueRef JSTimeUtil::isLeapYear(JSContextRef context, JSObjectRef function, 
@@ -399,7 +426,7 @@ JSValueRef JSTimeUtil::isLeapYear(JSContextRef context, JSObjectRef function,
        Try {
                TimeUtilPrivObject* privateObject = static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(thisObject));
 
-               if (argumentCount < 1) {
+               if (argumentCount != 1) {
                        LogError("Wrong parameters");
                        ThrowMsg(InvalidArgumentException, "Wrong parameters");
                }
@@ -421,56 +448,12 @@ JSValueRef JSTimeUtil::isLeapYear(JSContextRef context, JSObjectRef function,
                        return converter.toJSValueRef(false);
 
                return converter.toJSValueRef(true);    
-       } Catch (InvalidArgumentException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");;
-       } Catch (UnsupportedException) {
-               LogError("JSTimeUtil::hasInstance NotSupportedException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR , "Not Support");
-       } Catch (PlatformException) {
+       } Catch(ConversionException) {
                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 JSValueMakeNull(context);
-}
-
-JSValueRef JSTimeUtil::durationDifference(JSContextRef context, JSObjectRef function, 
-       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
-       LogDebug("Entered");
-       Try {
-               TimeUtilPrivObject* privateObject = static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(thisObject));
-
-               if (argumentCount < 2) {
-                       LogError("Wrong parameters");
-                       ThrowMsg(InvalidArgumentException, "Wrong parameters");
-               }
-
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-               
-               TimeUtilConverter converter(context);
-
-               DurationProperties first = converter.getDurationPropertis(arguments[0], exception);
-               DurationProperties second = converter.getDurationPropertis(arguments[1], exception);
-
-               DurationProperties diff;
-               if (first.unit > second.unit) {
-                       long long firstLength = converter.convertDurationLength(first, second.unit);
-                       diff.unit = second.unit;
-                       diff.length = firstLength - second.length;
-               } else {
-                       long long secondLength = converter.convertDurationLength(second, first.unit);
-                       diff.unit = first.unit;
-                       diff.length = first.length - secondLength;
-               }
-               return converter.makeDurationObject(diff);
+               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 Value");;
+               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");
@@ -480,7 +463,7 @@ JSValueRef JSTimeUtil::durationDifference(JSContextRef context, JSObjectRef func
        } Catch (WrtDeviceApis::Commons::Exception) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");                    
        }
-       return JSValueMakeNull(context);
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
 }
 
 } //Tizen1_0
index 8a2af29..d33a4cb 100755 (executable)
@@ -127,10 +127,7 @@ class JSTimeUtil
        
     static JSValueRef isLeapYear(JSContextRef context, JSObjectRef function, 
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
-       
-    static JSValueRef durationDifference(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 adf60ad..b226d60 100755 (executable)
@@ -17,7 +17,7 @@
 
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/Exception.h>
 #include <CommonsJavaScript/ScopedJSStringRef.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/JSUtils.h>
 #include <Commons/RegexUtils.h>
 
+#include <API/TimeUtil/TimeUtilFactory.h>
 #include "TimeUtilConverter.h"
 
 #include "JSTZDate.h"
+#include "JSTimeDuration.h"
 
 using namespace TizenApis::Api::TimeUtil;
 using namespace WrtDeviceApis;
@@ -53,13 +55,13 @@ long TimeUtilConverter::FromJSValueReftolong(const JSValueRef& arg) {
                        && (JSValueIsNumber(m_context, arg)))
                return toLong(arg);
        else
-               ThrowMsg(Commons::InvalidArgumentException,
+               ThrowMsg(Commons::ConversionException,
                         "JSValueRef is JS null or JS undefined.");
 }
 
 TZDateProperties TimeUtilConverter::getPropertiesInTZDate(JSValueRef arg) {
        if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg)) {
-               ThrowMsg(Commons::InvalidArgumentException,
+               ThrowMsg(Commons::ConversionException,
                         "Message is JS null or JS undefined.");
        }
        JSObjectRef obj = toJSObjectRef(arg);
@@ -71,12 +73,12 @@ TZDateProperties TimeUtilConverter::getPropertiesInTZDate(JSObjectRef arg) {
        LogDebug("TZDate object=" << arg);
        if (!arg) {
                LogError("Object is null");
-               ThrowMsg(Commons::NullPointerException, "Private object not initialized");
+               ThrowMsg(Commons::ConversionException, "Private object not initialized");
        }
        TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(arg));
        if (!privateObject) {
                LogError("Private object is not set.");
-               ThrowMsg(Commons::NullPointerException, "Private object not initialized");
+               ThrowMsg(Commons::ConversionException, "Private object not initialized");
        }
        
        ITZDatePtr TZDate = privateObject->getObject();
@@ -94,28 +96,7 @@ TZDateProperties TimeUtilConverter::getPropertiesInTZDate(JSObjectRef arg) {
 }
 
 JSObjectRef TimeUtilConverter::makeDurationObject(const DurationProperties &duration) {
-       JSObjectRef propertyRef = JSObjectMake(m_context, NULL, NULL);
-       ScopedJSStringRef jsLengthString(JSStringCreateWithUTF8CString("length"));
-       ScopedJSStringRef jsUnitString(JSStringCreateWithUTF8CString("unit"));
-       std::string unitStr = "MSECS";
-       switch (duration.unit) {
-               case DAYS_UNIT:
-                       unitStr = "DAYS";
-                       break;
-               case SECONDS_UNIT:
-                       unitStr = "SECS";
-                       break;
-               case MINUTES_UNIT:
-                       unitStr = "MINS";
-                       break;
-               case HOURS_UNIT:
-                       unitStr = "HOURS";
-                       break;
-       }
-       JSObjectSetProperty(m_context, propertyRef, jsLengthString.get(), toJSValueRef(static_cast<double>(duration.length)), kJSPropertyAttributeNone, NULL);
-       JSObjectSetProperty(m_context, propertyRef, jsUnitString.get(), toJSValueRef(unitStr), kJSPropertyAttributeNone, NULL);
-
-       return propertyRef;
+       return JSTimeDuration::createJSObject(m_context, duration);
 }
 
 JSObjectRef TimeUtilConverter::makeMillisecondDurationObject(const long long length) {
@@ -131,44 +112,86 @@ JSObjectRef TimeUtilConverter::makeMillisecondDurationObject(const long long len
        return makeDurationObject(duration);
 }
 
-DurationProperties TimeUtilConverter::getDurationPropertis(JSValueRef value, JSValueRef* exception) {
+DurationProperties TimeUtilConverter::getDurationPropertis(JSValueRef value) {
        DurationProperties duration;
-       duration.length = getDurationLength(value, exception);
-       duration.unit = getDurationUnit(value, exception);
+       duration.length = getDurationLength(value);
+       duration.unit = getDurationUnit(value);
        return duration;
 }
 
-long long TimeUtilConverter::getDurationLength(JSValueRef value, JSValueRef* exception) {
-       JSValueRef l_JSProperty = JSUtils::getJSProperty(m_context, value, "length", exception);
-       double result = 0;
-       
-       if (l_JSProperty != NULL && JSValueIsNumber(m_context, l_JSProperty)) {
-               result = toDouble(l_JSProperty);
-       } else {
-               ThrowMsg(Commons::InvalidArgumentException, "Length doesn't exist or wrong type");
+long long TimeUtilConverter::getDurationLength(JSValueRef value) {
+       if (JSValueIsNull(m_context, value) || JSValueIsUndefined(m_context, value)) {
+               ThrowMsg(Commons::ConversionException,
+                        "Duration is JS null or JS undefined.");
        }
-       return static_cast<long long>(result);
+       JSObjectRef obj = toJSObjectRef(value);
+       return getDurationLength(obj);
 }
 
-short TimeUtilConverter::getDurationUnit(JSValueRef value, JSValueRef* exception) {
-       JSValueRef l_JSProperty = JSUtils::getJSProperty(m_context, value, "unit", exception);
-       std::string result = "MSECS";
-       
-       if (l_JSProperty != NULL && JSValueIsString(m_context, l_JSProperty)) {
-               result = toString(l_JSProperty);
+long long TimeUtilConverter::getDurationLength(JSObjectRef object) {
+       TimeDurationPrivObject* privateObject = static_cast<TimeDurationPrivObject*>(JSObjectGetPrivate(object));
+       if (!privateObject) {
+               LogError("Private object is not set.");
+               ThrowMsg(Commons::ConversionException, "Private object not initialized");
+       }
+
+       DurationProperties *duration = privateObject->getObject();
+
+       return duration->length;
+}
+
+short TimeUtilConverter::getDurationUnit(JSValueRef value) {
+       if (JSValueIsNull(m_context, value) || JSValueIsUndefined(m_context, value)) {
+               ThrowMsg(Commons::ConversionException,
+                        "Duration is JS null or JS undefined.");
+       }
+       JSObjectRef obj = toJSObjectRef(value);
+       return getDurationUnit(obj);
+}
+
+short TimeUtilConverter::getDurationUnit(JSObjectRef object) {
+       TimeDurationPrivObject* privateObject = static_cast<TimeDurationPrivObject*>(JSObjectGetPrivate(object));
+       if (!privateObject) {
+               LogError("Private object is not set.");
+               ThrowMsg(Commons::ConversionException, "Private object not initialized");
        }
 
-       if (!result.compare("DAYS"))
+       DurationProperties *duration = privateObject->getObject();
+
+       return duration->unit;
+
+}
+
+short TimeUtilConverter::toDurationUnit(std::string strUnit) {
+       if (!strUnit.compare("DAYS"))
                return DAYS_UNIT;
-       else if (!result.compare("SECS"))
+       else if (!strUnit.compare("SECS"))
                return SECONDS_UNIT;
-       else if (!result.compare("MINS"))
+       else if (!strUnit.compare("MINS"))
                return MINUTES_UNIT;
-       else if (!result.compare("HOURS"))
+       else if (!strUnit.compare("HOURS"))
                return HOURS_UNIT;
+       else if (!strUnit.compare("MSECS"))
+               return  MSECS_UNIT;
        else
-               return MSECS_UNIT;
+               return 0xff;
+}
 
+std::string TimeUtilConverter::toDurationUnitString(short unit) {
+       switch (unit) {
+               case DAYS_UNIT:
+                       return "DAYS";
+               case SECONDS_UNIT:
+                       return "SECS";
+               case MINUTES_UNIT:
+                       return "MINS";
+               case HOURS_UNIT:
+                       return "HOURS";
+               case MSECS_UNIT:
+                       return "MSECS";
+               default:
+                       return "";
+       }
 }
 
 long long TimeUtilConverter::convertDurationLength(DurationProperties duration, short unit) {
@@ -196,11 +219,12 @@ long long TimeUtilConverter::convertDurationLength(DurationProperties duration,
                        result = result * 24;
                        return result;
        }
+    return result;
 }
 
 std::time_t TimeUtilConverter::toTZDateTimeT(JSValueRef arg) {
        if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg)) {
-               ThrowMsg(Commons::InvalidArgumentException,
+               ThrowMsg(Commons::ConversionException,
                         "JSValueRef is JS null or JS undefined.");
        }
        JSObjectRef obj = toJSObjectRef(arg);
@@ -211,29 +235,44 @@ std::time_t TimeUtilConverter::toTZDateTimeT(JSValueRef arg) {
 std::time_t TimeUtilConverter::toTZDateTimeT(JSObjectRef arg) {
        if (!arg) {
                LogError("Object is null");
-               ThrowMsg(Commons::NullPointerException, "Private object not initialized");
+               ThrowMsg(Commons::ConversionException, "Private object not initialized");
        }
 
        TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(arg));
        if (!privateObject) {
                LogError("Private object is not set.");
-               ThrowMsg(Commons::NullPointerException, "Private object not initialized");
+               ThrowMsg(Commons::ConversionException, "Private object not initialized");
        }
 
        ITZDatePtr TZDate = privateObject->getObject();
 
-       TZDateProperties UTCProperties = TZDate->toLocalTimezone();
-       struct tm  localTm;
-
-       localTm.tm_year = UTCProperties.year - 1900;
-       localTm.tm_mon = UTCProperties.month;
-       localTm.tm_mday= UTCProperties.day;
-       localTm.tm_hour= UTCProperties.hours;
-       localTm.tm_min=UTCProperties.minutes;
-       localTm.tm_sec= UTCProperties.seconds;
-       localTm.tm_isdst = 0;
+       TZDateProperties UTCProperties = TZDate->toUTC();
+       struct tm  utcTm;
+
+       utcTm.tm_year = UTCProperties.year - 1900;
+       utcTm.tm_mon = UTCProperties.month;
+       utcTm.tm_mday= UTCProperties.day;
+       utcTm.tm_hour= UTCProperties.hours;
+       utcTm.tm_min=UTCProperties.minutes;
+       utcTm.tm_sec= UTCProperties.seconds;
+       utcTm.tm_isdst = 0;
+       return mktime(&utcTm);
+       
+}
 
-       return mktime(&localTm);
+JSObjectRef TimeUtilConverter::FromUTCTimeTToTZDate(std::time_t utcTime, const std::string &timezone) {
+       struct tm *tm = localtime(&utcTime);
+       TZDateProperties props;
+       props.year = tm->tm_year + 1900;
+       props.month = tm->tm_mon;
+       props.day = tm->tm_mday;
+       props.hours = tm->tm_hour;
+       props.minutes = tm->tm_min;
+       props.seconds = tm->tm_sec;
+       props.timezone = "UTC";
+
+       ITZDatePtr TZDate = TimeUtilFactory::getInstance().createTZDateObject(props);
+       return JSTZDate::createJSObject(m_context, TZDate->toTimezone(timezone));
 }
 
 }
index e7fcd3a..04b4b74 100755 (executable)
@@ -50,13 +50,17 @@ class TimeUtilConverter : public Converter
        TZDateProperties getPropertiesInTZDate(JSObjectRef arg);
        JSObjectRef makeDurationObject(const DurationProperties &duration);
        JSObjectRef makeMillisecondDurationObject(const long long length);
-       DurationProperties getDurationPropertis(JSValueRef value, JSValueRef* exception);
-       long long getDurationLength(JSValueRef value, JSValueRef* exception);
-       short getDurationUnit(JSValueRef value, JSValueRef* exception);
+       DurationProperties getDurationPropertis(JSValueRef value);
+       long long getDurationLength(JSValueRef value);
+       long long getDurationLength(JSObjectRef object);
+       short getDurationUnit(JSValueRef value);
+       short getDurationUnit(JSObjectRef object);
+       short toDurationUnit(std::string strUnit);
+       std::string toDurationUnitString(short unit);
        long long convertDurationLength(DurationProperties duration, short unit);
-
        std::time_t toTZDateTimeT(JSValueRef arg);
        std::time_t toTZDateTimeT(JSObjectRef arg);
+       JSObjectRef FromUTCTimeTToTZDate(std::time_t utcTime, const std::string &timezone);
 
 };
 
index ead733f..6c4a32f 100755 (executable)
  */
 
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
 #include <Commons/WrtWrapper/WrtWrappersMgr.h>
 #include "JSTimeUtil.h"
 #include "JSTZDate.h"
+#include "JSTimeDuration.h"
 
 void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface) {
        LogDebug("[TIZEN1.0\\TimeUtil] on_widget_start_callback ("<<widgetId<<")");
@@ -62,4 +63,9 @@ PLUGIN_CLASS_MAP_BEGIN
                "TZDate",
                TizenApis::Tizen1_0::JSTZDate::getClassRef(),
                NULL) 
+       PLUGIN_CLASS_MAP_ADD_CLASS(
+               WRT_JS_EXTENSION_OBJECT_TIZEN,
+               "TimeDuration",
+               TizenApis::Tizen1_0::JSTimeDuration::getClassRef(),
+               NULL) 
 PLUGIN_CLASS_MAP_END
index ef64b29..bb0a650 100755 (executable)
@@ -1,6 +1,12 @@
 set(TARGET_NAME       "wrt-plugins-tizen-1.0-tizen")
 set(DESTINATION_NAME  "tizen-1.0-tizen")
 
+pkg_search_module(wrt-plugins-plugin-manager REQUIRED wrt-plugins-plugin-manager)
+
+include_directories(
+    ${wrt-plugins-plugin-manager_INCLUDE_DIRS}
+)
+
 set(SRCS
   JSTizen.cpp
   JSFeature.cpp
@@ -12,7 +18,10 @@ set(SRCS
 
 add_library(${TARGET_NAME} SHARED ${SRCS})
 
-target_link_libraries(${TARGET_NAME} ${LIBS_COMMON} )
+target_link_libraries(${TARGET_NAME}
+    ${LIBS_WIDGETDB}
+    ${LIBS_COMMON}
+    ${wrt-plugins-plugin-manager_LIBRARIES})
 
 INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION ${DESTINATION_NAME})
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_NAME})
index ba52b48..b0f3bc1 100755 (executable)
@@ -21,7 +21,7 @@
  * @description        Reference from CalendarConverter.cpp
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/ScopedJSStringRef.h>
 #include <CommonsJavaScript/Validator.h>
 #include "FilterConverter.h"
index fae6337..cfc0323 100755 (executable)
@@ -21,7 +21,7 @@
  * @brief
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/Converter.h>
 #include "JSFeature.h"
@@ -123,8 +123,10 @@ JSValueRef JSFeature::getProperty(JSContextRef context, JSObjectRef object,
             if (priv->getObject()->isRequestedByWidget()) {
                 JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
                 if (jsResult) {
-                       WrtDeviceApis::Commons::IWidgetFeature::Params params = priv->getObject()->getParams();
-                       WrtDeviceApis::Commons::IWidgetFeature::ParamsIterator it = params.begin();
+                    WrtDeviceApis::WidgetDB::Api::IWidgetFeature::Params params =
+                        priv->getObject()->getParams();
+                    WrtDeviceApis::WidgetDB::Api::IWidgetFeature::ParamsIterator it =
+                        params.begin();
                     size_t i = 0;
                     for (; it != params.end(); ++it, ++i) {
                         std::pair<std::string, std::string> param = make_pair(it->first, it->second);
index 5afa8a5..0d93f87 100755 (executable)
 #include <string>
 #include <vector>
 #include <JavaScriptCore/JavaScript.h>
-#include <Commons/WrtWrapper/IWrtWrapper.h>
+#include <WidgetDB/IWidgetFeature.h>
 
 namespace TizenApis {
 namespace Tizen1_0 {
 namespace Tizen {
 
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<WrtDeviceApis::Commons::IWidgetFeaturePtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSFeaturePrivateObject;
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<WrtDeviceApis::WidgetDB::Api::IWidgetFeaturePtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSFeaturePrivateObject;
 
 /**
  * @class JSFeature
index fb4f54c..d90ba10 100755 (executable)
@@ -21,7 +21,7 @@
  * @brief
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include "JSFeatureParam.h"
 
index ad92400..51e7803 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include <cassert>
 #include <vector>
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/Converter.h>
 #include <Commons/WrtWrapper/IWrtWrapper.h>
@@ -34,6 +34,9 @@
 #include "JSTizen.h"
 #include "JSFeature.h"
 #include "plugin_config.h"
+#include <WidgetDB/WidgetDBMgr.h>
+#include <WidgetDB/IWidgetDB.h>
+#include <PluginManager/PluginManagerFactory.h>
 
 #include <iostream>
 
@@ -45,8 +48,10 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Tizen {
 
+using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 using namespace TizenApis::Api::Tizen;
+using namespace WrtDeviceApis::PluginManager::Api;
 
 JSClassDefinition JSTizen::m_classInfo =
 {
@@ -61,7 +66,7 @@ JSClassDefinition JSTizen::m_classInfo =
     hasProperty,
     getProperty,
     setProperty,
-    deleteProperty,
+    NULL, //deleteProperty,
     getPropertyNames,
     NULL,
     NULL,
@@ -106,7 +111,13 @@ void JSTizen::initialize(JSContextRef context, JSObjectRef object)
         return;
     }
 
-    PluginOnDemandPrivPtr privObject(new PluginOnDemandPriv(wrapper));
+    PluginOnDemandPrivPtr privObject(
+        new PluginOnDemandPriv(
+            wrapper,
+                       PluginManagerFactory::getInstance().getPluginManager(
+                           wrapper->getWidgetId(),
+                           PLUGIN_NAME,
+                           context)));
 
     priv = new TizenPrivate(context, privObject);
     if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
@@ -131,15 +142,31 @@ JSClassRef JSTizen::getClassRef()
     return m_classRef;
 }
 
-bool JSTizen::deleteProperty(JSContextRef context, JSObjectRef object,
-        JSStringRef propertyName, JSValueRef* exception)
-{
-    return true;
-}
+//bool JSTizen::deleteProperty(JSContextRef context, JSObjectRef object,
+//        JSStringRef propertyName, JSValueRef* exception)
+//{
+//    return true;
+//}
 
 void JSTizen::getPropertyNames(JSContextRef context, JSObjectRef object,
         JSPropertyNameAccumulatorRef propertyNames)
 {
+    Try
+    {
+        TizenPrivate* priv =
+            static_cast<TizenPrivate*>(JSObjectGetPrivate(object));
+        if (!priv || !priv->getObject()) {
+            LogError("No private obejct");
+            return;
+        }
+        PluginOnDemandPrivPtr privObj = priv->getObject();
+        privObj->getPluginManager()->addPropertiesToList(propertyNames);
+
+    }
+    Catch(Commons::Exception)
+    {
+        LogError("Error occured");
+    }
 }
 
 bool JSTizen::hasInstance(JSContextRef context, JSObjectRef constructor,
@@ -161,31 +188,15 @@ bool JSTizen::hasProperty(JSContextRef context,
 
     Try
     {
-        WrtDeviceApis::CommonsJavaScript::Converter converter(context);
-        std::string propName = converter.toString(propertyName);
-               LogDebug("checking property:" + propName);
-
-               TizenPrivate* priv = static_cast<TizenPrivate*>(JSObjectGetPrivate(object));
+        TizenPrivate* priv = static_cast<TizenPrivate*>(JSObjectGetPrivate(object));
 
         if (!priv || !priv->getObject()) {
             LogError("No private obejct");
             return false;
         }
-        PluginOnDemandPrivPtr privObj = priv->getObject();
-        PluginOnDemandPriv::ObjectListPtr objList = privObj->getObjectList();
-
-        if (objList->find(propName) != objList->end()) {
-            //already set so property exists
-            return true;
-        }
 
-        std::string pluginUri(PLUGIN_NAME);
-        pluginUri.append(".").append(propName);
-        if (privObj->getWrtWrapper()->isJSObjectAvailable(pluginUri)) {
-                       LogDebug(propName + " is available");
-            //property can be set
-            return true;
-        }
+        return priv->getObject()->getPluginManager()->hasChild(
+            CommonsJavaScript::Converter(context).toString(propertyName));
     }
     Catch(WrtDeviceApis::Commons::Exception)
     {
@@ -203,36 +214,15 @@ JSValueRef JSTizen::getProperty(JSContextRef context, JSObjectRef object,
 
     Try
     {
-        WrtDeviceApis::CommonsJavaScript::Converter converter(context);
-        std::string propName = converter.toString(propertyName);
-
         TizenPrivate* priv =
                 static_cast<TizenPrivate*>(JSObjectGetPrivate(object));
         if (!priv || !priv->getObject()) {
             LogError("No private obejct");
             return false;
         }
-        PluginOnDemandPrivPtr privObj = priv->getObject();
-        PluginOnDemandPriv::ObjectListPtr objList = privObj->getObjectList();
 
-        PluginOnDemandPriv::ObjectList::iterator it = objList->find(propName);
-        if (it != objList->end()) {
-            //return already set value
-            return it->second;
-        }
-
-        std::string pluginUri(PLUGIN_NAME);
-        pluginUri.append(".").append(propName);
-           LogDebug("load new object : " << pluginUri);
-        //load new plugin
-        privObj->setAllowSettingProperty(true);
-        privObj->getWrtWrapper()->loadJSObject(pluginUri);
-        privObj->setAllowSettingProperty(false);
-        it = objList->find(propName);
-        if (it != objList->end()) {
-            //return value
-            return it->second;
-        }
+        return priv->getObject()->getPluginManager()->getProperty(
+            CommonsJavaScript::Converter(context).toString(propertyName));
     }
     Catch(WrtDeviceApis::Commons::Exception)
     {
@@ -250,24 +240,15 @@ bool JSTizen::setProperty(JSContextRef context, JSObjectRef object,
     LogDebug("entered");
     Try
     {
-        WrtDeviceApis::CommonsJavaScript::Converter converter(context);
-        std::string propName = converter.toString(propertyName);
-
         TizenPrivate* priv =
                 static_cast<TizenPrivate*>(JSObjectGetPrivate(object));
         if (!priv || !priv->getObject()) {
             LogError("No private obejct");
             return false;
         }
-        PluginOnDemandPrivPtr privObj = priv->getObject();
-
-        std::string pluginUri(PLUGIN_NAME);
-        pluginUri.append(".").append(propName);
-        if (privObj->getAllowSettingProperty()) {
-                JSValueProtect(priv->getContext(), value);
-                (*privObj->getObjectList())[propName] = value;
-            return true;
-        }
+        priv->getObject()->getPluginManager()->setProperty(
+            CommonsJavaScript::Converter(context).toString(propertyName),
+            value);
     }
     Catch(WrtDeviceApis::Commons::Exception)
     {
@@ -313,7 +294,9 @@ JSValueRef JSTizen::listAvailableFeatures(JSContextRef context, JSObjectRef obje
         return WrtDeviceApis::CommonsJavaScript::JSDOMExceptionFactory::UnknownException.make(context, exception);
     }
     JSObjectRef result = JSCreateArrayObject(context, 0, NULL);
-    IWrtWrapper::Features features = wrapper->getRegisteredFeatures();
+    WidgetDB::Api::IWidgetDBPtr widgetDB =
+        WidgetDB::Api::getWidgetDB(wrapper->getWidgetId());
+    WidgetDB::Api::Features features = widgetDB->getRegisteredFeatures();
     for (size_t i=0; i<features.size(); ++i) {
         JSFeaturePrivateObject *priv = new JSFeaturePrivateObject(context, features[i]);
         JSObjectRef tempObj = JSObjectMake(context, JSFeature::getClassRef(), priv);
@@ -359,7 +342,9 @@ JSValueRef JSTizen::listActivatedFeatures(JSContextRef context, JSObjectRef obje
         return WrtDeviceApis::CommonsJavaScript::JSDOMExceptionFactory::UnknownException.make(context, exception);
     }
     JSObjectRef result = JSCreateArrayObject(context, 0, NULL);
-    IWrtWrapper::Features features = wrapper->getWidgetFeatures();
+    WidgetDB::Api::IWidgetDBPtr widgetDB =
+        WidgetDB::Api::getWidgetDB(wrapper->getWidgetId());
+    WidgetDB::Api::Features features = widgetDB->getWidgetFeatures();
     for (size_t i=0; i<features.size(); ++i) {
         JSFeaturePrivateObject *priv = new JSFeaturePrivateObject(context, features[i]);
         JSObjectRef tempObj = JSObjectMake(context, JSFeature::getClassRef(), priv);
index 3418116..5e20146 100755 (executable)
@@ -27,10 +27,14 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Tizen {
 
-PluginOnDemandPriv::PluginOnDemandPriv(const WrtDeviceApis::Commons::IWrtWrapperPtr &wrapper) :
-    m_objectList(new ObjectList()),
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::PluginManager::Api;
+
+PluginOnDemandPriv::PluginOnDemandPriv(const IWrtWrapperPtr &wrapper,
+                                       const IPluginManagerPtr &pluginManager) :
     m_wrtWrapper(wrapper),
-    m_allowSettingProperty(false)
+    m_pluginManager(pluginManager)
 {
 }
 
@@ -38,24 +42,14 @@ PluginOnDemandPriv::~PluginOnDemandPriv()
 {
 }
 
-WrtDeviceApis::Commons::IWrtWrapperPtr PluginOnDemandPriv::getWrtWrapper() const
+IWrtWrapperPtr PluginOnDemandPriv::getWrtWrapper() const
 {
     return m_wrtWrapper;
 }
 
-PluginOnDemandPriv::ObjectListPtr PluginOnDemandPriv::getObjectList() const
-{
-    return m_objectList;
-}
-
-bool PluginOnDemandPriv::getAllowSettingProperty() const
-{
-    return m_allowSettingProperty;
-}
-
-void PluginOnDemandPriv::setAllowSettingProperty(bool allowSettingProperty)
+IPluginManagerPtr PluginOnDemandPriv::getPluginManager() const
 {
-    m_allowSettingProperty = allowSettingProperty;
+    return m_pluginManager;
 }
 
 }
index 72620c9..4ae66e2 100755 (executable)
@@ -29,6 +29,7 @@
 #include <dpl/shared_ptr.h>
 #include <JavaScriptCore/JavaScript.h>
 #include <Commons/WrtWrapper/IWrtWrapper.h>
+#include <PluginManager/IPluginManager.h>
 
 namespace TizenApis {
 namespace Tizen1_0 {
@@ -37,21 +38,20 @@ namespace Tizen {
 class PluginOnDemandPriv
 {
   public:
+    PluginOnDemandPriv(
+        const WrtDeviceApis::Commons::IWrtWrapperPtr &wrapper,
+        const WrtDeviceApis::PluginManager::Api::IPluginManagerPtr &pluginManager);
 
-    typedef std::map<std::string, JSValueRef> ObjectList;
-    typedef DPL::SharedPtr<ObjectList> ObjectListPtr;
-
-    explicit PluginOnDemandPriv(const WrtDeviceApis::Commons::IWrtWrapperPtr &wrapper);
     virtual ~PluginOnDemandPriv();
+
     WrtDeviceApis::Commons::IWrtWrapperPtr getWrtWrapper() const;
-    ObjectListPtr getObjectList() const;
-    bool getAllowSettingProperty() const;
-    void setAllowSettingProperty(bool allowSettingProperty);
+
+    WrtDeviceApis::PluginManager::Api::IPluginManagerPtr getPluginManager() const;
 
   private:
-    ObjectListPtr m_objectList;
     WrtDeviceApis::Commons::IWrtWrapperPtr m_wrtWrapper;
-    bool m_allowSettingProperty;
+    WrtDeviceApis::PluginManager::Api::IPluginManagerPtr m_pluginManager;
+
 };
 
 typedef DPL::SharedPtr<PluginOnDemandPriv> PluginOnDemandPrivPtr;
index 99873c5..a2f091a 100755 (executable)
@@ -21,7 +21,7 @@
  * @brief
  */
 
-#include <dpl/log.h>
+#include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
 #include <Commons/WrtWrapper/WrtWrappersMgr.h>
 #include <Commons/Exception.h>