From 30a79e8adfad5c207259bf82b6be3af06bf0b9ec Mon Sep 17 00:00:00 2001 From: Jinkun Jang Date: Sat, 16 Mar 2013 01:21:56 +0900 Subject: [PATCH] merge with master --- AUTHORS | 1 - CMakeLists.txt | 152 +- LICENSE.APLv2 | 202 -- NOTICE | 3 - packaging/wrt-plugins-tizen.spec | 25 +- pkgconfigs/wrt-plugins-tizen-alarm.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-application.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-bluetooth.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-bookmark.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-calendar.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-callhistory.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-common.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-contact.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-content.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-datacontrol.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-datasync.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-download.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-filesystem.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-log.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-messageport.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-messaging.pc.in | 13 + .../wrt-plugins-tizen-networkbearerselection.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-nfc.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-notification.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-package.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-power.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-push.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-secureelement.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-systeminfo.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-systemsetting.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-timeutil.pc.in | 13 + pkgconfigs/wrt-plugins-tizen-tizen.pc.in | 13 + src/.project | 11 + src/Alarm/AlarmAbsolute.cpp | 125 + src/Alarm/AlarmAbsolute.h | 70 + src/Alarm/AlarmConverter.cpp | 267 ++ src/Alarm/AlarmConverter.h | 66 + src/Alarm/AlarmRelative.cpp | 101 + src/Alarm/AlarmRelative.h | 71 + src/Alarm/CMakeLists.txt | 58 + src/Alarm/JSAlarmAbsolute.cpp | 385 +++ src/Alarm/JSAlarmAbsolute.h | 89 + src/Alarm/JSAlarmManager.cpp | 585 +++++ src/Alarm/JSAlarmManager.h | 68 + src/Alarm/JSAlarmRelative.cpp | 332 +++ src/Alarm/JSAlarmRelative.h | 80 + src/Alarm/alarm_common.h | 61 + src/Alarm/config.xml | 15 + src/Alarm/plugin_config.cpp | 105 + src/Alarm/plugin_config.h | 44 + src/Alarm/plugin_initializer.cpp | 79 + src/Application/AppManagerWrapper.cpp | 306 +++ src/Application/AppManagerWrapper.h | 99 + src/Application/Application.cpp | 166 ++ src/Application/Application.h | 55 + .../ApplicationAsyncCallbackManager.cpp | 30 + src/Application/ApplicationAsyncCallbackManager.h | 46 + src/Application/ApplicationCert.cpp | 51 + src/Application/ApplicationCert.h | 53 + src/Application/ApplicationContext.cpp | 50 + src/Application/ApplicationContext.h | 54 + src/Application/ApplicationControl.cpp | 172 ++ src/Application/ApplicationControl.h | 77 + src/Application/ApplicationControlData.cpp | 54 + src/Application/ApplicationControlData.h | 54 + src/Application/ApplicationController.cpp | 541 ++++ src/Application/ApplicationController.h | 98 + src/Application/ApplicationConverter.cpp | 360 +++ src/Application/ApplicationConverter.h | 65 + src/Application/ApplicationFactory.cpp | 38 + src/Application/ApplicationFactory.h | 40 + src/Application/ApplicationInformation.cpp | 153 ++ src/Application/ApplicationInformation.h | 82 + .../ApplicationInformationEventPrivateData.h | 65 + src/Application/ApplicationListenerManager.cpp | 29 + src/Application/ApplicationListenerManager.h | 97 + src/Application/ApplicationManager.cpp | 1654 ++++++++++++ src/Application/ApplicationManager.h | 265 ++ src/Application/ApplicationUtil.cpp | 134 + src/Application/ApplicationUtil.h | 55 + src/Application/CMakeLists.txt | 94 + .../EventApplicationAddAppInfoEventListener.h | 65 + .../EventApplicationAppInfoEventListener.h | 94 + src/Application/EventApplicationFindAppControl.h | 73 + src/Application/EventApplicationGetAppCerts.h | 72 + src/Application/EventApplicationGetAppContext.h | 70 + src/Application/EventApplicationGetAppInfo.h | 70 + src/Application/EventApplicationGetAppsContext.h | 61 + src/Application/EventApplicationGetAppsInfo.h | 61 + src/Application/EventApplicationGetCurrApp.h | 57 + .../EventApplicationGetRequestedAppControl.h | 69 + src/Application/EventApplicationKill.h | 54 + src/Application/EventApplicationLaunch.h | 51 + src/Application/EventApplicationLaunchAppControl.h | 116 + .../EventApplicationRemoveAppInfoEventListener.h | 51 + src/Application/IApplicationManager.cpp | 47 + src/Application/IApplicationManager.h | 92 + src/Application/JSApplication.cpp | 249 ++ src/Application/JSApplication.h | 124 + src/Application/JSApplicationCert.cpp | 131 + src/Application/JSApplicationCert.h | 81 + src/Application/JSApplicationContext.cpp | 169 ++ src/Application/JSApplicationContext.h | 91 + src/Application/JSApplicationControl.cpp | 293 +++ src/Application/JSApplicationControl.h | 129 + src/Application/JSApplicationControlData.cpp | 226 ++ src/Application/JSApplicationControlData.h | 106 + .../JSApplicationEventCallbackManager.cpp | 247 ++ .../JSApplicationEventCallbackManager.h | 84 + src/Application/JSApplicationInformation.cpp | 210 ++ src/Application/JSApplicationInformation.h | 107 + src/Application/JSApplicationManager.cpp | 1171 +++++++++ src/Application/JSApplicationManager.h | 152 ++ src/Application/JSRequestedApplicationControl.cpp | 264 ++ src/Application/JSRequestedApplicationControl.h | 136 + src/Application/RequestedApplicationControl.cpp | 142 ++ src/Application/RequestedApplicationControl.h | 59 + src/Application/config.xml | 35 + src/Application/plugin_config.cpp | 290 +++ src/Application/plugin_config.h | 66 + src/Application/plugin_initializer.cpp | 92 + src/Bluetooth/BTDevice.h | 65 + src/Bluetooth/BluetoothAdapterListener.cpp | 370 +++ src/Bluetooth/BluetoothAdapterListener.h | 94 + src/Bluetooth/BluetoothAdapterManager.cpp | 1086 ++++++++ src/Bluetooth/BluetoothAdapterManager.h | 106 + src/Bluetooth/BluetoothCBManager.cpp | 587 +++++ src/Bluetooth/BluetoothCBManager.h | 95 + src/Bluetooth/BluetoothClass.cpp | 258 ++ src/Bluetooth/BluetoothClass.h | 68 + src/Bluetooth/BluetoothConverter.cpp | 362 +++ src/Bluetooth/BluetoothConverter.h | 60 + src/Bluetooth/BluetoothDeviceManager.cpp | 338 +++ src/Bluetooth/BluetoothDeviceManager.h | 77 + src/Bluetooth/BluetoothDeviceManagerListener.cpp | 84 + src/Bluetooth/BluetoothDeviceManagerListener.h | 56 + src/Bluetooth/BluetoothFactory.cpp | 68 + src/Bluetooth/BluetoothFactory.h | 51 + src/Bluetooth/BluetoothMultiCallback.cpp | 97 + src/Bluetooth/BluetoothMultiCallback.h | 133 + .../API => }/Bluetooth/BluetoothProperty.h | 0 src/Bluetooth/BluetoothServiceHandlerManager.cpp | 167 ++ src/Bluetooth/BluetoothServiceHandlerManager.h | 65 + src/Bluetooth/BluetoothSocketListener.cpp | 97 + src/Bluetooth/BluetoothSocketListener.h | 53 + src/Bluetooth/BluetoothSocketManager.cpp | 181 ++ src/Bluetooth/BluetoothSocketManager.h | 67 + src/Bluetooth/CMakeLists.txt | 79 + src/Bluetooth/EventBTConnectToServiceByUUID.h | 46 + src/Bluetooth/EventBTCreateDestroyBonding.cpp | 61 + src/Bluetooth/EventBTCreateDestroyBonding.h | 54 + src/Bluetooth/EventBTGetAdapter.h | 42 + src/Bluetooth/EventBTGetDevice.cpp | 46 + src/Bluetooth/EventBTGetDevice.h | 49 + src/Bluetooth/EventBTGetKnownDevices.cpp | 34 + src/Bluetooth/EventBTGetKnownDevices.h | 48 + src/Bluetooth/EventBTOnDiscoveryDevices.cpp | 49 + src/Bluetooth/EventBTOnDiscoveryDevices.h | 59 + src/Bluetooth/EventBTRegisterRFCOMM.h | 54 + src/Bluetooth/EventBTServiceOnConnect.cpp | 50 + src/Bluetooth/EventBTServiceOnConnect.h | 58 + src/Bluetooth/EventBTSetName.h | 49 + src/Bluetooth/EventBTSetPowered.h | 53 + src/Bluetooth/EventBTSetVisible.h | 49 + src/Bluetooth/EventBTSocketNotification.cpp | 61 + src/Bluetooth/EventBTSocketNotification.h | 66 + src/Bluetooth/EventBTStopDiscovery.h | 44 + src/Bluetooth/EventBTUnregisterRFCOMM.h | 41 + src/Bluetooth/IBluetoothAdapterManager.cpp | 50 + src/Bluetooth/IBluetoothAdapterManager.h | 84 + src/Bluetooth/IBluetoothDeviceManager.cpp | 38 + src/Bluetooth/IBluetoothDeviceManager.h | 64 + src/Bluetooth/IBluetoothServiceHandlerManager.cpp | 38 + src/Bluetooth/IBluetoothServiceHandlerManager.h | 53 + src/Bluetooth/IBluetoothSocketManager.cpp | 34 + src/Bluetooth/IBluetoothSocketManager.h | 54 + src/Bluetooth/JSBluetoothAdapter.cpp | 1390 +++++++++++ src/Bluetooth/JSBluetoothAdapter.h | 151 ++ src/Bluetooth/JSBluetoothClass.cpp | 309 +++ src/Bluetooth/JSBluetoothClass.h | 70 + src/Bluetooth/JSBluetoothClassDeviceMajor.cpp | 181 ++ src/Bluetooth/JSBluetoothClassDeviceMajor.h | 59 + src/Bluetooth/JSBluetoothClassDeviceMinor.cpp | 244 ++ src/Bluetooth/JSBluetoothClassDeviceMinor.h | 58 + src/Bluetooth/JSBluetoothClassDeviceService.cpp | 181 ++ src/Bluetooth/JSBluetoothClassDeviceService.h | 57 + src/Bluetooth/JSBluetoothDevice.cpp | 504 ++++ src/Bluetooth/JSBluetoothDevice.h | 67 + src/Bluetooth/JSBluetoothManager.cpp | 234 ++ src/Bluetooth/JSBluetoothManager.h | 58 + src/Bluetooth/JSBluetoothServiceHandler.cpp | 409 +++ src/Bluetooth/JSBluetoothServiceHandler.h | 63 + src/Bluetooth/JSBluetoothSocket.cpp | 502 ++++ src/Bluetooth/JSBluetoothSocket.h | 95 + src/Bluetooth/config.xml | 26 + src/Bluetooth/plugin_config.cpp | 166 ++ src/Bluetooth/plugin_config.h | 59 + src/Bluetooth/plugin_initializer.cpp | 73 + src/Bookmark/BookmarkData.h | 47 + src/Bookmark/BookmarkManager.cpp | 264 ++ src/Bookmark/BookmarkManager.h | 79 + src/Bookmark/CMakeLists.txt | 47 + src/Bookmark/JSBookmarkFolder.cpp | 180 ++ src/Bookmark/JSBookmarkFolder.h | 58 + src/Bookmark/JSBookmarkItem.cpp | 166 ++ src/Bookmark/JSBookmarkItem.h | 57 + src/Bookmark/JSBookmarkManager.cpp | 244 ++ src/Bookmark/JSBookmarkManager.h | 60 + src/Bookmark/config.xml | 19 + src/Bookmark/plugin_config.cpp | 109 + src/Bookmark/plugin_config.h | 39 + src/Bookmark/plugin_initializer.cpp | 105 + src/CMakeLists.txt | 76 +- src/Calendar/CMakeLists.txt | 87 + src/Calendar/Calendar.cpp | 1324 ++++++++++ src/Calendar/Calendar.h | 53 + src/Calendar/CalendarAsyncCallbackManager.cpp | 23 + src/Calendar/CalendarAsyncCallbackManager.h | 47 + src/Calendar/CalendarConverter.cpp | 1017 ++++++++ src/Calendar/CalendarConverter.h | 111 + src/Calendar/CalendarEvent.cpp | 503 ++++ src/Calendar/CalendarEvent.h | 237 ++ src/Calendar/CalendarFactory.cpp | 47 + src/Calendar/CalendarFactory.h | 45 + src/Calendar/CalendarFilter.cpp | 607 +++++ src/Calendar/CalendarFilter.h | 112 + src/Calendar/CalendarFilterValidator.cpp | 64 + src/Calendar/CalendarFilterValidator.h | 41 + src/Calendar/CalendarListenerManager.cpp | 23 + src/Calendar/CalendarListenerManager.h | 89 + src/Calendar/CalendarManager.cpp | 344 +++ src/Calendar/CalendarManager.h | 49 + src/Calendar/CalendarMultiCallback.h | 128 + src/Calendar/CalendarResponseDispatcher.cpp | 337 +++ src/Calendar/CalendarResponseDispatcher.h | 77 + src/Calendar/CalendarUtility.cpp | 133 + src/Calendar/CalendarUtility.h | 40 + src/Calendar/EventAlarm.cpp | 82 + src/Calendar/EventAlarm.h | 75 + src/Calendar/EventAttendee.cpp | 148 ++ src/Calendar/EventAttendee.h | 121 + src/Calendar/EventId.cpp | 66 + src/Calendar/EventId.h | 60 + src/Calendar/EventRecurrenceRule.cpp | 155 ++ src/Calendar/EventRecurrenceRule.h | 109 + src/Calendar/EventWrapper.cpp | 2349 +++++++++++++++++ src/Calendar/EventWrapper.h | 119 + src/Calendar/ICalendar.cpp | 118 + src/Calendar/ICalendar.h | 162 ++ src/Calendar/ICalendarManager.cpp | 58 + src/Calendar/ICalendarManager.h | 56 + src/Calendar/IEventAddEvent.h | 66 + src/Calendar/IEventAddEvents.h | 78 + src/Calendar/IEventClearWatch.h | 68 + src/Calendar/IEventCreateEventFromString.h | 90 + src/Calendar/IEventDeleteEvent.h | 68 + src/Calendar/IEventDeleteEvents.h | 68 + src/Calendar/IEventExpandEventRecurrence.h | 102 + src/Calendar/IEventExportEventToString.h | 88 + src/Calendar/IEventFindEvents.h | 143 ++ src/Calendar/IEventGet.h | 77 + src/Calendar/IEventGetCalendar.h | 89 + src/Calendar/IEventGetCalendars.h | 76 + src/Calendar/IEventGetDefaultCalendar.h | 77 + src/Calendar/IEventGetUnifiedCalendar.h | 77 + src/Calendar/IEventUpdateEvent.h | 79 + src/Calendar/IEventUpdateEvents.h | 78 + src/Calendar/IEventWatchChanges.h | 89 + src/Calendar/JSCalendar.cpp | 1165 +++++++++ src/Calendar/JSCalendar.h | 206 ++ src/Calendar/JSCalendarAlarm.cpp | 311 +++ src/Calendar/JSCalendarAlarm.h | 108 + src/Calendar/JSCalendarAttendee.cpp | 335 +++ src/Calendar/JSCalendarAttendee.h | 118 + src/Calendar/JSCalendarEvent.cpp | 425 ++++ src/Calendar/JSCalendarEvent.h | 132 + src/Calendar/JSCalendarEventId.cpp | 267 ++ src/Calendar/JSCalendarEventId.h | 107 + src/Calendar/JSCalendarItemProperties.cpp | 1422 +++++++++++ src/Calendar/JSCalendarItemProperties.h | 328 +++ src/Calendar/JSCalendarManager.cpp | 419 ++++ src/Calendar/JSCalendarManager.h | 173 ++ src/Calendar/JSCalendarRecurrenceRule.cpp | 338 +++ src/Calendar/JSCalendarRecurrenceRule.h | 118 + src/Calendar/JSCalendarTask.cpp | 280 +++ src/Calendar/JSCalendarTask.h | 115 + src/Calendar/JSNumberArray.cpp | 600 +++++ src/Calendar/JSNumberArray.h | 181 ++ src/Calendar/JSStringArray.cpp | 595 +++++ src/Calendar/JSStringArray.h | 180 ++ src/Calendar/JSTZDateArray.cpp | 611 +++++ src/Calendar/JSTZDateArray.h | 181 ++ src/Calendar/OnEventsChanged.h | 96 + src/Calendar/config.xml | 20 + src/Calendar/plugin_config.cpp | 267 ++ src/Calendar/plugin_config.h | 58 + src/Calendar/plugin_initializer.cpp | 115 + src/Callhistory/CMakeLists.txt | 74 + src/Callhistory/CallHistory.cpp | 880 +++++++ src/Callhistory/CallHistory.h | 160 ++ .../CallHistoryAsyncCallbackManager.cpp | 29 + src/Callhistory/CallHistoryAsyncCallbackManager.h | 46 + src/Callhistory/CallHistoryDefine.h | 69 + src/Callhistory/CallHistoryEntry.cpp | 89 + src/Callhistory/CallHistoryEntry.h | 44 + src/Callhistory/CallHistoryEntryProperties.cpp | 183 ++ src/Callhistory/CallHistoryEntryProperties.h | 91 + src/Callhistory/CallHistoryFactory.cpp | 49 + src/Callhistory/CallHistoryFactory.h | 43 + src/Callhistory/CallHistoryFilter.cpp | 301 +++ src/Callhistory/CallHistoryFilter.h | 66 + src/Callhistory/CallHistoryListenerManager.cpp | 29 + src/Callhistory/CallHistoryListenerManager.h | 79 + src/Callhistory/CallHistoryMultiCallback.cpp | 42 + src/Callhistory/CallHistoryMultiCallback.h | 61 + src/Callhistory/CallHistoryStaticController.cpp | 79 + src/Callhistory/CallHistoryStaticController.h | 43 + src/Callhistory/Converter.cpp | 265 ++ src/Callhistory/Converter.h | 72 + src/Callhistory/EventCallHistory.h | 49 + src/Callhistory/EventCallHistoryListener.cpp | 48 + src/Callhistory/EventCallHistoryListener.h | 59 + src/Callhistory/EventCallHistoryTemplate.h | 49 + src/Callhistory/EventFindCallHistory.cpp | 112 + src/Callhistory/EventFindCallHistory.h | 69 + src/Callhistory/EventRemoveAll.h | 38 + src/Callhistory/EventRemoveBatch.h | 46 + src/Callhistory/ICallHistory.cpp | 39 + src/Callhistory/ICallHistory.h | 64 + src/Callhistory/ICallHistoryEntry.cpp | 35 + src/Callhistory/ICallHistoryEntry.h | 42 + src/Callhistory/JSCallHistory.cpp | 532 ++++ src/Callhistory/JSCallHistory.h | 93 + src/Callhistory/JSCallHistoryEntry.cpp | 226 ++ src/Callhistory/JSCallHistoryEntry.h | 75 + src/Callhistory/JSRemoteParty.cpp | 157 ++ src/Callhistory/JSRemoteParty.h | 69 + src/Callhistory/RemoteParty.h | 53 + src/Callhistory/ResponseDispatcher.cpp | 127 + src/Callhistory/ResponseDispatcher.h | 50 + src/Callhistory/config.xml | 20 + src/Callhistory/plugin_config.cpp | 128 + src/Callhistory/plugin_config.h | 50 + src/Callhistory/plugin_initializer.cpp | 75 + src/Common/ArgumentValidationChecker.cpp | 139 ++ src/Common/ArgumentValidationChecker.h | 82 + src/Common/ArgumentValidator.cpp | 243 ++ src/Common/ArgumentValidator.h | 65 + src/Common/AsyncCallbackManager.h | 96 + src/Common/CMakeLists.txt | 30 + src/Common/CallbackUserData.cpp | 94 + src/Common/CallbackUserData.h | 53 + src/Common/GlobalContextManager.cpp | 92 + src/Common/GlobalContextManager.h | 78 + src/Common/IListenerManager.h | 155 ++ src/Common/JSTizenException.cpp | 144 ++ src/Common/JSTizenException.h | 96 + src/Common/JSTizenExceptionFactory.cpp | 55 + src/Common/JSTizenExceptionFactory.h | 43 + src/Common/JSUtil.cpp | 205 ++ src/Common/JSUtil.h | 381 +++ src/Common/JSWebAPIError.cpp | 331 +++ src/Common/JSWebAPIError.h | 115 + src/Common/JSWebAPIError2.cpp | 272 ++ src/Common/JSWebAPIError2.h | 95 + src/Common/JSWebAPIErrorFactory.cpp | 266 ++ src/Common/JSWebAPIErrorFactory.h | 97 + src/Common/Logger.h | 55 + src/Common/MultiCallbackUserData.cpp | 95 + src/Common/MultiCallbackUserData.h | 51 + src/Common/PlatformException.cpp | 130 + src/Common/PlatformException.h | 103 + src/Common/SecurityExceptions.h | 70 + src/Common/StandaloneConsole/CMakeLists.txt | 24 + src/Common/StandaloneConsole/JSConsole.cpp | 134 + src/Common/StandaloneConsole/JSConsole.h | 53 + src/Common/StandaloneConsole/StandaloneConsole.cpp | 403 +++ src/Common/StandaloneConsole/StandaloneConsole.h | 68 + src/Common/TizenExceptionData.cpp | 41 + src/Common/TizenExceptionData.h | 47 + src/Common/WebAPIError.cpp | 49 + src/Common/WebAPIError.h | 47 + src/Contact/AddressBook.cpp | 1910 ++++++++++++++ src/Contact/AddressBook.h | 171 ++ src/Contact/AddressBookController.cpp | 481 ++++ src/Contact/AddressBookController.h | 88 + src/Contact/CMakeLists.txt | 128 + src/Contact/Contact.cpp | 128 + src/Contact/Contact.h | 56 + src/Contact/ContactAddress.cpp | 340 +++ src/Contact/ContactAddress.h | 128 + src/Contact/ContactAnniversary.cpp | 108 + src/Contact/ContactAnniversary.h | 73 + src/Contact/ContactAsyncCallbackManager.cpp | 36 + src/Contact/ContactAsyncCallbackManager.h | 53 + src/Contact/ContactConverter.cpp | 1424 +++++++++++ src/Contact/ContactConverter.h | 185 ++ src/Contact/ContactEmailAddress.cpp | 126 + src/Contact/ContactEmailAddress.h | 81 + src/Contact/ContactFactory.cpp | 59 + src/Contact/ContactFactory.h | 53 + src/Contact/ContactFilterValidator.cpp | 87 + src/Contact/ContactFilterValidator.h | 47 + src/Contact/ContactGroup.cpp | 245 ++ src/Contact/ContactGroup.h | 110 + src/{platform/Tizen => }/Contact/ContactImpl.h | 0 src/Contact/ContactListenerManager.cpp | 36 + src/Contact/ContactListenerManager.h | 135 + src/Contact/ContactManager.cpp | 980 ++++++++ src/Contact/ContactManager.h | 135 + src/Contact/ContactManagerController.cpp | 473 ++++ src/Contact/ContactManagerController.h | 88 + src/Contact/ContactName.cpp | 320 +++ src/Contact/ContactName.h | 128 + src/Contact/ContactObjectA2PConverter.cpp | 1611 ++++++++++++ src/Contact/ContactObjectA2PConverter.h | 90 + src/Contact/ContactObjectP2AConverter.cpp | 842 +++++++ src/Contact/ContactObjectP2AConverter.h | 73 + src/Contact/ContactOrganization.cpp | 194 ++ src/Contact/ContactOrganization.h | 95 + src/Contact/ContactPhoneNumber.cpp | 131 + src/Contact/ContactPhoneNumber.h | 82 + src/Contact/ContactQueue.cpp | 247 ++ src/Contact/ContactQueue.h | 95 + src/Contact/ContactRef.cpp | 111 + src/Contact/ContactRef.h | 73 + src/Contact/ContactSearchEngine.cpp | 1132 +++++++++ src/Contact/ContactSearchEngine.h | 150 ++ src/Contact/ContactTypes.h | 91 + src/Contact/ContactUtility.cpp | 174 ++ src/Contact/ContactUtility.h | 60 + src/Contact/ContactWebSite.cpp | 107 + src/Contact/ContactWebSite.h | 72 + src/Contact/ContactsSvcChangeListenerManager.cpp | 633 +++++ src/Contact/ContactsSvcChangeListenerManager.h | 134 + src/Contact/ContactsSvcObjectConverter.cpp | 595 +++++ src/Contact/ContactsSvcObjectConverter.h | 57 + src/Contact/ContactsSvcWrapper.cpp | 285 +++ src/Contact/ContactsSvcWrapper.h | 68 + src/Contact/EventAddressBookAdd.h | 94 + src/Contact/EventAddressBookAddBatch.h | 94 + src/Contact/EventAddressBookAddChangeListener.h | 117 + src/Contact/EventAddressBookAddGroup.h | 94 + src/Contact/EventAddressBookChangeListener.h | 249 ++ src/Contact/EventAddressBookFind.h | 137 + src/Contact/EventAddressBookGet.h | 116 + src/Contact/EventAddressBookGetGroup.h | 116 + src/Contact/EventAddressBookGetGroups.h | 95 + src/Contact/EventAddressBookRemove.h | 93 + src/Contact/EventAddressBookRemoveBatch.h | 93 + src/Contact/EventAddressBookRemoveChangeListener.h | 96 + src/Contact/EventAddressBookRemoveGroup.h | 93 + src/Contact/EventAddressBookUpdate.h | 94 + src/Contact/EventAddressBookUpdateBatch.h | 94 + src/Contact/EventAddressBookUpdateGroup.h | 95 + src/Contact/EventContactManagerAddChangeListener.h | 117 + src/Contact/EventContactManagerChangeListener.h | 227 ++ src/Contact/EventContactManagerFind.h | 137 + src/Contact/EventContactManagerGet.h | 116 + src/Contact/EventContactManagerGetAddressBook.h | 116 + src/Contact/EventContactManagerGetAddressBooks.h | 94 + .../EventContactManagerGetDefaultAddressBook.h | 94 + .../EventContactManagerGetUnifiedAddressBook.h | 94 + src/Contact/EventContactManagerRemove.h | 93 + src/Contact/EventContactManagerRemoveBatch.h | 93 + .../EventContactManagerRemoveChangeListener.h | 96 + src/Contact/EventContactManagerUpdate.h | 94 + src/Contact/EventContactManagerUpdateBatch.h | 94 + src/Contact/EventPersonLink.h | 93 + src/Contact/EventPersonUnlink.h | 119 + src/Contact/IAddressBook.cpp | 152 ++ src/Contact/IAddressBook.h | 127 + src/Contact/IContact.cpp | 695 ++++++ src/Contact/IContact.h | 212 ++ src/Contact/IContactEventPrivateData.h | 46 + src/Contact/IContactManager.cpp | 129 + src/Contact/IContactManager.h | 97 + src/Contact/IPerson.cpp | 324 +++ src/Contact/IPerson.h | 140 ++ src/Contact/JSAddressBook.cpp | 1684 +++++++++++++ src/Contact/JSAddressBook.h | 200 ++ src/Contact/JSAddressBookArray.cpp | 630 +++++ src/Contact/JSAddressBookArray.h | 190 ++ src/Contact/JSAddressBookChangeCallbackManager.cpp | 254 ++ src/Contact/JSAddressBookChangeCallbackManager.h | 91 + src/Contact/JSAttributesOfInterestArray.cpp | 618 +++++ src/Contact/JSAttributesOfInterestArray.h | 185 ++ src/Contact/JSContact.cpp | 1083 ++++++++ src/Contact/JSContact.h | 269 ++ src/Contact/JSContactAddress.cpp | 623 +++++ src/Contact/JSContactAddress.h | 187 ++ src/Contact/JSContactAddressArray.cpp | 630 +++++ src/Contact/JSContactAddressArray.h | 189 ++ src/Contact/JSContactAddressTypeArray.cpp | 630 +++++ src/Contact/JSContactAddressTypeArray.h | 191 ++ src/Contact/JSContactAnniversary.cpp | 326 +++ src/Contact/JSContactAnniversary.h | 120 + src/Contact/JSContactAnniversaryArray.cpp | 630 +++++ src/Contact/JSContactAnniversaryArray.h | 190 ++ src/Contact/JSContactArray.cpp | 630 +++++ src/Contact/JSContactArray.h | 190 ++ src/Contact/JSContactEmailAddress.cpp | 390 +++ src/Contact/JSContactEmailAddress.h | 131 + src/Contact/JSContactEmailAddressArray.cpp | 630 +++++ src/Contact/JSContactEmailAddressArray.h | 190 ++ src/Contact/JSContactEmailAddressTypeArray.cpp | 625 +++++ src/Contact/JSContactEmailAddressTypeArray.h | 191 ++ src/Contact/JSContactGroup.cpp | 500 ++++ src/Contact/JSContactGroup.h | 159 ++ src/Contact/JSContactGroupArray.cpp | 630 +++++ src/Contact/JSContactGroupArray.h | 190 ++ src/Contact/JSContactManager.cpp | 1270 ++++++++++ src/Contact/JSContactManager.h | 174 ++ .../JSContactManagerChangeCallbackManager.cpp | 254 ++ .../JSContactManagerChangeCallbackManager.h | 91 + src/Contact/JSContactName.cpp | 687 +++++ src/Contact/JSContactName.h | 203 ++ src/Contact/JSContactOrganization.cpp | 496 ++++ src/Contact/JSContactOrganization.h | 164 ++ src/Contact/JSContactOrganizationArray.cpp | 629 +++++ src/Contact/JSContactOrganizationArray.h | 190 ++ src/Contact/JSContactPhoneNumber.cpp | 391 +++ src/Contact/JSContactPhoneNumber.h | 131 + src/Contact/JSContactPhoneNumberArray.cpp | 630 +++++ src/Contact/JSContactPhoneNumberArray.h | 190 ++ src/Contact/JSContactPhoneNumberTypeArray.cpp | 624 +++++ src/Contact/JSContactPhoneNumberTypeArray.h | 191 ++ src/Contact/JSContactRef.cpp | 321 +++ src/Contact/JSContactRef.h | 121 + src/Contact/JSContactWebSite.cpp | 327 +++ src/Contact/JSContactWebSite.h | 121 + src/Contact/JSContactWebSiteArray.cpp | 630 +++++ src/Contact/JSContactWebSiteArray.h | 190 ++ src/Contact/JSPerson.cpp | 730 ++++++ src/Contact/JSPerson.h | 175 ++ src/Contact/JSPersonArray.cpp | 636 +++++ src/Contact/JSPersonArray.h | 190 ++ src/Contact/JSStringArray.cpp | 600 +++++ src/Contact/JSStringArray.h | 187 ++ src/Contact/Person.cpp | 270 ++ src/Contact/Person.h | 60 + src/Contact/PersonFilterValidator.cpp | 54 + src/Contact/PersonFilterValidator.h | 47 + src/Contact/PersonSearchEngine.cpp | 454 ++++ src/Contact/PersonSearchEngine.h | 89 + src/Contact/config.xml | 19 + src/Contact/plugin_config.cpp | 403 +++ src/Contact/plugin_config.h | 68 + src/Contact/plugin_initializer.cpp | 135 + src/Content/AudioLyrics.cpp | 67 + src/Content/AudioLyrics.h | 65 + src/Content/AudioLyricsUtil.cpp | 147 ++ src/Content/AudioLyricsUtil.h | 44 + src/Content/CMakeLists.txt | 73 + src/Content/ContentAsyncCallbackManager.cpp | 29 + src/Content/ContentAsyncCallbackManager.h | 51 + src/Content/ContentAudio.cpp | 204 ++ src/Content/ContentAudio.h | 120 + src/Content/ContentController.cpp | 161 ++ src/Content/ContentController.h | 57 + src/Content/ContentConverter.cpp | 133 + src/Content/ContentConverter.h | 73 + src/Content/ContentFactory.cpp | 40 + src/Content/ContentFactory.h | 41 + src/Content/ContentFilterValidator.cpp | 80 + src/Content/ContentFilterValidator.h | 52 + src/Content/ContentFolder.cpp | 141 ++ src/Content/ContentFolder.h | 87 + src/Content/ContentImage.cpp | 127 + src/Content/ContentImage.h | 83 + src/Content/ContentListener.cpp | 143 ++ src/Content/ContentListener.h | 47 + src/Content/ContentManager.cpp | 1329 ++++++++++ src/Content/ContentManager.h | 83 + src/Content/ContentMedia.cpp | 242 ++ src/Content/ContentMedia.h | 129 + src/Content/ContentSearchVisitor.cpp | 329 +++ src/Content/ContentSearchVisitor.h | 103 + src/Content/ContentUtility.cpp | 61 + src/Content/ContentUtility.h | 41 + src/Content/ContentVideo.cpp | 162 ++ src/Content/ContentVideo.h | 88 + src/Content/IContentManager.cpp | 333 +++ src/Content/IContentManager.h | 77 + src/Content/IEventFind.h | 193 ++ src/Content/IEventFindMedia.h | 162 ++ src/Content/IEventGetDirectories.h | 161 ++ src/Content/IEventUpdate.h | 72 + src/Content/IEventUpdateBatch.h | 71 + src/Content/JSAudio.cpp | 648 +++++ src/Content/JSAudio.h | 199 ++ src/Content/JSAudioLyrics.cpp | 249 ++ src/Content/JSAudioLyrics.h | 111 + src/Content/JSContent.cpp | 562 +++++ src/Content/JSContent.h | 188 ++ src/Content/JSContentManager.cpp | 903 +++++++ src/Content/JSContentManager.h | 166 ++ src/Content/JSFolder.cpp | 297 +++ src/Content/JSFolder.h | 128 + src/Content/JSImage.cpp | 293 +++ src/Content/JSImage.h | 136 + src/Content/JSVideo.cpp | 388 +++ src/Content/JSVideo.h | 165 ++ src/Content/config.xml | 20 + src/Content/plugin_config.cpp | 177 ++ src/Content/plugin_config.h | 53 + src/Content/plugin_initializer.cpp | 91 + src/DataControl/CMakeLists.txt | 60 + .../DataControlAsyncCallbackManager.cpp | 24 + src/DataControl/DataControlAsyncCallbackManager.h | 46 + src/DataControl/DataControlConverter.cpp | 146 ++ src/DataControl/DataControlConverter.h | 47 + src/DataControl/DataControlErrorObject.h | 58 + src/DataControl/DataControlFactory.cpp | 58 + src/DataControl/DataControlFactory.h | 52 + src/DataControl/DataControlListener.cpp | 319 +++ src/DataControl/DataControlListener.h | 94 + src/DataControl/DataType.h | 57 + src/DataControl/EventAddValue.h | 57 + src/DataControl/EventDelete.h | 55 + src/DataControl/EventGetIndexedRow.h | 53 + src/DataControl/EventGetValue.h | 58 + src/DataControl/EventInsert.h | 55 + src/DataControl/EventRemoveValue.h | 55 + src/DataControl/EventSelect.h | 77 + src/DataControl/EventUpdate.h | 58 + src/DataControl/EventUpdateValue.h | 60 + src/DataControl/IMappedDataControlConsumer.cpp | 41 + src/DataControl/IMappedDataControlConsumer.h | 72 + src/DataControl/ISelectDataObject.cpp | 36 + src/DataControl/ISelectDataObject.h | 50 + src/DataControl/ISqlDataControlConsumer.cpp | 40 + src/DataControl/ISqlDataControlConsumer.h | 72 + src/DataControl/JSDataControlManager.cpp | 204 ++ src/DataControl/JSDataControlManager.h | 59 + src/DataControl/JSMappedDataControlConsumer.cpp | 523 ++++ src/DataControl/JSMappedDataControlConsumer.h | 82 + src/DataControl/JSSQLDataControlConsumer.cpp | 542 ++++ src/DataControl/JSSQLDataControlConsumer.h | 82 + src/DataControl/JSSelectObjectArrayValues.cpp | 474 ++++ src/DataControl/JSSelectObjectArrayValues.h | 177 ++ src/DataControl/MappedDataControlConsumer.cpp | 904 +++++++ src/DataControl/MappedDataControlConsumer.h | 168 ++ src/DataControl/RowData.h | 67 + src/DataControl/SelectDataObject.cpp | 295 +++ src/DataControl/SelectDataObject.h | 70 + src/DataControl/SqlDataControlConsumer.cpp | 1007 ++++++++ src/DataControl/SqlDataControlConsumer.h | 165 ++ src/DataControl/config.xml | 14 + src/DataControl/plugin_config.cpp | 78 + src/DataControl/plugin_config.h | 38 + src/DataControl/plugin_initializer.cpp | 80 + src/DataSync/CMakeLists.txt | 64 + src/DataSync/DataSyncConverter.cpp | 273 ++ src/DataSync/DataSyncConverter.h | 72 + src/DataSync/DataSyncListenerManager.cpp | 23 + src/DataSync/DataSyncListenerManager.h | 88 + src/DataSync/DataSyncManager.cpp | 1109 +++++++++ src/DataSync/DataSyncManager.h | 57 + src/DataSync/DataSyncMultiCallback.h | 73 + src/DataSync/DataSyncResponseDispatcher.cpp | 104 + src/DataSync/DataSyncResponseDispatcher.h | 48 + src/DataSync/IDataSyncManager.cpp | 94 + src/DataSync/IDataSyncManager.h | 81 + src/DataSync/IEventAddProfile.h | 67 + src/DataSync/IEventGetAllProfiles.h | 68 + src/DataSync/IEventGetLastSyncStatistics.h | 80 + src/DataSync/IEventGetMaxProfilesNum.h | 66 + src/DataSync/IEventGetProfile.h | 81 + src/DataSync/IEventGetProfilesNum.h | 66 + src/DataSync/IEventRemoveProfile.h | 68 + src/DataSync/IEventStartSync.h | 80 + src/DataSync/IEventStopSync.h | 68 + src/DataSync/IEventUpdateProfile.h | 68 + src/DataSync/JSDataSyncManager.cpp | 890 +++++++ src/DataSync/JSDataSyncManager.h | 209 ++ src/DataSync/JSSyncInfo.cpp | 301 +++ src/DataSync/JSSyncInfo.h | 106 + src/DataSync/JSSyncProfileInfo.cpp | 272 ++ src/DataSync/JSSyncProfileInfo.h | 104 + src/DataSync/JSSyncServiceInfo.cpp | 286 +++ src/DataSync/JSSyncServiceInfo.h | 105 + src/DataSync/JSSyncStatistics.cpp | 205 ++ src/DataSync/JSSyncStatistics.h | 96 + src/DataSync/OnDataSyncStateChanged.h | 136 + src/DataSync/SyncInfo.cpp | 109 + src/DataSync/SyncInfo.h | 100 + src/DataSync/SyncProfileInfo.cpp | 85 + src/DataSync/SyncProfileInfo.h | 67 + src/DataSync/SyncServiceInfo.cpp | 97 + src/DataSync/SyncServiceInfo.h | 74 + src/DataSync/SyncStatistics.cpp | 170 ++ src/DataSync/SyncStatistics.h | 104 + src/DataSync/config.xml | 15 + src/DataSync/plugin_config.cpp | 180 ++ src/DataSync/plugin_config.h | 49 + src/DataSync/plugin_initializer.cpp | 98 + src/Download/CMakeLists.txt | 56 + src/Download/DownloadCallback.cpp | 161 ++ src/Download/DownloadCallback.h | 50 + src/Download/DownloadManager.cpp | 614 +++++ src/Download/DownloadManager.h | 61 + src/Download/DownloadRequest.cpp | 75 + src/Download/DownloadRequest.h | 51 + src/Download/DownloadState.h | 34 + src/Download/JSDownloadManager.cpp | 376 +++ src/Download/JSDownloadManager.h | 151 ++ src/Download/JSDownloadRequest.cpp | 196 ++ src/Download/JSDownloadRequest.h | 83 + src/Download/config.xml | 15 + src/Download/plugin_config.cpp | 80 + src/Download/plugin_config.h | 47 + src/Download/plugin_initializer.cpp | 97 + src/Filesystem/CMakeLists.txt | 95 + src/Filesystem/Converter.cpp | 293 +++ src/Filesystem/Converter.h | 77 + src/Filesystem/Encodings.cpp | 30 + src/Filesystem/Encodings.h | 33 + src/Filesystem/Enums.h | 112 + src/Filesystem/EventCopy.cpp | 64 + src/Filesystem/EventCopy.h | 88 + src/Filesystem/EventCreate.cpp | 54 + src/Filesystem/EventCreate.h | 75 + src/Filesystem/EventFind.cpp | 61 + src/Filesystem/EventFind.h | 89 + src/Filesystem/EventGetNodeData.cpp | 41 + src/Filesystem/EventGetNodeData.h | 47 + src/Filesystem/EventGetStorage.cpp | 48 + src/Filesystem/EventGetStorage.h | 47 + src/Filesystem/EventListNodes.cpp | 58 + src/Filesystem/EventListNodes.h | 79 + src/Filesystem/EventListStorages.cpp | 38 + src/Filesystem/EventListStorages.h | 44 + src/Filesystem/EventMove.cpp | 64 + src/Filesystem/EventMove.h | 88 + src/Filesystem/EventOpen.cpp | 54 + src/Filesystem/EventOpen.h | 68 + src/Filesystem/EventReadText.cpp | 44 + src/Filesystem/EventReadText.h | 55 + src/Filesystem/EventRemove.cpp | 46 + src/Filesystem/EventRemove.h | 66 + src/Filesystem/EventResolve.cpp | 42 + src/Filesystem/EventResolve.h | 67 + src/Filesystem/EventStorageStateChanged.h | 51 + src/Filesystem/EventStoragestateChanged.cpp | 38 + src/Filesystem/FilesystemAsyncCallbackManager.cpp | 23 + src/Filesystem/FilesystemAsyncCallbackManager.h | 46 + src/Filesystem/FilesystemListenerManager.cpp | 23 + src/Filesystem/FilesystemListenerManager.h | 74 + src/Filesystem/FilesystemUtils.cpp | 218 ++ src/Filesystem/FilesystemUtils.h | 40 + src/Filesystem/IManager.cpp | 49 + src/Filesystem/IManager.h | 174 ++ src/Filesystem/INode.cpp | 37 + src/Filesystem/INode.h | 186 ++ src/Filesystem/INodeTypes.h | 36 + src/Filesystem/IPath.cpp | 38 + src/Filesystem/IPath.h | 157 ++ src/Filesystem/IStream.cpp | 27 + src/Filesystem/IStream.h | 129 + src/Filesystem/JSFile.cpp | 1140 +++++++++ src/Filesystem/JSFile.h | 286 +++ src/Filesystem/JSFilestream.cpp | 474 ++++ src/Filesystem/JSFilestream.h | 172 ++ src/Filesystem/JSFilesystemManager.cpp | 499 ++++ src/Filesystem/JSFilesystemManager.h | 124 + src/Filesystem/JSStorage.cpp | 169 ++ src/Filesystem/JSStorage.h | 100 + src/Filesystem/Manager.cpp | 910 +++++++ src/Filesystem/Manager.h | 188 ++ src/Filesystem/Node.cpp | 567 +++++ src/Filesystem/Node.h | 115 + src/Filesystem/NodeFilter.cpp | 108 + src/Filesystem/NodeFilter.h | 77 + src/Filesystem/NodeFilterMatcher.cpp | 75 + src/Filesystem/NodeFilterMatcher.h | 50 + src/Filesystem/Path.cpp | 120 + src/Filesystem/Path.h | 68 + src/Filesystem/PathUtils.cpp | 37 + src/Filesystem/PathUtils.h | 42 + src/Filesystem/ResponseDispatcher.cpp | 311 +++ src/Filesystem/ResponseDispatcher.h | 67 + src/Filesystem/StorageProperties.cpp | 82 + src/Filesystem/StorageProperties.h | 70 + src/Filesystem/StorageStaticController.cpp | 66 + src/Filesystem/StorageStaticController.h | 44 + src/Filesystem/Stream.cpp | 318 +++ src/Filesystem/Stream.h | 107 + src/Filesystem/Utils.cpp | 101 + src/Filesystem/Utils.h | 34 + src/Filesystem/config.xml | 20 + src/Filesystem/plugin_config.cpp | 437 ++++ src/Filesystem/plugin_config.h | 150 ++ src/Filesystem/plugin_initializer.cpp | 76 + src/Log/CMakeLists.txt | 30 + src/Log/JSTizenLog.cpp | 164 ++ src/Log/JSTizenLog.h | 114 + src/Log/config.xml | 23 + src/Log/plugin_initializer.cpp | 39 + src/MessagePort/CMakeLists.txt | 66 + .../EventLocalMessagePortAddMessagePortListener.h | 118 + src/MessagePort/EventLocalMessagePortListener.h | 100 + ...ventLocalMessagePortRemoveMessagePortListener.h | 97 + ...ventMessagePortManagerRequestLocalMessagePort.h | 119 + ...entMessagePortManagerRequestRemoteMessagePort.h | 138 + ...sagePortManagerRequestTrustedLocalMessagePort.h | 119 + ...agePortManagerRequestTrustedRemoteMessagePort.h | 138 + .../EventRemoteMessagePortSendMessage.h | 122 + src/MessagePort/ILocalMessagePort.cpp | 55 + src/MessagePort/ILocalMessagePort.h | 68 + src/MessagePort/IMessagePortManager.cpp | 73 + src/MessagePort/IMessagePortManager.h | 64 + src/MessagePort/IRemoteMessagePort.cpp | 48 + src/MessagePort/IRemoteMessagePort.h | 62 + src/MessagePort/JSLocalMessagePort.cpp | 413 +++ src/MessagePort/JSLocalMessagePort.h | 97 + src/MessagePort/JSMessagePortManager.cpp | 668 +++++ src/MessagePort/JSMessagePortManager.h | 108 + src/MessagePort/JSRemoteMessagePort.cpp | 340 +++ src/MessagePort/JSRemoteMessagePort.h | 97 + src/MessagePort/LocalMessagePort.cpp | 176 ++ src/MessagePort/LocalMessagePort.h | 85 + src/MessagePort/LocalMessagePortController.cpp | 100 + src/MessagePort/LocalMessagePortController.h | 69 + src/MessagePort/MessagePortConverter.cpp | 175 ++ src/MessagePort/MessagePortConverter.h | 60 + src/MessagePort/MessagePortDataItem.h | 47 + src/MessagePort/MessagePortFactory.cpp | 48 + src/MessagePort/MessagePortFactory.h | 51 + src/MessagePort/MessagePortImpl.h | 30 + src/MessagePort/MessagePortListenerManager.cpp | 36 + src/MessagePort/MessagePortListenerManager.h | 98 + src/MessagePort/MessagePortManager.cpp | 222 ++ src/MessagePort/MessagePortManager.h | 72 + src/MessagePort/MessagePortManagerProxy.cpp | 322 +++ src/MessagePort/MessagePortManagerProxy.h | 105 + src/MessagePort/MessagePortUtility.cpp | 133 + src/MessagePort/MessagePortUtility.h | 57 + src/MessagePort/RemoteMessagePort.cpp | 135 + src/MessagePort/RemoteMessagePort.h | 65 + src/MessagePort/config.xml | 15 + src/MessagePort/plugin_config.cpp | 133 + src/MessagePort/plugin_config.h | 43 + src/MessagePort/plugin_initializer.cpp | 83 + src/Messaging/Attachment.cpp | 131 + src/Messaging/Attachment.h | 50 + src/Messaging/AttachmentFactory.cpp | 471 ++++ src/Messaging/AttachmentFactory.h | 67 + src/Messaging/Attachments.cpp | 289 +++ src/Messaging/Attachments.h | 234 ++ src/Messaging/BccRecipient.cpp | 74 + src/Messaging/BccRecipient.h | 57 + src/Messaging/BinarySms.cpp | 106 + src/Messaging/BinarySms.h | 65 + src/Messaging/Body.cpp | 59 + src/Messaging/Body.h | 76 + src/Messaging/CMakeLists.txt | 162 ++ src/Messaging/CallbackMgr.cpp | 166 ++ src/Messaging/CallbackMgr.h | 77 + src/Messaging/CallbackNumber.cpp | 62 + src/Messaging/CallbackNumber.h | 76 + src/Messaging/CcRecipient.cpp | 74 + src/Messaging/CcRecipient.h | 59 + src/Messaging/Conversation.cpp | 874 +++++++ src/Messaging/Conversation.h | 109 + src/Messaging/ConversationFilterValidator.cpp | 88 + src/Messaging/ConversationFilterValidator.h | 51 + .../ConversationFilterValidatorFactory.cpp | 56 + src/Messaging/ConversationFilterValidatorFactory.h | 49 + src/Messaging/ConversationQueryGenerator.cpp | 131 + src/Messaging/ConversationQueryGenerator.h | 61 + src/Messaging/ConverterMessage.cpp | 623 +++++ src/Messaging/ConverterMessage.h | 152 ++ src/Messaging/DBus/Connection.cpp | 346 +++ src/Messaging/DBus/Connection.h | 142 ++ src/Messaging/DBus/Message.cpp | 139 ++ src/Messaging/DBus/Message.h | 86 + src/Messaging/DBus/MessageEvent.h | 32 + src/Messaging/Email.cpp | 1389 +++++++++++ src/Messaging/Email.h | 144 ++ src/Messaging/EmailAccountInfo.cpp | 83 + src/Messaging/EmailAccountInfo.h | 59 + src/Messaging/EmailConverter.cpp | 139 ++ src/Messaging/EmailConverter.h | 44 + src/Messaging/EmailService.cpp | 311 +++ src/Messaging/EmailService.h | 101 + src/Messaging/EmailUtils.cpp | 126 + src/Messaging/EmailUtils.h | 75 + src/Messaging/EmitterConversationReceived.cpp | 24 + src/Messaging/EmitterConversationReceived.h | 37 + src/Messaging/EmitterFolderReceived.cpp | 24 + src/Messaging/EmitterFolderReceived.h | 37 + src/Messaging/EmitterMessageReceived.cpp | 23 + src/Messaging/EmitterMessageReceived.h | 36 + src/Messaging/EmptyMessage.cpp | 123 + src/Messaging/EmptyMessage.h | 70 + src/Messaging/EventAddDraftMessage.h | 70 + src/Messaging/EventDeleteConversations.h | 75 + src/Messaging/EventDeleteMessage.h | 46 + src/Messaging/EventDeleteMessages.h | 75 + src/Messaging/EventGetConversationId.h | 50 + src/Messaging/EventGetMessagingService.h | 108 + src/Messaging/EventMessageReceived.cpp | 63 + src/Messaging/EventMessageReceived.h | 67 + src/Messaging/EventMessagingService.h | 121 + src/Messaging/EventMessagingServicePrivateData.cpp | 50 + src/Messaging/EventMessagingServicePrivateData.h | 74 + src/Messaging/EventMessagingStorage.h | 94 + src/Messaging/EventOnSendingFailed.h | 67 + src/Messaging/EventQueryConversations.h | 90 + src/Messaging/EventQueryFolders.h | 93 + src/Messaging/EventQueryMessages.h | 111 + src/Messaging/EventSendMessage.h | 78 + src/Messaging/EventSendMessagePrivateData.cpp | 43 + src/Messaging/EventSendMessagePrivateData.h | 45 + src/Messaging/EventUpdateMessage.h | 49 + src/Messaging/EventUpdateMessages.h | 67 + src/Messaging/FolderFilterValidator.cpp | 141 ++ src/Messaging/FolderFilterValidator.h | 63 + src/Messaging/FolderFilterValidatorFactory.cpp | 49 + src/Messaging/FolderFilterValidatorFactory.h | 50 + src/Messaging/FolderQueryGenerator.cpp | 175 ++ src/Messaging/FolderQueryGenerator.h | 102 + src/Messaging/From.cpp | 59 + src/Messaging/From.h | 67 + src/Messaging/IAttachment.cpp | 238 ++ src/Messaging/IAttachment.h | 174 ++ src/Messaging/IBinarySms.cpp | 35 + src/Messaging/IBinarySms.h | 45 + src/Messaging/IConversation.h | 80 + src/Messaging/IEmail.cpp | 56 + src/Messaging/IEmail.h | 92 + src/Messaging/IEmailAccount.cpp | 54 + src/Messaging/IEmailAccount.h | 70 + src/Messaging/IEmptyMessage.cpp | 38 + src/Messaging/IEmptyMessage.h | 49 + src/Messaging/IMessage.cpp | 299 +++ src/Messaging/IMessage.h | 401 +++ src/Messaging/IMessageFolder.h | 57 + src/Messaging/IMessaging.cpp | 35 + src/Messaging/IMessaging.h | 113 + src/Messaging/IMessagingService.cpp | 62 + src/Messaging/IMessagingService.h | 172 ++ src/Messaging/IMessagingServiceManager.cpp | 35 + src/Messaging/IMessagingServiceManager.h | 61 + src/Messaging/IMessagingTypes.h | 94 + src/Messaging/IMms.cpp | 71 + src/Messaging/IMms.h | 78 + src/Messaging/IMmsSlide.h | 59 + src/Messaging/IMmsSlideProperties.h | 237 ++ src/Messaging/IMmsSlides.h | 101 + src/Messaging/ISendingObserver.h | 71 + src/Messaging/ISms.cpp | 53 + src/Messaging/ISms.h | 50 + src/Messaging/JSConversation.cpp | 272 ++ src/Messaging/JSConversation.h | 115 + src/Messaging/JSMessage.cpp | 1899 ++++++++++++++ src/Messaging/JSMessage.h | 333 +++ src/Messaging/JSMessageAttachment.cpp | 584 +++++ src/Messaging/JSMessageAttachment.h | 140 ++ src/Messaging/JSMessageBody.cpp | 539 ++++ src/Messaging/JSMessageBody.h | 151 ++ src/Messaging/JSMessageFolder.cpp | 314 +++ src/Messaging/JSMessageFolder.h | 125 + src/Messaging/JSMessagePrivateObject.h | 57 + src/Messaging/JSMessagingService.cpp | 1300 ++++++++++ src/Messaging/JSMessagingService.h | 113 + src/Messaging/JSMessagingServiceManager.cpp | 260 ++ src/Messaging/JSMessagingServiceManager.h | 100 + src/Messaging/JSMessagingStorage.cpp | 1833 ++++++++++++++ src/Messaging/JSMessagingStorage.h | 144 ++ src/Messaging/JSRecipientArray.cpp | 384 +++ src/Messaging/JSRecipientArray.h | 172 ++ src/Messaging/MailSender.cpp | 314 +++ src/Messaging/MailSender.h | 80 + src/Messaging/MailSync.cpp | 738 ++++++ src/Messaging/MailSync.h | 183 ++ src/Messaging/MessageAsyncCallbackManager.cpp | 29 + src/Messaging/MessageAsyncCallbackManager.h | 48 + src/Messaging/MessageEventPrivateData.h | 52 + src/Messaging/MessageFactory.cpp | 291 +++ src/Messaging/MessageFactory.h | 112 + src/Messaging/MessageFilterValidator.cpp | 204 ++ src/Messaging/MessageFilterValidator.h | 75 + src/Messaging/MessageFilterValidatorFactory.cpp | 73 + src/Messaging/MessageFilterValidatorFactory.h | 62 + src/Messaging/MessageFolder.cpp | 137 + src/Messaging/MessageFolder.h | 89 + src/Messaging/MessageListenerManager.cpp | 29 + src/Messaging/MessageListenerManager.h | 95 + src/Messaging/MessagePriority.cpp | 50 + src/Messaging/MessagePriority.h | 71 + src/Messaging/MessageProperties.h | 50 + src/Messaging/MessageQueryGenerator.cpp | 890 +++++++ src/Messaging/MessageQueryGenerator.h | 146 ++ src/Messaging/MessageSendCallback.h | 41 + src/Messaging/MessageStorageFactory.cpp | 45 + src/Messaging/MessageStorageFactory.h | 43 + src/Messaging/Messaging.cpp | 2628 +++++++++++++++++++ src/Messaging/Messaging.h | 239 ++ src/Messaging/MessagingController.cpp | 368 +++ src/Messaging/MessagingController.h | 61 + src/Messaging/MessagingErrorMsg.h | 33 + src/Messaging/MessagingFactory.cpp | 44 + src/Messaging/MessagingFactory.h | 43 + src/Messaging/MessagingListener.cpp | 914 +++++++ src/Messaging/MessagingListener.h | 119 + src/Messaging/MessagingService.cpp | 319 +++ src/Messaging/MessagingService.h | 110 + src/Messaging/MessagingServiceManager.cpp | 236 ++ src/Messaging/MessagingServiceManager.h | 81 + src/Messaging/MessagingStorageMultiCallback.cpp | 67 + src/Messaging/MessagingStorageMultiCallback.h | 109 + src/Messaging/Mms.cpp | 1435 +++++++++++ src/Messaging/Mms.h | 126 + src/Messaging/MmsSlide.cpp | 162 ++ src/Messaging/MmsSlide.h | 80 + src/Messaging/MmsSlideProperty.cpp | 64 + src/Messaging/MmsSlideProperty.h | 77 + src/Messaging/MmsSlides.cpp | 93 + src/Messaging/MmsSlides.h | 64 + src/Messaging/MsgServiceHandleMgr.h | 105 + src/Messaging/NetworkStatus.cpp | 84 + src/Messaging/NetworkStatus.h | 59 + src/Messaging/Recipient.cpp | 203 ++ src/Messaging/Recipient.h | 105 + src/Messaging/ReqReceiverMessage.cpp | 811 ++++++ src/Messaging/ReqReceiverMessage.h | 149 ++ src/Messaging/ScopedMail.h | 55 + src/Messaging/ScopedMailAttachment.h | 55 + src/Messaging/ScopedMailbox.h | 56 + src/Messaging/Sms.cpp | 1186 +++++++++ src/Messaging/Sms.h | 145 ++ src/Messaging/SourceAddress.cpp | 68 + src/Messaging/SourceAddress.h | 55 + .../StorageChangesConversationFilterValidator.cpp | 68 + .../StorageChangesConversationFilterValidator.h | 52 + ...geChangesConversationFilterValidatorFactory.cpp | 66 + ...rageChangesConversationFilterValidatorFactory.h | 55 + .../StorageChangesConversationGenerator.cpp | 687 +++++ .../StorageChangesConversationGenerator.h | 112 + .../StorageChangesFolderFilterValidator.cpp | 57 + .../StorageChangesFolderFilterValidator.h | 52 + .../StorageChangesFolderFilterValidatorFactory.cpp | 56 + .../StorageChangesFolderFilterValidatorFactory.h | 50 + src/Messaging/StorageChangesFolderGenerator.cpp | 491 ++++ src/Messaging/StorageChangesFolderGenerator.h | 97 + .../StorageChangesMessageFilterValidator.cpp | 61 + .../StorageChangesMessageFilterValidator.h | 52 + ...StorageChangesMessageFilterValidatorFactory.cpp | 73 + .../StorageChangesMessageFilterValidatorFactory.h | 58 + src/Messaging/StorageChangesMessageGenerator.cpp | 882 +++++++ src/Messaging/StorageChangesMessageGenerator.h | 122 + src/Messaging/Subject.cpp | 61 + src/Messaging/Subject.h | 76 + src/Messaging/SyncNetworkStatus.cpp | 90 + src/Messaging/SyncNetworkStatus.h | 57 + src/Messaging/ToRecipient.cpp | 76 + src/Messaging/ToRecipient.h | 57 + src/Messaging/ValidityPeriodHours.cpp | 54 + src/Messaging/ValidityPeriodHours.h | 69 + src/Messaging/VirtualMessage.cpp | 100 + src/Messaging/VirtualMessage.h | 80 + src/{platform/API => }/Messaging/config.cmake | 0 .../config.cmake.platformTizen} | 0 src/Messaging/config.xml | 26 + src/{platform/API => }/Messaging/log.h | 0 src/Messaging/messageDB/MessageStorageReader.cpp | 484 ++++ .../Messaging/messageDB/MessageStorageReader.h | 0 .../Messaging/messageDB/MsgSqliteWrapper.cpp | 0 .../Messaging/messageDB/MsgSqliteWrapper.h | 0 src/Messaging/plugin_config.cpp | 361 +++ src/Messaging/plugin_config.h | 62 + src/Messaging/plugin_initializer.cpp | 92 + src/NFC/CMakeLists.txt | 71 + src/NFC/EventNFC.h | 58 + src/NFC/EventNFCChanged.h | 99 + src/NFC/EventNFCChangedPrivateData.cpp | 43 + src/NFC/EventNFCChangedPrivateData.h | 45 + src/NFC/EventTagAction.h | 91 + src/NFC/EventTargetAction.h | 62 + src/NFC/INFCAdapter.cpp | 35 + src/NFC/INFCAdapter.h | 63 + src/NFC/INFCTag.cpp | 37 + src/NFC/INFCTag.h | 86 + src/NFC/INFCTarget.cpp | 33 + src/NFC/INFCTarget.h | 53 + src/NFC/INdefMessage.h | 52 + src/NFC/INdefRecord.h | 57 + src/NFC/JSNFCAdapter.cpp | 696 ++++++ src/NFC/JSNFCAdapter.h | 129 + src/NFC/JSNFCManager.cpp | 218 ++ src/NFC/JSNFCManager.h | 86 + src/NFC/JSNFCTag.cpp | 435 ++++ src/NFC/JSNFCTag.h | 113 + src/NFC/JSNFCTarget.cpp | 353 +++ src/NFC/JSNFCTarget.h | 112 + src/NFC/JSNdefMessage.cpp | 386 +++ src/NFC/JSNdefMessage.h | 105 + src/NFC/JSNdefRecord.cpp | 273 ++ src/NFC/JSNdefRecord.h | 96 + src/NFC/JSNdefRecordArray.cpp | 767 ++++++ src/NFC/JSNdefRecordArray.h | 176 ++ src/NFC/JSNdefRecordMedia.cpp | 206 ++ src/NFC/JSNdefRecordMedia.h | 84 + src/NFC/JSNdefRecordText.cpp | 237 ++ src/NFC/JSNdefRecordText.h | 84 + src/NFC/JSNdefRecordURI.cpp | 203 ++ src/NFC/JSNdefRecordURI.h | 83 + src/NFC/NFCAdapter.cpp | 287 +++ src/NFC/NFCAdapter.h | 84 + src/NFC/NFCAsyncCallbackManager.cpp | 30 + src/NFC/NFCAsyncCallbackManager.h | 46 + src/NFC/NFCChangedCallback.h | 39 + src/NFC/NFCConverter.cpp | 417 ++++ src/NFC/NFCConverter.h | 70 + src/NFC/NFCDefaultAdapter.cpp | 475 ++++ src/NFC/NFCDefaultAdapter.h | 94 + src/NFC/NFCFactory.cpp | 88 + src/NFC/NFCFactory.h | 62 + src/NFC/NFCListenerManager.cpp | 29 + src/NFC/NFCListenerManager.h | 128 + src/NFC/NFCStaticController.cpp | 210 ++ src/NFC/NFCStaticController.h | 56 + src/NFC/NFCTag.cpp | 456 ++++ src/NFC/NFCTag.h | 77 + src/NFC/NFCTagProperties.h | 46 + src/NFC/NFCTarget.cpp | 209 ++ src/NFC/NFCTarget.h | 57 + src/NFC/NFCUtil.cpp | 359 +++ src/NFC/NFCUtil.h | 57 + src/NFC/NdefMessage.cpp | 228 ++ src/NFC/NdefMessage.h | 58 + src/NFC/NdefRecord.cpp | 378 +++ src/NFC/NdefRecord.h | 64 + src/NFC/NdefRecordProperties.h | 66 + src/NFC/ResponseDispatcher.cpp | 263 ++ src/NFC/ResponseDispatcher.h | 65 + src/NFC/TagFilter.cpp | 48 + src/NFC/TagFilter.h | 52 + src/NFC/config.xml | 35 + src/NFC/plugin_config.cpp | 180 ++ src/NFC/plugin_config.h | 42 + src/NFC/plugin_initializer.cpp | 85 + src/NetworkBearerSelection/CMakeLists.txt | 33 + .../EventNetworkBearerRelease.h | 67 + .../EventNetworkBearerSelection.h | 79 + .../INetworkBearerSelection.cpp | 37 + .../INetworkBearerSelection.h | 58 + .../JSNetworkBearerSelection.cpp | 279 +++ .../JSNetworkBearerSelection.h | 55 + .../JSNetworkBearerSelectionCallbackManager.cpp | 289 +++ .../JSNetworkBearerSelectionCallbackManager.h | 89 + .../NetworkBearerSelection.cpp | 330 +++ .../NetworkBearerSelection.h | 110 + .../NetworkBearerSelectionFactory.cpp | 41 + .../NetworkBearerSelectionFactory.h | 42 + .../NetworkBearerSelectionResponseDispatcher.cpp | 151 ++ .../NetworkBearerSelectionResponseDispatcher.h | 61 + .../OnNetworkBearerSelectionStateChanged.h | 63 + src/NetworkBearerSelection/config.xml | 19 + src/NetworkBearerSelection/plugin_config.cpp | 84 + src/NetworkBearerSelection/plugin_config.h | 39 + src/NetworkBearerSelection/plugin_initializer.cpp | 65 + src/Notification/CMakeLists.txt | 81 + src/Notification/INotification.cpp | 35 + src/Notification/INotification.h | 186 ++ src/Notification/INotificationManager.cpp | 33 + src/Notification/INotificationManager.h | 51 + src/Notification/JSNotificationLine.cpp | 323 +++ src/Notification/JSNotificationLine.h | 114 + src/Notification/JSNotificationLineArray.cpp | 622 +++++ src/Notification/JSNotificationLineArray.h | 194 ++ src/Notification/JSNotificationManager.cpp | 535 ++++ src/Notification/JSNotificationManager.h | 69 + src/Notification/JSStatusNotification.cpp | 677 +++++ src/Notification/JSStatusNotification.h | 88 + src/Notification/JSStringArray.cpp | 602 +++++ src/Notification/JSStringArray.h | 187 ++ src/Notification/NotificationConverter.cpp | 368 +++ src/Notification/NotificationConverter.h | 67 + src/Notification/NotificationFactory.cpp | 74 + src/Notification/NotificationFactory.h | 49 + src/Notification/NotificationLine.cpp | 236 ++ src/Notification/NotificationLine.h | 63 + src/Notification/NotificationManager.cpp | 1352 ++++++++++ src/Notification/NotificationManager.h | 75 + src/Notification/StatusNotification.cpp | 2310 +++++++++++++++++ src/Notification/StatusNotification.h | 126 + src/Notification/config.xml | 21 + src/Notification/plugin_config.cpp | 81 + src/Notification/plugin_config.h | 37 + src/Notification/plugin_initializer.cpp | 73 + src/Package/CMakeLists.txt | 59 + src/Package/JSPackageInformation.cpp | 213 ++ src/Package/JSPackageInformation.h | 119 + src/Package/JSPackageManager.cpp | 505 ++++ src/Package/JSPackageManager.h | 123 + src/Package/PackageInformation.cpp | 32 + src/Package/PackageInformation.h | 52 + src/Package/PackageManager.cpp | 748 ++++++ src/Package/PackageManager.h | 120 + src/Package/config.xml | 20 + src/Package/plugin_config.cpp | 183 ++ src/Package/plugin_config.h | 54 + src/Package/plugin_initializer.cpp | 78 + src/Power/CMakeLists.txt | 50 + src/Power/JSPowerManager.cpp | 311 +++ src/Power/JSPowerManager.h | 172 ++ src/Power/PowerManager.cpp | 270 ++ src/Power/PowerManager.h | 81 + src/Power/config.xml | 15 + src/Power/plugin_config.cpp | 177 ++ src/Power/plugin_config.h | 49 + src/Power/plugin_initializer.cpp | 82 + src/Power/test/CMakeLists.txt | 28 + src/Power/test/TestEngine.js | 1020 ++++++++ src/Power/test/TestPower.js | 312 +++ src/Power/test/main.cpp | 85 + src/Push/CMakeLists.txt | 51 + src/Push/IEventConnectService.h | 67 + src/Push/IEventDisconnectService.h | 53 + src/Push/IEventGetRegistrationId.h | 64 + src/Push/IEventRegisterService.h | 76 + src/Push/IEventUnregisterService.h | 53 + src/Push/IPushManager.cpp | 63 + src/Push/IPushManager.h | 60 + src/Push/JSPushManager.cpp | 509 ++++ src/Push/JSPushManager.h | 131 + src/Push/JSPushMessage.cpp | 211 ++ src/Push/JSPushMessage.h | 95 + src/Push/OnPushNotified.h | 69 + src/Push/PushAsyncCallbackManager.cpp | 22 + src/Push/PushAsyncCallbackManager.h | 46 + src/Push/PushConverter.cpp | 57 + src/Push/PushConverter.h | 50 + src/Push/PushListenerManager.cpp | 22 + src/Push/PushListenerManager.h | 84 + src/Push/PushManager.cpp | 529 ++++ src/Push/PushManager.h | 58 + src/Push/PushMessage.cpp | 74 + src/Push/PushMessage.h | 56 + src/Push/PushResponseDispatcher.cpp | 166 ++ src/Push/PushResponseDispatcher.h | 64 + src/Push/config.xml | 15 + src/Push/plugin_config.cpp | 124 + src/Push/plugin_config.h | 44 + src/Push/plugin_initializer.cpp | 83 + src/SecureElement/CMakeLists.txt | 63 + src/SecureElement/EventSEService.h | 132 + src/SecureElement/ISEChannel.cpp | 34 + src/SecureElement/ISEChannel.h | 51 + src/SecureElement/ISEReader.cpp | 34 + src/SecureElement/ISEReader.h | 55 + src/SecureElement/ISEService.cpp | 34 + src/SecureElement/ISEService.h | 55 + src/SecureElement/ISESession.cpp | 34 + src/SecureElement/ISESession.h | 56 + src/SecureElement/JSSEChannel.cpp | 272 ++ src/SecureElement/JSSEChannel.h | 105 + src/SecureElement/JSSEReader.cpp | 278 +++ src/SecureElement/JSSEReader.h | 112 + src/SecureElement/JSSEService.cpp | 338 +++ src/SecureElement/JSSEService.h | 103 + src/SecureElement/JSSESession.cpp | 382 +++ src/SecureElement/JSSESession.h | 126 + src/SecureElement/SEAsyncCallbackManager.cpp | 30 + src/SecureElement/SEAsyncCallbackManager.h | 46 + src/SecureElement/SEChannel.cpp | 133 + src/SecureElement/SEChannel.h | 54 + src/SecureElement/SEConverter.cpp | 94 + src/SecureElement/SEConverter.h | 49 + src/SecureElement/SEFactory.cpp | 50 + src/SecureElement/SEFactory.h | 51 + src/SecureElement/SEListener.h | 39 + src/SecureElement/SEListenerManager.cpp | 30 + src/SecureElement/SEListenerManager.h | 83 + src/SecureElement/SEReader.cpp | 125 + src/SecureElement/SEReader.h | 58 + src/SecureElement/SEResponseDispatcher.cpp | 216 ++ src/SecureElement/SEResponseDispatcher.h | 62 + src/SecureElement/SEService.cpp | 172 ++ src/SecureElement/SEService.h | 63 + src/SecureElement/SESession.cpp | 142 ++ src/SecureElement/SESession.h | 58 + src/SecureElement/SEUtil.cpp | 52 + src/SecureElement/SEUtil.h | 41 + src/SecureElement/config.xml | 15 + src/SecureElement/plugin_initializer.cpp | 58 + src/SystemSetting/CMakeLists.txt | 43 + src/SystemSetting/ConverterSystemSetting.cpp | 123 + src/SystemSetting/ConverterSystemSetting.h | 49 + src/SystemSetting/EventGetSetting.h | 74 + src/SystemSetting/EventSetRingtone.h | 66 + src/SystemSetting/EventSetSetting.h | 68 + src/SystemSetting/EventSetWallpaper.h | 66 + src/SystemSetting/ISystemSetting.cpp | 40 + src/SystemSetting/ISystemSetting.h | 72 + src/SystemSetting/ISystemSettingType.h | 46 + src/SystemSetting/JSSystemSetting.cpp | 321 +++ src/SystemSetting/JSSystemSetting.h | 55 + src/SystemSetting/SystemSetting.cpp | 279 +++ src/SystemSetting/SystemSetting.h | 65 + .../SystemSettingAsyncCallbackManager.cpp | 35 + .../SystemSettingAsyncCallbackManager.h | 54 + src/SystemSetting/SystemSettingFactory.cpp | 41 + src/SystemSetting/SystemSettingFactory.h | 42 + .../SystemSettingResponseDispatcher.cpp | 246 ++ .../SystemSettingResponseDispatcher.h | 70 + src/SystemSetting/config.xml | 19 + src/SystemSetting/plugin_config.cpp | 108 + src/SystemSetting/plugin_config.h | 39 + src/SystemSetting/plugin_initializer.cpp | 79 + src/Systeminfo/BaseProperties.h | 83 + src/Systeminfo/CMakeLists.txt | 80 + src/Systeminfo/EventGetSysteminfo.cpp | 70 + src/Systeminfo/EventGetSysteminfo.h | 52 + src/Systeminfo/EventWatchSysteminfo.cpp | 453 ++++ src/Systeminfo/EventWatchSysteminfo.h | 79 + src/Systeminfo/ISysteminfo.cpp | 36 + src/Systeminfo/ISysteminfo.h | 61 + src/Systeminfo/JSBatteryInfo.cpp | 126 + src/Systeminfo/JSBatteryInfo.h | 48 + src/Systeminfo/JSBuildInfo.cpp | 125 + src/Systeminfo/JSBuildInfo.h | 48 + src/Systeminfo/JSCellularNetworkInfo.cpp | 168 ++ src/Systeminfo/JSCellularNetworkInfo.h | 49 + src/Systeminfo/JSCpuInfo.cpp | 121 + src/Systeminfo/JSCpuInfo.h | 48 + src/Systeminfo/JSDeviceCapabilitiesInfo.cpp | 276 ++ src/Systeminfo/JSDeviceCapabilitiesInfo.h | 49 + src/Systeminfo/JSDeviceOrientationInfo.cpp | 120 + src/Systeminfo/JSDeviceOrientationInfo.h | 48 + src/Systeminfo/JSDisplayInfo.cpp | 143 ++ src/Systeminfo/JSDisplayInfo.h | 48 + src/Systeminfo/JSLocaleInfo.cpp | 124 + src/Systeminfo/JSLocaleInfo.h | 48 + src/Systeminfo/JSNetworkInfo.cpp | 120 + src/Systeminfo/JSNetworkInfo.h | 48 + src/Systeminfo/JSPeripheralInfo.cpp | 120 + src/Systeminfo/JSPeripheralInfo.h | 48 + src/Systeminfo/JSSIMInfo.cpp | 153 ++ src/Systeminfo/JSSIMInfo.h | 48 + src/Systeminfo/JSStorageInfo.cpp | 135 + src/Systeminfo/JSStorageInfo.h | 48 + src/Systeminfo/JSSysteminfo.cpp | 315 +++ src/Systeminfo/JSSysteminfo.h | 61 + src/Systeminfo/JSWifiNetworkInfo.cpp | 137 + src/Systeminfo/JSWifiNetworkInfo.h | 48 + src/Systeminfo/Systeminfo.cpp | 1755 +++++++++++++ src/Systeminfo/Systeminfo.h | 225 ++ src/Systeminfo/SysteminfoAsyncCallbackManager.cpp | 23 + src/Systeminfo/SysteminfoAsyncCallbackManager.h | 46 + src/Systeminfo/SysteminfoFactory.cpp | 40 + src/Systeminfo/SysteminfoFactory.h | 42 + src/Systeminfo/SysteminfoListener.cpp | 66 + src/Systeminfo/SysteminfoListener.h | 51 + src/Systeminfo/SysteminfoListenerManager.cpp | 23 + src/Systeminfo/SysteminfoListenerManager.h | 79 + src/Systeminfo/SysteminfoPropertyInfo.h | 319 +++ src/Systeminfo/config.xml | 26 + src/Systeminfo/plugin_config.cpp | 110 + src/Systeminfo/plugin_config.h | 39 + src/Systeminfo/plugin_initializer.cpp | 78 + src/TimeUtil/CMakeLists.txt | 48 + src/TimeUtil/DurationProperties.h | 56 + src/TimeUtil/JSTZDate.cpp | 1468 +++++++++++ src/TimeUtil/JSTZDate.h | 228 ++ src/TimeUtil/JSTimeDuration.cpp | 400 +++ src/TimeUtil/JSTimeDuration.h | 124 + src/TimeUtil/JSTimeUtil.cpp | 348 +++ src/TimeUtil/JSTimeUtil.h | 138 + src/TimeUtil/TZDate.cpp | 695 ++++++ src/TimeUtil/TZDate.h | 113 + src/TimeUtil/TZDateProperties.h | 54 + src/TimeUtil/TimeUtil.cpp | 198 ++ src/TimeUtil/TimeUtil.h | 53 + src/TimeUtil/TimeUtilConverter.cpp | 292 +++ src/TimeUtil/TimeUtilConverter.h | 71 + src/TimeUtil/TimeUtilTools.cpp | 171 ++ src/TimeUtil/TimeUtilTools.h | 61 + src/TimeUtil/config.xml | 16 + src/TimeUtil/plugin_initializer.cpp | 72 + src/Tizen/AnyType.cpp | 396 +++ src/Tizen/AnyType.h | 162 ++ src/Tizen/AttributeFilter.cpp | 85 + src/Tizen/AttributeFilter.h | 97 + src/Tizen/AttributeRangeFilter.cpp | 85 + src/Tizen/AttributeRangeFilter.h | 115 + src/Tizen/CMakeLists.txt | 81 + src/Tizen/CompositeFilter.cpp | 101 + src/Tizen/CompositeFilter.h | 79 + src/Tizen/FilterConverter.cpp | 504 ++++ src/Tizen/FilterConverter.h | 98 + src/Tizen/FilterFactory.cpp | 67 + src/Tizen/FilterFactory.h | 65 + src/Tizen/FilterTypes.h | 59 + src/Tizen/FilterValidator.cpp | 97 + src/Tizen/FilterValidator.h | 87 + src/Tizen/IFilter.cpp | 38 + src/Tizen/IFilter.h | 74 + src/Tizen/IFilterVisitor.cpp | 41 + src/Tizen/IFilterVisitor.h | 61 + src/Tizen/JSAbstractFilterArray.cpp | 634 +++++ src/Tizen/JSAbstractFilterArray.h | 191 ++ src/Tizen/JSAttributeFilter.cpp | 400 +++ src/Tizen/JSAttributeFilter.h | 126 + src/Tizen/JSAttributeRangeFilter.cpp | 393 +++ src/Tizen/JSAttributeRangeFilter.h | 127 + src/Tizen/JSCompositeFilter.cpp | 334 +++ src/Tizen/JSCompositeFilter.h | 115 + src/Tizen/JSFeature.cpp | 153 ++ src/Tizen/JSFeature.h | 90 + src/Tizen/JSFeatureParam.cpp | 126 + src/Tizen/JSFeatureParam.h | 90 + src/Tizen/JSSimpleCoordinates.cpp | 319 +++ src/Tizen/JSSimpleCoordinates.h | 115 + src/Tizen/JSSortMode.cpp | 333 +++ src/Tizen/JSSortMode.h | 115 + src/Tizen/JSTizen.cpp | 352 +++ src/Tizen/JSTizen.h | 139 ++ src/Tizen/PluginOnDemandPriv.cpp | 57 + src/Tizen/PluginOnDemandPriv.h | 60 + src/Tizen/SimpleCoordinates.cpp | 63 + src/Tizen/SimpleCoordinates.h | 71 + src/Tizen/SortMode.cpp | 59 + src/Tizen/SortMode.h | 64 + src/Tizen/config.xml | 25 + src/Tizen/plugin_config.cpp | 98 + src/Tizen/plugin_config.h | 43 + src/Tizen/plugin_initializer.cpp | 113 + src/platform/API/Application/ApplicationCert.cpp | 53 - src/platform/API/Application/ApplicationCert.h | 55 - .../API/Application/ApplicationContext.cpp | 52 - src/platform/API/Application/ApplicationContext.h | 56 - .../API/Application/ApplicationControl.cpp | 174 -- src/platform/API/Application/ApplicationControl.h | 79 - .../API/Application/ApplicationControlData.cpp | 55 - .../API/Application/ApplicationControlData.h | 56 - .../API/Application/ApplicationFactory.cpp | 41 - src/platform/API/Application/ApplicationFactory.h | 42 - .../API/Application/ApplicationInformation.cpp | 118 - .../API/Application/ApplicationInformation.h | 73 - .../API/Application/ApplicationInstallInfo.cpp | 75 - .../API/Application/ApplicationInstallInfo.h | 59 - .../EventApplicationAddAppInfoEventListener.h | 67 - .../EventApplicationAppInfoEventListener.h | 96 - .../Application/EventApplicationFindAppControl.h | 75 - .../API/Application/EventApplicationGetAppCerts.h | 74 - .../Application/EventApplicationGetAppContext.h | 72 - .../API/Application/EventApplicationGetAppInfo.h | 72 - .../Application/EventApplicationGetAppsContext.h | 63 - .../API/Application/EventApplicationGetAppsInfo.h | 63 - .../API/Application/EventApplicationGetCurrApp.h | 59 - .../EventApplicationGetRequestedAppControl.h | 71 - .../API/Application/EventApplicationInstall.h | 110 - .../API/Application/EventApplicationKill.h | 56 - .../API/Application/EventApplicationLaunch.h | 53 - .../Application/EventApplicationLaunchAppControl.h | 118 - .../EventApplicationRemoveAppInfoEventListener.h | 53 - .../API/Application/IApplicationManager.cpp | 50 - src/platform/API/Application/IApplicationManager.h | 100 - .../Application/RequestedApplicationControl.cpp | 98 - .../API/Application/RequestedApplicationControl.h | 58 - src/platform/API/Application/config.cmake | 13 - src/platform/API/Bluetooth/BTDevice.h | 65 - src/platform/API/Bluetooth/BluetoothFactory.cpp | 71 - src/platform/API/Bluetooth/BluetoothFactory.h | 53 - .../API/Bluetooth/EventBTConnectToServiceByUUID.h | 47 - .../API/Bluetooth/EventBTCreateDestroyBonding.cpp | 65 - .../API/Bluetooth/EventBTCreateDestroyBonding.h | 55 - src/platform/API/Bluetooth/EventBTGetAdapter.h | 43 - src/platform/API/Bluetooth/EventBTGetDevice.cpp | 48 - src/platform/API/Bluetooth/EventBTGetDevice.h | 51 - .../API/Bluetooth/EventBTGetKnownDevices.cpp | 36 - .../API/Bluetooth/EventBTGetKnownDevices.h | 50 - .../API/Bluetooth/EventBTOnDiscoveryDevices.cpp | 51 - .../API/Bluetooth/EventBTOnDiscoveryDevices.h | 62 - src/platform/API/Bluetooth/EventBTRegisterRFCOMM.h | 56 - .../API/Bluetooth/EventBTServiceOnConnect.cpp | 52 - .../API/Bluetooth/EventBTServiceOnConnect.h | 60 - src/platform/API/Bluetooth/EventBTSetName.h | 49 - src/platform/API/Bluetooth/EventBTSetPowered.h | 54 - src/platform/API/Bluetooth/EventBTSetVisible.h | 51 - .../API/Bluetooth/EventBTSocketNotification.cpp | 63 - .../API/Bluetooth/EventBTSocketNotification.h | 68 - src/platform/API/Bluetooth/EventBTStopDiscovery.h | 45 - .../API/Bluetooth/EventBTUnregisterRFCOMM.h | 42 - .../API/Bluetooth/IBluetoothAdapterManager.cpp | 55 - .../API/Bluetooth/IBluetoothAdapterManager.h | 89 - .../API/Bluetooth/IBluetoothDeviceManager.cpp | 42 - .../API/Bluetooth/IBluetoothDeviceManager.h | 69 - .../Bluetooth/IBluetoothServiceHandlerManager.cpp | 40 - .../Bluetooth/IBluetoothServiceHandlerManager.h | 58 - .../API/Bluetooth/IBluetoothSocketManager.cpp | 39 - .../API/Bluetooth/IBluetoothSocketManager.h | 60 - src/platform/API/Bluetooth/config.cmake | 16 - src/platform/API/Calendar/CalendarEvent.cpp | 505 ---- src/platform/API/Calendar/CalendarEvent.h | 239 -- src/platform/API/Calendar/CalendarFactory.cpp | 50 - src/platform/API/Calendar/CalendarFactory.h | 46 - src/platform/API/Calendar/EventAlarm.cpp | 83 - src/platform/API/Calendar/EventAlarm.h | 77 - src/platform/API/Calendar/EventAttendee.cpp | 150 -- src/platform/API/Calendar/EventAttendee.h | 123 - src/platform/API/Calendar/EventId.cpp | 68 - src/platform/API/Calendar/EventId.h | 62 - src/platform/API/Calendar/EventRecurrenceRule.cpp | 157 -- src/platform/API/Calendar/EventRecurrenceRule.h | 111 - src/platform/API/Calendar/ICalendar.cpp | 119 - src/platform/API/Calendar/ICalendar.h | 154 -- src/platform/API/Calendar/ICalendarManager.cpp | 54 - src/platform/API/Calendar/ICalendarManager.h | 54 - src/platform/API/Calendar/IEventAddEvent.h | 68 - src/platform/API/Calendar/IEventAddEvents.h | 80 - src/platform/API/Calendar/IEventClearWatch.h | 70 - .../API/Calendar/IEventCreateEventFromString.h | 92 - src/platform/API/Calendar/IEventDeleteEvent.h | 70 - src/platform/API/Calendar/IEventDeleteEvents.h | 70 - .../API/Calendar/IEventExpandEventRecurrence.h | 104 - .../API/Calendar/IEventExportEventToString.h | 90 - src/platform/API/Calendar/IEventFindEvents.h | 145 -- src/platform/API/Calendar/IEventGet.h | 79 - src/platform/API/Calendar/IEventGetCalendar.h | 92 - src/platform/API/Calendar/IEventGetCalendars.h | 78 - .../API/Calendar/IEventGetDefaultCalendar.h | 80 - src/platform/API/Calendar/IEventUpdateEvent.h | 81 - src/platform/API/Calendar/IEventUpdateEvents.h | 80 - src/platform/API/Calendar/IEventWatchChanges.h | 91 - src/platform/API/Calendar/OnEventsChanged.h | 98 - src/platform/API/Calendar/config.cmake | 12 - src/platform/API/Callhistory/CallHistoryDefine.h | 68 - .../API/Callhistory/CallHistoryEntryProperties.cpp | 184 -- .../API/Callhistory/CallHistoryEntryProperties.h | 92 - .../API/Callhistory/CallHistoryFactory.cpp | 50 - src/platform/API/Callhistory/CallHistoryFactory.h | 44 - src/platform/API/Callhistory/EventCallHistory.h | 50 - .../API/Callhistory/EventCallHistoryListener.cpp | 50 - .../API/Callhistory/EventCallHistoryListener.h | 61 - .../API/Callhistory/EventCallHistoryTemplate.h | 51 - .../API/Callhistory/EventFindCallHistory.cpp | 112 - .../API/Callhistory/EventFindCallHistory.h | 69 - src/platform/API/Callhistory/EventRemoveAll.h | 39 - src/platform/API/Callhistory/EventRemoveBatch.h | 46 - src/platform/API/Callhistory/ICallHistory.cpp | 40 - src/platform/API/Callhistory/ICallHistory.h | 65 - src/platform/API/Callhistory/ICallHistoryEntry.cpp | 36 - src/platform/API/Callhistory/ICallHistoryEntry.h | 43 - src/platform/API/Callhistory/RemoteParty.h | 53 - src/platform/API/Callhistory/config.cmake | 10 - src/platform/API/Contact/ContactAddress.cpp | 342 --- src/platform/API/Contact/ContactAddress.h | 130 - src/platform/API/Contact/ContactAnniversary.cpp | 110 - src/platform/API/Contact/ContactAnniversary.h | 75 - src/platform/API/Contact/ContactEmailAddress.cpp | 128 - src/platform/API/Contact/ContactEmailAddress.h | 83 - src/platform/API/Contact/ContactFactory.cpp | 61 - src/platform/API/Contact/ContactFactory.h | 55 - src/platform/API/Contact/ContactGroup.cpp | 247 -- src/platform/API/Contact/ContactGroup.h | 112 - src/platform/API/Contact/ContactName.cpp | 322 --- src/platform/API/Contact/ContactName.h | 130 - src/platform/API/Contact/ContactOrganization.cpp | 196 -- src/platform/API/Contact/ContactOrganization.h | 97 - src/platform/API/Contact/ContactPhoneNumber.cpp | 133 - src/platform/API/Contact/ContactPhoneNumber.h | 84 - src/platform/API/Contact/ContactRef.cpp | 113 - src/platform/API/Contact/ContactRef.h | 75 - src/platform/API/Contact/ContactTypes.h | 93 - src/platform/API/Contact/ContactWebSite.cpp | 109 - src/platform/API/Contact/ContactWebSite.h | 74 - src/platform/API/Contact/EventAddressBookAdd.h | 96 - .../API/Contact/EventAddressBookAddBatch.h | 96 - .../Contact/EventAddressBookAddChangeListener.h | 119 - .../API/Contact/EventAddressBookAddGroup.h | 96 - .../API/Contact/EventAddressBookChangeListener.h | 251 -- src/platform/API/Contact/EventAddressBookFind.h | 139 -- src/platform/API/Contact/EventAddressBookGet.h | 118 - .../API/Contact/EventAddressBookGetGroup.h | 118 - .../API/Contact/EventAddressBookGetGroups.h | 97 - src/platform/API/Contact/EventAddressBookRemove.h | 95 - .../API/Contact/EventAddressBookRemoveBatch.h | 95 - .../Contact/EventAddressBookRemoveChangeListener.h | 98 - .../API/Contact/EventAddressBookRemoveGroup.h | 95 - src/platform/API/Contact/EventAddressBookUpdate.h | 96 - .../API/Contact/EventAddressBookUpdateBatch.h | 96 - .../API/Contact/EventAddressBookUpdateGroup.h | 97 - .../Contact/EventContactManagerAddChangeListener.h | 119 - .../Contact/EventContactManagerChangeListener.h | 229 -- src/platform/API/Contact/EventContactManagerFind.h | 139 -- src/platform/API/Contact/EventContactManagerGet.h | 118 - .../Contact/EventContactManagerGetAddressBook.h | 118 - .../Contact/EventContactManagerGetAddressBooks.h | 96 - .../EventContactManagerGetDefaultAddressBook.h | 96 - .../API/Contact/EventContactManagerRemove.h | 95 - .../API/Contact/EventContactManagerRemoveBatch.h | 95 - .../EventContactManagerRemoveChangeListener.h | 98 - .../API/Contact/EventContactManagerUpdate.h | 96 - .../API/Contact/EventContactManagerUpdateBatch.h | 96 - src/platform/API/Contact/EventPersonLink.h | 95 - src/platform/API/Contact/EventPersonUnlink.h | 121 - src/platform/API/Contact/IAddressBook.cpp | 154 -- src/platform/API/Contact/IAddressBook.h | 129 - src/platform/API/Contact/IContact.cpp | 697 ------ src/platform/API/Contact/IContact.h | 214 -- .../API/Contact/IContactEventPrivateData.h | 48 - src/platform/API/Contact/IContactManager.cpp | 124 - src/platform/API/Contact/IContactManager.h | 95 - src/platform/API/Contact/IPerson.cpp | 326 --- src/platform/API/Contact/IPerson.h | 142 -- src/platform/API/Contact/config.cmake | 18 - src/platform/API/Content/IEventBrowseFolder.h | 194 -- src/platform/API/Content/IEventFindFolder.h | 162 -- src/platform/API/Content/IEventFindMedia.h | 163 -- src/platform/API/Content/IEventUpdateMedia.h | 73 - src/platform/API/Content/IEventUpdateMediaItems.h | 72 - src/platform/API/Content/IMediacontentManager.cpp | 77 - src/platform/API/Content/IMediacontentManager.h | 78 - src/platform/API/Content/MediacontentAudio.cpp | 210 -- src/platform/API/Content/MediacontentAudio.h | 122 - src/platform/API/Content/MediacontentFactory.cpp | 43 - src/platform/API/Content/MediacontentFactory.h | 43 - src/platform/API/Content/MediacontentFolder.cpp | 143 -- src/platform/API/Content/MediacontentFolder.h | 89 - src/platform/API/Content/MediacontentImage.cpp | 131 - src/platform/API/Content/MediacontentImage.h | 85 - src/platform/API/Content/MediacontentLyrics.cpp | 69 - src/platform/API/Content/MediacontentLyrics.h | 67 - src/platform/API/Content/MediacontentMedia.cpp | 230 -- src/platform/API/Content/MediacontentMedia.h | 127 - src/platform/API/Content/MediacontentVideo.cpp | 167 -- src/platform/API/Content/MediacontentVideo.h | 89 - src/platform/API/Content/config.cmake | 28 - src/platform/API/Download/DownloadRequest.cpp | 86 - src/platform/API/Download/DownloadRequest.h | 63 - src/platform/API/Download/IDownloadManager.cpp | 84 - src/platform/API/Download/IDownloadManager.h | 82 - src/platform/API/Download/IEventCancelDownload.h | 66 - .../API/Download/IEventGetDownloadRequest.h | 79 - src/platform/API/Download/IEventGetMIMEType.h | 78 - src/platform/API/Download/IEventGetState.h | 78 - src/platform/API/Download/IEventPauseDownload.h | 66 - src/platform/API/Download/IEventResumeDownload.h | 66 - src/platform/API/Download/IEventSetListener.h | 78 - src/platform/API/Download/IEventStartDownload.h | 90 - src/platform/API/Download/OnDownloadStateChanged.h | 126 - src/platform/API/Download/config.cmake | 6 - src/platform/API/Filesystem/Enums.h | 111 - src/platform/API/Filesystem/EventCopy.cpp | 66 - src/platform/API/Filesystem/EventCopy.h | 90 - src/platform/API/Filesystem/EventCreate.cpp | 56 - src/platform/API/Filesystem/EventCreate.h | 77 - src/platform/API/Filesystem/EventFind.cpp | 63 - src/platform/API/Filesystem/EventFind.h | 91 - src/platform/API/Filesystem/EventGetStorage.cpp | 50 - src/platform/API/Filesystem/EventGetStorage.h | 49 - src/platform/API/Filesystem/EventListNodes.cpp | 60 - src/platform/API/Filesystem/EventListNodes.h | 81 - src/platform/API/Filesystem/EventListStorages.cpp | 40 - src/platform/API/Filesystem/EventListStorages.h | 46 - src/platform/API/Filesystem/EventMove.cpp | 66 - src/platform/API/Filesystem/EventMove.h | 90 - src/platform/API/Filesystem/EventOpen.cpp | 44 - src/platform/API/Filesystem/EventOpen.h | 67 - src/platform/API/Filesystem/EventReadText.cpp | 35 - src/platform/API/Filesystem/EventReadText.h | 54 - src/platform/API/Filesystem/EventRemove.cpp | 48 - src/platform/API/Filesystem/EventRemove.h | 68 - src/platform/API/Filesystem/EventResolve.cpp | 44 - src/platform/API/Filesystem/EventResolve.h | 69 - .../API/Filesystem/EventStorageStateChanged.h | 53 - .../API/Filesystem/EventStoragestateChanged.cpp | 40 - src/platform/API/Filesystem/IManager.cpp | 51 - src/platform/API/Filesystem/IManager.h | 176 -- src/platform/API/Filesystem/INode.cpp | 39 - src/platform/API/Filesystem/INode.h | 188 -- src/platform/API/Filesystem/INodeTypes.h | 38 - src/platform/API/Filesystem/IPath.cpp | 40 - src/platform/API/Filesystem/IPath.h | 159 -- src/platform/API/Filesystem/IStream.cpp | 29 - src/platform/API/Filesystem/IStream.h | 128 - src/platform/API/Filesystem/NodeFilter.cpp | 110 - src/platform/API/Filesystem/NodeFilter.h | 79 - src/platform/API/Filesystem/PathUtils.cpp | 39 - src/platform/API/Filesystem/PathUtils.h | 44 - src/platform/API/Filesystem/StorageProperties.cpp | 84 - src/platform/API/Filesystem/StorageProperties.h | 72 - src/platform/API/Filesystem/config.cmake | 23 - src/platform/API/Filter/AnyType.cpp | 399 --- src/platform/API/Filter/AnyType.h | 165 -- src/platform/API/Filter/AttributeFilter.cpp | 88 - src/platform/API/Filter/AttributeFilter.h | 100 - src/platform/API/Filter/AttributeRangeFilter.cpp | 88 - src/platform/API/Filter/AttributeRangeFilter.h | 118 - src/platform/API/Filter/CompositeFilter.cpp | 104 - src/platform/API/Filter/CompositeFilter.h | 82 - src/platform/API/Filter/FilterFactory.cpp | 70 - src/platform/API/Filter/FilterFactory.h | 68 - src/platform/API/Filter/FilterTypes.h | 63 - src/platform/API/Filter/FilterValidator.cpp | 100 - src/platform/API/Filter/FilterValidator.h | 90 - src/platform/API/Filter/IFilter.cpp | 41 - src/platform/API/Filter/IFilter.h | 77 - src/platform/API/Filter/IFilterVisitor.cpp | 44 - src/platform/API/Filter/IFilterVisitor.h | 64 - src/platform/API/Filter/SimpleCoordinates.cpp | 66 - src/platform/API/Filter/SimpleCoordinates.h | 74 - src/platform/API/Filter/SortMode.cpp | 62 - src/platform/API/Filter/SortMode.h | 67 - src/platform/API/Filter/config.cmake | 14 - src/platform/API/Messaging/AttachmentFactory.cpp | 473 ---- src/platform/API/Messaging/AttachmentFactory.h | 69 - src/platform/API/Messaging/Attachments.cpp | 290 --- src/platform/API/Messaging/Attachments.h | 236 -- src/platform/API/Messaging/BccRecipient.cpp | 76 - src/platform/API/Messaging/BccRecipient.h | 59 - src/platform/API/Messaging/Body.cpp | 61 - src/platform/API/Messaging/Body.h | 78 - src/platform/API/Messaging/CallbackNumber.cpp | 64 - src/platform/API/Messaging/CallbackNumber.h | 78 - src/platform/API/Messaging/CcRecipient.cpp | 76 - src/platform/API/Messaging/CcRecipient.h | 61 - .../API/Messaging/ConversationFilterValidator.cpp | 90 - .../API/Messaging/ConversationFilterValidator.h | 54 - .../ConversationFilterValidatorFactory.cpp | 58 - .../Messaging/ConversationFilterValidatorFactory.h | 53 - src/platform/API/Messaging/EmailAccountInfo.cpp | 85 - src/platform/API/Messaging/EmailAccountInfo.h | 61 - .../API/Messaging/EmitterConversationReceived.cpp | 26 - .../API/Messaging/EmitterConversationReceived.h | 38 - .../API/Messaging/EmitterFolderReceived.cpp | 26 - src/platform/API/Messaging/EmitterFolderReceived.h | 39 - .../API/Messaging/EmitterMessageReceived.cpp | 25 - .../API/Messaging/EmitterMessageReceived.h | 38 - src/platform/API/Messaging/EventAddDraftMessage.h | 72 - .../API/Messaging/EventDeleteConversations.h | 77 - src/platform/API/Messaging/EventDeleteMessage.h | 48 - src/platform/API/Messaging/EventDeleteMessages.h | 77 - .../API/Messaging/EventGetConversationId.h | 52 - .../API/Messaging/EventGetMessagingService.h | 110 - .../API/Messaging/EventMessageReceived.cpp | 65 - src/platform/API/Messaging/EventMessageReceived.h | 69 - src/platform/API/Messaging/EventMessagingService.h | 123 - src/platform/API/Messaging/EventMessagingStorage.h | 96 - src/platform/API/Messaging/EventOnSendingFailed.h | 69 - .../API/Messaging/EventQueryConversations.h | 92 - src/platform/API/Messaging/EventQueryFolders.h | 95 - src/platform/API/Messaging/EventQueryMessages.h | 113 - src/platform/API/Messaging/EventSendMessage.h | 80 - src/platform/API/Messaging/EventUpdateMessage.h | 51 - src/platform/API/Messaging/EventUpdateMessages.h | 69 - .../API/Messaging/FolderFilterValidator.cpp | 144 -- src/platform/API/Messaging/FolderFilterValidator.h | 66 - .../API/Messaging/FolderFilterValidatorFactory.cpp | 51 - .../API/Messaging/FolderFilterValidatorFactory.h | 52 - src/platform/API/Messaging/From.cpp | 61 - src/platform/API/Messaging/From.h | 69 - src/platform/API/Messaging/IAttachment.cpp | 240 -- src/platform/API/Messaging/IAttachment.h | 176 -- src/platform/API/Messaging/IBinarySms.cpp | 37 - src/platform/API/Messaging/IBinarySms.h | 47 - src/platform/API/Messaging/IConversation.h | 82 - src/platform/API/Messaging/IEmail.cpp | 57 - src/platform/API/Messaging/IEmail.h | 94 - src/platform/API/Messaging/IEmailAccount.cpp | 56 - src/platform/API/Messaging/IEmailAccount.h | 72 - src/platform/API/Messaging/IEmptyMessage.cpp | 40 - src/platform/API/Messaging/IEmptyMessage.h | 51 - src/platform/API/Messaging/IMessage.cpp | 289 --- src/platform/API/Messaging/IMessage.h | 388 --- src/platform/API/Messaging/IMessageFolder.h | 59 - src/platform/API/Messaging/IMessaging.cpp | 37 - src/platform/API/Messaging/IMessaging.h | 115 - src/platform/API/Messaging/IMessagingService.cpp | 65 - src/platform/API/Messaging/IMessagingService.h | 174 -- .../API/Messaging/IMessagingServiceManager.cpp | 38 - .../API/Messaging/IMessagingServiceManager.h | 63 - src/platform/API/Messaging/IMessagingTypes.h | 96 - src/platform/API/Messaging/IMms.cpp | 72 - src/platform/API/Messaging/IMms.h | 80 - src/platform/API/Messaging/IMmsSlide.h | 61 - src/platform/API/Messaging/IMmsSlideProperties.h | 239 -- src/platform/API/Messaging/IMmsSlides.h | 103 - src/platform/API/Messaging/ISms.cpp | 54 - src/platform/API/Messaging/ISms.h | 52 - .../API/Messaging/MessageEventPrivateData.h | 54 - src/platform/API/Messaging/MessageFactory.cpp | 293 --- src/platform/API/Messaging/MessageFactory.h | 114 - .../API/Messaging/MessageFilterValidator.cpp | 206 -- .../API/Messaging/MessageFilterValidator.h | 78 - .../Messaging/MessageFilterValidatorFactory.cpp | 75 - .../API/Messaging/MessageFilterValidatorFactory.h | 64 - src/platform/API/Messaging/MessagePriority.cpp | 52 - src/platform/API/Messaging/MessagePriority.h | 73 - src/platform/API/Messaging/MessageProperties.h | 52 - .../API/Messaging/MessageStorageFactory.cpp | 48 - src/platform/API/Messaging/MessageStorageFactory.h | 45 - src/platform/API/Messaging/MessagingFactory.cpp | 46 - src/platform/API/Messaging/MessagingFactory.h | 45 - src/platform/API/Messaging/MmsSlide.cpp | 164 -- src/platform/API/Messaging/MmsSlide.h | 82 - src/platform/API/Messaging/MmsSlideProperty.cpp | 66 - src/platform/API/Messaging/MmsSlideProperty.h | 79 - src/platform/API/Messaging/MmsSlides.cpp | 95 - src/platform/API/Messaging/MmsSlides.h | 66 - src/platform/API/Messaging/Recipient.cpp | 205 -- src/platform/API/Messaging/Recipient.h | 107 - src/platform/API/Messaging/ReqReceiverMessage.cpp | 856 ------- src/platform/API/Messaging/ReqReceiverMessage.h | 151 -- src/platform/API/Messaging/SourceAddress.cpp | 70 - src/platform/API/Messaging/SourceAddress.h | 57 - .../StorageChangesConversationFilterValidator.cpp | 71 - .../StorageChangesConversationFilterValidator.h | 55 - ...geChangesConversationFilterValidatorFactory.cpp | 68 - ...rageChangesConversationFilterValidatorFactory.h | 57 - .../StorageChangesConversationGenerator.cpp | 690 ----- .../StorageChangesConversationGenerator.h | 114 - .../StorageChangesFolderFilterValidator.cpp | 60 - .../StorageChangesFolderFilterValidator.h | 55 - .../StorageChangesFolderFilterValidatorFactory.cpp | 58 - .../StorageChangesFolderFilterValidatorFactory.h | 52 - .../Messaging/StorageChangesFolderGenerator.cpp | 493 ---- .../API/Messaging/StorageChangesFolderGenerator.h | 100 - .../StorageChangesMessageFilterValidator.cpp | 64 - .../StorageChangesMessageFilterValidator.h | 55 - ...StorageChangesMessageFilterValidatorFactory.cpp | 75 - .../StorageChangesMessageFilterValidatorFactory.h | 60 - .../Messaging/StorageChangesMessageGenerator.cpp | 884 ------- .../API/Messaging/StorageChangesMessageGenerator.h | 124 - src/platform/API/Messaging/Subject.cpp | 63 - src/platform/API/Messaging/Subject.h | 78 - src/platform/API/Messaging/ToRecipient.cpp | 78 - src/platform/API/Messaging/ToRecipient.h | 59 - src/platform/API/Messaging/ValidityPeriodHours.cpp | 56 - src/platform/API/Messaging/ValidityPeriodHours.h | 71 - src/platform/API/Messaging/VirtualMessage.cpp | 102 - src/platform/API/Messaging/VirtualMessage.h | 82 - src/platform/API/NFC/EventNFC.h | 60 - src/platform/API/NFC/EventNFCChanged.h | 101 - src/platform/API/NFC/EventTagAction.h | 93 - src/platform/API/NFC/EventTargetAction.h | 64 - src/platform/API/NFC/INFCAdapter.cpp | 37 - src/platform/API/NFC/INFCAdapter.h | 65 - src/platform/API/NFC/INFCTag.cpp | 39 - src/platform/API/NFC/INFCTag.h | 88 - src/platform/API/NFC/INFCTarget.cpp | 35 - src/platform/API/NFC/INFCTarget.h | 55 - src/platform/API/NFC/INdefMessage.h | 54 - src/platform/API/NFC/INdefRecord.h | 59 - src/platform/API/NFC/NFCFactory.cpp | 90 - src/platform/API/NFC/NFCFactory.h | 64 - src/platform/API/NFC/NFCTagProperties.h | 48 - src/platform/API/NFC/NdefRecordProperties.h | 68 - src/platform/API/NFC/TagFilter.cpp | 50 - src/platform/API/NFC/TagFilter.h | 54 - src/platform/API/NFC/config.cmake | 10 - .../EventNetworkBearerRelease.h | 68 - .../EventNetworkBearerSelection.h | 80 - .../INetworkBearerSelection.cpp | 38 - .../INetworkBearerSelection.h | 59 - .../NetworkBearerSelectionFactory.cpp | 43 - .../NetworkBearerSelectionFactory.h | 44 - .../OnNetworkBearerSelectionStateChanged.h | 65 - .../API/NetworkBearerSelection/config.cmake | 7 - src/platform/API/Notification/INotification.cpp | 37 - src/platform/API/Notification/INotification.h | 74 - .../API/Notification/INotificationManager.cpp | 38 - .../API/Notification/INotificationManager.h | 53 - .../API/Notification/NotificationFactory.cpp | 58 - .../API/Notification/NotificationFactory.h | 51 - src/platform/API/Notification/config.cmake | 8 - src/platform/API/Power/IEventGetScreenBrightness.h | 59 - src/platform/API/Power/IEventIsScreenOn.h | 61 - src/platform/API/Power/IEventRelease.h | 60 - src/platform/API/Power/IEventRequest.h | 70 - .../API/Power/IEventRestoreScreenBrightness.h | 50 - src/platform/API/Power/IEventSetScreenBrightness.h | 61 - .../API/Power/IEventSetScreenStateChangeListener.h | 61 - src/platform/API/Power/IEventTurnScreenOff.h | 51 - src/platform/API/Power/IEventTurnScreenOn.h | 50 - .../Power/IEventUnsetScreenStateChangeListener.h | 52 - src/platform/API/Power/IPowerManager.cpp | 96 - src/platform/API/Power/IPowerManager.h | 82 - src/platform/API/Power/OnPowerStateChanged.h | 88 - src/platform/API/Power/PowerCommon.h | 47 - src/platform/API/Power/config.cmake | 5 - src/platform/API/SystemSetting/EventGetSetting.h | 76 - src/platform/API/SystemSetting/EventSetRingtone.h | 68 - src/platform/API/SystemSetting/EventSetSetting.h | 70 - src/platform/API/SystemSetting/EventSetWallpaper.h | 68 - src/platform/API/SystemSetting/ISystemSetting.cpp | 41 - src/platform/API/SystemSetting/ISystemSetting.h | 74 - .../API/SystemSetting/ISystemSettingType.h | 48 - .../API/SystemSetting/SystemSettingFactory.cpp | 43 - .../API/SystemSetting/SystemSettingFactory.h | 44 - src/platform/API/SystemSetting/config.cmake | 7 - src/platform/API/Systeminfo/BaseProperties.h | 83 - src/platform/API/Systeminfo/EventGetSysteminfo.cpp | 72 - src/platform/API/Systeminfo/EventGetSysteminfo.h | 54 - .../API/Systeminfo/EventWatchSysteminfo.cpp | 416 ---- src/platform/API/Systeminfo/EventWatchSysteminfo.h | 81 - src/platform/API/Systeminfo/ISysteminfo.cpp | 38 - src/platform/API/Systeminfo/ISysteminfo.h | 63 - src/platform/API/Systeminfo/SysteminfoFactory.cpp | 42 - src/platform/API/Systeminfo/SysteminfoFactory.h | 44 - .../API/Systeminfo/SysteminfoPropertyInfo.h | 285 --- src/platform/API/Systeminfo/config.cmake | 9 - src/platform/API/TimeUtil/DurationProperties.h | 59 - src/platform/API/TimeUtil/EventSetCurrentTZDate.h | 53 - src/platform/API/TimeUtil/ITZDate.h | 98 - src/platform/API/TimeUtil/ITimeUtil.h | 58 - src/platform/API/TimeUtil/TZDateProperties.h | 56 - src/platform/API/TimeUtil/TimeUtilFactory.cpp | 50 - src/platform/API/TimeUtil/TimeUtilFactory.h | 54 - src/platform/API/TimeUtil/TimezoneProperties.h | 43 - src/platform/API/TimeUtil/config.cmake | 6 - src/platform/API/config.cmake | 18 - src/platform/CMakeLists.txt | 3 - .../Tizen/Application/AppManagerWrapper.cpp | 634 ----- src/platform/Tizen/Application/AppManagerWrapper.h | 175 -- src/platform/Tizen/Application/Application.cpp | 159 -- src/platform/Tizen/Application/Application.h | 55 - .../Tizen/Application/ApplicationManager.cpp | 1924 -------------- .../Tizen/Application/ApplicationManager.h | 301 --- src/platform/Tizen/Application/config.cmake | 38 - .../Tizen/Bluetooth/BluetoothAdapterManager.cpp | 1074 -------- .../Tizen/Bluetooth/BluetoothAdapterManager.h | 110 - .../Tizen/Bluetooth/BluetoothCBManager.cpp | 593 ----- src/platform/Tizen/Bluetooth/BluetoothCBManager.h | 97 - .../Tizen/Bluetooth/BluetoothDeviceManager.cpp | 342 --- .../Tizen/Bluetooth/BluetoothDeviceManager.h | 82 - .../Bluetooth/BluetoothServiceHandlerManager.cpp | 171 -- .../Bluetooth/BluetoothServiceHandlerManager.h | 67 - .../Tizen/Bluetooth/BluetoothSocketManager.cpp | 187 -- .../Tizen/Bluetooth/BluetoothSocketManager.h | 72 - src/platform/Tizen/Bluetooth/config.cmake | 22 - src/platform/Tizen/Calendar/Calendar.cpp | 1313 ---------- src/platform/Tizen/Calendar/Calendar.h | 57 - src/platform/Tizen/Calendar/CalendarFilter.cpp | 562 ----- src/platform/Tizen/Calendar/CalendarFilter.h | 114 - .../Tizen/Calendar/CalendarFilterValidator.cpp | 66 - .../Tizen/Calendar/CalendarFilterValidator.h | 43 - src/platform/Tizen/Calendar/CalendarManager.cpp | 326 --- src/platform/Tizen/Calendar/CalendarManager.h | 50 - src/platform/Tizen/Calendar/EventWrapper.cpp | 2319 ----------------- src/platform/Tizen/Calendar/EventWrapper.h | 127 - src/platform/Tizen/Calendar/config.cmake | 25 - src/platform/Tizen/Callhistory/CallHistory.cpp | 874 ------- src/platform/Tizen/Callhistory/CallHistory.h | 162 -- .../Tizen/Callhistory/CallHistoryEntry.cpp | 92 - src/platform/Tizen/Callhistory/CallHistoryEntry.h | 45 - .../Tizen/Callhistory/CallHistoryFilter.cpp | 303 --- src/platform/Tizen/Callhistory/CallHistoryFilter.h | 69 - src/platform/Tizen/Callhistory/config.cmake | 27 - src/platform/Tizen/Contact/AddressBook.cpp | 1776 ------------- src/platform/Tizen/Contact/AddressBook.h | 170 -- src/platform/Tizen/Contact/Contact.cpp | 131 - src/platform/Tizen/Contact/Contact.h | 58 - .../Tizen/Contact/ContactFilterValidator.cpp | 89 - .../Tizen/Contact/ContactFilterValidator.h | 49 - src/platform/Tizen/Contact/ContactManager.cpp | 860 ------- src/platform/Tizen/Contact/ContactManager.h | 128 - .../Tizen/Contact/ContactObjectA2PConverter.cpp | 1614 ------------ .../Tizen/Contact/ContactObjectA2PConverter.h | 92 - .../Tizen/Contact/ContactObjectP2AConverter.cpp | 845 ------- .../Tizen/Contact/ContactObjectP2AConverter.h | 75 - src/platform/Tizen/Contact/ContactSearchEngine.cpp | 1117 --------- src/platform/Tizen/Contact/ContactSearchEngine.h | 152 -- src/platform/Tizen/Contact/ContactUtility.cpp | 176 -- src/platform/Tizen/Contact/ContactUtility.h | 62 - .../Contact/ContactsSvcChangeListenerManager.cpp | 634 ----- .../Contact/ContactsSvcChangeListenerManager.h | 136 - .../Tizen/Contact/ContactsSvcObjectConverter.cpp | 444 ---- .../Tizen/Contact/ContactsSvcObjectConverter.h | 59 - src/platform/Tizen/Contact/ContactsSvcWrapper.cpp | 267 -- src/platform/Tizen/Contact/ContactsSvcWrapper.h | 68 - src/platform/Tizen/Contact/Person.cpp | 273 -- src/platform/Tizen/Contact/Person.h | 62 - .../Tizen/Contact/PersonFilterValidator.cpp | 56 - src/platform/Tizen/Contact/PersonFilterValidator.h | 49 - src/platform/Tizen/Contact/PersonSearchEngine.cpp | 457 ---- src/platform/Tizen/Contact/PersonSearchEngine.h | 91 - src/platform/Tizen/Contact/config.cmake | 37 - .../Tizen/Content/MediaFilterValidator.cpp | 80 - src/platform/Tizen/Content/MediaFilterValidator.h | 54 - src/platform/Tizen/Content/MediaSearchVisitor.cpp | 342 --- src/platform/Tizen/Content/MediaSearchVisitor.h | 105 - src/platform/Tizen/Content/MediaWrapper.cpp | 136 - src/platform/Tizen/Content/MediaWrapper.h | 46 - src/platform/Tizen/Content/MediacontentManager.cpp | 1341 ---------- src/platform/Tizen/Content/MediacontentManager.h | 90 - src/platform/Tizen/Content/config.cmake | 30 - src/platform/Tizen/DBus/Connection.cpp | 345 --- src/platform/Tizen/DBus/Connection.h | 142 -- src/platform/Tizen/DBus/Message.cpp | 139 -- src/platform/Tizen/DBus/Message.h | 86 - src/platform/Tizen/DBus/MessageEvent.h | 32 - src/platform/Tizen/DBus/config.cmake | 16 - src/platform/Tizen/Download/DownloadManager.cpp | 785 ------ src/platform/Tizen/Download/DownloadManager.h | 53 - src/platform/Tizen/Download/config.cmake | 18 - src/platform/Tizen/Filesystem/Manager.cpp | 914 ------- src/platform/Tizen/Filesystem/Manager.h | 190 -- src/platform/Tizen/Filesystem/Node.cpp | 569 ----- src/platform/Tizen/Filesystem/Node.h | 117 - .../Tizen/Filesystem/NodeFilterMatcher.cpp | 79 - src/platform/Tizen/Filesystem/NodeFilterMatcher.h | 52 - src/platform/Tizen/Filesystem/Path.cpp | 123 - src/platform/Tizen/Filesystem/Path.h | 70 - src/platform/Tizen/Filesystem/Stream.cpp | 308 --- src/platform/Tizen/Filesystem/Stream.h | 104 - src/platform/Tizen/Filesystem/System.cpp | 35 - src/platform/Tizen/Filesystem/System.h | 36 - src/platform/Tizen/Filesystem/Utils.cpp | 103 - src/platform/Tizen/Filesystem/Utils.h | 36 - src/platform/Tizen/Filesystem/config.cmake | 29 - src/platform/Tizen/Messaging/Attachment.cpp | 133 - src/platform/Tizen/Messaging/Attachment.h | 52 - src/platform/Tizen/Messaging/BinarySms.cpp | 109 - src/platform/Tizen/Messaging/BinarySms.h | 67 - src/platform/Tizen/Messaging/CallbackMgr.cpp | 168 -- src/platform/Tizen/Messaging/CallbackMgr.h | 79 - src/platform/Tizen/Messaging/Conversation.cpp | 877 ------- src/platform/Tizen/Messaging/Conversation.h | 111 - .../Tizen/Messaging/ConversationQueryGenerator.cpp | 134 - .../Tizen/Messaging/ConversationQueryGenerator.h | 64 - src/platform/Tizen/Messaging/Email.cpp | 1357 ---------- src/platform/Tizen/Messaging/Email.h | 146 -- src/platform/Tizen/Messaging/EmailConverter.cpp | 141 -- src/platform/Tizen/Messaging/EmailConverter.h | 46 - src/platform/Tizen/Messaging/EmailService.cpp | 313 --- src/platform/Tizen/Messaging/EmailService.h | 103 - src/platform/Tizen/Messaging/EmailUtils.cpp | 94 - src/platform/Tizen/Messaging/EmailUtils.h | 66 - src/platform/Tizen/Messaging/EmptyMessage.cpp | 126 - src/platform/Tizen/Messaging/EmptyMessage.h | 72 - .../Tizen/Messaging/FolderQueryGenerator.cpp | 178 -- .../Tizen/Messaging/FolderQueryGenerator.h | 104 - src/platform/Tizen/Messaging/ISendingObserver.h | 73 - src/platform/Tizen/Messaging/MailSender.cpp | 316 --- src/platform/Tizen/Messaging/MailSender.h | 82 - src/platform/Tizen/Messaging/MailSync.cpp | 740 ------ src/platform/Tizen/Messaging/MailSync.h | 185 -- src/platform/Tizen/Messaging/MessageFolder.cpp | 139 -- src/platform/Tizen/Messaging/MessageFolder.h | 91 - .../Tizen/Messaging/MessageQueryGenerator.cpp | 878 ------- .../Tizen/Messaging/MessageQueryGenerator.h | 148 -- src/platform/Tizen/Messaging/Messaging.cpp | 2631 -------------------- src/platform/Tizen/Messaging/Messaging.h | 241 -- src/platform/Tizen/Messaging/MessagingService.cpp | 322 --- src/platform/Tizen/Messaging/MessagingService.h | 112 - .../Tizen/Messaging/MessagingServiceManager.cpp | 242 -- .../Tizen/Messaging/MessagingServiceManager.h | 83 - src/platform/Tizen/Messaging/Mms.cpp | 1423 ----------- src/platform/Tizen/Messaging/Mms.h | 126 - src/platform/Tizen/Messaging/MmsSlide.cpp | 17 - src/platform/Tizen/Messaging/MmsSlide.h | 37 - src/platform/Tizen/Messaging/MsgServiceHandleMgr.h | 107 - src/platform/Tizen/Messaging/NetworkStatus.cpp | 86 - src/platform/Tizen/Messaging/NetworkStatus.h | 61 - src/platform/Tizen/Messaging/ScopedMail.h | 57 - .../Tizen/Messaging/ScopedMailAttachment.h | 57 - src/platform/Tizen/Messaging/ScopedMailbox.h | 58 - src/platform/Tizen/Messaging/Sms.cpp | 1178 --------- src/platform/Tizen/Messaging/Sms.h | 145 -- src/platform/Tizen/Messaging/SyncNetworkStatus.cpp | 92 - src/platform/Tizen/Messaging/SyncNetworkStatus.h | 59 - .../Messaging/messageDB/MessageStorageReader.cpp | 606 ----- src/platform/Tizen/NFC/NFCAdapter.cpp | 290 --- src/platform/Tizen/NFC/NFCAdapter.h | 86 - src/platform/Tizen/NFC/NFCDefaultAdapter.cpp | 477 ---- src/platform/Tizen/NFC/NFCDefaultAdapter.h | 97 - src/platform/Tizen/NFC/NFCTag.cpp | 460 ---- src/platform/Tizen/NFC/NFCTag.h | 79 - src/platform/Tizen/NFC/NFCTarget.cpp | 212 -- src/platform/Tizen/NFC/NFCTarget.h | 59 - src/platform/Tizen/NFC/NFCUtil.cpp | 364 --- src/platform/Tizen/NFC/NFCUtil.h | 60 - src/platform/Tizen/NFC/NdefMessage.cpp | 231 -- src/platform/Tizen/NFC/NdefMessage.h | 60 - src/platform/Tizen/NFC/NdefRecord.cpp | 381 --- src/platform/Tizen/NFC/NdefRecord.h | 66 - src/platform/Tizen/NFC/config.cmake | 24 - .../NetworkBearerSelection.cpp | 316 --- .../NetworkBearerSelection.h | 111 - .../Tizen/NetworkBearerSelection/config.cmake | 18 - .../Tizen/Notification/NotificationManager.cpp | 479 ---- .../Tizen/Notification/NotificationManager.h | 64 - .../Tizen/Notification/StatusNotification.cpp | 693 ------ .../Tizen/Notification/StatusNotification.h | 94 - src/platform/Tizen/Notification/config.cmake | 23 - src/platform/Tizen/Power/PowerManager.cpp | 418 ---- src/platform/Tizen/Power/PowerManager.h | 56 - src/platform/Tizen/Power/config.cmake | 24 - src/platform/Tizen/SystemSetting/SystemSetting.cpp | 282 --- src/platform/Tizen/SystemSetting/SystemSetting.h | 68 - src/platform/Tizen/SystemSetting/config.cmake | 18 - src/platform/Tizen/Systeminfo/Systeminfo.cpp | 1493 ----------- src/platform/Tizen/Systeminfo/Systeminfo.h | 217 -- src/platform/Tizen/Systeminfo/config.cmake | 30 - src/platform/Tizen/TimeUtil/TZDate.cpp | 698 ------ src/platform/Tizen/TimeUtil/TZDate.h | 88 - src/platform/Tizen/TimeUtil/TimeUtil.cpp | 206 -- src/platform/Tizen/TimeUtil/TimeUtil.h | 57 - src/platform/Tizen/TimeUtil/TimeUtilTools.cpp | 173 -- src/platform/Tizen/TimeUtil/TimeUtilTools.h | 63 - src/platform/Tizen/TimeUtil/config.cmake | 19 - src/platform/Tizen/config.cmake | 18 - src/standards/CMakeLists.txt | 6 - src/standards/Tizen/Alarm/AlarmAbsolute.cpp | 126 - src/standards/Tizen/Alarm/AlarmAbsolute.h | 72 - src/standards/Tizen/Alarm/AlarmConverter.cpp | 270 -- src/standards/Tizen/Alarm/AlarmConverter.h | 69 - src/standards/Tizen/Alarm/AlarmRelative.cpp | 103 - src/standards/Tizen/Alarm/AlarmRelative.h | 73 - src/standards/Tizen/Alarm/CMakeLists.txt | 37 - src/standards/Tizen/Alarm/JSAlarmAbsolute.cpp | 388 --- src/standards/Tizen/Alarm/JSAlarmAbsolute.h | 93 - src/standards/Tizen/Alarm/JSAlarmManager.cpp | 588 ----- src/standards/Tizen/Alarm/JSAlarmManager.h | 70 - src/standards/Tizen/Alarm/JSAlarmRelative.cpp | 335 --- src/standards/Tizen/Alarm/JSAlarmRelative.h | 84 - src/standards/Tizen/Alarm/alarm_common.h | 63 - src/standards/Tizen/Alarm/config.xml | 15 - src/standards/Tizen/Alarm/plugin_config.cpp | 107 - src/standards/Tizen/Alarm/plugin_config.h | 46 - src/standards/Tizen/Alarm/plugin_initializer.cpp | 79 - .../ApplicationAsyncCallbackManager.cpp | 32 - .../Application/ApplicationAsyncCallbackManager.h | 48 - .../Tizen/Application/ApplicationController.cpp | 632 ----- .../Tizen/Application/ApplicationController.h | 105 - .../Tizen/Application/ApplicationConverter.cpp | 398 --- .../Tizen/Application/ApplicationConverter.h | 71 - .../ApplicationInformationEventPrivateData.h | 67 - .../Application/ApplicationListenerManager.cpp | 31 - .../Tizen/Application/ApplicationListenerManager.h | 99 - .../Tizen/Application/ApplicationUtil.cpp | 138 - src/standards/Tizen/Application/ApplicationUtil.h | 56 - src/standards/Tizen/Application/CMakeLists.txt | 51 - src/standards/Tizen/Application/JSApplication.cpp | 270 -- src/standards/Tizen/Application/JSApplication.h | 126 - .../Tizen/Application/JSApplicationCert.cpp | 134 - .../Tizen/Application/JSApplicationCert.h | 84 - .../Tizen/Application/JSApplicationContext.cpp | 172 -- .../Tizen/Application/JSApplicationContext.h | 93 - .../Tizen/Application/JSApplicationControl.cpp | 296 --- .../Tizen/Application/JSApplicationControl.h | 130 - .../Tizen/Application/JSApplicationControlData.cpp | 229 -- .../Tizen/Application/JSApplicationControlData.h | 108 - .../JSApplicationEventCallbackManager.cpp | 249 -- .../JSApplicationEventCallbackManager.h | 86 - .../Tizen/Application/JSApplicationInformation.cpp | 198 -- .../Tizen/Application/JSApplicationInformation.h | 107 - .../Tizen/Application/JSApplicationInstallInfo.cpp | 179 -- .../Tizen/Application/JSApplicationInstallInfo.h | 99 - .../Tizen/Application/JSApplicationManager.cpp | 1476 ----------- .../Tizen/Application/JSApplicationManager.h | 172 -- .../Application/JSRequestedApplicationControl.cpp | 285 --- .../Application/JSRequestedApplicationControl.h | 136 - src/standards/Tizen/Application/config.xml | 30 - src/standards/Tizen/Application/plugin_config.cpp | 339 --- src/standards/Tizen/Application/plugin_config.h | 73 - .../Tizen/Application/plugin_initializer.cpp | 94 - .../Tizen/Bluetooth/BluetoothAdapterListener.cpp | 370 --- .../Tizen/Bluetooth/BluetoothAdapterListener.h | 96 - src/standards/Tizen/Bluetooth/BluetoothClass.cpp | 258 -- src/standards/Tizen/Bluetooth/BluetoothClass.h | 68 - .../Tizen/Bluetooth/BluetoothConverter.cpp | 362 --- src/standards/Tizen/Bluetooth/BluetoothConverter.h | 60 - .../Bluetooth/BluetoothDeviceManagerListener.cpp | 84 - .../Bluetooth/BluetoothDeviceManagerListener.h | 58 - .../Tizen/Bluetooth/BluetoothMultiCallback.cpp | 97 - .../Tizen/Bluetooth/BluetoothMultiCallback.h | 133 - .../Tizen/Bluetooth/BluetoothSocketListener.cpp | 96 - .../Tizen/Bluetooth/BluetoothSocketListener.h | 55 - src/standards/Tizen/Bluetooth/CMakeLists.txt | 40 - .../Tizen/Bluetooth/JSBluetoothAdapter.cpp | 1386 ----------- src/standards/Tizen/Bluetooth/JSBluetoothAdapter.h | 152 -- src/standards/Tizen/Bluetooth/JSBluetoothClass.cpp | 309 --- src/standards/Tizen/Bluetooth/JSBluetoothClass.h | 74 - .../Bluetooth/JSBluetoothClassDeviceMajor.cpp | 181 -- .../Tizen/Bluetooth/JSBluetoothClassDeviceMajor.h | 59 - .../Bluetooth/JSBluetoothClassDeviceMinor.cpp | 244 -- .../Tizen/Bluetooth/JSBluetoothClassDeviceMinor.h | 58 - .../Bluetooth/JSBluetoothClassDeviceService.cpp | 181 -- .../Bluetooth/JSBluetoothClassDeviceService.h | 57 - .../Tizen/Bluetooth/JSBluetoothDevice.cpp | 502 ---- src/standards/Tizen/Bluetooth/JSBluetoothDevice.h | 68 - .../Tizen/Bluetooth/JSBluetoothManager.cpp | 244 -- src/standards/Tizen/Bluetooth/JSBluetoothManager.h | 56 - .../Tizen/Bluetooth/JSBluetoothServiceHandler.cpp | 409 --- .../Tizen/Bluetooth/JSBluetoothServiceHandler.h | 63 - .../Tizen/Bluetooth/JSBluetoothSocket.cpp | 524 ---- src/standards/Tizen/Bluetooth/JSBluetoothSocket.h | 94 - src/standards/Tizen/Bluetooth/config.xml | 22 - src/standards/Tizen/Bluetooth/plugin_config.cpp | 149 -- src/standards/Tizen/Bluetooth/plugin_config.h | 59 - .../Tizen/Bluetooth/plugin_initializer.cpp | 67 - src/standards/Tizen/CMakeLists.txt | 52 - src/standards/Tizen/Calendar/CMakeLists.txt | 48 - .../Calendar/CalendarAsyncCallbackManager.cpp | 23 - .../Tizen/Calendar/CalendarAsyncCallbackManager.h | 49 - src/standards/Tizen/Calendar/CalendarConverter.cpp | 1021 -------- src/standards/Tizen/Calendar/CalendarConverter.h | 113 - .../Tizen/Calendar/CalendarListenerManager.cpp | 23 - .../Tizen/Calendar/CalendarListenerManager.h | 91 - .../Tizen/Calendar/CalendarMultiCallback.h | 130 - .../Tizen/Calendar/CalendarResponseDispatcher.cpp | 339 --- .../Tizen/Calendar/CalendarResponseDispatcher.h | 79 - src/standards/Tizen/Calendar/JSCalendar.cpp | 1154 --------- src/standards/Tizen/Calendar/JSCalendar.h | 208 -- src/standards/Tizen/Calendar/JSCalendarAlarm.cpp | 321 --- src/standards/Tizen/Calendar/JSCalendarAlarm.h | 110 - .../Tizen/Calendar/JSCalendarAttendee.cpp | 339 --- src/standards/Tizen/Calendar/JSCalendarAttendee.h | 120 - src/standards/Tizen/Calendar/JSCalendarEvent.cpp | 459 ---- src/standards/Tizen/Calendar/JSCalendarEvent.h | 138 - src/standards/Tizen/Calendar/JSCalendarEventId.cpp | 271 -- src/standards/Tizen/Calendar/JSCalendarEventId.h | 109 - .../Tizen/Calendar/JSCalendarItemProperties.cpp | 1389 ----------- .../Tizen/Calendar/JSCalendarItemProperties.h | 321 --- src/standards/Tizen/Calendar/JSCalendarManager.cpp | 351 --- src/standards/Tizen/Calendar/JSCalendarManager.h | 165 -- .../Tizen/Calendar/JSCalendarRecurrenceRule.cpp | 341 --- .../Tizen/Calendar/JSCalendarRecurrenceRule.h | 120 - src/standards/Tizen/Calendar/JSCalendarTask.cpp | 312 --- src/standards/Tizen/Calendar/JSCalendarTask.h | 121 - src/standards/Tizen/Calendar/JSNumberArray.cpp | 598 ----- src/standards/Tizen/Calendar/JSNumberArray.h | 183 -- src/standards/Tizen/Calendar/JSStringArray.cpp | 597 ----- src/standards/Tizen/Calendar/JSStringArray.h | 182 -- src/standards/Tizen/Calendar/JSTZDateArray.cpp | 602 ----- src/standards/Tizen/Calendar/JSTZDateArray.h | 183 -- src/standards/Tizen/Calendar/config.xml | 20 - src/standards/Tizen/Calendar/plugin_config.cpp | 258 -- src/standards/Tizen/Calendar/plugin_config.h | 59 - .../Tizen/Calendar/plugin_initializer.cpp | 117 - src/standards/Tizen/Callhistory/CMakeLists.txt | 36 - .../CallHistoryAsyncCallbackManager.cpp | 29 - .../Callhistory/CallHistoryAsyncCallbackManager.h | 46 - .../Callhistory/CallHistoryListenerManager.cpp | 29 - .../Tizen/Callhistory/CallHistoryListenerManager.h | 81 - .../Tizen/Callhistory/CallHistoryMultiCallback.cpp | 42 - .../Tizen/Callhistory/CallHistoryMultiCallback.h | 61 - .../Callhistory/CallHistoryStaticController.cpp | 79 - .../Callhistory/CallHistoryStaticController.h | 42 - src/standards/Tizen/Callhistory/Converter.cpp | 265 -- src/standards/Tizen/Callhistory/Converter.h | 70 - src/standards/Tizen/Callhistory/JSCallHistory.cpp | 533 ---- src/standards/Tizen/Callhistory/JSCallHistory.h | 92 - .../Tizen/Callhistory/JSCallHistoryEntry.cpp | 232 -- .../Tizen/Callhistory/JSCallHistoryEntry.h | 73 - src/standards/Tizen/Callhistory/JSRemoteParty.cpp | 157 -- src/standards/Tizen/Callhistory/JSRemoteParty.h | 67 - .../Tizen/Callhistory/ResponseDispatcher.cpp | 124 - .../Tizen/Callhistory/ResponseDispatcher.h | 48 - src/standards/Tizen/Callhistory/config.xml | 20 - src/standards/Tizen/Callhistory/plugin_config.cpp | 127 - src/standards/Tizen/Callhistory/plugin_config.h | 49 - .../Tizen/Callhistory/plugin_initializer.cpp | 74 - src/standards/Tizen/Common/AsyncCallbackManager.h | 96 - src/standards/Tizen/Common/CMakeLists.txt | 16 - src/standards/Tizen/Common/IListenerManager.h | 155 -- src/standards/Tizen/Common/JSTizenException.cpp | 144 -- src/standards/Tizen/Common/JSTizenException.h | 98 - .../Tizen/Common/JSTizenExceptionFactory.cpp | 58 - .../Tizen/Common/JSTizenExceptionFactory.h | 44 - src/standards/Tizen/Common/JSWebAPIError.cpp | 298 --- src/standards/Tizen/Common/JSWebAPIError.h | 105 - src/standards/Tizen/Common/SecurityExceptions.h | 70 - src/standards/Tizen/Common/TizenExceptionData.cpp | 41 - src/standards/Tizen/Common/TizenExceptionData.h | 47 - .../Tizen/Contact/AddressBookController.cpp | 465 ---- .../Tizen/Contact/AddressBookController.h | 90 - src/standards/Tizen/Contact/CMakeLists.txt | 73 - .../Tizen/Contact/ContactAsyncCallbackManager.cpp | 38 - .../Tizen/Contact/ContactAsyncCallbackManager.h | 55 - src/standards/Tizen/Contact/ContactConverter.cpp | 1428 ----------- src/standards/Tizen/Contact/ContactConverter.h | 187 -- .../Tizen/Contact/ContactListenerManager.cpp | 38 - .../Tizen/Contact/ContactListenerManager.h | 138 - .../Tizen/Contact/ContactManagerController.cpp | 462 ---- .../Tizen/Contact/ContactManagerController.h | 90 - src/standards/Tizen/Contact/JSAddressBook.cpp | 1689 ------------- src/standards/Tizen/Contact/JSAddressBook.h | 202 -- src/standards/Tizen/Contact/JSAddressBookArray.cpp | 633 ----- src/standards/Tizen/Contact/JSAddressBookArray.h | 192 -- .../Contact/JSAddressBookChangeCallbackManager.cpp | 256 -- .../Contact/JSAddressBookChangeCallbackManager.h | 93 - .../Tizen/Contact/JSAttributesOfInterestArray.cpp | 621 ----- .../Tizen/Contact/JSAttributesOfInterestArray.h | 187 -- src/standards/Tizen/Contact/JSContact.cpp | 1086 -------- src/standards/Tizen/Contact/JSContact.h | 271 -- src/standards/Tizen/Contact/JSContactAddress.cpp | 626 ----- src/standards/Tizen/Contact/JSContactAddress.h | 189 -- .../Tizen/Contact/JSContactAddressArray.cpp | 633 ----- .../Tizen/Contact/JSContactAddressArray.h | 191 -- .../Tizen/Contact/JSContactAddressTypeArray.cpp | 633 ----- .../Tizen/Contact/JSContactAddressTypeArray.h | 193 -- .../Tizen/Contact/JSContactAnniversary.cpp | 329 --- src/standards/Tizen/Contact/JSContactAnniversary.h | 122 - .../Tizen/Contact/JSContactAnniversaryArray.cpp | 633 ----- .../Tizen/Contact/JSContactAnniversaryArray.h | 192 -- src/standards/Tizen/Contact/JSContactArray.cpp | 633 ----- src/standards/Tizen/Contact/JSContactArray.h | 192 -- .../Tizen/Contact/JSContactEmailAddress.cpp | 393 --- .../Tizen/Contact/JSContactEmailAddress.h | 133 - .../Tizen/Contact/JSContactEmailAddressArray.cpp | 633 ----- .../Tizen/Contact/JSContactEmailAddressArray.h | 192 -- .../Contact/JSContactEmailAddressTypeArray.cpp | 628 ----- .../Tizen/Contact/JSContactEmailAddressTypeArray.h | 193 -- src/standards/Tizen/Contact/JSContactGroup.cpp | 503 ---- src/standards/Tizen/Contact/JSContactGroup.h | 161 -- .../Tizen/Contact/JSContactGroupArray.cpp | 633 ----- src/standards/Tizen/Contact/JSContactGroupArray.h | 192 -- src/standards/Tizen/Contact/JSContactManager.cpp | 1199 --------- src/standards/Tizen/Contact/JSContactManager.h | 166 -- .../JSContactManagerChangeCallbackManager.cpp | 256 -- .../JSContactManagerChangeCallbackManager.h | 93 - src/standards/Tizen/Contact/JSContactName.cpp | 690 ----- src/standards/Tizen/Contact/JSContactName.h | 205 -- .../Tizen/Contact/JSContactOrganization.cpp | 499 ---- .../Tizen/Contact/JSContactOrganization.h | 166 -- .../Tizen/Contact/JSContactOrganizationArray.cpp | 632 ----- .../Tizen/Contact/JSContactOrganizationArray.h | 192 -- .../Tizen/Contact/JSContactPhoneNumber.cpp | 394 --- src/standards/Tizen/Contact/JSContactPhoneNumber.h | 133 - .../Tizen/Contact/JSContactPhoneNumberArray.cpp | 633 ----- .../Tizen/Contact/JSContactPhoneNumberArray.h | 192 -- .../Contact/JSContactPhoneNumberTypeArray.cpp | 627 ----- .../Tizen/Contact/JSContactPhoneNumberTypeArray.h | 193 -- src/standards/Tizen/Contact/JSContactRef.cpp | 324 --- src/standards/Tizen/Contact/JSContactRef.h | 123 - src/standards/Tizen/Contact/JSContactWebSite.cpp | 330 --- src/standards/Tizen/Contact/JSContactWebSite.h | 123 - .../Tizen/Contact/JSContactWebSiteArray.cpp | 633 ----- .../Tizen/Contact/JSContactWebSiteArray.h | 192 -- src/standards/Tizen/Contact/JSPerson.cpp | 733 ------ src/standards/Tizen/Contact/JSPerson.h | 177 -- src/standards/Tizen/Contact/JSPersonArray.cpp | 639 ----- src/standards/Tizen/Contact/JSPersonArray.h | 192 -- src/standards/Tizen/Contact/JSStringArray.cpp | 602 ----- src/standards/Tizen/Contact/JSStringArray.h | 189 -- src/standards/Tizen/Contact/config.xml | 19 - src/standards/Tizen/Contact/plugin_config.cpp | 394 --- src/standards/Tizen/Contact/plugin_config.h | 69 - src/standards/Tizen/Contact/plugin_initializer.cpp | 135 - src/standards/Tizen/Content/CMakeLists.txt | 50 - .../Tizen/Content/ContentAsyncCallbackManager.cpp | 31 - .../Tizen/Content/ContentAsyncCallbackManager.h | 53 - src/standards/Tizen/Content/ContentController.cpp | 163 -- src/standards/Tizen/Content/ContentController.h | 61 - src/standards/Tizen/Content/ContentConverter.cpp | 135 - src/standards/Tizen/Content/ContentConverter.h | 76 - src/standards/Tizen/Content/JSAudio.cpp | 649 ----- src/standards/Tizen/Content/JSAudio.h | 201 -- src/standards/Tizen/Content/JSContentManager.cpp | 667 ----- src/standards/Tizen/Content/JSContentManager.h | 146 -- src/standards/Tizen/Content/JSFolder.cpp | 298 --- src/standards/Tizen/Content/JSFolder.h | 130 - src/standards/Tizen/Content/JSImage.cpp | 294 --- src/standards/Tizen/Content/JSImage.h | 138 - src/standards/Tizen/Content/JSMedia.cpp | 543 ---- src/standards/Tizen/Content/JSMedia.h | 184 -- src/standards/Tizen/Content/JSMediaLyrics.cpp | 250 -- src/standards/Tizen/Content/JSMediaLyrics.h | 114 - src/standards/Tizen/Content/JSVideo.cpp | 391 --- src/standards/Tizen/Content/JSVideo.h | 167 -- src/standards/Tizen/Content/MediaLyricsUtil.cpp | 148 -- src/standards/Tizen/Content/MediaLyricsUtil.h | 49 - src/standards/Tizen/Content/config.xml | 20 - src/standards/Tizen/Content/plugin_config.cpp | 155 -- src/standards/Tizen/Content/plugin_config.h | 51 - src/standards/Tizen/Content/plugin_initializer.cpp | 90 - src/standards/Tizen/Download/CMakeLists.txt | 35 - src/standards/Tizen/Download/DownloadConverter.cpp | 60 - src/standards/Tizen/Download/DownloadConverter.h | 52 - .../Tizen/Download/DownloadListenerManager.cpp | 22 - .../Tizen/Download/DownloadListenerManager.h | 89 - .../Tizen/Download/DownloadMultiCallback.h | 82 - .../Tizen/Download/DownloadResponseDispatcher.cpp | 116 - .../Tizen/Download/DownloadResponseDispatcher.h | 49 - src/standards/Tizen/Download/JSDownloadManager.cpp | 919 ------- src/standards/Tizen/Download/JSDownloadManager.h | 163 -- src/standards/Tizen/Download/JSDownloadRequest.cpp | 275 -- src/standards/Tizen/Download/JSDownloadRequest.h | 111 - src/standards/Tizen/Download/config.xml | 15 - src/standards/Tizen/Download/plugin_config.cpp | 82 - src/standards/Tizen/Download/plugin_config.h | 48 - .../Tizen/Download/plugin_initializer.cpp | 90 - src/standards/Tizen/Filesystem/CMakeLists.txt | 48 - src/standards/Tizen/Filesystem/Converter.cpp | 293 --- src/standards/Tizen/Filesystem/Converter.h | 77 - src/standards/Tizen/Filesystem/Encodings.cpp | 29 - src/standards/Tizen/Filesystem/Encodings.h | 32 - .../Tizen/Filesystem/EventGetNodeData.cpp | 41 - src/standards/Tizen/Filesystem/EventGetNodeData.h | 47 - .../Filesystem/FilesystemAsyncCallbackManager.cpp | 29 - .../Filesystem/FilesystemAsyncCallbackManager.h | 46 - .../Tizen/Filesystem/FilesystemListenerManager.cpp | 28 - .../Tizen/Filesystem/FilesystemListenerManager.h | 76 - src/standards/Tizen/Filesystem/FilesystemUtils.cpp | 163 -- src/standards/Tizen/Filesystem/FilesystemUtils.h | 40 - src/standards/Tizen/Filesystem/JSFile.cpp | 1130 --------- src/standards/Tizen/Filesystem/JSFile.h | 286 --- src/standards/Tizen/Filesystem/JSFilestream.cpp | 433 ---- src/standards/Tizen/Filesystem/JSFilestream.h | 172 -- .../Tizen/Filesystem/JSFilesystemManager.cpp | 487 ---- .../Tizen/Filesystem/JSFilesystemManager.h | 124 - src/standards/Tizen/Filesystem/JSStorage.cpp | 170 -- src/standards/Tizen/Filesystem/JSStorage.h | 100 - .../Tizen/Filesystem/ResponseDispatcher.cpp | 295 --- .../Tizen/Filesystem/ResponseDispatcher.h | 67 - .../Tizen/Filesystem/StorageStaticController.cpp | 66 - .../Tizen/Filesystem/StorageStaticController.h | 44 - src/standards/Tizen/Filesystem/config.xml | 21 - src/standards/Tizen/Filesystem/plugin_config.cpp | 391 --- src/standards/Tizen/Filesystem/plugin_config.h | 146 -- .../Tizen/Filesystem/plugin_initializer.cpp | 76 - src/standards/Tizen/Messaging/CMakeLists.txt | 70 - src/standards/Tizen/Messaging/ConverterMessage.cpp | 610 ----- src/standards/Tizen/Messaging/ConverterMessage.h | 148 -- .../Messaging/EventMessagingServicePrivateData.cpp | 50 - .../Messaging/EventMessagingServicePrivateData.h | 74 - .../Messaging/EventSendMessagePrivateData.cpp | 43 - .../Tizen/Messaging/EventSendMessagePrivateData.h | 45 - src/standards/Tizen/Messaging/JSConversation.cpp | 270 -- src/standards/Tizen/Messaging/JSConversation.h | 115 - src/standards/Tizen/Messaging/JSMessage.cpp | 1942 --------------- src/standards/Tizen/Messaging/JSMessage.h | 333 --- .../Tizen/Messaging/JSMessageAttachment.cpp | 578 ----- .../Tizen/Messaging/JSMessageAttachment.h | 140 -- src/standards/Tizen/Messaging/JSMessageBody.cpp | 532 ---- src/standards/Tizen/Messaging/JSMessageBody.h | 151 -- src/standards/Tizen/Messaging/JSMessageFolder.cpp | 307 --- src/standards/Tizen/Messaging/JSMessageFolder.h | 125 - .../Tizen/Messaging/JSMessagePrivateObject.h | 57 - .../Tizen/Messaging/JSMessagingService.cpp | 1293 ---------- src/standards/Tizen/Messaging/JSMessagingService.h | 113 - .../Tizen/Messaging/JSMessagingServiceManager.cpp | 260 -- .../Tizen/Messaging/JSMessagingServiceManager.h | 100 - .../Tizen/Messaging/JSMessagingStorage.cpp | 1833 -------------- src/standards/Tizen/Messaging/JSMessagingStorage.h | 144 -- src/standards/Tizen/Messaging/JSRecipientArray.cpp | 384 --- src/standards/Tizen/Messaging/JSRecipientArray.h | 172 -- .../Messaging/MessageAsyncCallbackManager.cpp | 29 - .../Tizen/Messaging/MessageAsyncCallbackManager.h | 48 - .../Tizen/Messaging/MessageListenerManager.cpp | 29 - .../Tizen/Messaging/MessageListenerManager.h | 95 - .../Tizen/Messaging/MessageSendCallback.h | 41 - .../Tizen/Messaging/MessagingController.cpp | 368 --- .../Tizen/Messaging/MessagingController.h | 61 - src/standards/Tizen/Messaging/MessagingErrorMsg.h | 33 - .../Tizen/Messaging/MessagingListener.cpp | 914 ------- src/standards/Tizen/Messaging/MessagingListener.h | 119 - .../Messaging/MessagingStorageMultiCallback.cpp | 67 - .../Messaging/MessagingStorageMultiCallback.h | 109 - src/standards/Tizen/Messaging/config.xml | 26 - src/standards/Tizen/Messaging/plugin_config.cpp | 340 --- src/standards/Tizen/Messaging/plugin_config.h | 62 - .../Tizen/Messaging/plugin_initializer.cpp | 92 - src/standards/Tizen/NFC/CMakeLists.txt | 36 - .../Tizen/NFC/EventNFCChangedPrivateData.cpp | 43 - .../Tizen/NFC/EventNFCChangedPrivateData.h | 45 - src/standards/Tizen/NFC/JSNFCAdapter.cpp | 699 ------ src/standards/Tizen/NFC/JSNFCAdapter.h | 129 - src/standards/Tizen/NFC/JSNFCManager.cpp | 219 -- src/standards/Tizen/NFC/JSNFCManager.h | 86 - src/standards/Tizen/NFC/JSNFCTag.cpp | 436 ---- src/standards/Tizen/NFC/JSNFCTag.h | 113 - src/standards/Tizen/NFC/JSNFCTarget.cpp | 354 --- src/standards/Tizen/NFC/JSNFCTarget.h | 112 - src/standards/Tizen/NFC/JSNdefMessage.cpp | 387 --- src/standards/Tizen/NFC/JSNdefMessage.h | 105 - src/standards/Tizen/NFC/JSNdefRecord.cpp | 274 -- src/standards/Tizen/NFC/JSNdefRecord.h | 96 - src/standards/Tizen/NFC/JSNdefRecordArray.cpp | 768 ------ src/standards/Tizen/NFC/JSNdefRecordArray.h | 176 -- src/standards/Tizen/NFC/JSNdefRecordMedia.cpp | 207 -- src/standards/Tizen/NFC/JSNdefRecordMedia.h | 84 - src/standards/Tizen/NFC/JSNdefRecordText.cpp | 238 -- src/standards/Tizen/NFC/JSNdefRecordText.h | 84 - src/standards/Tizen/NFC/JSNdefRecordURI.cpp | 205 -- src/standards/Tizen/NFC/JSNdefRecordURI.h | 83 - .../Tizen/NFC/NFCAsyncCallbackManager.cpp | 30 - src/standards/Tizen/NFC/NFCAsyncCallbackManager.h | 46 - src/standards/Tizen/NFC/NFCChangedCallback.h | 39 - src/standards/Tizen/NFC/NFCConverter.cpp | 418 ---- src/standards/Tizen/NFC/NFCConverter.h | 74 - src/standards/Tizen/NFC/NFCListenerManager.cpp | 30 - src/standards/Tizen/NFC/NFCListenerManager.h | 130 - src/standards/Tizen/NFC/NFCStaticController.cpp | 211 -- src/standards/Tizen/NFC/NFCStaticController.h | 57 - src/standards/Tizen/NFC/ResponseDispatcher.cpp | 264 -- src/standards/Tizen/NFC/ResponseDispatcher.h | 67 - src/standards/Tizen/NFC/config.xml | 35 - src/standards/Tizen/NFC/plugin_config.cpp | 179 -- src/standards/Tizen/NFC/plugin_config.h | 42 - src/standards/Tizen/NFC/plugin_initializer.cpp | 85 - .../Tizen/NetworkBearerSelection/CMakeLists.txt | 22 - .../JSNetworkBearerSelection.cpp | 278 --- .../JSNetworkBearerSelection.h | 57 - .../JSNetworkBearerSelectionCallbackManager.cpp | 291 --- .../JSNetworkBearerSelectionCallbackManager.h | 90 - .../NetworkBearerSelectionResponseDispatcher.cpp | 154 -- .../NetworkBearerSelectionResponseDispatcher.h | 63 - .../Tizen/NetworkBearerSelection/config.xml | 19 - .../Tizen/NetworkBearerSelection/plugin_config.cpp | 84 - .../Tizen/NetworkBearerSelection/plugin_config.h | 39 - .../NetworkBearerSelection/plugin_initializer.cpp | 60 - src/standards/Tizen/Notification/CMakeLists.txt | 34 - .../Tizen/Notification/JSNotificationManager.cpp | 522 ---- .../Tizen/Notification/JSNotificationManager.h | 70 - .../Tizen/Notification/JSStatusNotification.cpp | 502 ---- .../Tizen/Notification/JSStatusNotification.h | 85 - .../Tizen/Notification/NotificationConverter.cpp | 202 -- .../Tizen/Notification/NotificationConverter.h | 50 - .../Tizen/Notification/NotificationCoverter.cpp | 59 - src/standards/Tizen/Notification/config.xml | 19 - src/standards/Tizen/Notification/plugin_config.cpp | 92 - src/standards/Tizen/Notification/plugin_config.h | 41 - .../Tizen/Notification/plugin_initializer.cpp | 66 - src/standards/Tizen/Power/CMakeLists.txt | 32 - src/standards/Tizen/Power/JSPowerManager.cpp | 703 ------ src/standards/Tizen/Power/JSPowerManager.h | 193 -- src/standards/Tizen/Power/PowerConverter.cpp | 126 - src/standards/Tizen/Power/PowerConverter.h | 58 - src/standards/Tizen/Power/PowerListenerManager.cpp | 23 - src/standards/Tizen/Power/PowerListenerManager.h | 88 - .../Tizen/Power/PowerResponseDispatcher.cpp | 80 - .../Tizen/Power/PowerResponseDispatcher.h | 50 - src/standards/Tizen/Power/config.xml | 15 - src/standards/Tizen/Power/plugin_config.cpp | 184 -- src/standards/Tizen/Power/plugin_config.h | 51 - src/standards/Tizen/Power/plugin_initializer.cpp | 86 - src/standards/Tizen/SecureStorage/CMakeLists.txt | 23 - .../Tizen/SecureStorage/JSSecureStorageManager.cpp | 408 --- .../Tizen/SecureStorage/JSSecureStorageManager.h | 72 - .../Tizen/SecureStorage/SecureStorageManager.cpp | 266 -- .../Tizen/SecureStorage/SecureStorageManager.h | 54 - src/standards/Tizen/SecureStorage/config.xml | 18 - .../Tizen/SecureStorage/plugin_config.cpp | 128 - src/standards/Tizen/SecureStorage/plugin_config.h | 39 - .../Tizen/SecureStorage/plugin_initializer.cpp | 63 - src/standards/Tizen/SystemSetting/CMakeLists.txt | 29 - .../Tizen/SystemSetting/ConverterSystemSetting.cpp | 123 - .../Tizen/SystemSetting/ConverterSystemSetting.h | 49 - .../Tizen/SystemSetting/JSSystemSetting.cpp | 324 --- .../Tizen/SystemSetting/JSSystemSetting.h | 57 - .../SystemSettingAsyncCallbackManager.cpp | 35 - .../SystemSettingAsyncCallbackManager.h | 54 - .../SystemSettingResponseDispatcher.cpp | 249 -- .../SystemSettingResponseDispatcher.h | 72 - src/standards/Tizen/SystemSetting/config.xml | 19 - .../Tizen/SystemSetting/plugin_config.cpp | 108 - src/standards/Tizen/SystemSetting/plugin_config.h | 39 - .../Tizen/SystemSetting/plugin_initializer.cpp | 79 - src/standards/Tizen/Systeminfo/CMakeLists.txt | 34 - src/standards/Tizen/Systeminfo/JSBatteryInfo.cpp | 126 - src/standards/Tizen/Systeminfo/JSBatteryInfo.h | 48 - src/standards/Tizen/Systeminfo/JSBuildInfo.cpp | 121 - src/standards/Tizen/Systeminfo/JSBuildInfo.h | 48 - .../Tizen/Systeminfo/JSCellularNetworkInfo.cpp | 154 -- .../Tizen/Systeminfo/JSCellularNetworkInfo.h | 48 - src/standards/Tizen/Systeminfo/JSCpuInfo.cpp | 122 - src/standards/Tizen/Systeminfo/JSCpuInfo.h | 48 - .../Tizen/Systeminfo/JSDeviceCapabilitiesInfo.cpp | 250 -- .../Tizen/Systeminfo/JSDeviceCapabilitiesInfo.h | 48 - .../Tizen/Systeminfo/JSDeviceOrientationInfo.cpp | 121 - .../Tizen/Systeminfo/JSDeviceOrientationInfo.h | 48 - src/standards/Tizen/Systeminfo/JSDisplayInfo.cpp | 144 -- src/standards/Tizen/Systeminfo/JSDisplayInfo.h | 48 - src/standards/Tizen/Systeminfo/JSNetworkInfo.cpp | 121 - src/standards/Tizen/Systeminfo/JSNetworkInfo.h | 48 - src/standards/Tizen/Systeminfo/JSSIMInfo.cpp | 146 -- src/standards/Tizen/Systeminfo/JSSIMInfo.h | 48 - src/standards/Tizen/Systeminfo/JSStorageInfo.cpp | 132 - src/standards/Tizen/Systeminfo/JSStorageInfo.h | 48 - src/standards/Tizen/Systeminfo/JSSysteminfo.cpp | 332 --- src/standards/Tizen/Systeminfo/JSSysteminfo.h | 61 - .../Tizen/Systeminfo/JSWifiNetworkInfo.cpp | 138 - src/standards/Tizen/Systeminfo/JSWifiNetworkInfo.h | 48 - .../Systeminfo/SysteminfoAsyncCallbackManager.cpp | 29 - .../Systeminfo/SysteminfoAsyncCallbackManager.h | 46 - .../Tizen/Systeminfo/SysteminfoListener.cpp | 66 - .../Tizen/Systeminfo/SysteminfoListener.h | 51 - .../Tizen/Systeminfo/SysteminfoListenerManager.cpp | 29 - .../Tizen/Systeminfo/SysteminfoListenerManager.h | 81 - src/standards/Tizen/Systeminfo/config.xml | 15 - src/standards/Tizen/Systeminfo/plugin_config.cpp | 109 - src/standards/Tizen/Systeminfo/plugin_config.h | 40 - .../Tizen/Systeminfo/plugin_initializer.cpp | 78 - src/standards/Tizen/TimeUtil/CMakeLists.txt | 38 - src/standards/Tizen/TimeUtil/JSTZDate.cpp | 1470 ----------- src/standards/Tizen/TimeUtil/JSTZDate.h | 228 -- src/standards/Tizen/TimeUtil/JSTimeDuration.cpp | 403 --- src/standards/Tizen/TimeUtil/JSTimeDuration.h | 124 - src/standards/Tizen/TimeUtil/JSTimeUtil.cpp | 351 --- src/standards/Tizen/TimeUtil/JSTimeUtil.h | 138 - src/standards/Tizen/TimeUtil/TimeUtilConverter.cpp | 295 --- src/standards/Tizen/TimeUtil/TimeUtilConverter.h | 74 - src/standards/Tizen/TimeUtil/config.xml | 16 - .../Tizen/TimeUtil/plugin_initializer.cpp | 72 - src/standards/Tizen/Tizen/CMakeLists.txt | 53 - src/standards/Tizen/Tizen/FilterConverter.cpp | 506 ---- src/standards/Tizen/Tizen/FilterConverter.h | 100 - .../Tizen/Tizen/JSAbstractFilterArray.cpp | 636 ----- src/standards/Tizen/Tizen/JSAbstractFilterArray.h | 193 -- src/standards/Tizen/Tizen/JSAttributeFilter.cpp | 402 --- src/standards/Tizen/Tizen/JSAttributeFilter.h | 128 - .../Tizen/Tizen/JSAttributeRangeFilter.cpp | 395 --- src/standards/Tizen/Tizen/JSAttributeRangeFilter.h | 129 - src/standards/Tizen/Tizen/JSCompositeFilter.cpp | 336 --- src/standards/Tizen/Tizen/JSCompositeFilter.h | 117 - src/standards/Tizen/Tizen/JSFeature.cpp | 155 -- src/standards/Tizen/Tizen/JSFeature.h | 92 - src/standards/Tizen/Tizen/JSFeatureParam.cpp | 128 - src/standards/Tizen/Tizen/JSFeatureParam.h | 92 - src/standards/Tizen/Tizen/JSSimpleCoordinates.cpp | 321 --- src/standards/Tizen/Tizen/JSSimpleCoordinates.h | 117 - src/standards/Tizen/Tizen/JSSortMode.cpp | 335 --- src/standards/Tizen/Tizen/JSSortMode.h | 117 - src/standards/Tizen/Tizen/JSTizen.cpp | 354 --- src/standards/Tizen/Tizen/JSTizen.h | 141 -- src/standards/Tizen/Tizen/PluginOnDemandPriv.cpp | 60 - src/standards/Tizen/Tizen/PluginOnDemandPriv.h | 63 - src/standards/Tizen/Tizen/config.xml | 25 - src/standards/Tizen/Tizen/plugin_config.cpp | 101 - src/standards/Tizen/Tizen/plugin_config.h | 46 - src/standards/Tizen/Tizen/plugin_initializer.cpp | 113 - 2630 files changed, 240716 insertions(+), 205902 deletions(-) delete mode 100644 AUTHORS delete mode 100644 LICENSE.APLv2 delete mode 100644 NOTICE create mode 100755 pkgconfigs/wrt-plugins-tizen-alarm.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-application.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-bluetooth.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-bookmark.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-calendar.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-callhistory.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-common.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-contact.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-content.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-datacontrol.pc.in create mode 100644 pkgconfigs/wrt-plugins-tizen-datasync.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-download.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-filesystem.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-log.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-messageport.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-messaging.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-networkbearerselection.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-nfc.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-notification.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-package.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-power.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-push.pc.in create mode 100644 pkgconfigs/wrt-plugins-tizen-secureelement.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-systeminfo.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-systemsetting.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-timeutil.pc.in create mode 100755 pkgconfigs/wrt-plugins-tizen-tizen.pc.in create mode 100644 src/.project create mode 100755 src/Alarm/AlarmAbsolute.cpp create mode 100755 src/Alarm/AlarmAbsolute.h create mode 100755 src/Alarm/AlarmConverter.cpp create mode 100755 src/Alarm/AlarmConverter.h create mode 100755 src/Alarm/AlarmRelative.cpp create mode 100755 src/Alarm/AlarmRelative.h create mode 100755 src/Alarm/CMakeLists.txt create mode 100755 src/Alarm/JSAlarmAbsolute.cpp create mode 100755 src/Alarm/JSAlarmAbsolute.h create mode 100755 src/Alarm/JSAlarmManager.cpp create mode 100755 src/Alarm/JSAlarmManager.h create mode 100755 src/Alarm/JSAlarmRelative.cpp create mode 100755 src/Alarm/JSAlarmRelative.h create mode 100755 src/Alarm/alarm_common.h create mode 100755 src/Alarm/config.xml create mode 100755 src/Alarm/plugin_config.cpp create mode 100755 src/Alarm/plugin_config.h create mode 100755 src/Alarm/plugin_initializer.cpp create mode 100644 src/Application/AppManagerWrapper.cpp create mode 100644 src/Application/AppManagerWrapper.h create mode 100644 src/Application/Application.cpp create mode 100644 src/Application/Application.h create mode 100755 src/Application/ApplicationAsyncCallbackManager.cpp create mode 100644 src/Application/ApplicationAsyncCallbackManager.h create mode 100644 src/Application/ApplicationCert.cpp create mode 100644 src/Application/ApplicationCert.h create mode 100755 src/Application/ApplicationContext.cpp create mode 100755 src/Application/ApplicationContext.h create mode 100755 src/Application/ApplicationControl.cpp create mode 100755 src/Application/ApplicationControl.h create mode 100755 src/Application/ApplicationControlData.cpp create mode 100755 src/Application/ApplicationControlData.h create mode 100644 src/Application/ApplicationController.cpp create mode 100755 src/Application/ApplicationController.h create mode 100755 src/Application/ApplicationConverter.cpp create mode 100755 src/Application/ApplicationConverter.h create mode 100755 src/Application/ApplicationFactory.cpp create mode 100755 src/Application/ApplicationFactory.h create mode 100755 src/Application/ApplicationInformation.cpp create mode 100755 src/Application/ApplicationInformation.h create mode 100755 src/Application/ApplicationInformationEventPrivateData.h create mode 100755 src/Application/ApplicationListenerManager.cpp create mode 100644 src/Application/ApplicationListenerManager.h create mode 100644 src/Application/ApplicationManager.cpp create mode 100644 src/Application/ApplicationManager.h create mode 100755 src/Application/ApplicationUtil.cpp create mode 100755 src/Application/ApplicationUtil.h create mode 100755 src/Application/CMakeLists.txt create mode 100755 src/Application/EventApplicationAddAppInfoEventListener.h create mode 100755 src/Application/EventApplicationAppInfoEventListener.h create mode 100755 src/Application/EventApplicationFindAppControl.h create mode 100644 src/Application/EventApplicationGetAppCerts.h create mode 100755 src/Application/EventApplicationGetAppContext.h create mode 100755 src/Application/EventApplicationGetAppInfo.h create mode 100755 src/Application/EventApplicationGetAppsContext.h create mode 100755 src/Application/EventApplicationGetAppsInfo.h create mode 100644 src/Application/EventApplicationGetCurrApp.h create mode 100644 src/Application/EventApplicationGetRequestedAppControl.h create mode 100755 src/Application/EventApplicationKill.h create mode 100755 src/Application/EventApplicationLaunch.h create mode 100755 src/Application/EventApplicationLaunchAppControl.h create mode 100755 src/Application/EventApplicationRemoveAppInfoEventListener.h create mode 100644 src/Application/IApplicationManager.cpp create mode 100644 src/Application/IApplicationManager.h create mode 100644 src/Application/JSApplication.cpp create mode 100644 src/Application/JSApplication.h create mode 100644 src/Application/JSApplicationCert.cpp create mode 100644 src/Application/JSApplicationCert.h create mode 100644 src/Application/JSApplicationContext.cpp create mode 100755 src/Application/JSApplicationContext.h create mode 100644 src/Application/JSApplicationControl.cpp create mode 100755 src/Application/JSApplicationControl.h create mode 100644 src/Application/JSApplicationControlData.cpp create mode 100755 src/Application/JSApplicationControlData.h create mode 100755 src/Application/JSApplicationEventCallbackManager.cpp create mode 100755 src/Application/JSApplicationEventCallbackManager.h create mode 100644 src/Application/JSApplicationInformation.cpp create mode 100755 src/Application/JSApplicationInformation.h create mode 100644 src/Application/JSApplicationManager.cpp create mode 100644 src/Application/JSApplicationManager.h create mode 100644 src/Application/JSRequestedApplicationControl.cpp create mode 100644 src/Application/JSRequestedApplicationControl.h create mode 100644 src/Application/RequestedApplicationControl.cpp create mode 100644 src/Application/RequestedApplicationControl.h create mode 100755 src/Application/config.xml create mode 100755 src/Application/plugin_config.cpp create mode 100755 src/Application/plugin_config.h create mode 100755 src/Application/plugin_initializer.cpp create mode 100644 src/Bluetooth/BTDevice.h create mode 100644 src/Bluetooth/BluetoothAdapterListener.cpp create mode 100644 src/Bluetooth/BluetoothAdapterListener.h create mode 100755 src/Bluetooth/BluetoothAdapterManager.cpp create mode 100644 src/Bluetooth/BluetoothAdapterManager.h create mode 100644 src/Bluetooth/BluetoothCBManager.cpp create mode 100644 src/Bluetooth/BluetoothCBManager.h create mode 100644 src/Bluetooth/BluetoothClass.cpp create mode 100644 src/Bluetooth/BluetoothClass.h create mode 100644 src/Bluetooth/BluetoothConverter.cpp create mode 100644 src/Bluetooth/BluetoothConverter.h create mode 100644 src/Bluetooth/BluetoothDeviceManager.cpp create mode 100644 src/Bluetooth/BluetoothDeviceManager.h create mode 100644 src/Bluetooth/BluetoothDeviceManagerListener.cpp create mode 100644 src/Bluetooth/BluetoothDeviceManagerListener.h create mode 100644 src/Bluetooth/BluetoothFactory.cpp create mode 100644 src/Bluetooth/BluetoothFactory.h create mode 100644 src/Bluetooth/BluetoothMultiCallback.cpp create mode 100644 src/Bluetooth/BluetoothMultiCallback.h rename src/{platform/API => }/Bluetooth/BluetoothProperty.h (100%) create mode 100644 src/Bluetooth/BluetoothServiceHandlerManager.cpp create mode 100644 src/Bluetooth/BluetoothServiceHandlerManager.h create mode 100644 src/Bluetooth/BluetoothSocketListener.cpp create mode 100644 src/Bluetooth/BluetoothSocketListener.h create mode 100644 src/Bluetooth/BluetoothSocketManager.cpp create mode 100644 src/Bluetooth/BluetoothSocketManager.h create mode 100755 src/Bluetooth/CMakeLists.txt create mode 100644 src/Bluetooth/EventBTConnectToServiceByUUID.h create mode 100644 src/Bluetooth/EventBTCreateDestroyBonding.cpp create mode 100644 src/Bluetooth/EventBTCreateDestroyBonding.h create mode 100644 src/Bluetooth/EventBTGetAdapter.h create mode 100644 src/Bluetooth/EventBTGetDevice.cpp create mode 100644 src/Bluetooth/EventBTGetDevice.h create mode 100644 src/Bluetooth/EventBTGetKnownDevices.cpp create mode 100644 src/Bluetooth/EventBTGetKnownDevices.h create mode 100644 src/Bluetooth/EventBTOnDiscoveryDevices.cpp create mode 100644 src/Bluetooth/EventBTOnDiscoveryDevices.h create mode 100644 src/Bluetooth/EventBTRegisterRFCOMM.h create mode 100644 src/Bluetooth/EventBTServiceOnConnect.cpp create mode 100644 src/Bluetooth/EventBTServiceOnConnect.h create mode 100644 src/Bluetooth/EventBTSetName.h create mode 100644 src/Bluetooth/EventBTSetPowered.h create mode 100644 src/Bluetooth/EventBTSetVisible.h create mode 100644 src/Bluetooth/EventBTSocketNotification.cpp create mode 100644 src/Bluetooth/EventBTSocketNotification.h create mode 100644 src/Bluetooth/EventBTStopDiscovery.h create mode 100644 src/Bluetooth/EventBTUnregisterRFCOMM.h create mode 100644 src/Bluetooth/IBluetoothAdapterManager.cpp create mode 100644 src/Bluetooth/IBluetoothAdapterManager.h create mode 100644 src/Bluetooth/IBluetoothDeviceManager.cpp create mode 100644 src/Bluetooth/IBluetoothDeviceManager.h create mode 100644 src/Bluetooth/IBluetoothServiceHandlerManager.cpp create mode 100644 src/Bluetooth/IBluetoothServiceHandlerManager.h create mode 100644 src/Bluetooth/IBluetoothSocketManager.cpp create mode 100644 src/Bluetooth/IBluetoothSocketManager.h create mode 100644 src/Bluetooth/JSBluetoothAdapter.cpp create mode 100644 src/Bluetooth/JSBluetoothAdapter.h create mode 100644 src/Bluetooth/JSBluetoothClass.cpp create mode 100644 src/Bluetooth/JSBluetoothClass.h create mode 100644 src/Bluetooth/JSBluetoothClassDeviceMajor.cpp create mode 100644 src/Bluetooth/JSBluetoothClassDeviceMajor.h create mode 100644 src/Bluetooth/JSBluetoothClassDeviceMinor.cpp create mode 100644 src/Bluetooth/JSBluetoothClassDeviceMinor.h create mode 100644 src/Bluetooth/JSBluetoothClassDeviceService.cpp create mode 100644 src/Bluetooth/JSBluetoothClassDeviceService.h create mode 100644 src/Bluetooth/JSBluetoothDevice.cpp create mode 100644 src/Bluetooth/JSBluetoothDevice.h create mode 100644 src/Bluetooth/JSBluetoothManager.cpp create mode 100644 src/Bluetooth/JSBluetoothManager.h create mode 100644 src/Bluetooth/JSBluetoothServiceHandler.cpp create mode 100644 src/Bluetooth/JSBluetoothServiceHandler.h create mode 100644 src/Bluetooth/JSBluetoothSocket.cpp create mode 100644 src/Bluetooth/JSBluetoothSocket.h create mode 100644 src/Bluetooth/config.xml create mode 100644 src/Bluetooth/plugin_config.cpp create mode 100644 src/Bluetooth/plugin_config.h create mode 100644 src/Bluetooth/plugin_initializer.cpp create mode 100755 src/Bookmark/BookmarkData.h create mode 100755 src/Bookmark/BookmarkManager.cpp create mode 100755 src/Bookmark/BookmarkManager.h create mode 100755 src/Bookmark/CMakeLists.txt create mode 100755 src/Bookmark/JSBookmarkFolder.cpp create mode 100755 src/Bookmark/JSBookmarkFolder.h create mode 100755 src/Bookmark/JSBookmarkItem.cpp create mode 100755 src/Bookmark/JSBookmarkItem.h create mode 100755 src/Bookmark/JSBookmarkManager.cpp create mode 100755 src/Bookmark/JSBookmarkManager.h create mode 100755 src/Bookmark/config.xml create mode 100755 src/Bookmark/plugin_config.cpp create mode 100755 src/Bookmark/plugin_config.h create mode 100755 src/Bookmark/plugin_initializer.cpp mode change 100644 => 100755 src/CMakeLists.txt create mode 100755 src/Calendar/CMakeLists.txt create mode 100755 src/Calendar/Calendar.cpp create mode 100755 src/Calendar/Calendar.h create mode 100755 src/Calendar/CalendarAsyncCallbackManager.cpp create mode 100755 src/Calendar/CalendarAsyncCallbackManager.h create mode 100755 src/Calendar/CalendarConverter.cpp create mode 100755 src/Calendar/CalendarConverter.h create mode 100755 src/Calendar/CalendarEvent.cpp create mode 100755 src/Calendar/CalendarEvent.h create mode 100755 src/Calendar/CalendarFactory.cpp create mode 100755 src/Calendar/CalendarFactory.h create mode 100755 src/Calendar/CalendarFilter.cpp create mode 100755 src/Calendar/CalendarFilter.h create mode 100755 src/Calendar/CalendarFilterValidator.cpp create mode 100755 src/Calendar/CalendarFilterValidator.h create mode 100755 src/Calendar/CalendarListenerManager.cpp create mode 100755 src/Calendar/CalendarListenerManager.h create mode 100755 src/Calendar/CalendarManager.cpp create mode 100755 src/Calendar/CalendarManager.h create mode 100755 src/Calendar/CalendarMultiCallback.h create mode 100755 src/Calendar/CalendarResponseDispatcher.cpp create mode 100755 src/Calendar/CalendarResponseDispatcher.h create mode 100755 src/Calendar/CalendarUtility.cpp create mode 100755 src/Calendar/CalendarUtility.h create mode 100755 src/Calendar/EventAlarm.cpp create mode 100755 src/Calendar/EventAlarm.h create mode 100755 src/Calendar/EventAttendee.cpp create mode 100755 src/Calendar/EventAttendee.h create mode 100755 src/Calendar/EventId.cpp create mode 100755 src/Calendar/EventId.h create mode 100755 src/Calendar/EventRecurrenceRule.cpp create mode 100755 src/Calendar/EventRecurrenceRule.h create mode 100755 src/Calendar/EventWrapper.cpp create mode 100755 src/Calendar/EventWrapper.h create mode 100755 src/Calendar/ICalendar.cpp create mode 100755 src/Calendar/ICalendar.h create mode 100755 src/Calendar/ICalendarManager.cpp create mode 100755 src/Calendar/ICalendarManager.h create mode 100755 src/Calendar/IEventAddEvent.h create mode 100755 src/Calendar/IEventAddEvents.h create mode 100755 src/Calendar/IEventClearWatch.h create mode 100755 src/Calendar/IEventCreateEventFromString.h create mode 100755 src/Calendar/IEventDeleteEvent.h create mode 100755 src/Calendar/IEventDeleteEvents.h create mode 100755 src/Calendar/IEventExpandEventRecurrence.h create mode 100755 src/Calendar/IEventExportEventToString.h create mode 100755 src/Calendar/IEventFindEvents.h create mode 100755 src/Calendar/IEventGet.h create mode 100755 src/Calendar/IEventGetCalendar.h create mode 100755 src/Calendar/IEventGetCalendars.h create mode 100755 src/Calendar/IEventGetDefaultCalendar.h create mode 100755 src/Calendar/IEventGetUnifiedCalendar.h create mode 100755 src/Calendar/IEventUpdateEvent.h create mode 100755 src/Calendar/IEventUpdateEvents.h create mode 100755 src/Calendar/IEventWatchChanges.h create mode 100755 src/Calendar/JSCalendar.cpp create mode 100755 src/Calendar/JSCalendar.h create mode 100755 src/Calendar/JSCalendarAlarm.cpp create mode 100755 src/Calendar/JSCalendarAlarm.h create mode 100755 src/Calendar/JSCalendarAttendee.cpp create mode 100755 src/Calendar/JSCalendarAttendee.h create mode 100755 src/Calendar/JSCalendarEvent.cpp create mode 100755 src/Calendar/JSCalendarEvent.h create mode 100755 src/Calendar/JSCalendarEventId.cpp create mode 100755 src/Calendar/JSCalendarEventId.h create mode 100755 src/Calendar/JSCalendarItemProperties.cpp create mode 100755 src/Calendar/JSCalendarItemProperties.h create mode 100755 src/Calendar/JSCalendarManager.cpp create mode 100755 src/Calendar/JSCalendarManager.h create mode 100755 src/Calendar/JSCalendarRecurrenceRule.cpp create mode 100755 src/Calendar/JSCalendarRecurrenceRule.h create mode 100755 src/Calendar/JSCalendarTask.cpp create mode 100755 src/Calendar/JSCalendarTask.h create mode 100755 src/Calendar/JSNumberArray.cpp create mode 100755 src/Calendar/JSNumberArray.h create mode 100755 src/Calendar/JSStringArray.cpp create mode 100755 src/Calendar/JSStringArray.h create mode 100755 src/Calendar/JSTZDateArray.cpp create mode 100755 src/Calendar/JSTZDateArray.h create mode 100755 src/Calendar/OnEventsChanged.h create mode 100755 src/Calendar/config.xml create mode 100755 src/Calendar/plugin_config.cpp create mode 100755 src/Calendar/plugin_config.h create mode 100755 src/Calendar/plugin_initializer.cpp create mode 100755 src/Callhistory/CMakeLists.txt create mode 100755 src/Callhistory/CallHistory.cpp create mode 100755 src/Callhistory/CallHistory.h create mode 100755 src/Callhistory/CallHistoryAsyncCallbackManager.cpp create mode 100755 src/Callhistory/CallHistoryAsyncCallbackManager.h create mode 100755 src/Callhistory/CallHistoryDefine.h create mode 100755 src/Callhistory/CallHistoryEntry.cpp create mode 100755 src/Callhistory/CallHistoryEntry.h create mode 100755 src/Callhistory/CallHistoryEntryProperties.cpp create mode 100755 src/Callhistory/CallHistoryEntryProperties.h create mode 100755 src/Callhistory/CallHistoryFactory.cpp create mode 100755 src/Callhistory/CallHistoryFactory.h create mode 100755 src/Callhistory/CallHistoryFilter.cpp create mode 100755 src/Callhistory/CallHistoryFilter.h create mode 100755 src/Callhistory/CallHistoryListenerManager.cpp create mode 100755 src/Callhistory/CallHistoryListenerManager.h create mode 100755 src/Callhistory/CallHistoryMultiCallback.cpp create mode 100755 src/Callhistory/CallHistoryMultiCallback.h create mode 100755 src/Callhistory/CallHistoryStaticController.cpp create mode 100755 src/Callhistory/CallHistoryStaticController.h create mode 100755 src/Callhistory/Converter.cpp create mode 100755 src/Callhistory/Converter.h create mode 100755 src/Callhistory/EventCallHistory.h create mode 100755 src/Callhistory/EventCallHistoryListener.cpp create mode 100755 src/Callhistory/EventCallHistoryListener.h create mode 100755 src/Callhistory/EventCallHistoryTemplate.h create mode 100755 src/Callhistory/EventFindCallHistory.cpp create mode 100755 src/Callhistory/EventFindCallHistory.h create mode 100755 src/Callhistory/EventRemoveAll.h create mode 100755 src/Callhistory/EventRemoveBatch.h create mode 100755 src/Callhistory/ICallHistory.cpp create mode 100755 src/Callhistory/ICallHistory.h create mode 100755 src/Callhistory/ICallHistoryEntry.cpp create mode 100755 src/Callhistory/ICallHistoryEntry.h create mode 100755 src/Callhistory/JSCallHistory.cpp create mode 100755 src/Callhistory/JSCallHistory.h create mode 100755 src/Callhistory/JSCallHistoryEntry.cpp create mode 100755 src/Callhistory/JSCallHistoryEntry.h create mode 100755 src/Callhistory/JSRemoteParty.cpp create mode 100755 src/Callhistory/JSRemoteParty.h create mode 100755 src/Callhistory/RemoteParty.h create mode 100755 src/Callhistory/ResponseDispatcher.cpp create mode 100755 src/Callhistory/ResponseDispatcher.h create mode 100755 src/Callhistory/config.xml create mode 100755 src/Callhistory/plugin_config.cpp create mode 100755 src/Callhistory/plugin_config.h create mode 100755 src/Callhistory/plugin_initializer.cpp create mode 100755 src/Common/ArgumentValidationChecker.cpp create mode 100755 src/Common/ArgumentValidationChecker.h create mode 100755 src/Common/ArgumentValidator.cpp create mode 100755 src/Common/ArgumentValidator.h create mode 100755 src/Common/AsyncCallbackManager.h create mode 100755 src/Common/CMakeLists.txt create mode 100755 src/Common/CallbackUserData.cpp create mode 100755 src/Common/CallbackUserData.h create mode 100755 src/Common/GlobalContextManager.cpp create mode 100755 src/Common/GlobalContextManager.h create mode 100755 src/Common/IListenerManager.h create mode 100755 src/Common/JSTizenException.cpp create mode 100755 src/Common/JSTizenException.h create mode 100755 src/Common/JSTizenExceptionFactory.cpp create mode 100755 src/Common/JSTizenExceptionFactory.h create mode 100755 src/Common/JSUtil.cpp create mode 100755 src/Common/JSUtil.h create mode 100755 src/Common/JSWebAPIError.cpp create mode 100755 src/Common/JSWebAPIError.h create mode 100644 src/Common/JSWebAPIError2.cpp create mode 100644 src/Common/JSWebAPIError2.h create mode 100644 src/Common/JSWebAPIErrorFactory.cpp create mode 100644 src/Common/JSWebAPIErrorFactory.h create mode 100644 src/Common/Logger.h create mode 100755 src/Common/MultiCallbackUserData.cpp create mode 100755 src/Common/MultiCallbackUserData.h create mode 100755 src/Common/PlatformException.cpp create mode 100755 src/Common/PlatformException.h create mode 100755 src/Common/SecurityExceptions.h create mode 100755 src/Common/StandaloneConsole/CMakeLists.txt create mode 100755 src/Common/StandaloneConsole/JSConsole.cpp create mode 100755 src/Common/StandaloneConsole/JSConsole.h create mode 100755 src/Common/StandaloneConsole/StandaloneConsole.cpp create mode 100755 src/Common/StandaloneConsole/StandaloneConsole.h create mode 100755 src/Common/TizenExceptionData.cpp create mode 100755 src/Common/TizenExceptionData.h create mode 100644 src/Common/WebAPIError.cpp create mode 100644 src/Common/WebAPIError.h create mode 100755 src/Contact/AddressBook.cpp create mode 100755 src/Contact/AddressBook.h create mode 100755 src/Contact/AddressBookController.cpp create mode 100755 src/Contact/AddressBookController.h create mode 100755 src/Contact/CMakeLists.txt create mode 100755 src/Contact/Contact.cpp create mode 100755 src/Contact/Contact.h create mode 100755 src/Contact/ContactAddress.cpp create mode 100755 src/Contact/ContactAddress.h create mode 100755 src/Contact/ContactAnniversary.cpp create mode 100755 src/Contact/ContactAnniversary.h create mode 100755 src/Contact/ContactAsyncCallbackManager.cpp create mode 100755 src/Contact/ContactAsyncCallbackManager.h create mode 100755 src/Contact/ContactConverter.cpp create mode 100755 src/Contact/ContactConverter.h create mode 100755 src/Contact/ContactEmailAddress.cpp create mode 100755 src/Contact/ContactEmailAddress.h create mode 100755 src/Contact/ContactFactory.cpp create mode 100755 src/Contact/ContactFactory.h create mode 100755 src/Contact/ContactFilterValidator.cpp create mode 100755 src/Contact/ContactFilterValidator.h create mode 100755 src/Contact/ContactGroup.cpp create mode 100755 src/Contact/ContactGroup.h rename src/{platform/Tizen => }/Contact/ContactImpl.h (100%) create mode 100755 src/Contact/ContactListenerManager.cpp create mode 100755 src/Contact/ContactListenerManager.h create mode 100755 src/Contact/ContactManager.cpp create mode 100755 src/Contact/ContactManager.h create mode 100755 src/Contact/ContactManagerController.cpp create mode 100755 src/Contact/ContactManagerController.h create mode 100755 src/Contact/ContactName.cpp create mode 100755 src/Contact/ContactName.h create mode 100755 src/Contact/ContactObjectA2PConverter.cpp create mode 100755 src/Contact/ContactObjectA2PConverter.h create mode 100755 src/Contact/ContactObjectP2AConverter.cpp create mode 100755 src/Contact/ContactObjectP2AConverter.h create mode 100755 src/Contact/ContactOrganization.cpp create mode 100755 src/Contact/ContactOrganization.h create mode 100755 src/Contact/ContactPhoneNumber.cpp create mode 100755 src/Contact/ContactPhoneNumber.h create mode 100644 src/Contact/ContactQueue.cpp create mode 100644 src/Contact/ContactQueue.h create mode 100755 src/Contact/ContactRef.cpp create mode 100755 src/Contact/ContactRef.h create mode 100755 src/Contact/ContactSearchEngine.cpp create mode 100755 src/Contact/ContactSearchEngine.h create mode 100755 src/Contact/ContactTypes.h create mode 100755 src/Contact/ContactUtility.cpp create mode 100755 src/Contact/ContactUtility.h create mode 100755 src/Contact/ContactWebSite.cpp create mode 100755 src/Contact/ContactWebSite.h create mode 100755 src/Contact/ContactsSvcChangeListenerManager.cpp create mode 100755 src/Contact/ContactsSvcChangeListenerManager.h create mode 100755 src/Contact/ContactsSvcObjectConverter.cpp create mode 100755 src/Contact/ContactsSvcObjectConverter.h create mode 100755 src/Contact/ContactsSvcWrapper.cpp create mode 100755 src/Contact/ContactsSvcWrapper.h create mode 100755 src/Contact/EventAddressBookAdd.h create mode 100755 src/Contact/EventAddressBookAddBatch.h create mode 100755 src/Contact/EventAddressBookAddChangeListener.h create mode 100755 src/Contact/EventAddressBookAddGroup.h create mode 100755 src/Contact/EventAddressBookChangeListener.h create mode 100755 src/Contact/EventAddressBookFind.h create mode 100755 src/Contact/EventAddressBookGet.h create mode 100755 src/Contact/EventAddressBookGetGroup.h create mode 100755 src/Contact/EventAddressBookGetGroups.h create mode 100755 src/Contact/EventAddressBookRemove.h create mode 100755 src/Contact/EventAddressBookRemoveBatch.h create mode 100755 src/Contact/EventAddressBookRemoveChangeListener.h create mode 100755 src/Contact/EventAddressBookRemoveGroup.h create mode 100755 src/Contact/EventAddressBookUpdate.h create mode 100755 src/Contact/EventAddressBookUpdateBatch.h create mode 100755 src/Contact/EventAddressBookUpdateGroup.h create mode 100755 src/Contact/EventContactManagerAddChangeListener.h create mode 100755 src/Contact/EventContactManagerChangeListener.h create mode 100755 src/Contact/EventContactManagerFind.h create mode 100755 src/Contact/EventContactManagerGet.h create mode 100755 src/Contact/EventContactManagerGetAddressBook.h create mode 100755 src/Contact/EventContactManagerGetAddressBooks.h create mode 100755 src/Contact/EventContactManagerGetDefaultAddressBook.h create mode 100644 src/Contact/EventContactManagerGetUnifiedAddressBook.h create mode 100755 src/Contact/EventContactManagerRemove.h create mode 100755 src/Contact/EventContactManagerRemoveBatch.h create mode 100755 src/Contact/EventContactManagerRemoveChangeListener.h create mode 100755 src/Contact/EventContactManagerUpdate.h create mode 100755 src/Contact/EventContactManagerUpdateBatch.h create mode 100755 src/Contact/EventPersonLink.h create mode 100755 src/Contact/EventPersonUnlink.h create mode 100755 src/Contact/IAddressBook.cpp create mode 100755 src/Contact/IAddressBook.h create mode 100755 src/Contact/IContact.cpp create mode 100755 src/Contact/IContact.h create mode 100755 src/Contact/IContactEventPrivateData.h create mode 100755 src/Contact/IContactManager.cpp create mode 100755 src/Contact/IContactManager.h create mode 100755 src/Contact/IPerson.cpp create mode 100755 src/Contact/IPerson.h create mode 100755 src/Contact/JSAddressBook.cpp create mode 100755 src/Contact/JSAddressBook.h create mode 100755 src/Contact/JSAddressBookArray.cpp create mode 100755 src/Contact/JSAddressBookArray.h create mode 100755 src/Contact/JSAddressBookChangeCallbackManager.cpp create mode 100755 src/Contact/JSAddressBookChangeCallbackManager.h create mode 100755 src/Contact/JSAttributesOfInterestArray.cpp create mode 100755 src/Contact/JSAttributesOfInterestArray.h create mode 100755 src/Contact/JSContact.cpp create mode 100755 src/Contact/JSContact.h create mode 100755 src/Contact/JSContactAddress.cpp create mode 100755 src/Contact/JSContactAddress.h create mode 100755 src/Contact/JSContactAddressArray.cpp create mode 100755 src/Contact/JSContactAddressArray.h create mode 100755 src/Contact/JSContactAddressTypeArray.cpp create mode 100755 src/Contact/JSContactAddressTypeArray.h create mode 100755 src/Contact/JSContactAnniversary.cpp create mode 100755 src/Contact/JSContactAnniversary.h create mode 100755 src/Contact/JSContactAnniversaryArray.cpp create mode 100755 src/Contact/JSContactAnniversaryArray.h create mode 100755 src/Contact/JSContactArray.cpp create mode 100755 src/Contact/JSContactArray.h create mode 100755 src/Contact/JSContactEmailAddress.cpp create mode 100755 src/Contact/JSContactEmailAddress.h create mode 100755 src/Contact/JSContactEmailAddressArray.cpp create mode 100755 src/Contact/JSContactEmailAddressArray.h create mode 100755 src/Contact/JSContactEmailAddressTypeArray.cpp create mode 100755 src/Contact/JSContactEmailAddressTypeArray.h create mode 100755 src/Contact/JSContactGroup.cpp create mode 100755 src/Contact/JSContactGroup.h create mode 100755 src/Contact/JSContactGroupArray.cpp create mode 100755 src/Contact/JSContactGroupArray.h create mode 100755 src/Contact/JSContactManager.cpp create mode 100755 src/Contact/JSContactManager.h create mode 100755 src/Contact/JSContactManagerChangeCallbackManager.cpp create mode 100755 src/Contact/JSContactManagerChangeCallbackManager.h create mode 100755 src/Contact/JSContactName.cpp create mode 100755 src/Contact/JSContactName.h create mode 100755 src/Contact/JSContactOrganization.cpp create mode 100755 src/Contact/JSContactOrganization.h create mode 100755 src/Contact/JSContactOrganizationArray.cpp create mode 100755 src/Contact/JSContactOrganizationArray.h create mode 100755 src/Contact/JSContactPhoneNumber.cpp create mode 100755 src/Contact/JSContactPhoneNumber.h create mode 100755 src/Contact/JSContactPhoneNumberArray.cpp create mode 100755 src/Contact/JSContactPhoneNumberArray.h create mode 100755 src/Contact/JSContactPhoneNumberTypeArray.cpp create mode 100755 src/Contact/JSContactPhoneNumberTypeArray.h create mode 100755 src/Contact/JSContactRef.cpp create mode 100755 src/Contact/JSContactRef.h create mode 100755 src/Contact/JSContactWebSite.cpp create mode 100755 src/Contact/JSContactWebSite.h create mode 100755 src/Contact/JSContactWebSiteArray.cpp create mode 100755 src/Contact/JSContactWebSiteArray.h create mode 100755 src/Contact/JSPerson.cpp create mode 100755 src/Contact/JSPerson.h create mode 100755 src/Contact/JSPersonArray.cpp create mode 100755 src/Contact/JSPersonArray.h create mode 100755 src/Contact/JSStringArray.cpp create mode 100755 src/Contact/JSStringArray.h create mode 100755 src/Contact/Person.cpp create mode 100755 src/Contact/Person.h create mode 100755 src/Contact/PersonFilterValidator.cpp create mode 100755 src/Contact/PersonFilterValidator.h create mode 100755 src/Contact/PersonSearchEngine.cpp create mode 100755 src/Contact/PersonSearchEngine.h create mode 100755 src/Contact/config.xml create mode 100755 src/Contact/plugin_config.cpp create mode 100755 src/Contact/plugin_config.h create mode 100755 src/Contact/plugin_initializer.cpp create mode 100755 src/Content/AudioLyrics.cpp create mode 100755 src/Content/AudioLyrics.h create mode 100755 src/Content/AudioLyricsUtil.cpp create mode 100755 src/Content/AudioLyricsUtil.h create mode 100755 src/Content/CMakeLists.txt create mode 100755 src/Content/ContentAsyncCallbackManager.cpp create mode 100755 src/Content/ContentAsyncCallbackManager.h create mode 100755 src/Content/ContentAudio.cpp create mode 100755 src/Content/ContentAudio.h create mode 100755 src/Content/ContentController.cpp create mode 100755 src/Content/ContentController.h create mode 100755 src/Content/ContentConverter.cpp create mode 100755 src/Content/ContentConverter.h create mode 100755 src/Content/ContentFactory.cpp create mode 100755 src/Content/ContentFactory.h create mode 100755 src/Content/ContentFilterValidator.cpp create mode 100755 src/Content/ContentFilterValidator.h create mode 100755 src/Content/ContentFolder.cpp create mode 100755 src/Content/ContentFolder.h create mode 100755 src/Content/ContentImage.cpp create mode 100755 src/Content/ContentImage.h create mode 100755 src/Content/ContentListener.cpp create mode 100755 src/Content/ContentListener.h create mode 100755 src/Content/ContentManager.cpp create mode 100755 src/Content/ContentManager.h create mode 100755 src/Content/ContentMedia.cpp create mode 100755 src/Content/ContentMedia.h create mode 100755 src/Content/ContentSearchVisitor.cpp create mode 100755 src/Content/ContentSearchVisitor.h create mode 100755 src/Content/ContentUtility.cpp create mode 100755 src/Content/ContentUtility.h create mode 100755 src/Content/ContentVideo.cpp create mode 100755 src/Content/ContentVideo.h create mode 100755 src/Content/IContentManager.cpp create mode 100755 src/Content/IContentManager.h create mode 100755 src/Content/IEventFind.h create mode 100755 src/Content/IEventFindMedia.h create mode 100755 src/Content/IEventGetDirectories.h create mode 100755 src/Content/IEventUpdate.h create mode 100755 src/Content/IEventUpdateBatch.h create mode 100755 src/Content/JSAudio.cpp create mode 100755 src/Content/JSAudio.h create mode 100755 src/Content/JSAudioLyrics.cpp create mode 100755 src/Content/JSAudioLyrics.h create mode 100755 src/Content/JSContent.cpp create mode 100755 src/Content/JSContent.h create mode 100755 src/Content/JSContentManager.cpp create mode 100755 src/Content/JSContentManager.h create mode 100755 src/Content/JSFolder.cpp create mode 100755 src/Content/JSFolder.h create mode 100755 src/Content/JSImage.cpp create mode 100755 src/Content/JSImage.h create mode 100755 src/Content/JSVideo.cpp create mode 100755 src/Content/JSVideo.h create mode 100755 src/Content/config.xml create mode 100755 src/Content/plugin_config.cpp create mode 100755 src/Content/plugin_config.h create mode 100755 src/Content/plugin_initializer.cpp create mode 100755 src/DataControl/CMakeLists.txt create mode 100755 src/DataControl/DataControlAsyncCallbackManager.cpp create mode 100755 src/DataControl/DataControlAsyncCallbackManager.h create mode 100755 src/DataControl/DataControlConverter.cpp create mode 100755 src/DataControl/DataControlConverter.h create mode 100755 src/DataControl/DataControlErrorObject.h create mode 100755 src/DataControl/DataControlFactory.cpp create mode 100755 src/DataControl/DataControlFactory.h create mode 100755 src/DataControl/DataControlListener.cpp create mode 100755 src/DataControl/DataControlListener.h create mode 100644 src/DataControl/DataType.h create mode 100755 src/DataControl/EventAddValue.h create mode 100755 src/DataControl/EventDelete.h create mode 100755 src/DataControl/EventGetIndexedRow.h create mode 100755 src/DataControl/EventGetValue.h create mode 100755 src/DataControl/EventInsert.h create mode 100755 src/DataControl/EventRemoveValue.h create mode 100755 src/DataControl/EventSelect.h create mode 100755 src/DataControl/EventUpdate.h create mode 100755 src/DataControl/EventUpdateValue.h create mode 100755 src/DataControl/IMappedDataControlConsumer.cpp create mode 100755 src/DataControl/IMappedDataControlConsumer.h create mode 100755 src/DataControl/ISelectDataObject.cpp create mode 100755 src/DataControl/ISelectDataObject.h create mode 100755 src/DataControl/ISqlDataControlConsumer.cpp create mode 100755 src/DataControl/ISqlDataControlConsumer.h create mode 100755 src/DataControl/JSDataControlManager.cpp create mode 100755 src/DataControl/JSDataControlManager.h create mode 100755 src/DataControl/JSMappedDataControlConsumer.cpp create mode 100755 src/DataControl/JSMappedDataControlConsumer.h create mode 100755 src/DataControl/JSSQLDataControlConsumer.cpp create mode 100755 src/DataControl/JSSQLDataControlConsumer.h create mode 100755 src/DataControl/JSSelectObjectArrayValues.cpp create mode 100755 src/DataControl/JSSelectObjectArrayValues.h create mode 100755 src/DataControl/MappedDataControlConsumer.cpp create mode 100755 src/DataControl/MappedDataControlConsumer.h create mode 100755 src/DataControl/RowData.h create mode 100755 src/DataControl/SelectDataObject.cpp create mode 100755 src/DataControl/SelectDataObject.h create mode 100755 src/DataControl/SqlDataControlConsumer.cpp create mode 100755 src/DataControl/SqlDataControlConsumer.h create mode 100755 src/DataControl/config.xml create mode 100755 src/DataControl/plugin_config.cpp create mode 100755 src/DataControl/plugin_config.h create mode 100755 src/DataControl/plugin_initializer.cpp create mode 100755 src/DataSync/CMakeLists.txt create mode 100755 src/DataSync/DataSyncConverter.cpp create mode 100755 src/DataSync/DataSyncConverter.h create mode 100755 src/DataSync/DataSyncListenerManager.cpp create mode 100755 src/DataSync/DataSyncListenerManager.h create mode 100755 src/DataSync/DataSyncManager.cpp create mode 100755 src/DataSync/DataSyncManager.h create mode 100755 src/DataSync/DataSyncMultiCallback.h create mode 100755 src/DataSync/DataSyncResponseDispatcher.cpp create mode 100755 src/DataSync/DataSyncResponseDispatcher.h create mode 100755 src/DataSync/IDataSyncManager.cpp create mode 100755 src/DataSync/IDataSyncManager.h create mode 100755 src/DataSync/IEventAddProfile.h create mode 100755 src/DataSync/IEventGetAllProfiles.h create mode 100755 src/DataSync/IEventGetLastSyncStatistics.h create mode 100755 src/DataSync/IEventGetMaxProfilesNum.h create mode 100755 src/DataSync/IEventGetProfile.h create mode 100755 src/DataSync/IEventGetProfilesNum.h create mode 100755 src/DataSync/IEventRemoveProfile.h create mode 100755 src/DataSync/IEventStartSync.h create mode 100755 src/DataSync/IEventStopSync.h create mode 100755 src/DataSync/IEventUpdateProfile.h create mode 100755 src/DataSync/JSDataSyncManager.cpp create mode 100755 src/DataSync/JSDataSyncManager.h create mode 100755 src/DataSync/JSSyncInfo.cpp create mode 100755 src/DataSync/JSSyncInfo.h create mode 100755 src/DataSync/JSSyncProfileInfo.cpp create mode 100755 src/DataSync/JSSyncProfileInfo.h create mode 100755 src/DataSync/JSSyncServiceInfo.cpp create mode 100755 src/DataSync/JSSyncServiceInfo.h create mode 100755 src/DataSync/JSSyncStatistics.cpp create mode 100755 src/DataSync/JSSyncStatistics.h create mode 100755 src/DataSync/OnDataSyncStateChanged.h create mode 100755 src/DataSync/SyncInfo.cpp create mode 100755 src/DataSync/SyncInfo.h create mode 100755 src/DataSync/SyncProfileInfo.cpp create mode 100755 src/DataSync/SyncProfileInfo.h create mode 100755 src/DataSync/SyncServiceInfo.cpp create mode 100755 src/DataSync/SyncServiceInfo.h create mode 100755 src/DataSync/SyncStatistics.cpp create mode 100755 src/DataSync/SyncStatistics.h create mode 100755 src/DataSync/config.xml create mode 100755 src/DataSync/plugin_config.cpp create mode 100755 src/DataSync/plugin_config.h create mode 100755 src/DataSync/plugin_initializer.cpp create mode 100755 src/Download/CMakeLists.txt create mode 100755 src/Download/DownloadCallback.cpp create mode 100644 src/Download/DownloadCallback.h create mode 100644 src/Download/DownloadManager.cpp create mode 100644 src/Download/DownloadManager.h create mode 100644 src/Download/DownloadRequest.cpp create mode 100644 src/Download/DownloadRequest.h create mode 100644 src/Download/DownloadState.h create mode 100644 src/Download/JSDownloadManager.cpp create mode 100644 src/Download/JSDownloadManager.h create mode 100755 src/Download/JSDownloadRequest.cpp create mode 100644 src/Download/JSDownloadRequest.h create mode 100755 src/Download/config.xml create mode 100755 src/Download/plugin_config.cpp create mode 100755 src/Download/plugin_config.h create mode 100644 src/Download/plugin_initializer.cpp create mode 100755 src/Filesystem/CMakeLists.txt create mode 100755 src/Filesystem/Converter.cpp create mode 100755 src/Filesystem/Converter.h create mode 100755 src/Filesystem/Encodings.cpp create mode 100755 src/Filesystem/Encodings.h create mode 100755 src/Filesystem/Enums.h create mode 100755 src/Filesystem/EventCopy.cpp create mode 100755 src/Filesystem/EventCopy.h create mode 100755 src/Filesystem/EventCreate.cpp create mode 100755 src/Filesystem/EventCreate.h create mode 100755 src/Filesystem/EventFind.cpp create mode 100755 src/Filesystem/EventFind.h create mode 100755 src/Filesystem/EventGetNodeData.cpp create mode 100755 src/Filesystem/EventGetNodeData.h create mode 100755 src/Filesystem/EventGetStorage.cpp create mode 100755 src/Filesystem/EventGetStorage.h create mode 100755 src/Filesystem/EventListNodes.cpp create mode 100755 src/Filesystem/EventListNodes.h create mode 100755 src/Filesystem/EventListStorages.cpp create mode 100755 src/Filesystem/EventListStorages.h create mode 100755 src/Filesystem/EventMove.cpp create mode 100755 src/Filesystem/EventMove.h create mode 100755 src/Filesystem/EventOpen.cpp create mode 100755 src/Filesystem/EventOpen.h create mode 100755 src/Filesystem/EventReadText.cpp create mode 100755 src/Filesystem/EventReadText.h create mode 100755 src/Filesystem/EventRemove.cpp create mode 100755 src/Filesystem/EventRemove.h create mode 100755 src/Filesystem/EventResolve.cpp create mode 100755 src/Filesystem/EventResolve.h create mode 100755 src/Filesystem/EventStorageStateChanged.h create mode 100755 src/Filesystem/EventStoragestateChanged.cpp create mode 100755 src/Filesystem/FilesystemAsyncCallbackManager.cpp create mode 100755 src/Filesystem/FilesystemAsyncCallbackManager.h create mode 100755 src/Filesystem/FilesystemListenerManager.cpp create mode 100755 src/Filesystem/FilesystemListenerManager.h create mode 100755 src/Filesystem/FilesystemUtils.cpp create mode 100755 src/Filesystem/FilesystemUtils.h create mode 100755 src/Filesystem/IManager.cpp create mode 100755 src/Filesystem/IManager.h create mode 100755 src/Filesystem/INode.cpp create mode 100755 src/Filesystem/INode.h create mode 100755 src/Filesystem/INodeTypes.h create mode 100755 src/Filesystem/IPath.cpp create mode 100755 src/Filesystem/IPath.h create mode 100755 src/Filesystem/IStream.cpp create mode 100755 src/Filesystem/IStream.h create mode 100755 src/Filesystem/JSFile.cpp create mode 100755 src/Filesystem/JSFile.h create mode 100755 src/Filesystem/JSFilestream.cpp create mode 100755 src/Filesystem/JSFilestream.h create mode 100755 src/Filesystem/JSFilesystemManager.cpp create mode 100755 src/Filesystem/JSFilesystemManager.h create mode 100755 src/Filesystem/JSStorage.cpp create mode 100755 src/Filesystem/JSStorage.h create mode 100755 src/Filesystem/Manager.cpp create mode 100755 src/Filesystem/Manager.h create mode 100755 src/Filesystem/Node.cpp create mode 100755 src/Filesystem/Node.h create mode 100755 src/Filesystem/NodeFilter.cpp create mode 100755 src/Filesystem/NodeFilter.h create mode 100755 src/Filesystem/NodeFilterMatcher.cpp create mode 100755 src/Filesystem/NodeFilterMatcher.h create mode 100755 src/Filesystem/Path.cpp create mode 100755 src/Filesystem/Path.h create mode 100755 src/Filesystem/PathUtils.cpp create mode 100755 src/Filesystem/PathUtils.h create mode 100755 src/Filesystem/ResponseDispatcher.cpp create mode 100755 src/Filesystem/ResponseDispatcher.h create mode 100755 src/Filesystem/StorageProperties.cpp create mode 100755 src/Filesystem/StorageProperties.h create mode 100755 src/Filesystem/StorageStaticController.cpp create mode 100755 src/Filesystem/StorageStaticController.h create mode 100755 src/Filesystem/Stream.cpp create mode 100755 src/Filesystem/Stream.h create mode 100755 src/Filesystem/Utils.cpp create mode 100755 src/Filesystem/Utils.h create mode 100755 src/Filesystem/config.xml create mode 100755 src/Filesystem/plugin_config.cpp create mode 100755 src/Filesystem/plugin_config.h create mode 100755 src/Filesystem/plugin_initializer.cpp create mode 100644 src/Log/CMakeLists.txt create mode 100755 src/Log/JSTizenLog.cpp create mode 100644 src/Log/JSTizenLog.h create mode 100644 src/Log/config.xml create mode 100644 src/Log/plugin_initializer.cpp create mode 100644 src/MessagePort/CMakeLists.txt create mode 100644 src/MessagePort/EventLocalMessagePortAddMessagePortListener.h create mode 100644 src/MessagePort/EventLocalMessagePortListener.h create mode 100644 src/MessagePort/EventLocalMessagePortRemoveMessagePortListener.h create mode 100644 src/MessagePort/EventMessagePortManagerRequestLocalMessagePort.h create mode 100644 src/MessagePort/EventMessagePortManagerRequestRemoteMessagePort.h create mode 100644 src/MessagePort/EventMessagePortManagerRequestTrustedLocalMessagePort.h create mode 100644 src/MessagePort/EventMessagePortManagerRequestTrustedRemoteMessagePort.h create mode 100644 src/MessagePort/EventRemoteMessagePortSendMessage.h create mode 100644 src/MessagePort/ILocalMessagePort.cpp create mode 100644 src/MessagePort/ILocalMessagePort.h create mode 100644 src/MessagePort/IMessagePortManager.cpp create mode 100644 src/MessagePort/IMessagePortManager.h create mode 100644 src/MessagePort/IRemoteMessagePort.cpp create mode 100644 src/MessagePort/IRemoteMessagePort.h create mode 100644 src/MessagePort/JSLocalMessagePort.cpp create mode 100644 src/MessagePort/JSLocalMessagePort.h create mode 100644 src/MessagePort/JSMessagePortManager.cpp create mode 100644 src/MessagePort/JSMessagePortManager.h create mode 100644 src/MessagePort/JSRemoteMessagePort.cpp create mode 100644 src/MessagePort/JSRemoteMessagePort.h create mode 100644 src/MessagePort/LocalMessagePort.cpp create mode 100644 src/MessagePort/LocalMessagePort.h create mode 100644 src/MessagePort/LocalMessagePortController.cpp create mode 100644 src/MessagePort/LocalMessagePortController.h create mode 100644 src/MessagePort/MessagePortConverter.cpp create mode 100644 src/MessagePort/MessagePortConverter.h create mode 100644 src/MessagePort/MessagePortDataItem.h create mode 100644 src/MessagePort/MessagePortFactory.cpp create mode 100644 src/MessagePort/MessagePortFactory.h create mode 100644 src/MessagePort/MessagePortImpl.h create mode 100644 src/MessagePort/MessagePortListenerManager.cpp create mode 100644 src/MessagePort/MessagePortListenerManager.h create mode 100644 src/MessagePort/MessagePortManager.cpp create mode 100644 src/MessagePort/MessagePortManager.h create mode 100644 src/MessagePort/MessagePortManagerProxy.cpp create mode 100644 src/MessagePort/MessagePortManagerProxy.h create mode 100644 src/MessagePort/MessagePortUtility.cpp create mode 100644 src/MessagePort/MessagePortUtility.h create mode 100644 src/MessagePort/RemoteMessagePort.cpp create mode 100644 src/MessagePort/RemoteMessagePort.h create mode 100644 src/MessagePort/config.xml create mode 100644 src/MessagePort/plugin_config.cpp create mode 100644 src/MessagePort/plugin_config.h create mode 100644 src/MessagePort/plugin_initializer.cpp create mode 100644 src/Messaging/Attachment.cpp create mode 100755 src/Messaging/Attachment.h create mode 100755 src/Messaging/AttachmentFactory.cpp create mode 100755 src/Messaging/AttachmentFactory.h create mode 100755 src/Messaging/Attachments.cpp create mode 100755 src/Messaging/Attachments.h create mode 100755 src/Messaging/BccRecipient.cpp create mode 100755 src/Messaging/BccRecipient.h create mode 100755 src/Messaging/BinarySms.cpp create mode 100755 src/Messaging/BinarySms.h create mode 100755 src/Messaging/Body.cpp create mode 100755 src/Messaging/Body.h create mode 100755 src/Messaging/CMakeLists.txt create mode 100644 src/Messaging/CallbackMgr.cpp create mode 100644 src/Messaging/CallbackMgr.h create mode 100755 src/Messaging/CallbackNumber.cpp create mode 100755 src/Messaging/CallbackNumber.h create mode 100755 src/Messaging/CcRecipient.cpp create mode 100755 src/Messaging/CcRecipient.h create mode 100644 src/Messaging/Conversation.cpp create mode 100644 src/Messaging/Conversation.h create mode 100755 src/Messaging/ConversationFilterValidator.cpp create mode 100644 src/Messaging/ConversationFilterValidator.h create mode 100755 src/Messaging/ConversationFilterValidatorFactory.cpp create mode 100644 src/Messaging/ConversationFilterValidatorFactory.h create mode 100755 src/Messaging/ConversationQueryGenerator.cpp create mode 100644 src/Messaging/ConversationQueryGenerator.h create mode 100644 src/Messaging/ConverterMessage.cpp create mode 100644 src/Messaging/ConverterMessage.h create mode 100755 src/Messaging/DBus/Connection.cpp create mode 100755 src/Messaging/DBus/Connection.h create mode 100755 src/Messaging/DBus/Message.cpp create mode 100755 src/Messaging/DBus/Message.h create mode 100755 src/Messaging/DBus/MessageEvent.h create mode 100644 src/Messaging/Email.cpp create mode 100755 src/Messaging/Email.h create mode 100755 src/Messaging/EmailAccountInfo.cpp create mode 100755 src/Messaging/EmailAccountInfo.h create mode 100644 src/Messaging/EmailConverter.cpp create mode 100644 src/Messaging/EmailConverter.h create mode 100644 src/Messaging/EmailService.cpp create mode 100644 src/Messaging/EmailService.h create mode 100755 src/Messaging/EmailUtils.cpp create mode 100755 src/Messaging/EmailUtils.h create mode 100755 src/Messaging/EmitterConversationReceived.cpp create mode 100755 src/Messaging/EmitterConversationReceived.h create mode 100755 src/Messaging/EmitterFolderReceived.cpp create mode 100755 src/Messaging/EmitterFolderReceived.h create mode 100755 src/Messaging/EmitterMessageReceived.cpp create mode 100755 src/Messaging/EmitterMessageReceived.h create mode 100644 src/Messaging/EmptyMessage.cpp create mode 100644 src/Messaging/EmptyMessage.h create mode 100644 src/Messaging/EventAddDraftMessage.h create mode 100644 src/Messaging/EventDeleteConversations.h create mode 100755 src/Messaging/EventDeleteMessage.h create mode 100755 src/Messaging/EventDeleteMessages.h create mode 100755 src/Messaging/EventGetConversationId.h create mode 100755 src/Messaging/EventGetMessagingService.h create mode 100755 src/Messaging/EventMessageReceived.cpp create mode 100755 src/Messaging/EventMessageReceived.h create mode 100755 src/Messaging/EventMessagingService.h create mode 100755 src/Messaging/EventMessagingServicePrivateData.cpp create mode 100755 src/Messaging/EventMessagingServicePrivateData.h create mode 100755 src/Messaging/EventMessagingStorage.h create mode 100755 src/Messaging/EventOnSendingFailed.h create mode 100644 src/Messaging/EventQueryConversations.h create mode 100644 src/Messaging/EventQueryFolders.h create mode 100644 src/Messaging/EventQueryMessages.h create mode 100755 src/Messaging/EventSendMessage.h create mode 100755 src/Messaging/EventSendMessagePrivateData.cpp create mode 100755 src/Messaging/EventSendMessagePrivateData.h create mode 100755 src/Messaging/EventUpdateMessage.h create mode 100755 src/Messaging/EventUpdateMessages.h create mode 100644 src/Messaging/FolderFilterValidator.cpp create mode 100644 src/Messaging/FolderFilterValidator.h create mode 100755 src/Messaging/FolderFilterValidatorFactory.cpp create mode 100644 src/Messaging/FolderFilterValidatorFactory.h create mode 100755 src/Messaging/FolderQueryGenerator.cpp create mode 100644 src/Messaging/FolderQueryGenerator.h create mode 100755 src/Messaging/From.cpp create mode 100755 src/Messaging/From.h create mode 100755 src/Messaging/IAttachment.cpp create mode 100755 src/Messaging/IAttachment.h create mode 100755 src/Messaging/IBinarySms.cpp create mode 100755 src/Messaging/IBinarySms.h create mode 100755 src/Messaging/IConversation.h create mode 100755 src/Messaging/IEmail.cpp create mode 100755 src/Messaging/IEmail.h create mode 100755 src/Messaging/IEmailAccount.cpp create mode 100755 src/Messaging/IEmailAccount.h create mode 100644 src/Messaging/IEmptyMessage.cpp create mode 100644 src/Messaging/IEmptyMessage.h create mode 100755 src/Messaging/IMessage.cpp create mode 100755 src/Messaging/IMessage.h create mode 100755 src/Messaging/IMessageFolder.h create mode 100755 src/Messaging/IMessaging.cpp create mode 100644 src/Messaging/IMessaging.h create mode 100755 src/Messaging/IMessagingService.cpp create mode 100755 src/Messaging/IMessagingService.h create mode 100755 src/Messaging/IMessagingServiceManager.cpp create mode 100755 src/Messaging/IMessagingServiceManager.h create mode 100644 src/Messaging/IMessagingTypes.h create mode 100755 src/Messaging/IMms.cpp create mode 100755 src/Messaging/IMms.h create mode 100755 src/Messaging/IMmsSlide.h create mode 100755 src/Messaging/IMmsSlideProperties.h create mode 100755 src/Messaging/IMmsSlides.h create mode 100644 src/Messaging/ISendingObserver.h create mode 100755 src/Messaging/ISms.cpp create mode 100755 src/Messaging/ISms.h create mode 100755 src/Messaging/JSConversation.cpp create mode 100755 src/Messaging/JSConversation.h create mode 100644 src/Messaging/JSMessage.cpp create mode 100755 src/Messaging/JSMessage.h create mode 100644 src/Messaging/JSMessageAttachment.cpp create mode 100755 src/Messaging/JSMessageAttachment.h create mode 100644 src/Messaging/JSMessageBody.cpp create mode 100755 src/Messaging/JSMessageBody.h create mode 100644 src/Messaging/JSMessageFolder.cpp create mode 100755 src/Messaging/JSMessageFolder.h create mode 100755 src/Messaging/JSMessagePrivateObject.h create mode 100644 src/Messaging/JSMessagingService.cpp create mode 100755 src/Messaging/JSMessagingService.h create mode 100644 src/Messaging/JSMessagingServiceManager.cpp create mode 100755 src/Messaging/JSMessagingServiceManager.h create mode 100644 src/Messaging/JSMessagingStorage.cpp create mode 100755 src/Messaging/JSMessagingStorage.h create mode 100755 src/Messaging/JSRecipientArray.cpp create mode 100755 src/Messaging/JSRecipientArray.h create mode 100644 src/Messaging/MailSender.cpp create mode 100755 src/Messaging/MailSender.h create mode 100644 src/Messaging/MailSync.cpp create mode 100755 src/Messaging/MailSync.h create mode 100755 src/Messaging/MessageAsyncCallbackManager.cpp create mode 100644 src/Messaging/MessageAsyncCallbackManager.h create mode 100755 src/Messaging/MessageEventPrivateData.h create mode 100755 src/Messaging/MessageFactory.cpp create mode 100755 src/Messaging/MessageFactory.h create mode 100755 src/Messaging/MessageFilterValidator.cpp create mode 100644 src/Messaging/MessageFilterValidator.h create mode 100755 src/Messaging/MessageFilterValidatorFactory.cpp create mode 100644 src/Messaging/MessageFilterValidatorFactory.h create mode 100755 src/Messaging/MessageFolder.cpp create mode 100644 src/Messaging/MessageFolder.h create mode 100755 src/Messaging/MessageListenerManager.cpp create mode 100644 src/Messaging/MessageListenerManager.h create mode 100755 src/Messaging/MessagePriority.cpp create mode 100755 src/Messaging/MessagePriority.h create mode 100755 src/Messaging/MessageProperties.h create mode 100755 src/Messaging/MessageQueryGenerator.cpp create mode 100644 src/Messaging/MessageQueryGenerator.h create mode 100755 src/Messaging/MessageSendCallback.h create mode 100755 src/Messaging/MessageStorageFactory.cpp create mode 100644 src/Messaging/MessageStorageFactory.h create mode 100755 src/Messaging/Messaging.cpp create mode 100644 src/Messaging/Messaging.h create mode 100644 src/Messaging/MessagingController.cpp create mode 100755 src/Messaging/MessagingController.h create mode 100644 src/Messaging/MessagingErrorMsg.h create mode 100755 src/Messaging/MessagingFactory.cpp create mode 100755 src/Messaging/MessagingFactory.h create mode 100644 src/Messaging/MessagingListener.cpp create mode 100755 src/Messaging/MessagingListener.h create mode 100755 src/Messaging/MessagingService.cpp create mode 100755 src/Messaging/MessagingService.h create mode 100644 src/Messaging/MessagingServiceManager.cpp create mode 100755 src/Messaging/MessagingServiceManager.h create mode 100755 src/Messaging/MessagingStorageMultiCallback.cpp create mode 100644 src/Messaging/MessagingStorageMultiCallback.h create mode 100644 src/Messaging/Mms.cpp create mode 100644 src/Messaging/Mms.h create mode 100755 src/Messaging/MmsSlide.cpp create mode 100755 src/Messaging/MmsSlide.h create mode 100755 src/Messaging/MmsSlideProperty.cpp create mode 100755 src/Messaging/MmsSlideProperty.h create mode 100755 src/Messaging/MmsSlides.cpp create mode 100755 src/Messaging/MmsSlides.h create mode 100644 src/Messaging/MsgServiceHandleMgr.h create mode 100755 src/Messaging/NetworkStatus.cpp create mode 100755 src/Messaging/NetworkStatus.h create mode 100755 src/Messaging/Recipient.cpp create mode 100755 src/Messaging/Recipient.h create mode 100755 src/Messaging/ReqReceiverMessage.cpp create mode 100755 src/Messaging/ReqReceiverMessage.h create mode 100644 src/Messaging/ScopedMail.h create mode 100644 src/Messaging/ScopedMailAttachment.h create mode 100644 src/Messaging/ScopedMailbox.h create mode 100644 src/Messaging/Sms.cpp create mode 100644 src/Messaging/Sms.h create mode 100755 src/Messaging/SourceAddress.cpp create mode 100755 src/Messaging/SourceAddress.h create mode 100755 src/Messaging/StorageChangesConversationFilterValidator.cpp create mode 100644 src/Messaging/StorageChangesConversationFilterValidator.h create mode 100755 src/Messaging/StorageChangesConversationFilterValidatorFactory.cpp create mode 100644 src/Messaging/StorageChangesConversationFilterValidatorFactory.h create mode 100755 src/Messaging/StorageChangesConversationGenerator.cpp create mode 100644 src/Messaging/StorageChangesConversationGenerator.h create mode 100755 src/Messaging/StorageChangesFolderFilterValidator.cpp create mode 100644 src/Messaging/StorageChangesFolderFilterValidator.h create mode 100755 src/Messaging/StorageChangesFolderFilterValidatorFactory.cpp create mode 100644 src/Messaging/StorageChangesFolderFilterValidatorFactory.h create mode 100755 src/Messaging/StorageChangesFolderGenerator.cpp create mode 100644 src/Messaging/StorageChangesFolderGenerator.h create mode 100755 src/Messaging/StorageChangesMessageFilterValidator.cpp create mode 100644 src/Messaging/StorageChangesMessageFilterValidator.h create mode 100755 src/Messaging/StorageChangesMessageFilterValidatorFactory.cpp create mode 100644 src/Messaging/StorageChangesMessageFilterValidatorFactory.h create mode 100755 src/Messaging/StorageChangesMessageGenerator.cpp create mode 100644 src/Messaging/StorageChangesMessageGenerator.h create mode 100755 src/Messaging/Subject.cpp create mode 100755 src/Messaging/Subject.h create mode 100755 src/Messaging/SyncNetworkStatus.cpp create mode 100755 src/Messaging/SyncNetworkStatus.h create mode 100755 src/Messaging/ToRecipient.cpp create mode 100755 src/Messaging/ToRecipient.h create mode 100755 src/Messaging/ValidityPeriodHours.cpp create mode 100755 src/Messaging/ValidityPeriodHours.h create mode 100755 src/Messaging/VirtualMessage.cpp create mode 100755 src/Messaging/VirtualMessage.h rename src/{platform/API => }/Messaging/config.cmake (100%) rename src/{platform/Tizen/Messaging/config.cmake => Messaging/config.cmake.platformTizen} (100%) create mode 100755 src/Messaging/config.xml rename src/{platform/API => }/Messaging/log.h (100%) create mode 100644 src/Messaging/messageDB/MessageStorageReader.cpp rename src/{platform/Tizen => }/Messaging/messageDB/MessageStorageReader.h (100%) mode change 100755 => 100644 rename src/{platform/Tizen => }/Messaging/messageDB/MsgSqliteWrapper.cpp (100%) mode change 100755 => 100644 rename src/{platform/Tizen => }/Messaging/messageDB/MsgSqliteWrapper.h (100%) mode change 100755 => 100644 create mode 100755 src/Messaging/plugin_config.cpp create mode 100755 src/Messaging/plugin_config.h create mode 100755 src/Messaging/plugin_initializer.cpp create mode 100755 src/NFC/CMakeLists.txt create mode 100755 src/NFC/EventNFC.h create mode 100755 src/NFC/EventNFCChanged.h create mode 100755 src/NFC/EventNFCChangedPrivateData.cpp create mode 100755 src/NFC/EventNFCChangedPrivateData.h create mode 100755 src/NFC/EventTagAction.h create mode 100755 src/NFC/EventTargetAction.h create mode 100755 src/NFC/INFCAdapter.cpp create mode 100755 src/NFC/INFCAdapter.h create mode 100755 src/NFC/INFCTag.cpp create mode 100755 src/NFC/INFCTag.h create mode 100755 src/NFC/INFCTarget.cpp create mode 100755 src/NFC/INFCTarget.h create mode 100755 src/NFC/INdefMessage.h create mode 100755 src/NFC/INdefRecord.h create mode 100644 src/NFC/JSNFCAdapter.cpp create mode 100755 src/NFC/JSNFCAdapter.h create mode 100644 src/NFC/JSNFCManager.cpp create mode 100755 src/NFC/JSNFCManager.h create mode 100644 src/NFC/JSNFCTag.cpp create mode 100755 src/NFC/JSNFCTag.h create mode 100644 src/NFC/JSNFCTarget.cpp create mode 100755 src/NFC/JSNFCTarget.h create mode 100644 src/NFC/JSNdefMessage.cpp create mode 100755 src/NFC/JSNdefMessage.h create mode 100644 src/NFC/JSNdefRecord.cpp create mode 100755 src/NFC/JSNdefRecord.h create mode 100644 src/NFC/JSNdefRecordArray.cpp create mode 100755 src/NFC/JSNdefRecordArray.h create mode 100644 src/NFC/JSNdefRecordMedia.cpp create mode 100755 src/NFC/JSNdefRecordMedia.h create mode 100644 src/NFC/JSNdefRecordText.cpp create mode 100755 src/NFC/JSNdefRecordText.h create mode 100644 src/NFC/JSNdefRecordURI.cpp create mode 100755 src/NFC/JSNdefRecordURI.h create mode 100644 src/NFC/NFCAdapter.cpp create mode 100755 src/NFC/NFCAdapter.h create mode 100755 src/NFC/NFCAsyncCallbackManager.cpp create mode 100644 src/NFC/NFCAsyncCallbackManager.h create mode 100755 src/NFC/NFCChangedCallback.h create mode 100755 src/NFC/NFCConverter.cpp create mode 100755 src/NFC/NFCConverter.h create mode 100644 src/NFC/NFCDefaultAdapter.cpp create mode 100755 src/NFC/NFCDefaultAdapter.h create mode 100755 src/NFC/NFCFactory.cpp create mode 100755 src/NFC/NFCFactory.h create mode 100755 src/NFC/NFCListenerManager.cpp create mode 100644 src/NFC/NFCListenerManager.h create mode 100644 src/NFC/NFCStaticController.cpp create mode 100755 src/NFC/NFCStaticController.h create mode 100644 src/NFC/NFCTag.cpp create mode 100755 src/NFC/NFCTag.h create mode 100755 src/NFC/NFCTagProperties.h create mode 100755 src/NFC/NFCTarget.cpp create mode 100755 src/NFC/NFCTarget.h create mode 100644 src/NFC/NFCUtil.cpp create mode 100755 src/NFC/NFCUtil.h create mode 100755 src/NFC/NdefMessage.cpp create mode 100755 src/NFC/NdefMessage.h create mode 100755 src/NFC/NdefRecord.cpp create mode 100755 src/NFC/NdefRecord.h create mode 100755 src/NFC/NdefRecordProperties.h create mode 100644 src/NFC/ResponseDispatcher.cpp create mode 100755 src/NFC/ResponseDispatcher.h create mode 100755 src/NFC/TagFilter.cpp create mode 100755 src/NFC/TagFilter.h create mode 100755 src/NFC/config.xml create mode 100755 src/NFC/plugin_config.cpp create mode 100755 src/NFC/plugin_config.h create mode 100755 src/NFC/plugin_initializer.cpp create mode 100755 src/NetworkBearerSelection/CMakeLists.txt create mode 100755 src/NetworkBearerSelection/EventNetworkBearerRelease.h create mode 100755 src/NetworkBearerSelection/EventNetworkBearerSelection.h create mode 100755 src/NetworkBearerSelection/INetworkBearerSelection.cpp create mode 100755 src/NetworkBearerSelection/INetworkBearerSelection.h create mode 100755 src/NetworkBearerSelection/JSNetworkBearerSelection.cpp create mode 100755 src/NetworkBearerSelection/JSNetworkBearerSelection.h create mode 100755 src/NetworkBearerSelection/JSNetworkBearerSelectionCallbackManager.cpp create mode 100755 src/NetworkBearerSelection/JSNetworkBearerSelectionCallbackManager.h create mode 100755 src/NetworkBearerSelection/NetworkBearerSelection.cpp create mode 100755 src/NetworkBearerSelection/NetworkBearerSelection.h create mode 100755 src/NetworkBearerSelection/NetworkBearerSelectionFactory.cpp create mode 100755 src/NetworkBearerSelection/NetworkBearerSelectionFactory.h create mode 100755 src/NetworkBearerSelection/NetworkBearerSelectionResponseDispatcher.cpp create mode 100755 src/NetworkBearerSelection/NetworkBearerSelectionResponseDispatcher.h create mode 100755 src/NetworkBearerSelection/OnNetworkBearerSelectionStateChanged.h create mode 100755 src/NetworkBearerSelection/config.xml create mode 100755 src/NetworkBearerSelection/plugin_config.cpp create mode 100755 src/NetworkBearerSelection/plugin_config.h create mode 100755 src/NetworkBearerSelection/plugin_initializer.cpp create mode 100755 src/Notification/CMakeLists.txt create mode 100755 src/Notification/INotification.cpp create mode 100755 src/Notification/INotification.h create mode 100755 src/Notification/INotificationManager.cpp create mode 100755 src/Notification/INotificationManager.h create mode 100755 src/Notification/JSNotificationLine.cpp create mode 100755 src/Notification/JSNotificationLine.h create mode 100755 src/Notification/JSNotificationLineArray.cpp create mode 100755 src/Notification/JSNotificationLineArray.h create mode 100644 src/Notification/JSNotificationManager.cpp create mode 100755 src/Notification/JSNotificationManager.h create mode 100755 src/Notification/JSStatusNotification.cpp create mode 100755 src/Notification/JSStatusNotification.h create mode 100755 src/Notification/JSStringArray.cpp create mode 100755 src/Notification/JSStringArray.h create mode 100755 src/Notification/NotificationConverter.cpp create mode 100755 src/Notification/NotificationConverter.h create mode 100755 src/Notification/NotificationFactory.cpp create mode 100755 src/Notification/NotificationFactory.h create mode 100755 src/Notification/NotificationLine.cpp create mode 100755 src/Notification/NotificationLine.h create mode 100755 src/Notification/NotificationManager.cpp create mode 100755 src/Notification/NotificationManager.h create mode 100755 src/Notification/StatusNotification.cpp create mode 100755 src/Notification/StatusNotification.h create mode 100644 src/Notification/config.xml create mode 100644 src/Notification/plugin_config.cpp create mode 100644 src/Notification/plugin_config.h create mode 100755 src/Notification/plugin_initializer.cpp create mode 100644 src/Package/CMakeLists.txt create mode 100644 src/Package/JSPackageInformation.cpp create mode 100644 src/Package/JSPackageInformation.h create mode 100644 src/Package/JSPackageManager.cpp create mode 100644 src/Package/JSPackageManager.h create mode 100644 src/Package/PackageInformation.cpp create mode 100644 src/Package/PackageInformation.h create mode 100644 src/Package/PackageManager.cpp create mode 100644 src/Package/PackageManager.h create mode 100755 src/Package/config.xml create mode 100644 src/Package/plugin_config.cpp create mode 100644 src/Package/plugin_config.h create mode 100644 src/Package/plugin_initializer.cpp create mode 100755 src/Power/CMakeLists.txt create mode 100755 src/Power/JSPowerManager.cpp create mode 100755 src/Power/JSPowerManager.h create mode 100755 src/Power/PowerManager.cpp create mode 100755 src/Power/PowerManager.h create mode 100755 src/Power/config.xml create mode 100755 src/Power/plugin_config.cpp create mode 100755 src/Power/plugin_config.h create mode 100755 src/Power/plugin_initializer.cpp create mode 100755 src/Power/test/CMakeLists.txt create mode 100755 src/Power/test/TestEngine.js create mode 100755 src/Power/test/TestPower.js create mode 100755 src/Power/test/main.cpp create mode 100755 src/Push/CMakeLists.txt create mode 100755 src/Push/IEventConnectService.h create mode 100755 src/Push/IEventDisconnectService.h create mode 100755 src/Push/IEventGetRegistrationId.h create mode 100644 src/Push/IEventRegisterService.h create mode 100755 src/Push/IEventUnregisterService.h create mode 100755 src/Push/IPushManager.cpp create mode 100755 src/Push/IPushManager.h create mode 100644 src/Push/JSPushManager.cpp create mode 100755 src/Push/JSPushManager.h create mode 100644 src/Push/JSPushMessage.cpp create mode 100755 src/Push/JSPushMessage.h create mode 100755 src/Push/OnPushNotified.h create mode 100755 src/Push/PushAsyncCallbackManager.cpp create mode 100644 src/Push/PushAsyncCallbackManager.h create mode 100755 src/Push/PushConverter.cpp create mode 100755 src/Push/PushConverter.h create mode 100755 src/Push/PushListenerManager.cpp create mode 100644 src/Push/PushListenerManager.h create mode 100644 src/Push/PushManager.cpp create mode 100755 src/Push/PushManager.h create mode 100755 src/Push/PushMessage.cpp create mode 100755 src/Push/PushMessage.h create mode 100644 src/Push/PushResponseDispatcher.cpp create mode 100755 src/Push/PushResponseDispatcher.h create mode 100755 src/Push/config.xml create mode 100755 src/Push/plugin_config.cpp create mode 100755 src/Push/plugin_config.h create mode 100644 src/Push/plugin_initializer.cpp create mode 100755 src/SecureElement/CMakeLists.txt create mode 100755 src/SecureElement/EventSEService.h create mode 100755 src/SecureElement/ISEChannel.cpp create mode 100755 src/SecureElement/ISEChannel.h create mode 100755 src/SecureElement/ISEReader.cpp create mode 100755 src/SecureElement/ISEReader.h create mode 100755 src/SecureElement/ISEService.cpp create mode 100755 src/SecureElement/ISEService.h create mode 100755 src/SecureElement/ISESession.cpp create mode 100755 src/SecureElement/ISESession.h create mode 100644 src/SecureElement/JSSEChannel.cpp create mode 100755 src/SecureElement/JSSEChannel.h create mode 100644 src/SecureElement/JSSEReader.cpp create mode 100755 src/SecureElement/JSSEReader.h create mode 100644 src/SecureElement/JSSEService.cpp create mode 100755 src/SecureElement/JSSEService.h create mode 100644 src/SecureElement/JSSESession.cpp create mode 100755 src/SecureElement/JSSESession.h create mode 100755 src/SecureElement/SEAsyncCallbackManager.cpp create mode 100644 src/SecureElement/SEAsyncCallbackManager.h create mode 100644 src/SecureElement/SEChannel.cpp create mode 100755 src/SecureElement/SEChannel.h create mode 100755 src/SecureElement/SEConverter.cpp create mode 100755 src/SecureElement/SEConverter.h create mode 100755 src/SecureElement/SEFactory.cpp create mode 100755 src/SecureElement/SEFactory.h create mode 100755 src/SecureElement/SEListener.h create mode 100755 src/SecureElement/SEListenerManager.cpp create mode 100644 src/SecureElement/SEListenerManager.h create mode 100755 src/SecureElement/SEReader.cpp create mode 100755 src/SecureElement/SEReader.h create mode 100644 src/SecureElement/SEResponseDispatcher.cpp create mode 100755 src/SecureElement/SEResponseDispatcher.h create mode 100755 src/SecureElement/SEService.cpp create mode 100755 src/SecureElement/SEService.h create mode 100755 src/SecureElement/SESession.cpp create mode 100755 src/SecureElement/SESession.h create mode 100755 src/SecureElement/SEUtil.cpp create mode 100755 src/SecureElement/SEUtil.h create mode 100755 src/SecureElement/config.xml create mode 100755 src/SecureElement/plugin_initializer.cpp create mode 100755 src/SystemSetting/CMakeLists.txt create mode 100755 src/SystemSetting/ConverterSystemSetting.cpp create mode 100755 src/SystemSetting/ConverterSystemSetting.h create mode 100755 src/SystemSetting/EventGetSetting.h create mode 100755 src/SystemSetting/EventSetRingtone.h create mode 100755 src/SystemSetting/EventSetSetting.h create mode 100755 src/SystemSetting/EventSetWallpaper.h create mode 100755 src/SystemSetting/ISystemSetting.cpp create mode 100755 src/SystemSetting/ISystemSetting.h create mode 100755 src/SystemSetting/ISystemSettingType.h create mode 100755 src/SystemSetting/JSSystemSetting.cpp create mode 100755 src/SystemSetting/JSSystemSetting.h create mode 100755 src/SystemSetting/SystemSetting.cpp create mode 100755 src/SystemSetting/SystemSetting.h create mode 100755 src/SystemSetting/SystemSettingAsyncCallbackManager.cpp create mode 100755 src/SystemSetting/SystemSettingAsyncCallbackManager.h create mode 100755 src/SystemSetting/SystemSettingFactory.cpp create mode 100755 src/SystemSetting/SystemSettingFactory.h create mode 100755 src/SystemSetting/SystemSettingResponseDispatcher.cpp create mode 100755 src/SystemSetting/SystemSettingResponseDispatcher.h create mode 100755 src/SystemSetting/config.xml create mode 100755 src/SystemSetting/plugin_config.cpp create mode 100755 src/SystemSetting/plugin_config.h create mode 100755 src/SystemSetting/plugin_initializer.cpp create mode 100755 src/Systeminfo/BaseProperties.h create mode 100755 src/Systeminfo/CMakeLists.txt create mode 100755 src/Systeminfo/EventGetSysteminfo.cpp create mode 100755 src/Systeminfo/EventGetSysteminfo.h create mode 100755 src/Systeminfo/EventWatchSysteminfo.cpp create mode 100755 src/Systeminfo/EventWatchSysteminfo.h create mode 100755 src/Systeminfo/ISysteminfo.cpp create mode 100755 src/Systeminfo/ISysteminfo.h create mode 100755 src/Systeminfo/JSBatteryInfo.cpp create mode 100755 src/Systeminfo/JSBatteryInfo.h create mode 100755 src/Systeminfo/JSBuildInfo.cpp create mode 100755 src/Systeminfo/JSBuildInfo.h create mode 100755 src/Systeminfo/JSCellularNetworkInfo.cpp create mode 100755 src/Systeminfo/JSCellularNetworkInfo.h create mode 100755 src/Systeminfo/JSCpuInfo.cpp create mode 100755 src/Systeminfo/JSCpuInfo.h create mode 100755 src/Systeminfo/JSDeviceCapabilitiesInfo.cpp create mode 100755 src/Systeminfo/JSDeviceCapabilitiesInfo.h create mode 100755 src/Systeminfo/JSDeviceOrientationInfo.cpp create mode 100755 src/Systeminfo/JSDeviceOrientationInfo.h create mode 100755 src/Systeminfo/JSDisplayInfo.cpp create mode 100755 src/Systeminfo/JSDisplayInfo.h create mode 100755 src/Systeminfo/JSLocaleInfo.cpp create mode 100755 src/Systeminfo/JSLocaleInfo.h create mode 100755 src/Systeminfo/JSNetworkInfo.cpp create mode 100755 src/Systeminfo/JSNetworkInfo.h create mode 100755 src/Systeminfo/JSPeripheralInfo.cpp create mode 100755 src/Systeminfo/JSPeripheralInfo.h create mode 100755 src/Systeminfo/JSSIMInfo.cpp create mode 100755 src/Systeminfo/JSSIMInfo.h create mode 100755 src/Systeminfo/JSStorageInfo.cpp create mode 100755 src/Systeminfo/JSStorageInfo.h create mode 100755 src/Systeminfo/JSSysteminfo.cpp create mode 100755 src/Systeminfo/JSSysteminfo.h create mode 100755 src/Systeminfo/JSWifiNetworkInfo.cpp create mode 100755 src/Systeminfo/JSWifiNetworkInfo.h create mode 100755 src/Systeminfo/Systeminfo.cpp create mode 100755 src/Systeminfo/Systeminfo.h create mode 100755 src/Systeminfo/SysteminfoAsyncCallbackManager.cpp create mode 100755 src/Systeminfo/SysteminfoAsyncCallbackManager.h create mode 100755 src/Systeminfo/SysteminfoFactory.cpp create mode 100755 src/Systeminfo/SysteminfoFactory.h create mode 100755 src/Systeminfo/SysteminfoListener.cpp create mode 100755 src/Systeminfo/SysteminfoListener.h create mode 100755 src/Systeminfo/SysteminfoListenerManager.cpp create mode 100755 src/Systeminfo/SysteminfoListenerManager.h create mode 100755 src/Systeminfo/SysteminfoPropertyInfo.h create mode 100755 src/Systeminfo/config.xml create mode 100755 src/Systeminfo/plugin_config.cpp create mode 100755 src/Systeminfo/plugin_config.h create mode 100755 src/Systeminfo/plugin_initializer.cpp create mode 100755 src/TimeUtil/CMakeLists.txt create mode 100755 src/TimeUtil/DurationProperties.h create mode 100755 src/TimeUtil/JSTZDate.cpp create mode 100755 src/TimeUtil/JSTZDate.h create mode 100755 src/TimeUtil/JSTimeDuration.cpp create mode 100755 src/TimeUtil/JSTimeDuration.h create mode 100755 src/TimeUtil/JSTimeUtil.cpp create mode 100755 src/TimeUtil/JSTimeUtil.h create mode 100755 src/TimeUtil/TZDate.cpp create mode 100755 src/TimeUtil/TZDate.h create mode 100755 src/TimeUtil/TZDateProperties.h create mode 100755 src/TimeUtil/TimeUtil.cpp create mode 100755 src/TimeUtil/TimeUtil.h create mode 100755 src/TimeUtil/TimeUtilConverter.cpp create mode 100755 src/TimeUtil/TimeUtilConverter.h create mode 100755 src/TimeUtil/TimeUtilTools.cpp create mode 100755 src/TimeUtil/TimeUtilTools.h create mode 100755 src/TimeUtil/config.xml create mode 100755 src/TimeUtil/plugin_initializer.cpp create mode 100644 src/Tizen/AnyType.cpp create mode 100644 src/Tizen/AnyType.h create mode 100644 src/Tizen/AttributeFilter.cpp create mode 100644 src/Tizen/AttributeFilter.h create mode 100644 src/Tizen/AttributeRangeFilter.cpp create mode 100644 src/Tizen/AttributeRangeFilter.h create mode 100644 src/Tizen/CMakeLists.txt create mode 100644 src/Tizen/CompositeFilter.cpp create mode 100644 src/Tizen/CompositeFilter.h create mode 100644 src/Tizen/FilterConverter.cpp create mode 100644 src/Tizen/FilterConverter.h create mode 100644 src/Tizen/FilterFactory.cpp create mode 100644 src/Tizen/FilterFactory.h create mode 100644 src/Tizen/FilterTypes.h create mode 100644 src/Tizen/FilterValidator.cpp create mode 100644 src/Tizen/FilterValidator.h create mode 100644 src/Tizen/IFilter.cpp create mode 100644 src/Tizen/IFilter.h create mode 100644 src/Tizen/IFilterVisitor.cpp create mode 100644 src/Tizen/IFilterVisitor.h create mode 100644 src/Tizen/JSAbstractFilterArray.cpp create mode 100644 src/Tizen/JSAbstractFilterArray.h create mode 100644 src/Tizen/JSAttributeFilter.cpp create mode 100644 src/Tizen/JSAttributeFilter.h create mode 100644 src/Tizen/JSAttributeRangeFilter.cpp create mode 100644 src/Tizen/JSAttributeRangeFilter.h create mode 100644 src/Tizen/JSCompositeFilter.cpp create mode 100644 src/Tizen/JSCompositeFilter.h create mode 100644 src/Tizen/JSFeature.cpp create mode 100644 src/Tizen/JSFeature.h create mode 100644 src/Tizen/JSFeatureParam.cpp create mode 100644 src/Tizen/JSFeatureParam.h create mode 100644 src/Tizen/JSSimpleCoordinates.cpp create mode 100644 src/Tizen/JSSimpleCoordinates.h create mode 100644 src/Tizen/JSSortMode.cpp create mode 100644 src/Tizen/JSSortMode.h create mode 100644 src/Tizen/JSTizen.cpp create mode 100644 src/Tizen/JSTizen.h create mode 100644 src/Tizen/PluginOnDemandPriv.cpp create mode 100644 src/Tizen/PluginOnDemandPriv.h create mode 100644 src/Tizen/SimpleCoordinates.cpp create mode 100644 src/Tizen/SimpleCoordinates.h create mode 100644 src/Tizen/SortMode.cpp create mode 100644 src/Tizen/SortMode.h create mode 100644 src/Tizen/config.xml create mode 100644 src/Tizen/plugin_config.cpp create mode 100644 src/Tizen/plugin_config.h create mode 100644 src/Tizen/plugin_initializer.cpp delete mode 100644 src/platform/API/Application/ApplicationCert.cpp delete mode 100644 src/platform/API/Application/ApplicationCert.h delete mode 100755 src/platform/API/Application/ApplicationContext.cpp delete mode 100755 src/platform/API/Application/ApplicationContext.h delete mode 100755 src/platform/API/Application/ApplicationControl.cpp delete mode 100755 src/platform/API/Application/ApplicationControl.h delete mode 100755 src/platform/API/Application/ApplicationControlData.cpp delete mode 100755 src/platform/API/Application/ApplicationControlData.h delete mode 100755 src/platform/API/Application/ApplicationFactory.cpp delete mode 100755 src/platform/API/Application/ApplicationFactory.h delete mode 100755 src/platform/API/Application/ApplicationInformation.cpp delete mode 100755 src/platform/API/Application/ApplicationInformation.h delete mode 100755 src/platform/API/Application/ApplicationInstallInfo.cpp delete mode 100755 src/platform/API/Application/ApplicationInstallInfo.h delete mode 100755 src/platform/API/Application/EventApplicationAddAppInfoEventListener.h delete mode 100755 src/platform/API/Application/EventApplicationAppInfoEventListener.h delete mode 100755 src/platform/API/Application/EventApplicationFindAppControl.h delete mode 100644 src/platform/API/Application/EventApplicationGetAppCerts.h delete mode 100755 src/platform/API/Application/EventApplicationGetAppContext.h delete mode 100755 src/platform/API/Application/EventApplicationGetAppInfo.h delete mode 100755 src/platform/API/Application/EventApplicationGetAppsContext.h delete mode 100755 src/platform/API/Application/EventApplicationGetAppsInfo.h delete mode 100644 src/platform/API/Application/EventApplicationGetCurrApp.h delete mode 100644 src/platform/API/Application/EventApplicationGetRequestedAppControl.h delete mode 100755 src/platform/API/Application/EventApplicationInstall.h delete mode 100755 src/platform/API/Application/EventApplicationKill.h delete mode 100755 src/platform/API/Application/EventApplicationLaunch.h delete mode 100755 src/platform/API/Application/EventApplicationLaunchAppControl.h delete mode 100755 src/platform/API/Application/EventApplicationRemoveAppInfoEventListener.h delete mode 100644 src/platform/API/Application/IApplicationManager.cpp delete mode 100644 src/platform/API/Application/IApplicationManager.h delete mode 100644 src/platform/API/Application/RequestedApplicationControl.cpp delete mode 100644 src/platform/API/Application/RequestedApplicationControl.h delete mode 100755 src/platform/API/Application/config.cmake delete mode 100644 src/platform/API/Bluetooth/BTDevice.h delete mode 100644 src/platform/API/Bluetooth/BluetoothFactory.cpp delete mode 100644 src/platform/API/Bluetooth/BluetoothFactory.h delete mode 100644 src/platform/API/Bluetooth/EventBTConnectToServiceByUUID.h delete mode 100644 src/platform/API/Bluetooth/EventBTCreateDestroyBonding.cpp delete mode 100644 src/platform/API/Bluetooth/EventBTCreateDestroyBonding.h delete mode 100644 src/platform/API/Bluetooth/EventBTGetAdapter.h delete mode 100644 src/platform/API/Bluetooth/EventBTGetDevice.cpp delete mode 100644 src/platform/API/Bluetooth/EventBTGetDevice.h delete mode 100644 src/platform/API/Bluetooth/EventBTGetKnownDevices.cpp delete mode 100644 src/platform/API/Bluetooth/EventBTGetKnownDevices.h delete mode 100644 src/platform/API/Bluetooth/EventBTOnDiscoveryDevices.cpp delete mode 100644 src/platform/API/Bluetooth/EventBTOnDiscoveryDevices.h delete mode 100644 src/platform/API/Bluetooth/EventBTRegisterRFCOMM.h delete mode 100644 src/platform/API/Bluetooth/EventBTServiceOnConnect.cpp delete mode 100644 src/platform/API/Bluetooth/EventBTServiceOnConnect.h delete mode 100644 src/platform/API/Bluetooth/EventBTSetName.h delete mode 100644 src/platform/API/Bluetooth/EventBTSetPowered.h delete mode 100644 src/platform/API/Bluetooth/EventBTSetVisible.h delete mode 100644 src/platform/API/Bluetooth/EventBTSocketNotification.cpp delete mode 100644 src/platform/API/Bluetooth/EventBTSocketNotification.h delete mode 100644 src/platform/API/Bluetooth/EventBTStopDiscovery.h delete mode 100644 src/platform/API/Bluetooth/EventBTUnregisterRFCOMM.h delete mode 100644 src/platform/API/Bluetooth/IBluetoothAdapterManager.cpp delete mode 100644 src/platform/API/Bluetooth/IBluetoothAdapterManager.h delete mode 100644 src/platform/API/Bluetooth/IBluetoothDeviceManager.cpp delete mode 100644 src/platform/API/Bluetooth/IBluetoothDeviceManager.h delete mode 100644 src/platform/API/Bluetooth/IBluetoothServiceHandlerManager.cpp delete mode 100644 src/platform/API/Bluetooth/IBluetoothServiceHandlerManager.h delete mode 100644 src/platform/API/Bluetooth/IBluetoothSocketManager.cpp delete mode 100644 src/platform/API/Bluetooth/IBluetoothSocketManager.h delete mode 100644 src/platform/API/Bluetooth/config.cmake delete mode 100755 src/platform/API/Calendar/CalendarEvent.cpp delete mode 100755 src/platform/API/Calendar/CalendarEvent.h delete mode 100755 src/platform/API/Calendar/CalendarFactory.cpp delete mode 100755 src/platform/API/Calendar/CalendarFactory.h delete mode 100755 src/platform/API/Calendar/EventAlarm.cpp delete mode 100755 src/platform/API/Calendar/EventAlarm.h delete mode 100755 src/platform/API/Calendar/EventAttendee.cpp delete mode 100755 src/platform/API/Calendar/EventAttendee.h delete mode 100755 src/platform/API/Calendar/EventId.cpp delete mode 100755 src/platform/API/Calendar/EventId.h delete mode 100755 src/platform/API/Calendar/EventRecurrenceRule.cpp delete mode 100755 src/platform/API/Calendar/EventRecurrenceRule.h delete mode 100755 src/platform/API/Calendar/ICalendar.cpp delete mode 100755 src/platform/API/Calendar/ICalendar.h delete mode 100755 src/platform/API/Calendar/ICalendarManager.cpp delete mode 100755 src/platform/API/Calendar/ICalendarManager.h delete mode 100755 src/platform/API/Calendar/IEventAddEvent.h delete mode 100755 src/platform/API/Calendar/IEventAddEvents.h delete mode 100755 src/platform/API/Calendar/IEventClearWatch.h delete mode 100755 src/platform/API/Calendar/IEventCreateEventFromString.h delete mode 100755 src/platform/API/Calendar/IEventDeleteEvent.h delete mode 100755 src/platform/API/Calendar/IEventDeleteEvents.h delete mode 100755 src/platform/API/Calendar/IEventExpandEventRecurrence.h delete mode 100755 src/platform/API/Calendar/IEventExportEventToString.h delete mode 100755 src/platform/API/Calendar/IEventFindEvents.h delete mode 100755 src/platform/API/Calendar/IEventGet.h delete mode 100755 src/platform/API/Calendar/IEventGetCalendar.h delete mode 100755 src/platform/API/Calendar/IEventGetCalendars.h delete mode 100755 src/platform/API/Calendar/IEventGetDefaultCalendar.h delete mode 100755 src/platform/API/Calendar/IEventUpdateEvent.h delete mode 100755 src/platform/API/Calendar/IEventUpdateEvents.h delete mode 100755 src/platform/API/Calendar/IEventWatchChanges.h delete mode 100755 src/platform/API/Calendar/OnEventsChanged.h delete mode 100755 src/platform/API/Calendar/config.cmake delete mode 100755 src/platform/API/Callhistory/CallHistoryDefine.h delete mode 100755 src/platform/API/Callhistory/CallHistoryEntryProperties.cpp delete mode 100755 src/platform/API/Callhistory/CallHistoryEntryProperties.h delete mode 100755 src/platform/API/Callhistory/CallHistoryFactory.cpp delete mode 100755 src/platform/API/Callhistory/CallHistoryFactory.h delete mode 100755 src/platform/API/Callhistory/EventCallHistory.h delete mode 100755 src/platform/API/Callhistory/EventCallHistoryListener.cpp delete mode 100755 src/platform/API/Callhistory/EventCallHistoryListener.h delete mode 100755 src/platform/API/Callhistory/EventCallHistoryTemplate.h delete mode 100755 src/platform/API/Callhistory/EventFindCallHistory.cpp delete mode 100755 src/platform/API/Callhistory/EventFindCallHistory.h delete mode 100755 src/platform/API/Callhistory/EventRemoveAll.h delete mode 100755 src/platform/API/Callhistory/EventRemoveBatch.h delete mode 100755 src/platform/API/Callhistory/ICallHistory.cpp delete mode 100755 src/platform/API/Callhistory/ICallHistory.h delete mode 100755 src/platform/API/Callhistory/ICallHistoryEntry.cpp delete mode 100755 src/platform/API/Callhistory/ICallHistoryEntry.h delete mode 100755 src/platform/API/Callhistory/RemoteParty.h delete mode 100755 src/platform/API/Callhistory/config.cmake delete mode 100755 src/platform/API/Contact/ContactAddress.cpp delete mode 100755 src/platform/API/Contact/ContactAddress.h delete mode 100755 src/platform/API/Contact/ContactAnniversary.cpp delete mode 100755 src/platform/API/Contact/ContactAnniversary.h delete mode 100755 src/platform/API/Contact/ContactEmailAddress.cpp delete mode 100755 src/platform/API/Contact/ContactEmailAddress.h delete mode 100755 src/platform/API/Contact/ContactFactory.cpp delete mode 100755 src/platform/API/Contact/ContactFactory.h delete mode 100755 src/platform/API/Contact/ContactGroup.cpp delete mode 100755 src/platform/API/Contact/ContactGroup.h delete mode 100755 src/platform/API/Contact/ContactName.cpp delete mode 100755 src/platform/API/Contact/ContactName.h delete mode 100755 src/platform/API/Contact/ContactOrganization.cpp delete mode 100755 src/platform/API/Contact/ContactOrganization.h delete mode 100755 src/platform/API/Contact/ContactPhoneNumber.cpp delete mode 100755 src/platform/API/Contact/ContactPhoneNumber.h delete mode 100755 src/platform/API/Contact/ContactRef.cpp delete mode 100755 src/platform/API/Contact/ContactRef.h delete mode 100755 src/platform/API/Contact/ContactTypes.h delete mode 100755 src/platform/API/Contact/ContactWebSite.cpp delete mode 100755 src/platform/API/Contact/ContactWebSite.h delete mode 100755 src/platform/API/Contact/EventAddressBookAdd.h delete mode 100755 src/platform/API/Contact/EventAddressBookAddBatch.h delete mode 100755 src/platform/API/Contact/EventAddressBookAddChangeListener.h delete mode 100755 src/platform/API/Contact/EventAddressBookAddGroup.h delete mode 100755 src/platform/API/Contact/EventAddressBookChangeListener.h delete mode 100755 src/platform/API/Contact/EventAddressBookFind.h delete mode 100755 src/platform/API/Contact/EventAddressBookGet.h delete mode 100755 src/platform/API/Contact/EventAddressBookGetGroup.h delete mode 100755 src/platform/API/Contact/EventAddressBookGetGroups.h delete mode 100755 src/platform/API/Contact/EventAddressBookRemove.h delete mode 100755 src/platform/API/Contact/EventAddressBookRemoveBatch.h delete mode 100755 src/platform/API/Contact/EventAddressBookRemoveChangeListener.h delete mode 100755 src/platform/API/Contact/EventAddressBookRemoveGroup.h delete mode 100755 src/platform/API/Contact/EventAddressBookUpdate.h delete mode 100755 src/platform/API/Contact/EventAddressBookUpdateBatch.h delete mode 100755 src/platform/API/Contact/EventAddressBookUpdateGroup.h delete mode 100755 src/platform/API/Contact/EventContactManagerAddChangeListener.h delete mode 100755 src/platform/API/Contact/EventContactManagerChangeListener.h delete mode 100755 src/platform/API/Contact/EventContactManagerFind.h delete mode 100755 src/platform/API/Contact/EventContactManagerGet.h delete mode 100755 src/platform/API/Contact/EventContactManagerGetAddressBook.h delete mode 100755 src/platform/API/Contact/EventContactManagerGetAddressBooks.h delete mode 100755 src/platform/API/Contact/EventContactManagerGetDefaultAddressBook.h delete mode 100755 src/platform/API/Contact/EventContactManagerRemove.h delete mode 100755 src/platform/API/Contact/EventContactManagerRemoveBatch.h delete mode 100755 src/platform/API/Contact/EventContactManagerRemoveChangeListener.h delete mode 100755 src/platform/API/Contact/EventContactManagerUpdate.h delete mode 100755 src/platform/API/Contact/EventContactManagerUpdateBatch.h delete mode 100755 src/platform/API/Contact/EventPersonLink.h delete mode 100755 src/platform/API/Contact/EventPersonUnlink.h delete mode 100755 src/platform/API/Contact/IAddressBook.cpp delete mode 100755 src/platform/API/Contact/IAddressBook.h delete mode 100755 src/platform/API/Contact/IContact.cpp delete mode 100755 src/platform/API/Contact/IContact.h delete mode 100755 src/platform/API/Contact/IContactEventPrivateData.h delete mode 100755 src/platform/API/Contact/IContactManager.cpp delete mode 100755 src/platform/API/Contact/IContactManager.h delete mode 100755 src/platform/API/Contact/IPerson.cpp delete mode 100755 src/platform/API/Contact/IPerson.h delete mode 100755 src/platform/API/Contact/config.cmake delete mode 100755 src/platform/API/Content/IEventBrowseFolder.h delete mode 100755 src/platform/API/Content/IEventFindFolder.h delete mode 100755 src/platform/API/Content/IEventFindMedia.h delete mode 100755 src/platform/API/Content/IEventUpdateMedia.h delete mode 100755 src/platform/API/Content/IEventUpdateMediaItems.h delete mode 100755 src/platform/API/Content/IMediacontentManager.cpp delete mode 100755 src/platform/API/Content/IMediacontentManager.h delete mode 100755 src/platform/API/Content/MediacontentAudio.cpp delete mode 100755 src/platform/API/Content/MediacontentAudio.h delete mode 100755 src/platform/API/Content/MediacontentFactory.cpp delete mode 100755 src/platform/API/Content/MediacontentFactory.h delete mode 100755 src/platform/API/Content/MediacontentFolder.cpp delete mode 100755 src/platform/API/Content/MediacontentFolder.h delete mode 100755 src/platform/API/Content/MediacontentImage.cpp delete mode 100755 src/platform/API/Content/MediacontentImage.h delete mode 100755 src/platform/API/Content/MediacontentLyrics.cpp delete mode 100755 src/platform/API/Content/MediacontentLyrics.h delete mode 100755 src/platform/API/Content/MediacontentMedia.cpp delete mode 100755 src/platform/API/Content/MediacontentMedia.h delete mode 100755 src/platform/API/Content/MediacontentVideo.cpp delete mode 100755 src/platform/API/Content/MediacontentVideo.h delete mode 100755 src/platform/API/Content/config.cmake delete mode 100644 src/platform/API/Download/DownloadRequest.cpp delete mode 100644 src/platform/API/Download/DownloadRequest.h delete mode 100755 src/platform/API/Download/IDownloadManager.cpp delete mode 100755 src/platform/API/Download/IDownloadManager.h delete mode 100644 src/platform/API/Download/IEventCancelDownload.h delete mode 100644 src/platform/API/Download/IEventGetDownloadRequest.h delete mode 100644 src/platform/API/Download/IEventGetMIMEType.h delete mode 100755 src/platform/API/Download/IEventGetState.h delete mode 100755 src/platform/API/Download/IEventPauseDownload.h delete mode 100755 src/platform/API/Download/IEventResumeDownload.h delete mode 100755 src/platform/API/Download/IEventSetListener.h delete mode 100755 src/platform/API/Download/IEventStartDownload.h delete mode 100755 src/platform/API/Download/OnDownloadStateChanged.h delete mode 100755 src/platform/API/Download/config.cmake delete mode 100755 src/platform/API/Filesystem/Enums.h delete mode 100755 src/platform/API/Filesystem/EventCopy.cpp delete mode 100755 src/platform/API/Filesystem/EventCopy.h delete mode 100755 src/platform/API/Filesystem/EventCreate.cpp delete mode 100755 src/platform/API/Filesystem/EventCreate.h delete mode 100755 src/platform/API/Filesystem/EventFind.cpp delete mode 100755 src/platform/API/Filesystem/EventFind.h delete mode 100755 src/platform/API/Filesystem/EventGetStorage.cpp delete mode 100755 src/platform/API/Filesystem/EventGetStorage.h delete mode 100755 src/platform/API/Filesystem/EventListNodes.cpp delete mode 100755 src/platform/API/Filesystem/EventListNodes.h delete mode 100755 src/platform/API/Filesystem/EventListStorages.cpp delete mode 100755 src/platform/API/Filesystem/EventListStorages.h delete mode 100755 src/platform/API/Filesystem/EventMove.cpp delete mode 100755 src/platform/API/Filesystem/EventMove.h delete mode 100755 src/platform/API/Filesystem/EventOpen.cpp delete mode 100755 src/platform/API/Filesystem/EventOpen.h delete mode 100755 src/platform/API/Filesystem/EventReadText.cpp delete mode 100755 src/platform/API/Filesystem/EventReadText.h delete mode 100755 src/platform/API/Filesystem/EventRemove.cpp delete mode 100755 src/platform/API/Filesystem/EventRemove.h delete mode 100755 src/platform/API/Filesystem/EventResolve.cpp delete mode 100755 src/platform/API/Filesystem/EventResolve.h delete mode 100755 src/platform/API/Filesystem/EventStorageStateChanged.h delete mode 100755 src/platform/API/Filesystem/EventStoragestateChanged.cpp delete mode 100755 src/platform/API/Filesystem/IManager.cpp delete mode 100755 src/platform/API/Filesystem/IManager.h delete mode 100755 src/platform/API/Filesystem/INode.cpp delete mode 100755 src/platform/API/Filesystem/INode.h delete mode 100755 src/platform/API/Filesystem/INodeTypes.h delete mode 100755 src/platform/API/Filesystem/IPath.cpp delete mode 100755 src/platform/API/Filesystem/IPath.h delete mode 100755 src/platform/API/Filesystem/IStream.cpp delete mode 100755 src/platform/API/Filesystem/IStream.h delete mode 100755 src/platform/API/Filesystem/NodeFilter.cpp delete mode 100755 src/platform/API/Filesystem/NodeFilter.h delete mode 100755 src/platform/API/Filesystem/PathUtils.cpp delete mode 100755 src/platform/API/Filesystem/PathUtils.h delete mode 100755 src/platform/API/Filesystem/StorageProperties.cpp delete mode 100755 src/platform/API/Filesystem/StorageProperties.h delete mode 100755 src/platform/API/Filesystem/config.cmake delete mode 100755 src/platform/API/Filter/AnyType.cpp delete mode 100755 src/platform/API/Filter/AnyType.h delete mode 100644 src/platform/API/Filter/AttributeFilter.cpp delete mode 100644 src/platform/API/Filter/AttributeFilter.h delete mode 100644 src/platform/API/Filter/AttributeRangeFilter.cpp delete mode 100644 src/platform/API/Filter/AttributeRangeFilter.h delete mode 100644 src/platform/API/Filter/CompositeFilter.cpp delete mode 100644 src/platform/API/Filter/CompositeFilter.h delete mode 100644 src/platform/API/Filter/FilterFactory.cpp delete mode 100644 src/platform/API/Filter/FilterFactory.h delete mode 100644 src/platform/API/Filter/FilterTypes.h delete mode 100644 src/platform/API/Filter/FilterValidator.cpp delete mode 100644 src/platform/API/Filter/FilterValidator.h delete mode 100644 src/platform/API/Filter/IFilter.cpp delete mode 100644 src/platform/API/Filter/IFilter.h delete mode 100644 src/platform/API/Filter/IFilterVisitor.cpp delete mode 100644 src/platform/API/Filter/IFilterVisitor.h delete mode 100644 src/platform/API/Filter/SimpleCoordinates.cpp delete mode 100644 src/platform/API/Filter/SimpleCoordinates.h delete mode 100644 src/platform/API/Filter/SortMode.cpp delete mode 100644 src/platform/API/Filter/SortMode.h delete mode 100755 src/platform/API/Filter/config.cmake delete mode 100755 src/platform/API/Messaging/AttachmentFactory.cpp delete mode 100755 src/platform/API/Messaging/AttachmentFactory.h delete mode 100755 src/platform/API/Messaging/Attachments.cpp delete mode 100755 src/platform/API/Messaging/Attachments.h delete mode 100755 src/platform/API/Messaging/BccRecipient.cpp delete mode 100755 src/platform/API/Messaging/BccRecipient.h delete mode 100755 src/platform/API/Messaging/Body.cpp delete mode 100755 src/platform/API/Messaging/Body.h delete mode 100755 src/platform/API/Messaging/CallbackNumber.cpp delete mode 100755 src/platform/API/Messaging/CallbackNumber.h delete mode 100755 src/platform/API/Messaging/CcRecipient.cpp delete mode 100755 src/platform/API/Messaging/CcRecipient.h delete mode 100755 src/platform/API/Messaging/ConversationFilterValidator.cpp delete mode 100755 src/platform/API/Messaging/ConversationFilterValidator.h delete mode 100755 src/platform/API/Messaging/ConversationFilterValidatorFactory.cpp delete mode 100755 src/platform/API/Messaging/ConversationFilterValidatorFactory.h delete mode 100755 src/platform/API/Messaging/EmailAccountInfo.cpp delete mode 100755 src/platform/API/Messaging/EmailAccountInfo.h delete mode 100755 src/platform/API/Messaging/EmitterConversationReceived.cpp delete mode 100755 src/platform/API/Messaging/EmitterConversationReceived.h delete mode 100755 src/platform/API/Messaging/EmitterFolderReceived.cpp delete mode 100755 src/platform/API/Messaging/EmitterFolderReceived.h delete mode 100755 src/platform/API/Messaging/EmitterMessageReceived.cpp delete mode 100755 src/platform/API/Messaging/EmitterMessageReceived.h delete mode 100755 src/platform/API/Messaging/EventAddDraftMessage.h delete mode 100755 src/platform/API/Messaging/EventDeleteConversations.h delete mode 100755 src/platform/API/Messaging/EventDeleteMessage.h delete mode 100755 src/platform/API/Messaging/EventDeleteMessages.h delete mode 100755 src/platform/API/Messaging/EventGetConversationId.h delete mode 100755 src/platform/API/Messaging/EventGetMessagingService.h delete mode 100755 src/platform/API/Messaging/EventMessageReceived.cpp delete mode 100755 src/platform/API/Messaging/EventMessageReceived.h delete mode 100755 src/platform/API/Messaging/EventMessagingService.h delete mode 100755 src/platform/API/Messaging/EventMessagingStorage.h delete mode 100755 src/platform/API/Messaging/EventOnSendingFailed.h delete mode 100755 src/platform/API/Messaging/EventQueryConversations.h delete mode 100755 src/platform/API/Messaging/EventQueryFolders.h delete mode 100755 src/platform/API/Messaging/EventQueryMessages.h delete mode 100755 src/platform/API/Messaging/EventSendMessage.h delete mode 100755 src/platform/API/Messaging/EventUpdateMessage.h delete mode 100755 src/platform/API/Messaging/EventUpdateMessages.h delete mode 100755 src/platform/API/Messaging/FolderFilterValidator.cpp delete mode 100755 src/platform/API/Messaging/FolderFilterValidator.h delete mode 100755 src/platform/API/Messaging/FolderFilterValidatorFactory.cpp delete mode 100755 src/platform/API/Messaging/FolderFilterValidatorFactory.h delete mode 100755 src/platform/API/Messaging/From.cpp delete mode 100755 src/platform/API/Messaging/From.h delete mode 100755 src/platform/API/Messaging/IAttachment.cpp delete mode 100755 src/platform/API/Messaging/IAttachment.h delete mode 100755 src/platform/API/Messaging/IBinarySms.cpp delete mode 100755 src/platform/API/Messaging/IBinarySms.h delete mode 100755 src/platform/API/Messaging/IConversation.h delete mode 100755 src/platform/API/Messaging/IEmail.cpp delete mode 100755 src/platform/API/Messaging/IEmail.h delete mode 100755 src/platform/API/Messaging/IEmailAccount.cpp delete mode 100755 src/platform/API/Messaging/IEmailAccount.h delete mode 100755 src/platform/API/Messaging/IEmptyMessage.cpp delete mode 100755 src/platform/API/Messaging/IEmptyMessage.h delete mode 100755 src/platform/API/Messaging/IMessage.cpp delete mode 100755 src/platform/API/Messaging/IMessage.h delete mode 100755 src/platform/API/Messaging/IMessageFolder.h delete mode 100755 src/platform/API/Messaging/IMessaging.cpp delete mode 100755 src/platform/API/Messaging/IMessaging.h delete mode 100755 src/platform/API/Messaging/IMessagingService.cpp delete mode 100755 src/platform/API/Messaging/IMessagingService.h delete mode 100755 src/platform/API/Messaging/IMessagingServiceManager.cpp delete mode 100755 src/platform/API/Messaging/IMessagingServiceManager.h delete mode 100755 src/platform/API/Messaging/IMessagingTypes.h delete mode 100755 src/platform/API/Messaging/IMms.cpp delete mode 100755 src/platform/API/Messaging/IMms.h delete mode 100755 src/platform/API/Messaging/IMmsSlide.h delete mode 100755 src/platform/API/Messaging/IMmsSlideProperties.h delete mode 100755 src/platform/API/Messaging/IMmsSlides.h delete mode 100755 src/platform/API/Messaging/ISms.cpp delete mode 100755 src/platform/API/Messaging/ISms.h delete mode 100755 src/platform/API/Messaging/MessageEventPrivateData.h delete mode 100755 src/platform/API/Messaging/MessageFactory.cpp delete mode 100755 src/platform/API/Messaging/MessageFactory.h delete mode 100755 src/platform/API/Messaging/MessageFilterValidator.cpp delete mode 100755 src/platform/API/Messaging/MessageFilterValidator.h delete mode 100755 src/platform/API/Messaging/MessageFilterValidatorFactory.cpp delete mode 100755 src/platform/API/Messaging/MessageFilterValidatorFactory.h delete mode 100755 src/platform/API/Messaging/MessagePriority.cpp delete mode 100755 src/platform/API/Messaging/MessagePriority.h delete mode 100755 src/platform/API/Messaging/MessageProperties.h delete mode 100755 src/platform/API/Messaging/MessageStorageFactory.cpp delete mode 100755 src/platform/API/Messaging/MessageStorageFactory.h delete mode 100755 src/platform/API/Messaging/MessagingFactory.cpp delete mode 100755 src/platform/API/Messaging/MessagingFactory.h delete mode 100755 src/platform/API/Messaging/MmsSlide.cpp delete mode 100755 src/platform/API/Messaging/MmsSlide.h delete mode 100755 src/platform/API/Messaging/MmsSlideProperty.cpp delete mode 100755 src/platform/API/Messaging/MmsSlideProperty.h delete mode 100755 src/platform/API/Messaging/MmsSlides.cpp delete mode 100755 src/platform/API/Messaging/MmsSlides.h delete mode 100755 src/platform/API/Messaging/Recipient.cpp delete mode 100755 src/platform/API/Messaging/Recipient.h delete mode 100755 src/platform/API/Messaging/ReqReceiverMessage.cpp delete mode 100755 src/platform/API/Messaging/ReqReceiverMessage.h delete mode 100755 src/platform/API/Messaging/SourceAddress.cpp delete mode 100755 src/platform/API/Messaging/SourceAddress.h delete mode 100755 src/platform/API/Messaging/StorageChangesConversationFilterValidator.cpp delete mode 100755 src/platform/API/Messaging/StorageChangesConversationFilterValidator.h delete mode 100755 src/platform/API/Messaging/StorageChangesConversationFilterValidatorFactory.cpp delete mode 100755 src/platform/API/Messaging/StorageChangesConversationFilterValidatorFactory.h delete mode 100755 src/platform/API/Messaging/StorageChangesConversationGenerator.cpp delete mode 100755 src/platform/API/Messaging/StorageChangesConversationGenerator.h delete mode 100755 src/platform/API/Messaging/StorageChangesFolderFilterValidator.cpp delete mode 100755 src/platform/API/Messaging/StorageChangesFolderFilterValidator.h delete mode 100755 src/platform/API/Messaging/StorageChangesFolderFilterValidatorFactory.cpp delete mode 100755 src/platform/API/Messaging/StorageChangesFolderFilterValidatorFactory.h delete mode 100755 src/platform/API/Messaging/StorageChangesFolderGenerator.cpp delete mode 100755 src/platform/API/Messaging/StorageChangesFolderGenerator.h delete mode 100755 src/platform/API/Messaging/StorageChangesMessageFilterValidator.cpp delete mode 100755 src/platform/API/Messaging/StorageChangesMessageFilterValidator.h delete mode 100755 src/platform/API/Messaging/StorageChangesMessageFilterValidatorFactory.cpp delete mode 100755 src/platform/API/Messaging/StorageChangesMessageFilterValidatorFactory.h delete mode 100644 src/platform/API/Messaging/StorageChangesMessageGenerator.cpp delete mode 100755 src/platform/API/Messaging/StorageChangesMessageGenerator.h delete mode 100755 src/platform/API/Messaging/Subject.cpp delete mode 100755 src/platform/API/Messaging/Subject.h delete mode 100644 src/platform/API/Messaging/ToRecipient.cpp delete mode 100644 src/platform/API/Messaging/ToRecipient.h delete mode 100755 src/platform/API/Messaging/ValidityPeriodHours.cpp delete mode 100755 src/platform/API/Messaging/ValidityPeriodHours.h delete mode 100755 src/platform/API/Messaging/VirtualMessage.cpp delete mode 100755 src/platform/API/Messaging/VirtualMessage.h delete mode 100755 src/platform/API/NFC/EventNFC.h delete mode 100755 src/platform/API/NFC/EventNFCChanged.h delete mode 100755 src/platform/API/NFC/EventTagAction.h delete mode 100755 src/platform/API/NFC/EventTargetAction.h delete mode 100755 src/platform/API/NFC/INFCAdapter.cpp delete mode 100755 src/platform/API/NFC/INFCAdapter.h delete mode 100755 src/platform/API/NFC/INFCTag.cpp delete mode 100755 src/platform/API/NFC/INFCTag.h delete mode 100755 src/platform/API/NFC/INFCTarget.cpp delete mode 100755 src/platform/API/NFC/INFCTarget.h delete mode 100755 src/platform/API/NFC/INdefMessage.h delete mode 100755 src/platform/API/NFC/INdefRecord.h delete mode 100755 src/platform/API/NFC/NFCFactory.cpp delete mode 100755 src/platform/API/NFC/NFCFactory.h delete mode 100755 src/platform/API/NFC/NFCTagProperties.h delete mode 100755 src/platform/API/NFC/NdefRecordProperties.h delete mode 100755 src/platform/API/NFC/TagFilter.cpp delete mode 100755 src/platform/API/NFC/TagFilter.h delete mode 100755 src/platform/API/NFC/config.cmake delete mode 100755 src/platform/API/NetworkBearerSelection/EventNetworkBearerRelease.h delete mode 100755 src/platform/API/NetworkBearerSelection/EventNetworkBearerSelection.h delete mode 100755 src/platform/API/NetworkBearerSelection/INetworkBearerSelection.cpp delete mode 100755 src/platform/API/NetworkBearerSelection/INetworkBearerSelection.h delete mode 100755 src/platform/API/NetworkBearerSelection/NetworkBearerSelectionFactory.cpp delete mode 100755 src/platform/API/NetworkBearerSelection/NetworkBearerSelectionFactory.h delete mode 100755 src/platform/API/NetworkBearerSelection/OnNetworkBearerSelectionStateChanged.h delete mode 100755 src/platform/API/NetworkBearerSelection/config.cmake delete mode 100644 src/platform/API/Notification/INotification.cpp delete mode 100644 src/platform/API/Notification/INotification.h delete mode 100644 src/platform/API/Notification/INotificationManager.cpp delete mode 100644 src/platform/API/Notification/INotificationManager.h delete mode 100644 src/platform/API/Notification/NotificationFactory.cpp delete mode 100644 src/platform/API/Notification/NotificationFactory.h delete mode 100644 src/platform/API/Notification/config.cmake delete mode 100755 src/platform/API/Power/IEventGetScreenBrightness.h delete mode 100644 src/platform/API/Power/IEventIsScreenOn.h delete mode 100755 src/platform/API/Power/IEventRelease.h delete mode 100755 src/platform/API/Power/IEventRequest.h delete mode 100755 src/platform/API/Power/IEventRestoreScreenBrightness.h delete mode 100755 src/platform/API/Power/IEventSetScreenBrightness.h delete mode 100755 src/platform/API/Power/IEventSetScreenStateChangeListener.h delete mode 100755 src/platform/API/Power/IEventTurnScreenOff.h delete mode 100755 src/platform/API/Power/IEventTurnScreenOn.h delete mode 100755 src/platform/API/Power/IEventUnsetScreenStateChangeListener.h delete mode 100755 src/platform/API/Power/IPowerManager.cpp delete mode 100755 src/platform/API/Power/IPowerManager.h delete mode 100755 src/platform/API/Power/OnPowerStateChanged.h delete mode 100755 src/platform/API/Power/PowerCommon.h delete mode 100755 src/platform/API/Power/config.cmake delete mode 100755 src/platform/API/SystemSetting/EventGetSetting.h delete mode 100755 src/platform/API/SystemSetting/EventSetRingtone.h delete mode 100755 src/platform/API/SystemSetting/EventSetSetting.h delete mode 100755 src/platform/API/SystemSetting/EventSetWallpaper.h delete mode 100755 src/platform/API/SystemSetting/ISystemSetting.cpp delete mode 100755 src/platform/API/SystemSetting/ISystemSetting.h delete mode 100755 src/platform/API/SystemSetting/ISystemSettingType.h delete mode 100755 src/platform/API/SystemSetting/SystemSettingFactory.cpp delete mode 100755 src/platform/API/SystemSetting/SystemSettingFactory.h delete mode 100644 src/platform/API/SystemSetting/config.cmake delete mode 100755 src/platform/API/Systeminfo/BaseProperties.h delete mode 100755 src/platform/API/Systeminfo/EventGetSysteminfo.cpp delete mode 100755 src/platform/API/Systeminfo/EventGetSysteminfo.h delete mode 100755 src/platform/API/Systeminfo/EventWatchSysteminfo.cpp delete mode 100755 src/platform/API/Systeminfo/EventWatchSysteminfo.h delete mode 100755 src/platform/API/Systeminfo/ISysteminfo.cpp delete mode 100755 src/platform/API/Systeminfo/ISysteminfo.h delete mode 100755 src/platform/API/Systeminfo/SysteminfoFactory.cpp delete mode 100755 src/platform/API/Systeminfo/SysteminfoFactory.h delete mode 100755 src/platform/API/Systeminfo/SysteminfoPropertyInfo.h delete mode 100755 src/platform/API/Systeminfo/config.cmake delete mode 100755 src/platform/API/TimeUtil/DurationProperties.h delete mode 100755 src/platform/API/TimeUtil/EventSetCurrentTZDate.h delete mode 100755 src/platform/API/TimeUtil/ITZDate.h delete mode 100755 src/platform/API/TimeUtil/ITimeUtil.h delete mode 100755 src/platform/API/TimeUtil/TZDateProperties.h delete mode 100755 src/platform/API/TimeUtil/TimeUtilFactory.cpp delete mode 100755 src/platform/API/TimeUtil/TimeUtilFactory.h delete mode 100755 src/platform/API/TimeUtil/TimezoneProperties.h delete mode 100755 src/platform/API/TimeUtil/config.cmake delete mode 100755 src/platform/API/config.cmake delete mode 100644 src/platform/CMakeLists.txt delete mode 100644 src/platform/Tizen/Application/AppManagerWrapper.cpp delete mode 100644 src/platform/Tizen/Application/AppManagerWrapper.h delete mode 100755 src/platform/Tizen/Application/Application.cpp delete mode 100644 src/platform/Tizen/Application/Application.h delete mode 100644 src/platform/Tizen/Application/ApplicationManager.cpp delete mode 100644 src/platform/Tizen/Application/ApplicationManager.h delete mode 100755 src/platform/Tizen/Application/config.cmake delete mode 100755 src/platform/Tizen/Bluetooth/BluetoothAdapterManager.cpp delete mode 100644 src/platform/Tizen/Bluetooth/BluetoothAdapterManager.h delete mode 100644 src/platform/Tizen/Bluetooth/BluetoothCBManager.cpp delete mode 100644 src/platform/Tizen/Bluetooth/BluetoothCBManager.h delete mode 100644 src/platform/Tizen/Bluetooth/BluetoothDeviceManager.cpp delete mode 100644 src/platform/Tizen/Bluetooth/BluetoothDeviceManager.h delete mode 100644 src/platform/Tizen/Bluetooth/BluetoothServiceHandlerManager.cpp delete mode 100644 src/platform/Tizen/Bluetooth/BluetoothServiceHandlerManager.h delete mode 100644 src/platform/Tizen/Bluetooth/BluetoothSocketManager.cpp delete mode 100644 src/platform/Tizen/Bluetooth/BluetoothSocketManager.h delete mode 100644 src/platform/Tizen/Bluetooth/config.cmake delete mode 100755 src/platform/Tizen/Calendar/Calendar.cpp delete mode 100755 src/platform/Tizen/Calendar/Calendar.h delete mode 100755 src/platform/Tizen/Calendar/CalendarFilter.cpp delete mode 100755 src/platform/Tizen/Calendar/CalendarFilter.h delete mode 100755 src/platform/Tizen/Calendar/CalendarFilterValidator.cpp delete mode 100755 src/platform/Tizen/Calendar/CalendarFilterValidator.h delete mode 100755 src/platform/Tizen/Calendar/CalendarManager.cpp delete mode 100755 src/platform/Tizen/Calendar/CalendarManager.h delete mode 100755 src/platform/Tizen/Calendar/EventWrapper.cpp delete mode 100755 src/platform/Tizen/Calendar/EventWrapper.h delete mode 100755 src/platform/Tizen/Calendar/config.cmake delete mode 100755 src/platform/Tizen/Callhistory/CallHistory.cpp delete mode 100755 src/platform/Tizen/Callhistory/CallHistory.h delete mode 100755 src/platform/Tizen/Callhistory/CallHistoryEntry.cpp delete mode 100755 src/platform/Tizen/Callhistory/CallHistoryEntry.h delete mode 100755 src/platform/Tizen/Callhistory/CallHistoryFilter.cpp delete mode 100755 src/platform/Tizen/Callhistory/CallHistoryFilter.h delete mode 100755 src/platform/Tizen/Callhistory/config.cmake delete mode 100755 src/platform/Tizen/Contact/AddressBook.cpp delete mode 100755 src/platform/Tizen/Contact/AddressBook.h delete mode 100755 src/platform/Tizen/Contact/Contact.cpp delete mode 100755 src/platform/Tizen/Contact/Contact.h delete mode 100755 src/platform/Tizen/Contact/ContactFilterValidator.cpp delete mode 100755 src/platform/Tizen/Contact/ContactFilterValidator.h delete mode 100755 src/platform/Tizen/Contact/ContactManager.cpp delete mode 100755 src/platform/Tizen/Contact/ContactManager.h delete mode 100755 src/platform/Tizen/Contact/ContactObjectA2PConverter.cpp delete mode 100755 src/platform/Tizen/Contact/ContactObjectA2PConverter.h delete mode 100755 src/platform/Tizen/Contact/ContactObjectP2AConverter.cpp delete mode 100755 src/platform/Tizen/Contact/ContactObjectP2AConverter.h delete mode 100755 src/platform/Tizen/Contact/ContactSearchEngine.cpp delete mode 100755 src/platform/Tizen/Contact/ContactSearchEngine.h delete mode 100755 src/platform/Tizen/Contact/ContactUtility.cpp delete mode 100755 src/platform/Tizen/Contact/ContactUtility.h delete mode 100755 src/platform/Tizen/Contact/ContactsSvcChangeListenerManager.cpp delete mode 100755 src/platform/Tizen/Contact/ContactsSvcChangeListenerManager.h delete mode 100755 src/platform/Tizen/Contact/ContactsSvcObjectConverter.cpp delete mode 100755 src/platform/Tizen/Contact/ContactsSvcObjectConverter.h delete mode 100755 src/platform/Tizen/Contact/ContactsSvcWrapper.cpp delete mode 100755 src/platform/Tizen/Contact/ContactsSvcWrapper.h delete mode 100755 src/platform/Tizen/Contact/Person.cpp delete mode 100755 src/platform/Tizen/Contact/Person.h delete mode 100755 src/platform/Tizen/Contact/PersonFilterValidator.cpp delete mode 100755 src/platform/Tizen/Contact/PersonFilterValidator.h delete mode 100755 src/platform/Tizen/Contact/PersonSearchEngine.cpp delete mode 100755 src/platform/Tizen/Contact/PersonSearchEngine.h delete mode 100755 src/platform/Tizen/Contact/config.cmake delete mode 100755 src/platform/Tizen/Content/MediaFilterValidator.cpp delete mode 100755 src/platform/Tizen/Content/MediaFilterValidator.h delete mode 100755 src/platform/Tizen/Content/MediaSearchVisitor.cpp delete mode 100755 src/platform/Tizen/Content/MediaSearchVisitor.h delete mode 100755 src/platform/Tizen/Content/MediaWrapper.cpp delete mode 100755 src/platform/Tizen/Content/MediaWrapper.h delete mode 100755 src/platform/Tizen/Content/MediacontentManager.cpp delete mode 100755 src/platform/Tizen/Content/MediacontentManager.h delete mode 100755 src/platform/Tizen/Content/config.cmake delete mode 100755 src/platform/Tizen/DBus/Connection.cpp delete mode 100755 src/platform/Tizen/DBus/Connection.h delete mode 100755 src/platform/Tizen/DBus/Message.cpp delete mode 100755 src/platform/Tizen/DBus/Message.h delete mode 100755 src/platform/Tizen/DBus/MessageEvent.h delete mode 100644 src/platform/Tizen/DBus/config.cmake delete mode 100755 src/platform/Tizen/Download/DownloadManager.cpp delete mode 100755 src/platform/Tizen/Download/DownloadManager.h delete mode 100755 src/platform/Tizen/Download/config.cmake delete mode 100755 src/platform/Tizen/Filesystem/Manager.cpp delete mode 100755 src/platform/Tizen/Filesystem/Manager.h delete mode 100755 src/platform/Tizen/Filesystem/Node.cpp delete mode 100755 src/platform/Tizen/Filesystem/Node.h delete mode 100755 src/platform/Tizen/Filesystem/NodeFilterMatcher.cpp delete mode 100755 src/platform/Tizen/Filesystem/NodeFilterMatcher.h delete mode 100755 src/platform/Tizen/Filesystem/Path.cpp delete mode 100755 src/platform/Tizen/Filesystem/Path.h delete mode 100755 src/platform/Tizen/Filesystem/Stream.cpp delete mode 100755 src/platform/Tizen/Filesystem/Stream.h delete mode 100755 src/platform/Tizen/Filesystem/System.cpp delete mode 100755 src/platform/Tizen/Filesystem/System.h delete mode 100755 src/platform/Tizen/Filesystem/Utils.cpp delete mode 100755 src/platform/Tizen/Filesystem/Utils.h delete mode 100755 src/platform/Tizen/Filesystem/config.cmake delete mode 100755 src/platform/Tizen/Messaging/Attachment.cpp delete mode 100755 src/platform/Tizen/Messaging/Attachment.h delete mode 100755 src/platform/Tizen/Messaging/BinarySms.cpp delete mode 100755 src/platform/Tizen/Messaging/BinarySms.h delete mode 100755 src/platform/Tizen/Messaging/CallbackMgr.cpp delete mode 100755 src/platform/Tizen/Messaging/CallbackMgr.h delete mode 100644 src/platform/Tizen/Messaging/Conversation.cpp delete mode 100755 src/platform/Tizen/Messaging/Conversation.h delete mode 100755 src/platform/Tizen/Messaging/ConversationQueryGenerator.cpp delete mode 100755 src/platform/Tizen/Messaging/ConversationQueryGenerator.h delete mode 100755 src/platform/Tizen/Messaging/Email.cpp delete mode 100755 src/platform/Tizen/Messaging/Email.h delete mode 100755 src/platform/Tizen/Messaging/EmailConverter.cpp delete mode 100755 src/platform/Tizen/Messaging/EmailConverter.h delete mode 100755 src/platform/Tizen/Messaging/EmailService.cpp delete mode 100755 src/platform/Tizen/Messaging/EmailService.h delete mode 100755 src/platform/Tizen/Messaging/EmailUtils.cpp delete mode 100755 src/platform/Tizen/Messaging/EmailUtils.h delete mode 100755 src/platform/Tizen/Messaging/EmptyMessage.cpp delete mode 100755 src/platform/Tizen/Messaging/EmptyMessage.h delete mode 100755 src/platform/Tizen/Messaging/FolderQueryGenerator.cpp delete mode 100755 src/platform/Tizen/Messaging/FolderQueryGenerator.h delete mode 100755 src/platform/Tizen/Messaging/ISendingObserver.h delete mode 100755 src/platform/Tizen/Messaging/MailSender.cpp delete mode 100755 src/platform/Tizen/Messaging/MailSender.h delete mode 100755 src/platform/Tizen/Messaging/MailSync.cpp delete mode 100755 src/platform/Tizen/Messaging/MailSync.h delete mode 100755 src/platform/Tizen/Messaging/MessageFolder.cpp delete mode 100755 src/platform/Tizen/Messaging/MessageFolder.h delete mode 100755 src/platform/Tizen/Messaging/MessageQueryGenerator.cpp delete mode 100755 src/platform/Tizen/Messaging/MessageQueryGenerator.h delete mode 100755 src/platform/Tizen/Messaging/Messaging.cpp delete mode 100755 src/platform/Tizen/Messaging/Messaging.h delete mode 100755 src/platform/Tizen/Messaging/MessagingService.cpp delete mode 100755 src/platform/Tizen/Messaging/MessagingService.h delete mode 100755 src/platform/Tizen/Messaging/MessagingServiceManager.cpp delete mode 100755 src/platform/Tizen/Messaging/MessagingServiceManager.h delete mode 100755 src/platform/Tizen/Messaging/Mms.cpp delete mode 100755 src/platform/Tizen/Messaging/Mms.h delete mode 100755 src/platform/Tizen/Messaging/MmsSlide.cpp delete mode 100755 src/platform/Tizen/Messaging/MmsSlide.h delete mode 100755 src/platform/Tizen/Messaging/MsgServiceHandleMgr.h delete mode 100755 src/platform/Tizen/Messaging/NetworkStatus.cpp delete mode 100755 src/platform/Tizen/Messaging/NetworkStatus.h delete mode 100755 src/platform/Tizen/Messaging/ScopedMail.h delete mode 100755 src/platform/Tizen/Messaging/ScopedMailAttachment.h delete mode 100755 src/platform/Tizen/Messaging/ScopedMailbox.h delete mode 100755 src/platform/Tizen/Messaging/Sms.cpp delete mode 100755 src/platform/Tizen/Messaging/Sms.h delete mode 100755 src/platform/Tizen/Messaging/SyncNetworkStatus.cpp delete mode 100755 src/platform/Tizen/Messaging/SyncNetworkStatus.h delete mode 100755 src/platform/Tizen/Messaging/messageDB/MessageStorageReader.cpp delete mode 100755 src/platform/Tizen/NFC/NFCAdapter.cpp delete mode 100755 src/platform/Tizen/NFC/NFCAdapter.h delete mode 100755 src/platform/Tizen/NFC/NFCDefaultAdapter.cpp delete mode 100755 src/platform/Tizen/NFC/NFCDefaultAdapter.h delete mode 100755 src/platform/Tizen/NFC/NFCTag.cpp delete mode 100755 src/platform/Tizen/NFC/NFCTag.h delete mode 100755 src/platform/Tizen/NFC/NFCTarget.cpp delete mode 100755 src/platform/Tizen/NFC/NFCTarget.h delete mode 100755 src/platform/Tizen/NFC/NFCUtil.cpp delete mode 100755 src/platform/Tizen/NFC/NFCUtil.h delete mode 100755 src/platform/Tizen/NFC/NdefMessage.cpp delete mode 100755 src/platform/Tizen/NFC/NdefMessage.h delete mode 100755 src/platform/Tizen/NFC/NdefRecord.cpp delete mode 100755 src/platform/Tizen/NFC/NdefRecord.h delete mode 100755 src/platform/Tizen/NFC/config.cmake delete mode 100755 src/platform/Tizen/NetworkBearerSelection/NetworkBearerSelection.cpp delete mode 100755 src/platform/Tizen/NetworkBearerSelection/NetworkBearerSelection.h delete mode 100755 src/platform/Tizen/NetworkBearerSelection/config.cmake delete mode 100644 src/platform/Tizen/Notification/NotificationManager.cpp delete mode 100644 src/platform/Tizen/Notification/NotificationManager.h delete mode 100644 src/platform/Tizen/Notification/StatusNotification.cpp delete mode 100644 src/platform/Tizen/Notification/StatusNotification.h delete mode 100644 src/platform/Tizen/Notification/config.cmake delete mode 100755 src/platform/Tizen/Power/PowerManager.cpp delete mode 100755 src/platform/Tizen/Power/PowerManager.h delete mode 100755 src/platform/Tizen/Power/config.cmake delete mode 100755 src/platform/Tizen/SystemSetting/SystemSetting.cpp delete mode 100755 src/platform/Tizen/SystemSetting/SystemSetting.h delete mode 100644 src/platform/Tizen/SystemSetting/config.cmake delete mode 100755 src/platform/Tizen/Systeminfo/Systeminfo.cpp delete mode 100755 src/platform/Tizen/Systeminfo/Systeminfo.h delete mode 100755 src/platform/Tizen/Systeminfo/config.cmake delete mode 100755 src/platform/Tizen/TimeUtil/TZDate.cpp delete mode 100755 src/platform/Tizen/TimeUtil/TZDate.h delete mode 100755 src/platform/Tizen/TimeUtil/TimeUtil.cpp delete mode 100755 src/platform/Tizen/TimeUtil/TimeUtil.h delete mode 100755 src/platform/Tizen/TimeUtil/TimeUtilTools.cpp delete mode 100755 src/platform/Tizen/TimeUtil/TimeUtilTools.h delete mode 100755 src/platform/Tizen/TimeUtil/config.cmake delete mode 100644 src/platform/Tizen/config.cmake delete mode 100644 src/standards/CMakeLists.txt delete mode 100755 src/standards/Tizen/Alarm/AlarmAbsolute.cpp delete mode 100755 src/standards/Tizen/Alarm/AlarmAbsolute.h delete mode 100755 src/standards/Tizen/Alarm/AlarmConverter.cpp delete mode 100755 src/standards/Tizen/Alarm/AlarmConverter.h delete mode 100755 src/standards/Tizen/Alarm/AlarmRelative.cpp delete mode 100755 src/standards/Tizen/Alarm/AlarmRelative.h delete mode 100755 src/standards/Tizen/Alarm/CMakeLists.txt delete mode 100755 src/standards/Tizen/Alarm/JSAlarmAbsolute.cpp delete mode 100755 src/standards/Tizen/Alarm/JSAlarmAbsolute.h delete mode 100755 src/standards/Tizen/Alarm/JSAlarmManager.cpp delete mode 100755 src/standards/Tizen/Alarm/JSAlarmManager.h delete mode 100755 src/standards/Tizen/Alarm/JSAlarmRelative.cpp delete mode 100755 src/standards/Tizen/Alarm/JSAlarmRelative.h delete mode 100755 src/standards/Tizen/Alarm/alarm_common.h delete mode 100755 src/standards/Tizen/Alarm/config.xml delete mode 100755 src/standards/Tizen/Alarm/plugin_config.cpp delete mode 100755 src/standards/Tizen/Alarm/plugin_config.h delete mode 100755 src/standards/Tizen/Alarm/plugin_initializer.cpp delete mode 100755 src/standards/Tizen/Application/ApplicationAsyncCallbackManager.cpp delete mode 100755 src/standards/Tizen/Application/ApplicationAsyncCallbackManager.h delete mode 100755 src/standards/Tizen/Application/ApplicationController.cpp delete mode 100755 src/standards/Tizen/Application/ApplicationController.h delete mode 100755 src/standards/Tizen/Application/ApplicationConverter.cpp delete mode 100755 src/standards/Tizen/Application/ApplicationConverter.h delete mode 100755 src/standards/Tizen/Application/ApplicationInformationEventPrivateData.h delete mode 100755 src/standards/Tizen/Application/ApplicationListenerManager.cpp delete mode 100755 src/standards/Tizen/Application/ApplicationListenerManager.h delete mode 100755 src/standards/Tizen/Application/ApplicationUtil.cpp delete mode 100755 src/standards/Tizen/Application/ApplicationUtil.h delete mode 100755 src/standards/Tizen/Application/CMakeLists.txt delete mode 100755 src/standards/Tizen/Application/JSApplication.cpp delete mode 100755 src/standards/Tizen/Application/JSApplication.h delete mode 100644 src/standards/Tizen/Application/JSApplicationCert.cpp delete mode 100644 src/standards/Tizen/Application/JSApplicationCert.h delete mode 100755 src/standards/Tizen/Application/JSApplicationContext.cpp delete mode 100755 src/standards/Tizen/Application/JSApplicationContext.h delete mode 100755 src/standards/Tizen/Application/JSApplicationControl.cpp delete mode 100755 src/standards/Tizen/Application/JSApplicationControl.h delete mode 100755 src/standards/Tizen/Application/JSApplicationControlData.cpp delete mode 100755 src/standards/Tizen/Application/JSApplicationControlData.h delete mode 100755 src/standards/Tizen/Application/JSApplicationEventCallbackManager.cpp delete mode 100755 src/standards/Tizen/Application/JSApplicationEventCallbackManager.h delete mode 100755 src/standards/Tizen/Application/JSApplicationInformation.cpp delete mode 100755 src/standards/Tizen/Application/JSApplicationInformation.h delete mode 100755 src/standards/Tizen/Application/JSApplicationInstallInfo.cpp delete mode 100755 src/standards/Tizen/Application/JSApplicationInstallInfo.h delete mode 100644 src/standards/Tizen/Application/JSApplicationManager.cpp delete mode 100644 src/standards/Tizen/Application/JSApplicationManager.h delete mode 100644 src/standards/Tizen/Application/JSRequestedApplicationControl.cpp delete mode 100644 src/standards/Tizen/Application/JSRequestedApplicationControl.h delete mode 100755 src/standards/Tizen/Application/config.xml delete mode 100755 src/standards/Tizen/Application/plugin_config.cpp delete mode 100755 src/standards/Tizen/Application/plugin_config.h delete mode 100755 src/standards/Tizen/Application/plugin_initializer.cpp delete mode 100644 src/standards/Tizen/Bluetooth/BluetoothAdapterListener.cpp delete mode 100644 src/standards/Tizen/Bluetooth/BluetoothAdapterListener.h delete mode 100644 src/standards/Tizen/Bluetooth/BluetoothClass.cpp delete mode 100644 src/standards/Tizen/Bluetooth/BluetoothClass.h delete mode 100644 src/standards/Tizen/Bluetooth/BluetoothConverter.cpp delete mode 100644 src/standards/Tizen/Bluetooth/BluetoothConverter.h delete mode 100644 src/standards/Tizen/Bluetooth/BluetoothDeviceManagerListener.cpp delete mode 100644 src/standards/Tizen/Bluetooth/BluetoothDeviceManagerListener.h delete mode 100644 src/standards/Tizen/Bluetooth/BluetoothMultiCallback.cpp delete mode 100644 src/standards/Tizen/Bluetooth/BluetoothMultiCallback.h delete mode 100644 src/standards/Tizen/Bluetooth/BluetoothSocketListener.cpp delete mode 100644 src/standards/Tizen/Bluetooth/BluetoothSocketListener.h delete mode 100644 src/standards/Tizen/Bluetooth/CMakeLists.txt delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothAdapter.cpp delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothAdapter.h delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothClass.cpp delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothClass.h delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothClassDeviceMajor.cpp delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothClassDeviceMajor.h delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothClassDeviceMinor.cpp delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothClassDeviceMinor.h delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothClassDeviceService.cpp delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothClassDeviceService.h delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothDevice.cpp delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothDevice.h delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothManager.cpp delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothManager.h delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothServiceHandler.cpp delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothServiceHandler.h delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothSocket.cpp delete mode 100644 src/standards/Tizen/Bluetooth/JSBluetoothSocket.h delete mode 100644 src/standards/Tizen/Bluetooth/config.xml delete mode 100644 src/standards/Tizen/Bluetooth/plugin_config.cpp delete mode 100644 src/standards/Tizen/Bluetooth/plugin_config.h delete mode 100644 src/standards/Tizen/Bluetooth/plugin_initializer.cpp delete mode 100755 src/standards/Tizen/CMakeLists.txt delete mode 100755 src/standards/Tizen/Calendar/CMakeLists.txt delete mode 100755 src/standards/Tizen/Calendar/CalendarAsyncCallbackManager.cpp delete mode 100755 src/standards/Tizen/Calendar/CalendarAsyncCallbackManager.h delete mode 100755 src/standards/Tizen/Calendar/CalendarConverter.cpp delete mode 100755 src/standards/Tizen/Calendar/CalendarConverter.h delete mode 100755 src/standards/Tizen/Calendar/CalendarListenerManager.cpp delete mode 100755 src/standards/Tizen/Calendar/CalendarListenerManager.h delete mode 100755 src/standards/Tizen/Calendar/CalendarMultiCallback.h delete mode 100755 src/standards/Tizen/Calendar/CalendarResponseDispatcher.cpp delete mode 100755 src/standards/Tizen/Calendar/CalendarResponseDispatcher.h delete mode 100755 src/standards/Tizen/Calendar/JSCalendar.cpp delete mode 100755 src/standards/Tizen/Calendar/JSCalendar.h delete mode 100755 src/standards/Tizen/Calendar/JSCalendarAlarm.cpp delete mode 100755 src/standards/Tizen/Calendar/JSCalendarAlarm.h delete mode 100755 src/standards/Tizen/Calendar/JSCalendarAttendee.cpp delete mode 100755 src/standards/Tizen/Calendar/JSCalendarAttendee.h delete mode 100755 src/standards/Tizen/Calendar/JSCalendarEvent.cpp delete mode 100755 src/standards/Tizen/Calendar/JSCalendarEvent.h delete mode 100755 src/standards/Tizen/Calendar/JSCalendarEventId.cpp delete mode 100755 src/standards/Tizen/Calendar/JSCalendarEventId.h delete mode 100755 src/standards/Tizen/Calendar/JSCalendarItemProperties.cpp delete mode 100755 src/standards/Tizen/Calendar/JSCalendarItemProperties.h delete mode 100755 src/standards/Tizen/Calendar/JSCalendarManager.cpp delete mode 100755 src/standards/Tizen/Calendar/JSCalendarManager.h delete mode 100755 src/standards/Tizen/Calendar/JSCalendarRecurrenceRule.cpp delete mode 100755 src/standards/Tizen/Calendar/JSCalendarRecurrenceRule.h delete mode 100755 src/standards/Tizen/Calendar/JSCalendarTask.cpp delete mode 100755 src/standards/Tizen/Calendar/JSCalendarTask.h delete mode 100755 src/standards/Tizen/Calendar/JSNumberArray.cpp delete mode 100755 src/standards/Tizen/Calendar/JSNumberArray.h delete mode 100755 src/standards/Tizen/Calendar/JSStringArray.cpp delete mode 100755 src/standards/Tizen/Calendar/JSStringArray.h delete mode 100755 src/standards/Tizen/Calendar/JSTZDateArray.cpp delete mode 100755 src/standards/Tizen/Calendar/JSTZDateArray.h delete mode 100755 src/standards/Tizen/Calendar/config.xml delete mode 100755 src/standards/Tizen/Calendar/plugin_config.cpp delete mode 100755 src/standards/Tizen/Calendar/plugin_config.h delete mode 100755 src/standards/Tizen/Calendar/plugin_initializer.cpp delete mode 100644 src/standards/Tizen/Callhistory/CMakeLists.txt delete mode 100755 src/standards/Tizen/Callhistory/CallHistoryAsyncCallbackManager.cpp delete mode 100755 src/standards/Tizen/Callhistory/CallHistoryAsyncCallbackManager.h delete mode 100755 src/standards/Tizen/Callhistory/CallHistoryListenerManager.cpp delete mode 100755 src/standards/Tizen/Callhistory/CallHistoryListenerManager.h delete mode 100755 src/standards/Tizen/Callhistory/CallHistoryMultiCallback.cpp delete mode 100755 src/standards/Tizen/Callhistory/CallHistoryMultiCallback.h delete mode 100755 src/standards/Tizen/Callhistory/CallHistoryStaticController.cpp delete mode 100755 src/standards/Tizen/Callhistory/CallHistoryStaticController.h delete mode 100755 src/standards/Tizen/Callhistory/Converter.cpp delete mode 100755 src/standards/Tizen/Callhistory/Converter.h delete mode 100755 src/standards/Tizen/Callhistory/JSCallHistory.cpp delete mode 100755 src/standards/Tizen/Callhistory/JSCallHistory.h delete mode 100755 src/standards/Tizen/Callhistory/JSCallHistoryEntry.cpp delete mode 100755 src/standards/Tizen/Callhistory/JSCallHistoryEntry.h delete mode 100755 src/standards/Tizen/Callhistory/JSRemoteParty.cpp delete mode 100755 src/standards/Tizen/Callhistory/JSRemoteParty.h delete mode 100755 src/standards/Tizen/Callhistory/ResponseDispatcher.cpp delete mode 100755 src/standards/Tizen/Callhistory/ResponseDispatcher.h delete mode 100755 src/standards/Tizen/Callhistory/config.xml delete mode 100755 src/standards/Tizen/Callhistory/plugin_config.cpp delete mode 100755 src/standards/Tizen/Callhistory/plugin_config.h delete mode 100755 src/standards/Tizen/Callhistory/plugin_initializer.cpp delete mode 100755 src/standards/Tizen/Common/AsyncCallbackManager.h delete mode 100755 src/standards/Tizen/Common/CMakeLists.txt delete mode 100755 src/standards/Tizen/Common/IListenerManager.h delete mode 100644 src/standards/Tizen/Common/JSTizenException.cpp delete mode 100644 src/standards/Tizen/Common/JSTizenException.h delete mode 100644 src/standards/Tizen/Common/JSTizenExceptionFactory.cpp delete mode 100644 src/standards/Tizen/Common/JSTizenExceptionFactory.h delete mode 100644 src/standards/Tizen/Common/JSWebAPIError.cpp delete mode 100644 src/standards/Tizen/Common/JSWebAPIError.h delete mode 100755 src/standards/Tizen/Common/SecurityExceptions.h delete mode 100644 src/standards/Tizen/Common/TizenExceptionData.cpp delete mode 100755 src/standards/Tizen/Common/TizenExceptionData.h delete mode 100755 src/standards/Tizen/Contact/AddressBookController.cpp delete mode 100755 src/standards/Tizen/Contact/AddressBookController.h delete mode 100755 src/standards/Tizen/Contact/CMakeLists.txt delete mode 100755 src/standards/Tizen/Contact/ContactAsyncCallbackManager.cpp delete mode 100755 src/standards/Tizen/Contact/ContactAsyncCallbackManager.h delete mode 100755 src/standards/Tizen/Contact/ContactConverter.cpp delete mode 100755 src/standards/Tizen/Contact/ContactConverter.h delete mode 100755 src/standards/Tizen/Contact/ContactListenerManager.cpp delete mode 100755 src/standards/Tizen/Contact/ContactListenerManager.h delete mode 100755 src/standards/Tizen/Contact/ContactManagerController.cpp delete mode 100755 src/standards/Tizen/Contact/ContactManagerController.h delete mode 100755 src/standards/Tizen/Contact/JSAddressBook.cpp delete mode 100755 src/standards/Tizen/Contact/JSAddressBook.h delete mode 100755 src/standards/Tizen/Contact/JSAddressBookArray.cpp delete mode 100755 src/standards/Tizen/Contact/JSAddressBookArray.h delete mode 100755 src/standards/Tizen/Contact/JSAddressBookChangeCallbackManager.cpp delete mode 100755 src/standards/Tizen/Contact/JSAddressBookChangeCallbackManager.h delete mode 100755 src/standards/Tizen/Contact/JSAttributesOfInterestArray.cpp delete mode 100755 src/standards/Tizen/Contact/JSAttributesOfInterestArray.h delete mode 100755 src/standards/Tizen/Contact/JSContact.cpp delete mode 100755 src/standards/Tizen/Contact/JSContact.h delete mode 100755 src/standards/Tizen/Contact/JSContactAddress.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactAddress.h delete mode 100755 src/standards/Tizen/Contact/JSContactAddressArray.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactAddressArray.h delete mode 100755 src/standards/Tizen/Contact/JSContactAddressTypeArray.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactAddressTypeArray.h delete mode 100755 src/standards/Tizen/Contact/JSContactAnniversary.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactAnniversary.h delete mode 100755 src/standards/Tizen/Contact/JSContactAnniversaryArray.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactAnniversaryArray.h delete mode 100755 src/standards/Tizen/Contact/JSContactArray.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactArray.h delete mode 100755 src/standards/Tizen/Contact/JSContactEmailAddress.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactEmailAddress.h delete mode 100755 src/standards/Tizen/Contact/JSContactEmailAddressArray.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactEmailAddressArray.h delete mode 100755 src/standards/Tizen/Contact/JSContactEmailAddressTypeArray.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactEmailAddressTypeArray.h delete mode 100755 src/standards/Tizen/Contact/JSContactGroup.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactGroup.h delete mode 100755 src/standards/Tizen/Contact/JSContactGroupArray.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactGroupArray.h delete mode 100755 src/standards/Tizen/Contact/JSContactManager.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactManager.h delete mode 100755 src/standards/Tizen/Contact/JSContactManagerChangeCallbackManager.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactManagerChangeCallbackManager.h delete mode 100755 src/standards/Tizen/Contact/JSContactName.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactName.h delete mode 100755 src/standards/Tizen/Contact/JSContactOrganization.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactOrganization.h delete mode 100755 src/standards/Tizen/Contact/JSContactOrganizationArray.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactOrganizationArray.h delete mode 100755 src/standards/Tizen/Contact/JSContactPhoneNumber.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactPhoneNumber.h delete mode 100755 src/standards/Tizen/Contact/JSContactPhoneNumberArray.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactPhoneNumberArray.h delete mode 100755 src/standards/Tizen/Contact/JSContactPhoneNumberTypeArray.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactPhoneNumberTypeArray.h delete mode 100755 src/standards/Tizen/Contact/JSContactRef.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactRef.h delete mode 100755 src/standards/Tizen/Contact/JSContactWebSite.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactWebSite.h delete mode 100755 src/standards/Tizen/Contact/JSContactWebSiteArray.cpp delete mode 100755 src/standards/Tizen/Contact/JSContactWebSiteArray.h delete mode 100755 src/standards/Tizen/Contact/JSPerson.cpp delete mode 100755 src/standards/Tizen/Contact/JSPerson.h delete mode 100755 src/standards/Tizen/Contact/JSPersonArray.cpp delete mode 100755 src/standards/Tizen/Contact/JSPersonArray.h delete mode 100755 src/standards/Tizen/Contact/JSStringArray.cpp delete mode 100755 src/standards/Tizen/Contact/JSStringArray.h delete mode 100755 src/standards/Tizen/Contact/config.xml delete mode 100755 src/standards/Tizen/Contact/plugin_config.cpp delete mode 100755 src/standards/Tizen/Contact/plugin_config.h delete mode 100755 src/standards/Tizen/Contact/plugin_initializer.cpp delete mode 100755 src/standards/Tizen/Content/CMakeLists.txt delete mode 100755 src/standards/Tizen/Content/ContentAsyncCallbackManager.cpp delete mode 100755 src/standards/Tizen/Content/ContentAsyncCallbackManager.h delete mode 100755 src/standards/Tizen/Content/ContentController.cpp delete mode 100755 src/standards/Tizen/Content/ContentController.h delete mode 100755 src/standards/Tizen/Content/ContentConverter.cpp delete mode 100755 src/standards/Tizen/Content/ContentConverter.h delete mode 100755 src/standards/Tizen/Content/JSAudio.cpp delete mode 100755 src/standards/Tizen/Content/JSAudio.h delete mode 100755 src/standards/Tizen/Content/JSContentManager.cpp delete mode 100755 src/standards/Tizen/Content/JSContentManager.h delete mode 100755 src/standards/Tizen/Content/JSFolder.cpp delete mode 100755 src/standards/Tizen/Content/JSFolder.h delete mode 100755 src/standards/Tizen/Content/JSImage.cpp delete mode 100755 src/standards/Tizen/Content/JSImage.h delete mode 100755 src/standards/Tizen/Content/JSMedia.cpp delete mode 100755 src/standards/Tizen/Content/JSMedia.h delete mode 100755 src/standards/Tizen/Content/JSMediaLyrics.cpp delete mode 100755 src/standards/Tizen/Content/JSMediaLyrics.h delete mode 100755 src/standards/Tizen/Content/JSVideo.cpp delete mode 100755 src/standards/Tizen/Content/JSVideo.h delete mode 100755 src/standards/Tizen/Content/MediaLyricsUtil.cpp delete mode 100755 src/standards/Tizen/Content/MediaLyricsUtil.h delete mode 100755 src/standards/Tizen/Content/config.xml delete mode 100755 src/standards/Tizen/Content/plugin_config.cpp delete mode 100755 src/standards/Tizen/Content/plugin_config.h delete mode 100755 src/standards/Tizen/Content/plugin_initializer.cpp delete mode 100755 src/standards/Tizen/Download/CMakeLists.txt delete mode 100755 src/standards/Tizen/Download/DownloadConverter.cpp delete mode 100755 src/standards/Tizen/Download/DownloadConverter.h delete mode 100755 src/standards/Tizen/Download/DownloadListenerManager.cpp delete mode 100755 src/standards/Tizen/Download/DownloadListenerManager.h delete mode 100755 src/standards/Tizen/Download/DownloadMultiCallback.h delete mode 100755 src/standards/Tizen/Download/DownloadResponseDispatcher.cpp delete mode 100755 src/standards/Tizen/Download/DownloadResponseDispatcher.h delete mode 100755 src/standards/Tizen/Download/JSDownloadManager.cpp delete mode 100755 src/standards/Tizen/Download/JSDownloadManager.h delete mode 100755 src/standards/Tizen/Download/JSDownloadRequest.cpp delete mode 100755 src/standards/Tizen/Download/JSDownloadRequest.h delete mode 100755 src/standards/Tizen/Download/config.xml delete mode 100755 src/standards/Tizen/Download/plugin_config.cpp delete mode 100755 src/standards/Tizen/Download/plugin_config.h delete mode 100755 src/standards/Tizen/Download/plugin_initializer.cpp delete mode 100755 src/standards/Tizen/Filesystem/CMakeLists.txt delete mode 100755 src/standards/Tizen/Filesystem/Converter.cpp delete mode 100755 src/standards/Tizen/Filesystem/Converter.h delete mode 100755 src/standards/Tizen/Filesystem/Encodings.cpp delete mode 100755 src/standards/Tizen/Filesystem/Encodings.h delete mode 100755 src/standards/Tizen/Filesystem/EventGetNodeData.cpp delete mode 100755 src/standards/Tizen/Filesystem/EventGetNodeData.h delete mode 100755 src/standards/Tizen/Filesystem/FilesystemAsyncCallbackManager.cpp delete mode 100755 src/standards/Tizen/Filesystem/FilesystemAsyncCallbackManager.h delete mode 100755 src/standards/Tizen/Filesystem/FilesystemListenerManager.cpp delete mode 100755 src/standards/Tizen/Filesystem/FilesystemListenerManager.h delete mode 100755 src/standards/Tizen/Filesystem/FilesystemUtils.cpp delete mode 100755 src/standards/Tizen/Filesystem/FilesystemUtils.h delete mode 100755 src/standards/Tizen/Filesystem/JSFile.cpp delete mode 100755 src/standards/Tizen/Filesystem/JSFile.h delete mode 100755 src/standards/Tizen/Filesystem/JSFilestream.cpp delete mode 100755 src/standards/Tizen/Filesystem/JSFilestream.h delete mode 100755 src/standards/Tizen/Filesystem/JSFilesystemManager.cpp delete mode 100755 src/standards/Tizen/Filesystem/JSFilesystemManager.h delete mode 100755 src/standards/Tizen/Filesystem/JSStorage.cpp delete mode 100755 src/standards/Tizen/Filesystem/JSStorage.h delete mode 100755 src/standards/Tizen/Filesystem/ResponseDispatcher.cpp delete mode 100755 src/standards/Tizen/Filesystem/ResponseDispatcher.h delete mode 100755 src/standards/Tizen/Filesystem/StorageStaticController.cpp delete mode 100755 src/standards/Tizen/Filesystem/StorageStaticController.h delete mode 100755 src/standards/Tizen/Filesystem/config.xml delete mode 100755 src/standards/Tizen/Filesystem/plugin_config.cpp delete mode 100755 src/standards/Tizen/Filesystem/plugin_config.h delete mode 100755 src/standards/Tizen/Filesystem/plugin_initializer.cpp delete mode 100755 src/standards/Tizen/Messaging/CMakeLists.txt delete mode 100755 src/standards/Tizen/Messaging/ConverterMessage.cpp delete mode 100755 src/standards/Tizen/Messaging/ConverterMessage.h delete mode 100755 src/standards/Tizen/Messaging/EventMessagingServicePrivateData.cpp delete mode 100755 src/standards/Tizen/Messaging/EventMessagingServicePrivateData.h delete mode 100755 src/standards/Tizen/Messaging/EventSendMessagePrivateData.cpp delete mode 100755 src/standards/Tizen/Messaging/EventSendMessagePrivateData.h delete mode 100755 src/standards/Tizen/Messaging/JSConversation.cpp delete mode 100755 src/standards/Tizen/Messaging/JSConversation.h delete mode 100755 src/standards/Tizen/Messaging/JSMessage.cpp delete mode 100755 src/standards/Tizen/Messaging/JSMessage.h delete mode 100755 src/standards/Tizen/Messaging/JSMessageAttachment.cpp delete mode 100755 src/standards/Tizen/Messaging/JSMessageAttachment.h delete mode 100755 src/standards/Tizen/Messaging/JSMessageBody.cpp delete mode 100755 src/standards/Tizen/Messaging/JSMessageBody.h delete mode 100755 src/standards/Tizen/Messaging/JSMessageFolder.cpp delete mode 100755 src/standards/Tizen/Messaging/JSMessageFolder.h delete mode 100755 src/standards/Tizen/Messaging/JSMessagePrivateObject.h delete mode 100644 src/standards/Tizen/Messaging/JSMessagingService.cpp delete mode 100755 src/standards/Tizen/Messaging/JSMessagingService.h delete mode 100644 src/standards/Tizen/Messaging/JSMessagingServiceManager.cpp delete mode 100755 src/standards/Tizen/Messaging/JSMessagingServiceManager.h delete mode 100755 src/standards/Tizen/Messaging/JSMessagingStorage.cpp delete mode 100755 src/standards/Tizen/Messaging/JSMessagingStorage.h delete mode 100755 src/standards/Tizen/Messaging/JSRecipientArray.cpp delete mode 100755 src/standards/Tizen/Messaging/JSRecipientArray.h delete mode 100755 src/standards/Tizen/Messaging/MessageAsyncCallbackManager.cpp delete mode 100755 src/standards/Tizen/Messaging/MessageAsyncCallbackManager.h delete mode 100755 src/standards/Tizen/Messaging/MessageListenerManager.cpp delete mode 100755 src/standards/Tizen/Messaging/MessageListenerManager.h delete mode 100755 src/standards/Tizen/Messaging/MessageSendCallback.h delete mode 100644 src/standards/Tizen/Messaging/MessagingController.cpp delete mode 100755 src/standards/Tizen/Messaging/MessagingController.h delete mode 100755 src/standards/Tizen/Messaging/MessagingErrorMsg.h delete mode 100755 src/standards/Tizen/Messaging/MessagingListener.cpp delete mode 100755 src/standards/Tizen/Messaging/MessagingListener.h delete mode 100755 src/standards/Tizen/Messaging/MessagingStorageMultiCallback.cpp delete mode 100755 src/standards/Tizen/Messaging/MessagingStorageMultiCallback.h delete mode 100755 src/standards/Tizen/Messaging/config.xml delete mode 100755 src/standards/Tizen/Messaging/plugin_config.cpp delete mode 100755 src/standards/Tizen/Messaging/plugin_config.h delete mode 100755 src/standards/Tizen/Messaging/plugin_initializer.cpp delete mode 100755 src/standards/Tizen/NFC/CMakeLists.txt delete mode 100755 src/standards/Tizen/NFC/EventNFCChangedPrivateData.cpp delete mode 100755 src/standards/Tizen/NFC/EventNFCChangedPrivateData.h delete mode 100755 src/standards/Tizen/NFC/JSNFCAdapter.cpp delete mode 100755 src/standards/Tizen/NFC/JSNFCAdapter.h delete mode 100755 src/standards/Tizen/NFC/JSNFCManager.cpp delete mode 100755 src/standards/Tizen/NFC/JSNFCManager.h delete mode 100755 src/standards/Tizen/NFC/JSNFCTag.cpp delete mode 100755 src/standards/Tizen/NFC/JSNFCTag.h delete mode 100755 src/standards/Tizen/NFC/JSNFCTarget.cpp delete mode 100755 src/standards/Tizen/NFC/JSNFCTarget.h delete mode 100755 src/standards/Tizen/NFC/JSNdefMessage.cpp delete mode 100755 src/standards/Tizen/NFC/JSNdefMessage.h delete mode 100755 src/standards/Tizen/NFC/JSNdefRecord.cpp delete mode 100755 src/standards/Tizen/NFC/JSNdefRecord.h delete mode 100755 src/standards/Tizen/NFC/JSNdefRecordArray.cpp delete mode 100755 src/standards/Tizen/NFC/JSNdefRecordArray.h delete mode 100755 src/standards/Tizen/NFC/JSNdefRecordMedia.cpp delete mode 100755 src/standards/Tizen/NFC/JSNdefRecordMedia.h delete mode 100755 src/standards/Tizen/NFC/JSNdefRecordText.cpp delete mode 100755 src/standards/Tizen/NFC/JSNdefRecordText.h delete mode 100755 src/standards/Tizen/NFC/JSNdefRecordURI.cpp delete mode 100755 src/standards/Tizen/NFC/JSNdefRecordURI.h delete mode 100755 src/standards/Tizen/NFC/NFCAsyncCallbackManager.cpp delete mode 100755 src/standards/Tizen/NFC/NFCAsyncCallbackManager.h delete mode 100755 src/standards/Tizen/NFC/NFCChangedCallback.h delete mode 100755 src/standards/Tizen/NFC/NFCConverter.cpp delete mode 100755 src/standards/Tizen/NFC/NFCConverter.h delete mode 100755 src/standards/Tizen/NFC/NFCListenerManager.cpp delete mode 100755 src/standards/Tizen/NFC/NFCListenerManager.h delete mode 100755 src/standards/Tizen/NFC/NFCStaticController.cpp delete mode 100755 src/standards/Tizen/NFC/NFCStaticController.h delete mode 100755 src/standards/Tizen/NFC/ResponseDispatcher.cpp delete mode 100755 src/standards/Tizen/NFC/ResponseDispatcher.h delete mode 100755 src/standards/Tizen/NFC/config.xml delete mode 100755 src/standards/Tizen/NFC/plugin_config.cpp delete mode 100755 src/standards/Tizen/NFC/plugin_config.h delete mode 100755 src/standards/Tizen/NFC/plugin_initializer.cpp delete mode 100755 src/standards/Tizen/NetworkBearerSelection/CMakeLists.txt delete mode 100755 src/standards/Tizen/NetworkBearerSelection/JSNetworkBearerSelection.cpp delete mode 100755 src/standards/Tizen/NetworkBearerSelection/JSNetworkBearerSelection.h delete mode 100755 src/standards/Tizen/NetworkBearerSelection/JSNetworkBearerSelectionCallbackManager.cpp delete mode 100755 src/standards/Tizen/NetworkBearerSelection/JSNetworkBearerSelectionCallbackManager.h delete mode 100755 src/standards/Tizen/NetworkBearerSelection/NetworkBearerSelectionResponseDispatcher.cpp delete mode 100755 src/standards/Tizen/NetworkBearerSelection/NetworkBearerSelectionResponseDispatcher.h delete mode 100755 src/standards/Tizen/NetworkBearerSelection/config.xml delete mode 100755 src/standards/Tizen/NetworkBearerSelection/plugin_config.cpp delete mode 100755 src/standards/Tizen/NetworkBearerSelection/plugin_config.h delete mode 100755 src/standards/Tizen/NetworkBearerSelection/plugin_initializer.cpp delete mode 100644 src/standards/Tizen/Notification/CMakeLists.txt delete mode 100644 src/standards/Tizen/Notification/JSNotificationManager.cpp delete mode 100644 src/standards/Tizen/Notification/JSNotificationManager.h delete mode 100644 src/standards/Tizen/Notification/JSStatusNotification.cpp delete mode 100644 src/standards/Tizen/Notification/JSStatusNotification.h delete mode 100644 src/standards/Tizen/Notification/NotificationConverter.cpp delete mode 100644 src/standards/Tizen/Notification/NotificationConverter.h delete mode 100644 src/standards/Tizen/Notification/NotificationCoverter.cpp delete mode 100644 src/standards/Tizen/Notification/config.xml delete mode 100644 src/standards/Tizen/Notification/plugin_config.cpp delete mode 100644 src/standards/Tizen/Notification/plugin_config.h delete mode 100644 src/standards/Tizen/Notification/plugin_initializer.cpp delete mode 100755 src/standards/Tizen/Power/CMakeLists.txt delete mode 100755 src/standards/Tizen/Power/JSPowerManager.cpp delete mode 100755 src/standards/Tizen/Power/JSPowerManager.h delete mode 100755 src/standards/Tizen/Power/PowerConverter.cpp delete mode 100755 src/standards/Tizen/Power/PowerConverter.h delete mode 100755 src/standards/Tizen/Power/PowerListenerManager.cpp delete mode 100755 src/standards/Tizen/Power/PowerListenerManager.h delete mode 100755 src/standards/Tizen/Power/PowerResponseDispatcher.cpp delete mode 100755 src/standards/Tizen/Power/PowerResponseDispatcher.h delete mode 100755 src/standards/Tizen/Power/config.xml delete mode 100755 src/standards/Tizen/Power/plugin_config.cpp delete mode 100755 src/standards/Tizen/Power/plugin_config.h delete mode 100755 src/standards/Tizen/Power/plugin_initializer.cpp delete mode 100644 src/standards/Tizen/SecureStorage/CMakeLists.txt delete mode 100644 src/standards/Tizen/SecureStorage/JSSecureStorageManager.cpp delete mode 100644 src/standards/Tizen/SecureStorage/JSSecureStorageManager.h delete mode 100644 src/standards/Tizen/SecureStorage/SecureStorageManager.cpp delete mode 100644 src/standards/Tizen/SecureStorage/SecureStorageManager.h delete mode 100644 src/standards/Tizen/SecureStorage/config.xml delete mode 100644 src/standards/Tizen/SecureStorage/plugin_config.cpp delete mode 100644 src/standards/Tizen/SecureStorage/plugin_config.h delete mode 100644 src/standards/Tizen/SecureStorage/plugin_initializer.cpp delete mode 100644 src/standards/Tizen/SystemSetting/CMakeLists.txt delete mode 100755 src/standards/Tizen/SystemSetting/ConverterSystemSetting.cpp delete mode 100755 src/standards/Tizen/SystemSetting/ConverterSystemSetting.h delete mode 100755 src/standards/Tizen/SystemSetting/JSSystemSetting.cpp delete mode 100755 src/standards/Tizen/SystemSetting/JSSystemSetting.h delete mode 100755 src/standards/Tizen/SystemSetting/SystemSettingAsyncCallbackManager.cpp delete mode 100755 src/standards/Tizen/SystemSetting/SystemSettingAsyncCallbackManager.h delete mode 100755 src/standards/Tizen/SystemSetting/SystemSettingResponseDispatcher.cpp delete mode 100755 src/standards/Tizen/SystemSetting/SystemSettingResponseDispatcher.h delete mode 100644 src/standards/Tizen/SystemSetting/config.xml delete mode 100755 src/standards/Tizen/SystemSetting/plugin_config.cpp delete mode 100755 src/standards/Tizen/SystemSetting/plugin_config.h delete mode 100755 src/standards/Tizen/SystemSetting/plugin_initializer.cpp delete mode 100755 src/standards/Tizen/Systeminfo/CMakeLists.txt delete mode 100755 src/standards/Tizen/Systeminfo/JSBatteryInfo.cpp delete mode 100755 src/standards/Tizen/Systeminfo/JSBatteryInfo.h delete mode 100755 src/standards/Tizen/Systeminfo/JSBuildInfo.cpp delete mode 100755 src/standards/Tizen/Systeminfo/JSBuildInfo.h delete mode 100755 src/standards/Tizen/Systeminfo/JSCellularNetworkInfo.cpp delete mode 100755 src/standards/Tizen/Systeminfo/JSCellularNetworkInfo.h delete mode 100755 src/standards/Tizen/Systeminfo/JSCpuInfo.cpp delete mode 100755 src/standards/Tizen/Systeminfo/JSCpuInfo.h delete mode 100755 src/standards/Tizen/Systeminfo/JSDeviceCapabilitiesInfo.cpp delete mode 100755 src/standards/Tizen/Systeminfo/JSDeviceCapabilitiesInfo.h delete mode 100755 src/standards/Tizen/Systeminfo/JSDeviceOrientationInfo.cpp delete mode 100755 src/standards/Tizen/Systeminfo/JSDeviceOrientationInfo.h delete mode 100755 src/standards/Tizen/Systeminfo/JSDisplayInfo.cpp delete mode 100755 src/standards/Tizen/Systeminfo/JSDisplayInfo.h delete mode 100755 src/standards/Tizen/Systeminfo/JSNetworkInfo.cpp delete mode 100755 src/standards/Tizen/Systeminfo/JSNetworkInfo.h delete mode 100755 src/standards/Tizen/Systeminfo/JSSIMInfo.cpp delete mode 100755 src/standards/Tizen/Systeminfo/JSSIMInfo.h delete mode 100755 src/standards/Tizen/Systeminfo/JSStorageInfo.cpp delete mode 100755 src/standards/Tizen/Systeminfo/JSStorageInfo.h delete mode 100755 src/standards/Tizen/Systeminfo/JSSysteminfo.cpp delete mode 100755 src/standards/Tizen/Systeminfo/JSSysteminfo.h delete mode 100755 src/standards/Tizen/Systeminfo/JSWifiNetworkInfo.cpp delete mode 100755 src/standards/Tizen/Systeminfo/JSWifiNetworkInfo.h delete mode 100755 src/standards/Tizen/Systeminfo/SysteminfoAsyncCallbackManager.cpp delete mode 100755 src/standards/Tizen/Systeminfo/SysteminfoAsyncCallbackManager.h delete mode 100755 src/standards/Tizen/Systeminfo/SysteminfoListener.cpp delete mode 100755 src/standards/Tizen/Systeminfo/SysteminfoListener.h delete mode 100755 src/standards/Tizen/Systeminfo/SysteminfoListenerManager.cpp delete mode 100755 src/standards/Tizen/Systeminfo/SysteminfoListenerManager.h delete mode 100755 src/standards/Tizen/Systeminfo/config.xml delete mode 100755 src/standards/Tizen/Systeminfo/plugin_config.cpp delete mode 100755 src/standards/Tizen/Systeminfo/plugin_config.h delete mode 100755 src/standards/Tizen/Systeminfo/plugin_initializer.cpp delete mode 100755 src/standards/Tizen/TimeUtil/CMakeLists.txt delete mode 100755 src/standards/Tizen/TimeUtil/JSTZDate.cpp delete mode 100755 src/standards/Tizen/TimeUtil/JSTZDate.h delete mode 100755 src/standards/Tizen/TimeUtil/JSTimeDuration.cpp delete mode 100755 src/standards/Tizen/TimeUtil/JSTimeDuration.h delete mode 100755 src/standards/Tizen/TimeUtil/JSTimeUtil.cpp delete mode 100755 src/standards/Tizen/TimeUtil/JSTimeUtil.h delete mode 100755 src/standards/Tizen/TimeUtil/TimeUtilConverter.cpp delete mode 100755 src/standards/Tizen/TimeUtil/TimeUtilConverter.h delete mode 100755 src/standards/Tizen/TimeUtil/config.xml delete mode 100755 src/standards/Tizen/TimeUtil/plugin_initializer.cpp delete mode 100755 src/standards/Tizen/Tizen/CMakeLists.txt delete mode 100755 src/standards/Tizen/Tizen/FilterConverter.cpp delete mode 100755 src/standards/Tizen/Tizen/FilterConverter.h delete mode 100755 src/standards/Tizen/Tizen/JSAbstractFilterArray.cpp delete mode 100755 src/standards/Tizen/Tizen/JSAbstractFilterArray.h delete mode 100755 src/standards/Tizen/Tizen/JSAttributeFilter.cpp delete mode 100755 src/standards/Tizen/Tizen/JSAttributeFilter.h delete mode 100755 src/standards/Tizen/Tizen/JSAttributeRangeFilter.cpp delete mode 100755 src/standards/Tizen/Tizen/JSAttributeRangeFilter.h delete mode 100755 src/standards/Tizen/Tizen/JSCompositeFilter.cpp delete mode 100755 src/standards/Tizen/Tizen/JSCompositeFilter.h delete mode 100755 src/standards/Tizen/Tizen/JSFeature.cpp delete mode 100755 src/standards/Tizen/Tizen/JSFeature.h delete mode 100755 src/standards/Tizen/Tizen/JSFeatureParam.cpp delete mode 100755 src/standards/Tizen/Tizen/JSFeatureParam.h delete mode 100755 src/standards/Tizen/Tizen/JSSimpleCoordinates.cpp delete mode 100755 src/standards/Tizen/Tizen/JSSimpleCoordinates.h delete mode 100755 src/standards/Tizen/Tizen/JSSortMode.cpp delete mode 100755 src/standards/Tizen/Tizen/JSSortMode.h delete mode 100755 src/standards/Tizen/Tizen/JSTizen.cpp delete mode 100755 src/standards/Tizen/Tizen/JSTizen.h delete mode 100755 src/standards/Tizen/Tizen/PluginOnDemandPriv.cpp delete mode 100755 src/standards/Tizen/Tizen/PluginOnDemandPriv.h delete mode 100755 src/standards/Tizen/Tizen/config.xml delete mode 100755 src/standards/Tizen/Tizen/plugin_config.cpp delete mode 100755 src/standards/Tizen/Tizen/plugin_config.h delete mode 100755 src/standards/Tizen/Tizen/plugin_initializer.cpp diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 09276ca..0000000 --- a/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Keeduck Kim diff --git a/CMakeLists.txt b/CMakeLists.txt index b5a97d0..e7061e2 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,22 +1,20 @@ -cmake_minimum_required(VERSION 2.6) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +PROJECT(wrt-plugins-tizen) - -project(wrt-plugins-tizen) - - -################################################################################ +# ----------------------------------------------------------------------------- # Required platform modules - -include(FindPkgConfig) - -pkg_search_module(webkit2 REQUIRED ewebkit2) -pkg_search_module(dpl REQUIRED dpl-efl) -pkg_search_module(dpl-event REQUIRED dpl-event-efl) -pkg_search_module(wrt-plugins-types REQUIRED wrt-plugins-types) -pkg_search_module(wrt-deviceapis-commons REQUIRED wrt-plugins-commons) -pkg_search_module(wrt-deviceapis-commons-javascript REQUIRED wrt-plugins-commons-javascript) - -include_directories( +# ----------------------------------------------------------------------------- +INCLUDE(FindPkgConfig) + +PKG_SEARCH_MODULE(webkit2 REQUIRED ewebkit2) +PKG_SEARCH_MODULE(dpl REQUIRED dpl-efl) +PKG_SEARCH_MODULE(dpl-event REQUIRED dpl-event-efl) +PKG_SEARCH_MODULE(wrt-plugins-types REQUIRED wrt-plugins-types) +PKG_SEARCH_MODULE(wrt-deviceapis-commons REQUIRED wrt-plugins-commons) +PKG_SEARCH_MODULE(wrt-deviceapis-commons-javascript REQUIRED wrt-plugins-commons-javascript) +PKG_SEARCH_MODULE(wrt-plugins-widgetdb REQUIRED wrt-plugins-widgetdb) + +INCLUDE_DIRECTORIES( ${webkit2_INCLUDE_DIRS} ${dpl_INCLUDE_DIRS} ${wrt-plugins-types_INCLUDE_DIRS} @@ -24,13 +22,9 @@ include_directories( ${wrt-deviceapis-commons-javascript_INCLUDE_DIRS} ) - -################################################################################ -# Build options - -# -# Logs -# +# ----------------------------------------------------------------------------- +# Determine the log option +# ----------------------------------------------------------------------------- OPTION(DPL_LOG "DPL logs status" ON) @@ -41,89 +35,99 @@ ELSE(DPL_LOG) MESSAGE(STATUS "Logging disabled for DPL") ENDIF(DPL_LOG) -############################################################################### +# ----------------------------------------------------------------------------- # Set build type (Release by default) +# ----------------------------------------------------------------------------- IF("${CMAKE_BUILD_TYPE}" STREQUAL "") SET(CMAKE_BUILD_TYPE Release) ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") -############################################################################## -# Compiler flags +# ----------------------------------------------------------------------------- +# CFlags +# ----------------------------------------------------------------------------- SET(CMAKE_C_FLAGS_PROFILING "-O0 -g -pg") SET(CMAKE_CXX_FLAGS_PROFILING "-O0 -std=c++0x -g -pg") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -std=c++0x -g") SET(CMAKE_C_FLAGS_RELEASE "-O2 -g") SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -std=c++0x -g") -#### - +ADD_DEFINITIONS("-DCLIENT_IPC_THREAD") ADD_DEFINITIONS("-DEXPORT_API=") ADD_DEFINITIONS("-Wall") #ADD_DEFINITIONS("-Werror") #ADD_DEFINITIONS("-Wextra") +ADD_DEFINITIONS("-DAPPLICATION_API_BACKWARD_COMPATIBILITY") + + +# ----------------------------------------------------------------------------- +# Schema of plugin's configuration file +# ----------------------------------------------------------------------------- +SET(COMMON_CONFIG_DTD ${CMAKE_CURRENT_SOURCE_DIR}/config.dtd) +SET(COMMON_CONFIG_DTD_DST /usr/etc/tizen-apis) +INSTALL(FILES ${COMMON_CONFIG_DTD} DESTINATION ${COMMON_CONFIG_DTD_DST}) -################################################################################ -# Miscellaneous variables +# ----------------------------------------------------------------------------- +# Global variables +# ----------------------------------------------------------------------------- -set(CONFIG_FILE_NAME "config.cmake") -set(DIR_COMMONS ${CMAKE_SOURCE_DIR}/src/commons) -set(LIBS_COMMON +SET(DESTINATION_LIB_PREFIX lib/wrt-plugins) + +SET(DESTINATION_HEADER_PREFIX include/${PROJECT_NAME}) + +SET(TOP ${CMAKE_SOURCE_DIR}/src) + +SET(LIBS_COMMON ${dpl_LDFLAGS} ${dpl-event_LDFLAGS} ${webkit2_LDFLAGS} ${wrt-deviceapis-commons_LDFLAGS} ${wrt-deviceapis-commons-javascript_LDFLAGS} - ) - - -################################################################################ -# Target platform - -if (NOT DEFINED PLATFORM) - set(PLATFORM "Tizen") -endif () - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/src - ${CMAKE_CURRENT_SOURCE_DIR}/src/platform - ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/${PLATFORM} - ${CMAKE_CURRENT_SOURCE_DIR}/src/standards ) -################################################################################ -# Schema of plugin's configuration file - -set(COMMON_CONFIG_DTD ${CMAKE_CURRENT_SOURCE_DIR}/config.dtd) -set(COMMON_CONFIG_DTD_DST /usr/etc/tizen-apis) -INSTALL(FILES ${COMMON_CONFIG_DTD} DESTINATION ${COMMON_CONFIG_DTD_DST}) - - -################################################################################ -# Macros used for including plugins from AL. +SET(CMAKE_INSTALL_RPATH ${wrt-deviceapis-commons_LIBRARY_DIRS}) -function(add_subdir NAME) - message(STATUS "Building: ${CMAKE_CURRENT_SOURCE_DIR}/${NAME}") - add_subdirectory(${NAME}) -endfunction() +SET(LIBS_WIDGETDB ${wrt-plugins-widgetdb_LIBRARIES}) +# ----------------------------------------------------------------------------- +# Macros for pkgconfig +# ----------------------------------------------------------------------------- +SET(PKGCONFIG_DIR ${CMAKE_SOURCE_DIR}/pkgconfigs) -################################################################################ -# Subdirectories +MACRO(configure_and_install_pkg PKG_FILE) + CONFIGURE_FILE(${PKGCONFIG_DIR}/${PKG_FILE}.in + ${PKGCONFIG_DIR}/${PKG_FILE} @ONLY) + INSTALL(FILES ${PKGCONFIG_DIR}/${PKG_FILE} DESTINATION lib/pkgconfig) +ENDMACRO(configure_and_install_pkg) -add_subdirectory(src) +# ----------------------------------------------------------------------------- +# Functions used for plugins +# ----------------------------------------------------------------------------- +FUNCTION(set_target NAME) + STRING(TOLOWER ${NAME} LOWER_NAME) + SET(${LOWER_NAME}_dest tizen-${LOWER_NAME} PARENT_SCOPE) + SET(${LOWER_NAME}_target wrt-plugins-tizen-${LOWER_NAME} PARENT_SCOPE) + SET(${LOWER_NAME}_impl wrt-plugins-tizen-${LOWER_NAME}-impl PARENT_SCOPE) + SET(${LOWER_NAME}_config wrt-plugins-tizen-${LOWER_NAME}-config PARENT_SCOPE) + configure_and_install_pkg(wrt-plugins-tizen-${LOWER_NAME}.pc) +ENDFUNCTION() -################################################################################ -# Cache -set(PLATFORM "${PLATFORM}" CACHE STRING "Target platform" FORCE) -set(CMAKE_CONFIG_FILE_NAME "${CMAKE_CONFIG_FILE_NAME}" CACHE - STRING "CMake configuration file name." FORCE) +FUNCTION(add_subdir NAME) + MESSAGE(STATUS "Building: ${CMAKE_CURRENT_SOURCE_DIR}/${NAME}") + ADD_SUBDIRECTORY(${NAME}) +ENDFUNCTION() -################################################################################ -# Summary +FUNCTION(add_plugin) + FOREACH(VALUE ${ARGN}) + set_target(${VALUE}) + ENDFOREACH(VALUE) + FOREACH(VALUE ${ARGN}) + add_subdir(${VALUE}) + ENDFOREACH(VALUE) +ENDFUNCTION() -message(STATUS "PLATFORM = ${PLATFORM}") +ADD_SUBDIRECTORY(src) diff --git a/LICENSE.APLv2 b/LICENSE.APLv2 deleted file mode 100644 index c260a37..0000000 --- a/LICENSE.APLv2 +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/NOTICE b/NOTICE deleted file mode 100644 index b616854..0000000 --- a/NOTICE +++ /dev/null @@ -1,3 +0,0 @@ -Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. -Except as noted, this software is licensed under Apache License, Version 2. -Please, see the LICENSE.APLv2 file for Apache License terms and conditions. diff --git a/packaging/wrt-plugins-tizen.spec b/packaging/wrt-plugins-tizen.spec index 15ac028..e139627 100755 --- a/packaging/wrt-plugins-tizen.spec +++ b/packaging/wrt-plugins-tizen.spec @@ -1,10 +1,11 @@ Name: wrt-plugins-tizen Summary: JavaScript plugins for WebRuntime -Version: 0.3.38 +Version: 0.4.5 Release: 0 Group: Development/Libraries License: Apache License, Version 2.0 Source0: %{name}-%{version}.tar.gz +BuildRequires: pkgconfig(capi-web-favorites) BuildRequires: pkgconfig(mm-fileinfo) BuildRequires: pkgconfig(libpcrecpp) BuildRequires: pkgconfig(calendar-service2) @@ -40,6 +41,7 @@ BuildRequires: pkgconfig(capi-network-connection) BuildRequires: pkgconfig(capi-telephony-call) BuildRequires: pkgconfig(capi-telephony-sim) BuildRequires: pkgconfig(capi-system-info) +BuildRequires: pkgconfig(capi-system-runtime-info) BuildRequires: pkgconfig(sensor) BuildRequires: pkgconfig(capi-system-sensor) BuildRequires: pkgconfig(capi-system-power) @@ -48,20 +50,34 @@ BuildRequires: pkgconfig(capi-system-system-settings) BuildRequires: pkgconfig(capi-system-device) BuildRequires: pkgconfig(capi-content-media-content) BuildRequires: pkgconfig(capi-media-metadata-extractor) +BuildRequires: pkgconfig(smartcard-service-common) +BuildRequires: pkgconfig(smartcard-service) BuildRequires: pkgconfig(pkgmgr) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(capi-appfw-package-manager) BuildRequires: pkgconfig(capi-web-url-download) BuildRequires: pkgconfig(push) BuildRequires: pkgconfig(notification) -BuildRequires: pkgconfig(osp-appfw) +BuildRequires: pkgconfig(message-port) +BuildRequires: pkgconfig(sync-agent) BuildRequires: expat-devel BuildRequires: cmake BuildRequires: gettext-devel +BuildRequires: boost-devel +BuildRequires: boost-thread +BuildRequires: boost-system +BuildRequires: boost-filesystem %description JavaScript plugins for WebRuntime +%package devel +Summary: Wrt-plugin-tizen development headers +Group: Development/Libraries +Requires: %{name} = %{version} + +%description devel +Wrt-plugin-tizen development headers %prep %setup -q @@ -72,7 +88,7 @@ JavaScript plugins for WebRuntime export LDFLAGS+="-Wl,--rpath=%{PREFIX} -Wl,--as-needed" -cmake . -DCMAKE_INSTALL_PREFIX=%{PREFIX} -DDPL_LOG="ON" +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DDPL_LOG="ON" make %{?jobs:-j%jobs} @@ -90,3 +106,6 @@ rm -rf %{buildroot} %{_libdir}/wrt-plugins/* /usr/etc/tizen-apis/* +%files devel +%{_includedir}/* +%{_libdir}/pkgconfig/* diff --git a/pkgconfigs/wrt-plugins-tizen-alarm.pc.in b/pkgconfigs/wrt-plugins-tizen-alarm.pc.in new file mode 100755 index 0000000..3109f46 --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-alarm.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=alarm +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: capi-appfw-application +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-application.pc.in b/pkgconfigs/wrt-plugins-tizen-application.pc.in new file mode 100755 index 0000000..0ac3dc6 --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-application.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=application +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: capi-appfw-app-manager capi-appfw-application capi-appfw-package-manager pkgmgr pkgmgr-info +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-bluetooth.pc.in b/pkgconfigs/wrt-plugins-tizen-bluetooth.pc.in new file mode 100755 index 0000000..d76b580 --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-bluetooth.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=bluetooth +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: capi-network-bluetooth +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-bookmark.pc.in b/pkgconfigs/wrt-plugins-tizen-bookmark.pc.in new file mode 100755 index 0000000..72b9e1e --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-bookmark.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=bookmark +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: capi-web-favorites +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-calendar.pc.in b/pkgconfigs/wrt-plugins-tizen-calendar.pc.in new file mode 100755 index 0000000..664e822 --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-calendar.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=calendar +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: calendar-service2 icu-i18n +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl +Cflags: -I${includedir}/${module_name} diff --git a/pkgconfigs/wrt-plugins-tizen-callhistory.pc.in b/pkgconfigs/wrt-plugins-tizen-callhistory.pc.in new file mode 100755 index 0000000..6325dfb --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-callhistory.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=callhistroy +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: contacts-service2 glib-2.0 libpcrecpp +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-common.pc.in b/pkgconfigs/wrt-plugins-tizen-common.pc.in new file mode 100755 index 0000000..567eecf --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-common.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=common +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-contact.pc.in b/pkgconfigs/wrt-plugins-tizen-contact.pc.in new file mode 100755 index 0000000..758eb7a --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-contact.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=contact +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: contacts-service2 libpcrecpp capi-web-url-download +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-content.pc.in b/pkgconfigs/wrt-plugins-tizen-content.pc.in new file mode 100755 index 0000000..b0a3847 --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-content.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=content +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: capi-content-media-content capi-media-metadata-extractor +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-datacontrol.pc.in b/pkgconfigs/wrt-plugins-tizen-datacontrol.pc.in new file mode 100755 index 0000000..d7cf242 --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-datacontrol.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=datacontrol +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: capi-appfw-application appsvc pkgmgr +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-datasync.pc.in b/pkgconfigs/wrt-plugins-tizen-datasync.pc.in new file mode 100644 index 0000000..582af64 --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-datasync.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=datasync +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: sync-agent +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl +Cflags: -I${includedir}/${module_name} diff --git a/pkgconfigs/wrt-plugins-tizen-download.pc.in b/pkgconfigs/wrt-plugins-tizen-download.pc.in new file mode 100755 index 0000000..311a1ef --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-download.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=download +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: capi-web-url-download +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-imp +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-filesystem.pc.in b/pkgconfigs/wrt-plugins-tizen-filesystem.pc.in new file mode 100755 index 0000000..106f82f --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-filesystem.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=log +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-log.pc.in b/pkgconfigs/wrt-plugins-tizen-log.pc.in new file mode 100755 index 0000000..d9b5e9c --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-log.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=application +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: capi-appfw-app-manager capi-appfw-application capi-appfw-package-manager wrt-deviceapis-commons wrt-deviceapis-commons-javascript pkgmgr pkgmgr-info +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-messageport.pc.in b/pkgconfigs/wrt-plugins-tizen-messageport.pc.in new file mode 100755 index 0000000..486097f --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-messageport.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=messageport +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: osp-appfw capi-appfw-app-manager +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-messaging.pc.in b/pkgconfigs/wrt-plugins-tizen-messaging.pc.in new file mode 100755 index 0000000..52c8807 --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-messaging.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=messaging +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: msg-service email-service dbus-1 +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-networkbearerselection.pc.in b/pkgconfigs/wrt-plugins-tizen-networkbearerselection.pc.in new file mode 100755 index 0000000..90393d7 --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-networkbearerselection.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=networkbearerselection +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: capi-network-connection +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-nfc.pc.in b/pkgconfigs/wrt-plugins-tizen-nfc.pc.in new file mode 100755 index 0000000..561a246 --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-nfc.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=nfc +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: capi-network-nfc +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-notification.pc.in b/pkgconfigs/wrt-plugins-tizen-notification.pc.in new file mode 100755 index 0000000..2868c81 --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-notification.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=notification +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: capi-appfw-application +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-package.pc.in b/pkgconfigs/wrt-plugins-tizen-package.pc.in new file mode 100755 index 0000000..88fe80f --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-package.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=package +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: capi-appfw-app-manager capi-appfw-package-manager wrt-deviceapis-commons wrt-deviceapis-commons-javascript pkgmgr pkgmgr-info +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-power.pc.in b/pkgconfigs/wrt-plugins-tizen-power.pc.in new file mode 100755 index 0000000..d0961f7 --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-power.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=power +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: capi-system-power pmapi capi-system-device +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-push.pc.in b/pkgconfigs/wrt-plugins-tizen-push.pc.in new file mode 100755 index 0000000..a73a959 --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-push.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=push +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: push capi-appfw-application +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-secureelement.pc.in b/pkgconfigs/wrt-plugins-tizen-secureelement.pc.in new file mode 100644 index 0000000..8fc93e7 --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-secureelement.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=secureelement +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: smartcard-service smartcard-service-common +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl +Cflags: -I${includedir}/${module_name} diff --git a/pkgconfigs/wrt-plugins-tizen-systeminfo.pc.in b/pkgconfigs/wrt-plugins-tizen-systeminfo.pc.in new file mode 100755 index 0000000..fdec6fe --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-systeminfo.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=systeminfo +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: capi-telephony-sim capi-network-connection capi-system-info capi-system-runtime-info capi-system-sensor sensor +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-systemsetting.pc.in b/pkgconfigs/wrt-plugins-tizen-systemsetting.pc.in new file mode 100755 index 0000000..690e4c2 --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-systemsetting.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=systemsetting +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: capi-system-system-settings +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-timeutil.pc.in b/pkgconfigs/wrt-plugins-tizen-timeutil.pc.in new file mode 100755 index 0000000..11dbf4d --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-timeutil.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=timeutil +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: icu-i18n icu-io icu-le icu-lx icu-uc +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-tizen.pc.in b/pkgconfigs/wrt-plugins-tizen-tizen.pc.in new file mode 100755 index 0000000..8b5303c --- /dev/null +++ b/pkgconfigs/wrt-plugins-tizen-tizen.pc.in @@ -0,0 +1,13 @@ +prefix=/usr +project_name=@CMAKE_PROJECT_NAME@ +module_name=tizen +exec_prefix=${prefix} +libdir=${prefix}/lib/wrt-plugins/tizen-${module_name} +includedir=${prefix}/include/${project_name} + +Name: wrt-plugins-tizen-${module_name} +Description: wrt-plugins-tizen-${module_name} +Version: @CMAKE_PROJECT_VERSION@ +Requires: wrt-plugins-plugin-manager +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config +Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/src/.project b/src/.project new file mode 100644 index 0000000..71966cf --- /dev/null +++ b/src/.project @@ -0,0 +1,11 @@ + + + wrt-plugins-tizen + + + + + + + + diff --git a/src/Alarm/AlarmAbsolute.cpp b/src/Alarm/AlarmAbsolute.cpp new file mode 100755 index 0000000..5816523 --- /dev/null +++ b/src/Alarm/AlarmAbsolute.cpp @@ -0,0 +1,125 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#include "AlarmAbsolute.h" +#include "alarm_common.h" +#include +#include +#include + +namespace DeviceAPI { +namespace Alarm { + +AlarmAbsolute::AlarmAbsolute() +{ + m_isRecurrence = false; + service_create(&m_service_handle); + service_add_extra_data(m_service_handle, ALARM_TYPE_KEY, ALARM_TYPE_ABSOLUTE_VALUE); + service_add_extra_data(m_service_handle, ALARM_ALSOLUTE_RECURRENCE_TYPE_KEY, ALARM_ALSOLUTE_RECURRENCE_TYPE_NONE); + m_recurrenceType = AbsoluteRecurrence::NoRecurrence; + m_id = -1; +} + +AlarmAbsolute::AlarmAbsolute(service_h handle) +{ + service_clone(&m_service_handle, handle); + m_id = -1; +} + +AlarmAbsolute::~AlarmAbsolute() +{ + service_destroy(m_service_handle); +} + +int AlarmAbsolute::getId() const +{ + return m_id; +} + +void AlarmAbsolute::setId(const int id) +{ + m_id = id; +} + +bool AlarmAbsolute::isRecurrence() +{ + return m_isRecurrence; +} + +void AlarmAbsolute::setIsRecurrence(bool value) +{ + m_isRecurrence = value; +} + +void AlarmAbsolute::setDate(struct tm date) +{ + char strDate[19]; + m_date = date; + + snprintf(strDate, sizeof(strDate), "%d %d %d %d %d %d",m_date.tm_year, m_date.tm_mon, + m_date.tm_mday, m_date.tm_hour, m_date.tm_min, m_date.tm_sec); + + LogInfo("setDate encrypted string = " << strDate); + service_add_extra_data(m_service_handle, ALARM_ALSOLUTE_DATE_KEY, strDate); + + LogInfo("AlarmAbsolute Date = " << " Sec: " << m_date.tm_sec << ", Min: "<< m_date.tm_min + << ", Hour:" << m_date.tm_hour << ", Day: " << m_date.tm_mday << ", MON: " << m_date.tm_mon + << ", Year: " << m_date.tm_year); +} + +struct tm AlarmAbsolute::getDate() +{ + return m_date; +} + +void AlarmAbsolute::setInterval(int interval) +{ + m_interval = interval; + m_recurrenceType = AbsoluteRecurrence::Interval; + service_add_extra_data(m_service_handle, ALARM_ALSOLUTE_RECURRENCE_TYPE_KEY, ALARM_ALSOLUTE_RECURRENCE_TYPE_INTERVAL); +} + +int AlarmAbsolute::getInterval() +{ + return m_interval; +} + +void AlarmAbsolute::setByDayRecurrence(std::vector &daysOfTheWeek) +{ + m_recurrenceType = AbsoluteRecurrence::ByDayValue; + m_daysOfTheWeek = daysOfTheWeek; + service_add_extra_data(m_service_handle, ALARM_ALSOLUTE_RECURRENCE_TYPE_KEY, ALARM_ALSOLUTE_RECURRENCE_TYPE_BYDAYVALUE); +} + +std::vector AlarmAbsolute::getByDayRecurrence() +{ + return m_daysOfTheWeek; +} + +AbsoluteRecurrence::Type AlarmAbsolute::getRecurrenceType() +{ + return m_recurrenceType; +} + +service_h AlarmAbsolute::getService() { + return m_service_handle; +} + +} +} + diff --git a/src/Alarm/AlarmAbsolute.h b/src/Alarm/AlarmAbsolute.h new file mode 100755 index 0000000..bd9a7b0 --- /dev/null +++ b/src/Alarm/AlarmAbsolute.h @@ -0,0 +1,70 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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_ALARMABSOLUTE_H_ +#define TIZENAPIS_API_ALARMABSOLUTE_H_ + +#include +#include +#include +#include +#include +#include +#include "alarm_common.h" + +namespace DeviceAPI { +namespace Alarm { + +class AlarmAbsolute; +typedef DPL::SharedPtr AlarmAbsolutePtr; +typedef std::vector AlarmAbsoluteArrayPtr; + +class AlarmAbsolute +{ + public: + AlarmAbsolute(); + AlarmAbsolute(service_h handle); + ~AlarmAbsolute(); + int getId() const; + void setId(const int id); + void setDate(struct tm date); + struct tm getDate(); + void setInterval(int interval); + int getInterval(); + bool isRecurrence(); + void setIsRecurrence(bool value); + void setByDayRecurrence(std::vector &daysOfTheWeek); + std::vector getByDayRecurrence(); + AbsoluteRecurrence::Type getRecurrenceType(); + service_h getService(); + + private: + int m_id; + struct tm m_date; + bool m_isRecurrence; + int m_interval; + service_h m_service_handle; + std::vector m_daysOfTheWeek; + AbsoluteRecurrence::Type m_recurrenceType; + +}; + +} +} + +#endif diff --git a/src/Alarm/AlarmConverter.cpp b/src/Alarm/AlarmConverter.cpp new file mode 100755 index 0000000..6aaade4 --- /dev/null +++ b/src/Alarm/AlarmConverter.cpp @@ -0,0 +1,267 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include "AlarmConverter.h" +#include "JSAlarmAbsolute.h" +#include "AlarmAbsolute.h" +#include "JSAlarmRelative.h" +#include "AlarmRelative.h" + +namespace DeviceAPI { +namespace Alarm { + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; + +AlarmConverter::AlarmConverter(JSContextRef context) : WrtDeviceApis::CommonsJavaScript::Converter(context) +{ + +} + +AlarmConverter::~AlarmConverter() +{ + +} + +int AlarmConverter::toNativeAlarmValue(std::vector daysOfTheWeek) +{ + int nativeValue = 0; + + for( unsigned int i=0; i AlarmConverter::convertFlagToDaysOfTheWeek(int byDayValue) +{ + std::vector daysOfTheWeek; + + if(byDayValue & ALARM_WEEK_FLAG_SUNDAY) + daysOfTheWeek.push_back("SU"); + if(byDayValue & ALARM_WEEK_FLAG_MONDAY) + daysOfTheWeek.push_back("MO"); + if(byDayValue & ALARM_WEEK_FLAG_TUESDAY) + daysOfTheWeek.push_back("TU"); + if(byDayValue & ALARM_WEEK_FLAG_WEDNESDAY) + daysOfTheWeek.push_back("WE"); + if(byDayValue & ALARM_WEEK_FLAG_THURSDAY) + daysOfTheWeek.push_back("TH"); + if(byDayValue & ALARM_WEEK_FLAG_FRIDAY) + daysOfTheWeek.push_back("FR"); + if(byDayValue & ALARM_WEEK_FLAG_SATURDAY) + daysOfTheWeek.push_back("SA"); + + return daysOfTheWeek; +} + +service_h AlarmConverter::toService(std::string id) +{ + service_h service; + service_create(&service); + LogError("[ILOVEFILM] Enter AlarmConverter toService std package = " << id.c_str()); + + service_set_operation(service, SERVICE_OPERATION_DEFAULT); + service_set_package(service, id.c_str()); + return service; +} +service_h AlarmConverter::toService(std::string id, std::string page) +{ + service_h service; + service_create(&service); + + LogError("[ILOVEFILM] Enter AlarmConverter toService std package = " << id.c_str()); + + service_set_operation(service, SERVICE_OPERATION_DEFAULT); + service_set_package(service, id.c_str()); + return service; +} + +bool AlarmConverter::toAlarmAbsolutePtr(int id, service_h handle, AlarmAbsolutePtr privateData) +{ + char* dateString; + char* alarmType; + struct tm date; + memset(&date, 0, sizeof(tm)); + int error = ALARM_ERROR_NONE; + + LogInfo("Enter AlarmConverter.toAlarmAbsolutePtr"); + + error = service_get_extra_data(handle, ALARM_ALSOLUTE_DATE_KEY, &dateString); + + LogInfo("Date Strng = " << dateString); + if(error != SERVICE_ERROR_NONE) + { + LogError("Fail to get AlarmDelay"); + return false; + } + sscanf(dateString, "%d %d %d %d %d %d", &date.tm_year, &date.tm_mon, + &date.tm_mday, &date.tm_hour, &date.tm_min, &date.tm_sec); + mktime(&date); + + LogInfo("Converter AlarmAbsolute Date = " << " Sec: " << date.tm_sec << ", Min: "<< date.tm_min + << ", Hour: " << date.tm_hour << ", Day: " << date.tm_mday << ", MON: " << date.tm_mon + << ", Year: " << date.tm_year); + + service_get_extra_data(handle, ALARM_ALSOLUTE_RECURRENCE_TYPE_KEY, &alarmType); + + if(!strcmp(alarmType, ALARM_ALSOLUTE_RECURRENCE_TYPE_INTERVAL)) { + int interval = 0; + alarm_get_scheduled_period(id, &interval); + LogInfo("interval type alarm: "<setInterval(interval); + } else if(!strcmp(alarmType, ALARM_ALSOLUTE_RECURRENCE_TYPE_BYDAYVALUE)) { + int byDayValue =0; + error = alarm_get_scheduled_recurrence_week_flag(id, &byDayValue); + LogInfo("daysOfWeek type alarm: "<0) { + std::vector result; + result = convertFlagToDaysOfTheWeek(byDayValue); + privateData->setByDayRecurrence(result); + } else { + LogInfo("Can't get the recurrence week flag."); + } + } + + privateData->setId(id); + privateData->setDate(date); + + return true; +} + +bool AlarmConverter::toAlarmRelativePtr(int id, service_h handle, AlarmRelativePtr privateData) +{ + int interval = 0; + char* delayString; + int delay; + + int error = ALARM_ERROR_NONE; + error = alarm_get_scheduled_period(id, &interval); + if(error != ALARM_ERROR_NONE) { + interval = 0; + } + + error = service_get_extra_data(handle, ALARM_RELATIVE_DELAY_KEY, &delayString); + if(error != SERVICE_ERROR_NONE) + { + LogError("Fail to get AlarmDelay"); + return false; + } + delay = atoi(delayString); + free(delayString); + + privateData->setId(id); + privateData->setDelay(delay); + privateData->setPeriod(interval); + + return true; +} + +int AlarmConverter::toNativeInterval(std::string freq, std::string interval) +{ + int freqInSecond = 0; + int intervalValue = toInt(interval); + + if (!freq.compare(ALARM_PROPERTY_MINUTELY_RECURRENCE)) + freqInSecond = 60; + else if (!freq.compare(ALARM_PROPERTY_HOURLY_RECURRENCE)) + freqInSecond = 3600; + else if (!freq.compare(ALARM_PROPERTY_DAILY_RECURRENCE)) + freqInSecond = 3600*24; + else if (!freq.compare(ALARM_PROPERTY_WEEKLY_RECURRENCE)) + freqInSecond = 3600 * 24 * 7; + + return freqInSecond * intervalValue; +} + +bool AlarmConverter::toAlarmService(service_h service, DeviceAPI::Application::ApplicationControlPtr appservice) + { + if (appservice->getOperation().compare("") != 0) { + LogDebug("operation is "<getOperation()); + service_set_operation(service, appservice->getOperation().c_str() ); + } else { + LogDebug("Error. operation is madatory field. cannot be null"); + return false; + } + + if (appservice->getUri().compare("") != 0) { + LogDebug("uri is not null"); + service_set_uri(service, appservice->getUri().c_str() ); + } + + if (appservice->getMime().compare("") != 0) { + LogDebug("mime is "<getMime()); + service_set_mime(service, appservice->getMime().c_str() ); + } + + LogDebug(">>> appservice->getAppControlDataArray"); + std::vector appControlDataArray = appservice->getAppControlDataArray(); + + if (!appControlDataArray.empty()) { + std::string key; + const char** arr = NULL; + LogDebug("serviceDataArray.size() : "<getKey(); + if (key.empty()) { + return false; + } + std::vector valueArray = appControlDataArray.at(i)->getValue(); + size_t size = valueArray.size(); + + arr = (const char**)calloc(sizeof(char*), size); + + for (size_t j = 0; j < size; j++) { + arr[j] = valueArray.at(j).c_str(); + } + + service_add_extra_data_array(service, key.c_str(), arr, size); + + if (arr) + free(arr); + } + } + return true; +} + +} +} + diff --git a/src/Alarm/AlarmConverter.h b/src/Alarm/AlarmConverter.h new file mode 100755 index 0000000..f5439ca --- /dev/null +++ b/src/Alarm/AlarmConverter.h @@ -0,0 +1,66 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _JS_TIZEN_ALARM_CONVERTER_H_ +#define _JS_TIZEN_ALARM_CONVERTER_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "JSAlarmAbsolute.h" +#include "AlarmAbsolute.h" +#include "JSAlarmRelative.h" +#include "AlarmRelative.h" + +namespace DeviceAPI { +namespace Alarm { + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; + +class AlarmConverter : public WrtDeviceApis::CommonsJavaScript::Converter +{ +public: + using Converter::toJSValueRef; + explicit AlarmConverter(JSContextRef context); + virtual ~AlarmConverter(); + + int toNativeAlarmValue(std::vector daysOfTheWeek); + std::vector convertFlagToDaysOfTheWeek(int byDayValue); + int toNativeValue(int interval); + std::vector toPrivateValue(int byDayValue); + service_h toService(std::string id); + service_h toService(std::string id, std::string page); + bool toAlarmAbsolutePtr(int id, service_h handle, AlarmAbsolutePtr ptr); + bool toAlarmRelativePtr(int id, service_h handle, AlarmRelativePtr ptr); + int toNativeInterval(std::string freq, std::string interval); + bool toAlarmService(service_h alarm_service, DeviceAPI::Application::ApplicationControlPtr ptr); +}; + +typedef ConverterFactory AlarmConverterFactory; + +} +} + +#endif /* _JS_TIZEN_ALARM_CONVERTER_H_ */ diff --git a/src/Alarm/AlarmRelative.cpp b/src/Alarm/AlarmRelative.cpp new file mode 100755 index 0000000..b8a497f --- /dev/null +++ b/src/Alarm/AlarmRelative.cpp @@ -0,0 +1,101 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#include "AlarmRelative.h" +#include "alarm_common.h" +#include +#include + +namespace DeviceAPI { +namespace Alarm { + +AlarmRelative::AlarmRelative() +{ + m_isRecurrence = false; + service_create(&m_service_handle); + service_add_extra_data(m_service_handle, ALARM_TYPE_KEY, ALARM_TYPE_RELATIVE_VALUE); + m_Period = 0; + m_id = -1; +} + +AlarmRelative::AlarmRelative(service_h handle) +{ + service_clone(&m_service_handle, handle); + m_Period = 0; + m_id = -1; +} + +AlarmRelative::~AlarmRelative() +{ + service_destroy(m_service_handle); +} + +int AlarmRelative::getId() const +{ + return m_id; +} + +void AlarmRelative::setId(const int id) +{ + m_id = id; +} + +bool AlarmRelative::isRecurrence() +{ + return m_isRecurrence; +} + +void AlarmRelative::setIsRecurrence(bool value) +{ + m_isRecurrence = value; +} + +void AlarmRelative::setDelay(int delay) +{ + char result[12]; + snprintf(result, sizeof(result), "%d", delay); + service_add_extra_data(m_service_handle, ALARM_RELATIVE_DELAY_KEY, result); + m_delay = delay; +} + +int AlarmRelative::getDelay() +{ + return m_delay; +} + +void AlarmRelative::setPeriod(int value) +{ + LogInfo("Param Peroid = " << value); + m_Period = value; + LogInfo("Setted Period = " << m_Period); +} + +int AlarmRelative::getPeriod() +{ + LogInfo("return Period = " << m_Period); + return m_Period; +} + +service_h AlarmRelative::getService() +{ + return m_service_handle; +} + +} +} + diff --git a/src/Alarm/AlarmRelative.h b/src/Alarm/AlarmRelative.h new file mode 100755 index 0000000..e730e67 --- /dev/null +++ b/src/Alarm/AlarmRelative.h @@ -0,0 +1,71 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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_ALARMRELATIVE_H_ +#define TIZENAPIS_API_ALARMRELATIVE_H_ + +#include +#include +#include +#include +#include +#include +#include "alarm_common.h" + +namespace DeviceAPI { +namespace Alarm { + +class AlarmRelative; +typedef DPL::SharedPtr AlarmRelativePtr; +typedef std::vector AlarmRelativeArrayPtr; + +class AlarmRelative +{ + public: + typedef enum { + ALARM_TYPE_DELAY, + ALARM_TYPE_DATE, + ALARM_TYPE_INVALID, + } alarm_type_e; + + AlarmRelative(); + AlarmRelative(service_h handle); + ~AlarmRelative(); + void setIsRecurrence(bool value); + int getId() const; + void setId(const int id); + void setDelay(int delay); + int getDelay(); + bool isRecurrence(); + void setPeriod(int value); + int getPeriod(); + service_h getService(); + + private: + int m_id; + int m_delay; + bool m_isRecurrence; + int m_Period; + service_h m_service_handle; + +}; + +} +} + +#endif diff --git a/src/Alarm/CMakeLists.txt b/src/Alarm/CMakeLists.txt new file mode 100755 index 0000000..3465d8f --- /dev/null +++ b/src/Alarm/CMakeLists.txt @@ -0,0 +1,58 @@ +SET(TARGET_NAME ${alarm_target}) +SET(DESTINATION_NAME ${alarm_dest}) +SET(TARGET_IMPL_NAME ${alarm_impl}) + +PKG_SEARCH_MODULE(application REQUIRED capi-appfw-application) + +INCLUDE_DIRECTORIES( + ${application_INCLUDE_DIRS} + ${TOP}/Common + ${TOP}/Application + ${TOP}/TimeUtil +) + +SET(CMAKE_INSTALL_RPATH + ${CMAKE_INSTALL_RPATH} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${application_dest} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timze_dest} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME} +) + +SET(SRCS_IMPL + AlarmAbsolute.cpp + AlarmConverter.cpp + AlarmRelative.cpp + JSAlarmAbsolute.cpp + JSAlarmManager.cpp + JSAlarmRelative.cpp +) + +ADD_LIBRARY(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL}) + +TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME} + ${LIBS_COMMON} + ${application_LIBRARIES} +) + +SET(SRCS + plugin_config.cpp + plugin_initializer.cpp +) + +ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS}) + +TARGET_LINK_LIBRARIES(${TARGET_NAME} + ${TARGET_IMPL_NAME} + ${application_impl} + ${application_config} + ${tizen_impl} + ${timeutil_impl} + ) + +INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) +INSTALL( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/alarm + FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE +) \ No newline at end of file diff --git a/src/Alarm/JSAlarmAbsolute.cpp b/src/Alarm/JSAlarmAbsolute.cpp new file mode 100755 index 0000000..23d1e2f --- /dev/null +++ b/src/Alarm/JSAlarmAbsolute.cpp @@ -0,0 +1,385 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include "AlarmAbsolute.h" +#include "AlarmConverter.h" +#include +#include + +#include "plugin_config.h" +#include "JSAlarmAbsolute.h" +#include "JSAlarmManager.h" + +namespace DeviceAPI { +namespace Alarm { + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + +JSClassRef JSAlarmAbsolute::m_jsClassRef = NULL; + +JSClassDefinition JSAlarmAbsolute::m_jsClassInfo = { + 0, + kJSClassAttributeNone, + TIZEN_ALARM_ABSOLUTE_INTERFACE, + NULL, + m_property, + m_function, + initialize, + finalize, + NULL, //hasProperty, + NULL, //getProperty, + NULL, //setProperty, + NULL, //deleteProperty,Geolocation + NULL, //getPropertyNames, + NULL, + constructor, // constructor + hasInstance, + NULL +}; + +JSStaticFunction JSAlarmAbsolute::m_function[] = { + { ALARM_FUNCTION_API_GET_NEXT_SCHEDULED_DATE, JSAlarmAbsolute::getNextScheduledDate, kJSPropertyAttributeNone }, + { 0, 0, 0 } +}; + +JSStaticValue JSAlarmAbsolute::m_property[] = { + { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_ID, getId, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_DATE, getDate, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_PERIOD, getInterval, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_DAYSOFTHEWEEK, getDaysOfTheWeek, NULL, kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +const JSClassRef JSAlarmAbsolute::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_jsClassInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSAlarmAbsolute::getClassInfo() +{ + return &m_jsClassInfo; +} + +void JSAlarmAbsolute::initialize(JSContextRef context, JSObjectRef object) +{ +} +void JSAlarmAbsolute::finalize(JSObjectRef object) +{ + JSAlarmAbsolutePriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + LogError("Private object is null"); + } + delete priv; + +} + +bool JSAlarmAbsolute::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) +{ + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + +JSObjectRef JSAlarmAbsolute::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + struct tm date; + AlarmConverter converter(ctx); + Validator validator(ctx); + + Try { + AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute()); + + if(argumentCount < 1) + { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + if(!validator.isDate(arguments[0])) + { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + + date = converter.toDateTm(arguments[0]); + privateData->setDate(date); + + if(argumentCount >= 2) + { + if(JSIsArrayValue(ctx, arguments[1])) { + std::vector daysOfTheWeek = converter.toVectorOfStrings(arguments[1]); + if(daysOfTheWeek.size() >0) { + privateData->setByDayRecurrence(daysOfTheWeek); + } + } else { + int interval = converter.toInt(arguments[1]); + if(interval <0) { + ThrowMsg(InvalidArgumentException, "Invalid period value."); + } + privateData->setInterval(interval); + } + } + + return JSValueToObject(ctx, createJSObject(ctx, privateData), exception); + } Catch(ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } Catch(UnsupportedException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } Catch(InvalidArgumentException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } Catch(Exception) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return NULL; +} + +AlarmAbsolutePtr JSAlarmAbsolute::getPrivData(JSObjectRef object) +{ + JSAlarmAbsolutePriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(ConversionException, "Object is null."); + } + AlarmAbsolutePtr result = priv->getObject(); + if (!result) { + ThrowMsg(ConversionException, "Private object is null."); + } + return result; +} + +JSValueRef JSAlarmAbsolute::createJSObject(JSContextRef context, const int id) +{ + AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute()); + privateData->setId(id); + + JSAlarmAbsolutePriv *priv = new JSAlarmAbsolutePriv(context, privateData); + if (!priv) { + ThrowMsg(ConversionException, "Object is null."); + } + return JSObjectMake(context, getClassRef(), static_cast(priv)); +} + +JSValueRef JSAlarmAbsolute::createJSObject(JSContextRef context, AlarmAbsolutePtr privateData) +{ + JSAlarmAbsolutePriv *priv = new JSAlarmAbsolutePriv(context, privateData); + if (!priv) { + ThrowMsg(ConversionException, "Object is null."); + } + return JSObjectMake(context, getClassRef(), static_cast(priv)); +} + +JSValueRef JSAlarmAbsolute::createJSObject(JSContextRef context, struct tm date, int interval) +{ + AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute()); + privateData->setDate(date); + + JSAlarmAbsolutePriv *priv = new JSAlarmAbsolutePriv(context, privateData); + if (!priv) { + ThrowMsg(ConversionException, "Object is null."); + } + return JSObjectMake(context, getClassRef(), static_cast(priv)); +} + +JSValueRef JSAlarmAbsolute::createJSObject(JSContextRef context, struct tm date) +{ + AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute()); + privateData->setDate(date); + + JSAlarmAbsolutePriv *priv = new JSAlarmAbsolutePriv(context, privateData); + if (!priv) { + ThrowMsg(ConversionException, "Object is null."); + } + return JSObjectMake(context, getClassRef(), static_cast(priv)); +} + +JSValueRef JSAlarmAbsolute::getNextScheduledDate( JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) +{ + LogError("GContext = " << DeviceAPI::Alarm::JSAlarmManager::gContext); + + struct tm date; + Converter converter(ctx); + int id; + Try + { + AlarmAbsolutePtr privateData = getPrivData(thisObject); + id = privateData->getId(); + int err = alarm_get_scheduled_date(id, &date); + JSValueRef result = converter.toJSValueRef(date); + + if(err != ALARM_ERROR_NONE) + { + return JSValueMakeNull(ctx); + } + return result; + } Catch(ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } Catch(UnsupportedException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } Catch(InvalidArgumentException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } Catch(Exception) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +JSValueRef JSAlarmAbsolute::getDate(JSContextRef ctx, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Converter converter(ctx); + struct tm date; + Try + { + AlarmAbsolutePtr privateData = getPrivData(object); + date = privateData->getDate(); + LogInfo("JSAlarmAbsolute Date = " << " Sec : " << date.tm_sec << " Min : "<< date.tm_min + << " Hour" << date.tm_hour << "Day : " << date.tm_mday << " MON : " << date.tm_mon + << " Year : " << date.tm_year); + + JSValueRef args[6]; + args[0] = JSValueMakeNumber(ctx, date.tm_year + 1900); + args[1] = JSValueMakeNumber(ctx, date.tm_mon); + args[2] = JSValueMakeNumber(ctx, date.tm_mday); + args[3] = JSValueMakeNumber(ctx, date.tm_hour); + args[4] = JSValueMakeNumber(ctx, date.tm_min); + args[5] = JSValueMakeNumber(ctx, date.tm_sec); + + JSObjectRef result = JSObjectMakeDate(ctx, 6, args, exception); + return result; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(ctx); +} + +JSValueRef JSAlarmAbsolute::getId(JSContextRef ctx, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Converter converter(ctx); + int id; + Try + { + AlarmAbsolutePtr privateData = getPrivData(object); + Converter converter(ctx); + id = privateData->getId(); + if(id >= 0) { + std::string strId = converter.toString(id); + return converter.toJSValueRef(strId); + } else { + return JSValueMakeNull(ctx); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(ctx); +} + +JSValueRef JSAlarmAbsolute::getInterval(JSContextRef ctx, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Converter converter(ctx); + int interval; + Try + { + AlarmAbsolutePtr privateData = getPrivData(object); + AbsoluteRecurrence::Type alarmType = privateData->getRecurrenceType(); + + if(alarmType == AbsoluteRecurrence::Interval) { + interval = privateData->getInterval(); + return converter.toJSValueRef(interval); + } else { + return JSValueMakeNull(ctx); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(ctx); +} + +JSValueRef JSAlarmAbsolute::getDaysOfTheWeek(JSContextRef ctx, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Converter converter(ctx); + + Try { + JSObjectRef jsResult = JSCreateArrayObject(ctx, 0, NULL); + AlarmAbsolutePtr privateData = getPrivData(object); + std::vector daysOfTheWeek = privateData->getByDayRecurrence(); + + if(daysOfTheWeek.size() >0) + { + if (jsResult == NULL) + { + ThrowMsg(NullPointerException, "Could not create js array object"); + } + + for(unsigned int i=0; i +#include +#include +#include "AlarmAbsolute.h" + +namespace DeviceAPI { +namespace Alarm { + +#define TIZEN_ALARM_ABSOLUTE_INTERFACE "AlarmAbsolute" + +#define TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_ID "id" +#define TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_DATE "date" +#define TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_PERIOD "period" +#define TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_DAYSOFTHEWEEK "daysOfTheWeek" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject JSAlarmAbsolutePriv; + +class JSAlarmAbsolute { +public: + static const JSClassDefinition* getClassInfo(); + static const JSClassRef getClassRef(); + static JSValueRef createJSObject(JSContextRef context, const int id); + static JSValueRef createJSObject(JSContextRef context, AlarmAbsolutePtr privateData); + static JSValueRef createJSObject(JSContextRef context, struct tm date, int interval); + static JSValueRef createJSObject(JSContextRef context, struct tm date); + static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + + +protected: + static void initialize(JSContextRef context, JSObjectRef object); + static void finalize(JSObjectRef object); + static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); + static JSValueRef getNextScheduledDate(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +private: + static AlarmAbsolutePtr getPrivData(JSObjectRef object); + + static JSValueRef getDate(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static JSValueRef getId(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static JSValueRef getInterval(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static JSValueRef getDaysOfTheWeek(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + + static JSClassDefinition m_jsClassInfo; + static JSClassRef m_jsClassRef; + static JSStaticFunction m_function[]; + static JSStaticValue m_property[]; +}; + +}// Alarm +} // TizenApis + +#endif diff --git a/src/Alarm/JSAlarmManager.cpp b/src/Alarm/JSAlarmManager.cpp new file mode 100755 index 0000000..d662dbd --- /dev/null +++ b/src/Alarm/JSAlarmManager.cpp @@ -0,0 +1,585 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "plugin_config.h" +#include "AlarmConverter.h" +#include "JSAlarmAbsolute.h" +#include "AlarmAbsolute.h" +#include "JSAlarmRelative.h" +#include "AlarmRelative.h" +#include "JSAlarmManager.h" + +namespace DeviceAPI { +namespace Alarm { + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + +static bool alarm_iterate_callback(int alarm_id, void *user_data) +{ + std::vector *alarmIds = reinterpret_cast*>(user_data); + + alarmIds->push_back(alarm_id); + return true; +} + +JSClassRef JSAlarmManager::m_jsClassRef = NULL; + +JSClassDefinition JSAlarmManager::m_jsClassInfo = { + 0, + kJSClassAttributeNone, + TIZEN_ALARM_INTERFACE, + NULL, + m_property, + m_function, + initialize, + finalize, + NULL, //hasProperty, + NULL, //getProperty, + NULL, //setProperty, + NULL, //deleteProperty,Geolocation + NULL, //getPropertyNames, + NULL, + NULL, // constructor + hasInstance, + NULL +}; + +JSStaticFunction JSAlarmManager::m_function[] = { + { ALARM_FUNCTION_API_ADD, JSAlarmManager::add,kJSPropertyAttributeNone }, + { ALARM_FUNCTION_API_REMOVE, JSAlarmManager::remove,kJSPropertyAttributeNone }, + { ALARM_FUNCTION_API_REMOVE_ALL, JSAlarmManager::removeAll,kJSPropertyAttributeNone }, + { ALARM_FUNCTION_API_GET_ALL, JSAlarmManager::getAll,kJSPropertyAttributeNone }, + { ALARM_FUNCTION_API_GET, JSAlarmManager::get,kJSPropertyAttributeNone }, + { 0, 0, 0 } +}; + +JSStaticValue JSAlarmManager::m_property[] = { + { TIZEN_ALARM_CONSTANT_PERIOD_MINUTE, getMin, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_ALARM_CONSTANT_PERIOD_HOUR, getHour, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_ALARM_CONSTANT_PERIOD_DAY, getDay, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_ALARM_CONSTANT_PERIOD_WEEK, getWeek, NULL, kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +const JSClassRef JSAlarmManager::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_jsClassInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSAlarmManager::getClassInfo() +{ + return &m_jsClassInfo; +} + +JSContextRef JSAlarmManager::gContext = NULL; + +void JSAlarmManager::initialize(JSContextRef ctx, JSObjectRef object) +{ + gContext = ctx; + LogInfo("GContext = " << gContext); +} + +void JSAlarmManager::finalize(JSObjectRef object) +{ +} + +bool JSAlarmManager::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) { + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + +JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + service_h service; + struct tm startDate; + int delay = 0; + int alarm_id; + std::string applicationId; + std::string page; + + AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_ADD); + TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception); + + Validator check(ctx, exception); + AlarmConverter converter(ctx); + DeviceAPI::Application::ApplicationConverter applicationConverter(ctx); + + Try { + if(argumentCount < 2) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + if(argumentCount >= 2) { + if( JSValueIsNull(ctx, arguments[1]) || JSValueIsUndefined(ctx, arguments[1]) ) { + ThrowMsg(InvalidArgumentException, "Wrong application id."); + } + applicationId = converter.toString(arguments[1]); + LogDebug("package:[" << applicationId << "]"); + } + + if(JSValueIsObjectOfClass(ctx, arguments[0], JSAlarmAbsolute::getClassRef())) { + // AlarmAbsolute obj + JSObjectRef alarmObj = JSValueToObject(ctx, arguments[0], exception); + JSAlarmAbsolutePriv *priv = static_cast(JSObjectGetPrivate(alarmObj)); + if (!priv) { + ThrowMsg(ConversionException, "Object is null."); + } + AlarmAbsolutePtr alarmPtr = priv->getObject(); + if (!alarmPtr) { + ThrowMsg(ConversionException, "Private object is null."); + } + + startDate = alarmPtr->getDate(); + service = alarmPtr->getService(); + + if(argumentCount >=3) { + // It's service object + if(JSValueIsObjectOfClass(ctx, arguments[2], DeviceAPI::Application::JSApplicationControl::getClassRef())) { + DeviceAPI::Application::ApplicationControlPtr appService = applicationConverter.toApplicationControl(arguments[2]); + if(converter.toAlarmService(service, appService) == false) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + } else if (JSValueIsNull(ctx, arguments[2]) || JSValueIsUndefined(ctx, arguments[2])) { + service_set_operation(service, SERVICE_OPERATION_DEFAULT); + } else { + ThrowMsg(ConversionException, "Wrong third parameter."); + } + } else { + service_set_operation(service, SERVICE_OPERATION_DEFAULT); + } + + LogDebug("applicationId:[" << applicationId << "]"); + service_set_app_id(service, applicationId.c_str()); + + AbsoluteRecurrence::Type alarmType = alarmPtr->getRecurrenceType(); + + int err = ALARM_ERROR_NONE; + if(alarmType == AbsoluteRecurrence::ByDayValue) { + int bydayValue = converter.toNativeAlarmValue(alarmPtr->getByDayRecurrence()); + LogInfo("Native bydayValue = " << bydayValue); + err = alarm_schedule_with_recurrence_week_flag(service, &startDate, bydayValue, &alarm_id); + } else if(alarmType == AbsoluteRecurrence::Interval) { + int interval = alarmPtr->getInterval(); + err = alarm_schedule_at_date(service, &startDate, interval, &alarm_id); + } else { + err = alarm_schedule_at_date(service, &startDate, 0, &alarm_id); + } + + if(err == ALARM_ERROR_NONE) { + alarmPtr->setId(alarm_id); + }else{ + LogDebug("err:[" << err << "]"); + ThrowMsg(PlatformException, "Alarm scheduling failed."); + } + } else if(JSValueIsObjectOfClass(ctx, arguments[0], JSAlarmRelative::getClassRef())) { + JSObjectRef alarmObj = JSValueToObject(ctx, arguments[0], exception); + JSAlarmRelativePriv *priv = static_cast(JSObjectGetPrivate(alarmObj)); + if (!priv) { + ThrowMsg(ConversionException, "Object is null."); + } + + AlarmRelativePtr alarmPtr = priv->getObject(); + if (!alarmPtr) { + ThrowMsg(ConversionException, "Private object is null."); + } + + delay = alarmPtr->getDelay(); + int interval = alarmPtr->getPeriod(); + service = alarmPtr->getService(); + + if(argumentCount >=3) { + // It's service object + if(JSValueIsObjectOfClass(ctx, arguments[2], DeviceAPI::Application::JSApplicationControl::getClassRef())) { + DeviceAPI::Application::ApplicationControlPtr appService = applicationConverter.toApplicationControl(arguments[2]); + if(converter.toAlarmService(service, appService) == false) { + ThrowMsg(ConversionException, "Wrong third parameter type."); + } + } else if (JSValueIsNull(ctx, arguments[2]) || JSValueIsUndefined(ctx, arguments[2])) { + service_set_operation(service, SERVICE_OPERATION_DEFAULT); + } else { + ThrowMsg(ConversionException, "Wrong third parameter."); + } + } else { + service_set_operation(service, SERVICE_OPERATION_DEFAULT); + } + + LogDebug("applicationId:[" << applicationId << "]"); + service_set_app_id(service, applicationId.c_str()); + + int err = alarm_schedule_after_delay(service, delay, interval, &alarm_id); + + if(err == ALARM_ERROR_NONE) { + alarmPtr->setId(alarm_id); + }else{ + LogDebug("err:[" << err << "]"); + } + } else { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + } Catch(ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } Catch(UnsupportedException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } Catch(InvalidArgumentException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } Catch(Exception) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return JSValueMakeUndefined(ctx); +} + +JSValueRef JSAlarmManager::remove(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + int err; + + AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_REMOVE); + TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception); + + Converter converter(ctx); + JSValueRef value; + int id; + + Try { + if(argumentCount < 1 ) { + value = JSValueMakeUndefined(ctx); + id = converter.toInt(value); + } else { + id = converter.toInt(arguments[0]); + } + + if(id <= 0) { + ThrowMsg(InvalidArgumentException, "Invalid id value."); + } + + err = alarm_cancel(id); + + if(err != ALARM_ERROR_NONE) + { + if(err == ALARM_ERROR_INVALID_PARAMETER) { + ThrowMsg(NotFoundException, "Alarm not found."); + } + else { + ThrowMsg(PlatformException, "Unknown error occurred."); + } + } + } Catch(ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } Catch(UnsupportedException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } Catch(InvalidArgumentException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } Catch (NotFoundException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } Catch(Exception) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return JSValueMakeUndefined(ctx); +} + +JSValueRef JSAlarmManager::removeAll(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + LogError("GContext = " << gContext); + AceSecurityStatus status = ALARM_CHECK_ACCESS( + ALARM_FUNCTION_API_REMOVE_ALL); + TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception); + + int returnVal = alarm_cancel_all(); + if (ALARM_ERROR_NONE!=returnVal) { + LogInfo("Error while removing all alarms: "< alarmIds; + + Try { + error = alarm_foreach_registered_alarm(alarm_iterate_callback, &alarmIds); + if (ALARM_ERROR_CONNECTION_FAIL == error) { + LogWarning("Alarm system may not be ready yet."); + alarmIds.clear(); + } else if(ALARM_ERROR_NONE != error) { + LogInfo("Error occurred while getting all alarms: "<>> pkg:[" << pkg << "]"); + return pkg; +} + +} // Alarm +} // TizenApis + diff --git a/src/Alarm/JSAlarmManager.h b/src/Alarm/JSAlarmManager.h new file mode 100755 index 0000000..5a2240d --- /dev/null +++ b/src/Alarm/JSAlarmManager.h @@ -0,0 +1,68 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _JS_TIZEN_ALARM_MANAGER +#define _JS_TIZEN_ALARM_MANAGER + +#include +#include + +namespace DeviceAPI { +namespace Alarm { + +#define TIZEN_ALARM_INTERFACE "AlarmManager" + +#define TIZEN_ALARM_CONSTANT_PERIOD_MINUTE "PERIOD_MINUTE" +#define TIZEN_ALARM_CONSTANT_PERIOD_HOUR "PERIOD_HOUR" +#define TIZEN_ALARM_CONSTANT_PERIOD_DAY "PERIOD_DAY" +#define TIZEN_ALARM_CONSTANT_PERIOD_WEEK "PERIOD_WEEK" + +class JSAlarmManager { +public: + static const JSClassDefinition* getClassInfo(); + static const JSClassRef getClassRef(); + static JSContextRef gContext; + +protected: + static void initialize(JSContextRef context, JSObjectRef object); + static void finalize(JSObjectRef object); + static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); + static JSValueRef add(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + static JSValueRef remove(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + static JSValueRef removeAll(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + static JSValueRef get(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + static JSValueRef getAll(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +private: + static JSValueRef getMin(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef getHour(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef getDay(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef getWeek(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static char* getPackageById(const char* appId); + + static JSClassDefinition m_jsClassInfo; + static JSClassRef m_jsClassRef; + static JSStaticFunction m_function[]; + static JSStaticValue m_property[]; + +}; + +} +} // TizenApis + +#endif diff --git a/src/Alarm/JSAlarmRelative.cpp b/src/Alarm/JSAlarmRelative.cpp new file mode 100755 index 0000000..177e0cc --- /dev/null +++ b/src/Alarm/JSAlarmRelative.cpp @@ -0,0 +1,332 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include "plugin_config.h" + +#include "AlarmRelative.h" +#include "AlarmConverter.h" +#include "JSAlarmRelative.h" +#include "JSAlarmManager.h" + +#include +#include + +namespace DeviceAPI { +namespace Alarm { + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + +JSClassRef JSAlarmRelative::m_jsClassRef = NULL; + +JSClassDefinition JSAlarmRelative::m_jsClassInfo = { + 0, + kJSClassAttributeNone, + TIZEN_ALARM_RELATIVE_INTERFACE, + NULL, + m_property, + m_function, + initialize, + finalize, + NULL, //hasProperty, + NULL, //getProperty, + NULL, //setProperty, + NULL, //deleteProperty,Geolocation + NULL, //getPropertyNames, + NULL, + constructor, // constructor + hasInstance, + NULL +}; + +JSStaticFunction JSAlarmRelative::m_function[] = { + { ALARM_FUNCTION_API_GET_REMAINING_SECONDS, JSAlarmRelative::getRemainingSeconds, kJSPropertyAttributeNone }, + { 0, 0, 0 } +}; + +JSStaticValue JSAlarmRelative::m_property[] = { + { TIZEN_ALARM_RELATIVE_ATTRIBUTE_ID, getId, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_ALARM_RELATIVE_ATTRIBUTE_DELAY, getDelay, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_ALARM_RELATIVE_ATTRIBUTE_PERIOD, getPeriod, NULL, kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +const JSClassRef JSAlarmRelative::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_jsClassInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSAlarmRelative::getClassInfo() +{ + return &m_jsClassInfo; +} + +void JSAlarmRelative::initialize(JSContextRef context, JSObjectRef object) +{ +} +void JSAlarmRelative::finalize(JSObjectRef object) +{ + JSAlarmRelativePriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + LogError("Private object is null"); + } + delete priv; +} + +bool JSAlarmRelative::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) +{ + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + +JSObjectRef JSAlarmRelative::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + AlarmConverter converter(ctx); + Validator validator(ctx); + int delay = 0; + int interval = 0; + + Try { + + if(argumentCount < 1) + { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + delay = converter.toInt(arguments[0]); + + if(delay < 0) { + ThrowMsg(InvalidArgumentException, "First parameter should be positive."); + } + + if(argumentCount >= 2) + { + // Ignores if it is optional + if(JSValueIsUndefined(ctx, arguments[1])) { + return JSValueToObject(ctx, createJSObject(ctx, delay, interval), exception); + } + + interval = converter.toInt(arguments[1]); + if(interval < 0) { + ThrowMsg(InvalidArgumentException, "Second parameter should be positive."); + } + + LogInfo("Constructor interval = " << interval); + } + + return JSValueToObject(ctx, createJSObject(ctx, delay, interval), exception); + } Catch(ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } Catch(UnsupportedException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } Catch(InvalidArgumentException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } Catch(Exception) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return NULL; +} + +AlarmRelativePtr JSAlarmRelative::getPrivData(JSObjectRef object) +{ + JSAlarmRelativePriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(ConversionException, "Object is null."); + } + AlarmRelativePtr result = priv->getObject(); + if (!result) { + ThrowMsg(ConversionException, "Private object is null."); + } + return result; +} + +JSValueRef JSAlarmRelative::createJSObject(JSContextRef context, AlarmRelativePtr privateData) +{ + JSAlarmRelativePriv *priv = new JSAlarmRelativePriv(context, privateData); + if (!priv) { + ThrowMsg(ConversionException, "Object is null."); + } + return JSObjectMake(context, getClassRef(), static_cast(priv)); +} + +JSValueRef JSAlarmRelative::createJSObject(JSContextRef context, int delay, int interval) +{ + AlarmRelativePtr privateData = AlarmRelativePtr(new AlarmRelative()); + privateData->setDelay(delay); + privateData->setPeriod(interval); + + JSAlarmRelativePriv *priv = new JSAlarmRelativePriv(context, privateData); + if (!priv) { + ThrowMsg(ConversionException, "Object is null."); + } + return JSObjectMake(context, getClassRef(), static_cast(priv)); +} + +JSValueRef JSAlarmRelative::getRemainingSeconds(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) +{ + struct tm date; + struct tm current; + time_t currentTime; + time_t nextTime; + Converter converter(ctx); + int id; + + Try { + AlarmRelativePtr privateData = getPrivData(thisObject); + id = privateData->getId(); + + int err = alarm_get_scheduled_date(id, &date); + if(err != ALARM_ERROR_NONE) + { + if(err == ALARM_ERROR_INVALID_PARAMETER) { + return JSValueMakeNull(ctx); + } else { + ThrowMsg(PlatformException, "Unknown exception occurred."); + } + } + + alarm_get_current_time(¤t); + + nextTime = mktime(&date); + currentTime = mktime(¤t); + + int result = nextTime - currentTime; + + LogDebug("nextTime: "<getId(); + if(id >= 0) { + std::string strId = converter.toString(id); + return converter.toJSValueRef(strId); + } else { + return JSValueMakeNull(ctx); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(ctx); +} + +JSValueRef JSAlarmRelative::getDelay(JSContextRef ctx, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Converter converter(ctx); + int delay; + Try + { + AlarmRelativePtr privateData = getPrivData(object); + delay = privateData->getDelay(); + LogInfo("JSAlarmRelative delay = " << delay); + if(delay >= 0) { + return converter.toJSValueRef(delay); + } else { + // Impossible + ThrowMsg(Exception, "Invalid delay value."); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(ctx); +} + +JSValueRef JSAlarmRelative::getPeriod(JSContextRef ctx, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + + Converter converter(ctx); + int period =0; + Try + { + AlarmRelativePtr privateData = getPrivData(object); + period = privateData->getPeriod(); + LogInfo("JSAlarmRelative interval = " << period); + if(period <=0) { + return JSValueMakeNull(ctx); + } else { + return converter.toJSValueRef(period); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(ctx); +} + +} // Alarm +} // TizenApis + + diff --git a/src/Alarm/JSAlarmRelative.h b/src/Alarm/JSAlarmRelative.h new file mode 100755 index 0000000..f0784a9 --- /dev/null +++ b/src/Alarm/JSAlarmRelative.h @@ -0,0 +1,80 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _JS_TIZEN_ALARMRELATIVE +#define _JS_TIZEN_ALARMRELATIVE + +#include +#include +#include +#include "AlarmRelative.h" + +namespace DeviceAPI { +namespace Alarm { + +#define TIZEN_ALARM_RELATIVE_INTERFACE "AlarmRelative" + +#define TIZEN_ALARM_RELATIVE_ATTRIBUTE_ID "id" +#define TIZEN_ALARM_RELATIVE_ATTRIBUTE_DELAY "delay" +#define TIZEN_ALARM_RELATIVE_ATTRIBUTE_PERIOD "period" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject JSAlarmRelativePriv; + +class JSAlarmRelative { +public: + static const JSClassDefinition* getClassInfo(); + static const JSClassRef getClassRef(); + static JSValueRef createJSObject(JSContextRef context, AlarmRelativePtr privateData); + static JSValueRef createJSObject(JSContextRef context, int delay, int interval); + static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +protected: + static void initialize(JSContextRef context, JSObjectRef object); + static void finalize(JSObjectRef object); + static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); + //static JSValueRef getRemainingDuration(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + static JSValueRef getRemainingSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + +private: + static AlarmRelativePtr getPrivData(JSObjectRef object); + + static JSValueRef getId(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static JSValueRef getDelay(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static JSValueRef getPeriod(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static JSClassDefinition m_jsClassInfo; + static JSClassRef m_jsClassRef; + static JSStaticFunction m_function[]; + static JSStaticValue m_property[]; +}; + +}// Alarm +} // TizenApis + +#endif diff --git a/src/Alarm/alarm_common.h b/src/Alarm/alarm_common.h new file mode 100755 index 0000000..bd38edf --- /dev/null +++ b/src/Alarm/alarm_common.h @@ -0,0 +1,61 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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_ALARM_COMMON_H_ +#define TIZENAPIS_API_ALARM_COMMON_H_ + +namespace DeviceAPI { +namespace Alarm { + +// Alarm Type +#define ALARM_TYPE_KEY "TYPE" +#define ALARM_TYPE_ABSOLUTE_VALUE "ABSOLUTE" +#define ALARM_TYPE_RELATIVE_VALUE "RELATIVE" + +// Absolute Alarm Recurrence +#define ALARM_ALSOLUTE_RECURRENCE_TYPE_KEY "RECURRENCE" +#define ALARM_ALSOLUTE_RECURRENCE_TYPE_INTERVAL "INTERVAL" +#define ALARM_ALSOLUTE_RECURRENCE_TYPE_BYDAYVALUE "BYDAYVALUE" +#define ALARM_ALSOLUTE_RECURRENCE_TYPE_NONE "NONE" +#define ALARM_ABSOLUTE_FREQUENCY_KEY "FREQUENCY" +#define ALARM_ABSOLUTE_FREQUENCY_INTERVAL "FREQUENCY_INTERVAL" +#define ALARM_ALSOLUTE_DATE_KEY "DATE" + +// Relative Alarm Delay +#define ALARM_RELATIVE_DELAY_KEY "RELATIVE_DELAY" + +// Frequency +#define ALARM_PROPERTY_MINUTELY_RECURRENCE "MINUTELY" +#define ALARM_PROPERTY_HOURLY_RECURRENCE "HOURLY" +#define ALARM_PROPERTY_DAILY_RECURRENCE "DAILY" +#define ALARM_PROPERTY_WEEKLY_RECURRENCE "WEEKLY" +#define ALARM_PROPERTY_MONTHLY_RECURRENCE "MONTHLY" +#define ALARM_PROPERTY_YEARLY_RECURRENCE "YEARLY" + +namespace AbsoluteRecurrence +{ + typedef enum + { + NoRecurrence, + ByDayValue, + Interval, + }Type; +} + +} +} +#endif diff --git a/src/Alarm/config.xml b/src/Alarm/config.xml new file mode 100755 index 0000000..0e01835 --- /dev/null +++ b/src/Alarm/config.xml @@ -0,0 +1,15 @@ + + + + libwrt-plugins-tizen-alarm.so + alarm.install.uri + SAMSUNG plugin group + SAMSUNG certificate authority + AAAABBBBCCCCDDDEEEE0000 + + + http://tizen.org/privilege/alarm + alarm + + + diff --git a/src/Alarm/plugin_config.cpp b/src/Alarm/plugin_config.cpp new file mode 100755 index 0000000..3f92932 --- /dev/null +++ b/src/Alarm/plugin_config.cpp @@ -0,0 +1,105 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include + +#include "plugin_config.h" + +#define ALARM_FEATURE_API "http://tizen.org/privilege/alarm" + +#define ALARM_DEVICE_CAP "alarm" + +using namespace WrtDeviceApis::Commons; + +namespace DeviceAPI { +namespace Alarm { + +static FunctionMapping createAlarmFunctions(); + +static FunctionMapping AlarmFunctions = + createAlarmFunctions(); + +DEFINE_FUNCTION_GETTER(Alarm, AlarmFunctions); + +static FunctionMapping createAlarmFunctions() +{ + /** + * Device capabilities + */ + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_ALARM, ALARM_DEVICE_CAP); + + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_ALARM); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_ALARM, DEVICE_CAP_ALARM); + + /** + * Api Features + */ + ACE_CREATE_FEATURE(FEATURE_ALARM, ALARM_FEATURE_API); + + ACE_CREATE_FEATURE_LIST(ALARM_FEATURES); + ACE_ADD_API_FEATURE(ALARM_FEATURES, FEATURE_ALARM); + + /** + * Functions + */ + FunctionMapping alarmMapping; + + // add + AceFunction addFunc = ACE_CREATE_FUNCTION( + FUNCTION_ADD, + ALARM_FUNCTION_API_ADD, + ALARM_FEATURES, + DEVICE_LIST_ALARM); + + alarmMapping.insert(std::make_pair( + ALARM_FUNCTION_API_ADD, + addFunc)); + + // remove + AceFunction removeFunc = ACE_CREATE_FUNCTION( + FUNCTION_REMOVE, + ALARM_FUNCTION_API_REMOVE, + ALARM_FEATURES, + DEVICE_LIST_ALARM); + + alarmMapping.insert(std::make_pair( + ALARM_FUNCTION_API_REMOVE, + removeFunc)); + + + // removeAll + AceFunction removeAllFunc = ACE_CREATE_FUNCTION( + FUNCTION_REMOVE_ALL, + ALARM_FUNCTION_API_REMOVE_ALL, + ALARM_FEATURES, + DEVICE_LIST_ALARM); + + alarmMapping.insert(std::make_pair( + ALARM_FUNCTION_API_REMOVE_ALL, + removeAllFunc)); + + return alarmMapping; +} + +} +} diff --git a/src/Alarm/plugin_config.h b/src/Alarm/plugin_config.h new file mode 100755 index 0000000..796e37b --- /dev/null +++ b/src/Alarm/plugin_config.h @@ -0,0 +1,44 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 _ALARM_PLUGIN_CONFIG_H_ +#define _ALARM_PLUGIN_CONFIG_H_ + +#include +#include + +#define ALARM_FUNCTION_API_GET_ALL "getAll" +#define ALARM_FUNCTION_API_GET "get" +#define ALARM_FUNCTION_API_ADD "add" +#define ALARM_FUNCTION_API_REMOVE "remove" +#define ALARM_FUNCTION_API_REMOVE_ALL "removeAll" +#define ALARM_FUNCTION_API_GET_NEXT_SCHEDULED_DATE "getNextScheduledDate" +#define ALARM_FUNCTION_API_GET_REMAINING_SECONDS "getRemainingSeconds" + +namespace DeviceAPI { +namespace Alarm { + +DECLARE_FUNCTION_GETTER(Alarm); + +#define ALARM_CHECK_ACCESS(functionName) \ + aceCheckAccess >( \ + getAlarmFunctionData, \ + functionName) +} +} +#endif + diff --git a/src/Alarm/plugin_initializer.cpp b/src/Alarm/plugin_initializer.cpp new file mode 100755 index 0000000..12672a5 --- /dev/null +++ b/src/Alarm/plugin_initializer.cpp @@ -0,0 +1,79 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include "JSAlarmManager.h" +#include "JSAlarmAbsolute.h" +#include "JSAlarmRelative.h" + +#define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen" + +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; + +void on_widget_start_callback(int widgetId) +{ + LogDebug("[Tizen\\AlarmManager ] on_widget_start_callback (" << widgetId << ")"); + Try + { + WrtAccessSingleton::Instance().initialize(widgetId); + } + Catch(Commons::Exception) + { + LogError("WrtAccess initialization failed"); + } +} + +void on_widget_stop_callback(int widgetId) +{ + LogDebug("[Tizen\\AlarmManager ] on_widget_stop_callback (" << widgetId << ")"); + Try + { + WrtAccessSingleton::Instance().deinitialize(widgetId); + } + Catch(Commons::Exception) + { + LogError("WrtAccess deinitialization failed"); + } +} + +PLUGIN_ON_WIDGET_START(on_widget_start_callback) +PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback) + +PLUGIN_CLASS_MAP_BEGIN +PLUGIN_CLASS_MAP_ADD_CLASS( + WRT_JS_EXTENSION_OBJECT_TIZEN, + "alarm", + (js_class_template_getter)DeviceAPI::Alarm::JSAlarmManager::getClassRef, + NULL) +PLUGIN_CLASS_MAP_ADD_CLASS( + WRT_JS_EXTENSION_OBJECT_TIZEN, + TIZEN_ALARM_ABSOLUTE_INTERFACE, + (js_class_template_getter)DeviceAPI::Alarm::JSAlarmAbsolute::getClassRef, + NULL) +PLUGIN_CLASS_MAP_ADD_CLASS( + WRT_JS_EXTENSION_OBJECT_TIZEN, + TIZEN_ALARM_RELATIVE_INTERFACE, + (js_class_template_getter)DeviceAPI::Alarm::JSAlarmRelative::getClassRef, + NULL) +PLUGIN_CLASS_MAP_END + diff --git a/src/Application/AppManagerWrapper.cpp b/src/Application/AppManagerWrapper.cpp new file mode 100644 index 0000000..4018899 --- /dev/null +++ b/src/Application/AppManagerWrapper.cpp @@ -0,0 +1,306 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 "AppManagerWrapper.h" + +#include +#include +#include +#include + +// To get package id from appId +#include + +IMPLEMENT_SINGLETON(DeviceAPI::Application::AppManagerWrapper) + +namespace DeviceAPI { +namespace Application { + +using namespace std; +using namespace WrtDeviceApis::Commons; + + +AppManagerWrapper::AppManagerWrapper() : + m_registeredCallback(false), + m_watchIdAcc(0) +{ +} + +AppManagerWrapper::~AppManagerWrapper() +{ + if(m_registeredCallback) + { + unregisterAppListChangedCallbacks(); + } +} + +void AppManagerWrapper::registerAppListChangedCallbacks(IAppManagerAppListChangedCallbacks *callbacks) +{ + if(callbacks == NULL) + { + LogWarning("Parameter is NULL."); + return; + } + + if(!m_registeredCallback) + { + registerAppListChangedCallbacks(); + } + + m_callbacks.insert(callbacks); +} + +void AppManagerWrapper::unregisterAppListChangedCallbacks(IAppManagerAppListChangedCallbacks *callbacks) +{ + if(callbacks == NULL) + { + LogWarning("Parameter is NULL."); + return; + } + + if(m_callbacks.size() == 0) + { + LogWarning("No callbacks are registered."); + return; + } + + AppListChangedCallbacksSet::iterator iter = m_callbacks.find(callbacks); + if(iter == m_callbacks.end()) + { + LogWarning("Callbacks " << callbacks << " are not registered."); + return; + } + + m_callbacks.erase(iter); + + if(m_callbacks.size() == 0) + { + unregisterAppListChangedCallbacks(); + } +} + + +long AppManagerWrapper::getWatchIdAndInc() +{ + return ++m_watchIdAcc; +} + +void AppManagerWrapper::appListChangedCallback(app_manger_event_type_e event_type, + const char *appId, + void *user_data) +{ + if(user_data == NULL) + { + LogWarning("app_manager listener passed NULL user_data"); + return; + } + + AppManagerWrapper *appManager = (AppManagerWrapper *)user_data; + + appManager->appListChangedCallback(event_type, appId); +} + +void AppManagerWrapper::appListChangedCallback(app_manger_event_type_e event_type, + const char *appId) +{ + if(appId == NULL) + { + LogWarning("app_manager listener gave a NULL package name."); + return; + } + + switch(event_type) + { + case APP_MANAGER_EVENT_INSTALLED: + appListAppInstalled(appId); + break; + case APP_MANAGER_EVENT_UNINSTALLED: + appListAppUninstalled(appId); + break; + case APP_MANAGER_EVENT_UPDATED: + appListAppUpdated(appId); + break; + default: + LogWarning("app_manager listener gave wrong event_type : " << event_type); + break; + } +} + +void AppManagerWrapper::appListAppInstalled(const char *appId) +{ + LogDebug("app installed : " << appId); + + AppListChangedCallbacksSet::iterator iter = m_callbacks.begin(); + for(; iter != m_callbacks.end(); iter++) + { + (*iter)->onAppManagerEventInstalled(appId); + } +} + +void AppManagerWrapper::appListAppUninstalled(const char *appId) +{ + LogDebug("app uninstalled : " << appId); + + AppListChangedCallbacksSet::iterator iter = m_callbacks.begin(); + for(; iter != m_callbacks.end(); iter++) + { + (*iter)->onAppManagerEventUninstalled(appId); + } +} + +void AppManagerWrapper::appListAppUpdated(const char *appId) +{ + LogDebug("app updated : " << appId); + + AppListChangedCallbacksSet::iterator iter = m_callbacks.begin(); + for(; iter != m_callbacks.end(); iter++) + { + (*iter)->onAppManagerEventUpdated(appId); + } +} + +void AppManagerWrapper::registerAppListChangedCallbacks() +{ + if(m_registeredCallback) + { + LogWarning("Callback already registered."); + return; + } + + // AppManagerWrapper will be used as a singleton object, + // so this pointer of it can be passed as a parameter of a async function. + int result = app_manager_set_app_list_changed_cb(appListChangedCallback, this); + if (result != APP_MANAGER_ERROR_NONE) + { + LogWarning("app_manager_set_app_list_changed_cb() returns APP_MANAGER_ERROR_INVALID_PARAMETER"); + + ThrowMsg(InvalidArgumentException, "Error while registering listener to app_manager"); + } + + m_registeredCallback = true; +} + +void AppManagerWrapper::unregisterAppListChangedCallbacks() +{ + if(!m_registeredCallback) + { + LogWarning("Callback already unregistered."); + return; + } + + app_manager_unset_app_list_changed_cb(); + + m_registeredCallback = false; +} + +// @20130125-wscho: current pkgmanager has a problem while db operation. +// So, below function is temporal function. all attribute should be filled to appInfoObject +// when that is created. +// See ApplicationManager.cpp +bool AppManagerWrapper::initializeAppInfo(ApplicationInformationPtr &appInfo) +{ + std::string appId = appInfo->getAppId(); + char* packageId = NULL; + int ret = 0; + + //LogDebug("InitializeAppInfo for " << appInfo->getAppId().c_str()); + + ret = package_manager_get_package_id_by_app_id(appId.c_str(), &packageId); + if (ret != PACKAGE_MANAGER_ERROR_NONE) + { + LogDebug("Fail to get package id with appId : " << appId.c_str()); + } + +// Below code is already run on ApplicationManager.cpp +#if 0 + char* name = NULL; + char* iconPath = NULL; + bool noDisplay = false; + pkgmgrinfo_appinfo_h appinfo_h; + + ret = pkgmgrinfo_appinfo_get_appinfo(appId.c_str(), &appinfo_h); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get appinfo by " << appId.c_str()); + } + + ret = pkgmgrinfo_appinfo_get_label(appinfo_h, &name); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get name by " << appId.c_str()); + } + appInfo->setName(name); + + ret = pkgmgrinfo_appinfo_get_icon(appinfo_h, &iconPath); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get icon by " << appId.c_str()); + } + appInfo->setIconPath(iconPath); + + ret = pkgmgrinfo_appinfo_is_nodisplay(appinfo_h, &noDisplay); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get nodisplay by " << appId.c_str()); + } + appInfo->setShow(!noDisplay); + + ret = pkgmgrinfo_appinfo_foreach_category(appinfo_h, category_cb, (void*)appInfo.Get()); + if (ret < 0) + { + LogDebug("Fail to get categories " << appId.c_str()); + } + + ret = pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h); + if (ret < 0) + { + LogDebug("Fail to destroy " << appId.c_str()); + } +#endif + + char *version = NULL; + int total_size = 0; + int installed_time = 0; + pkgmgrinfo_pkginfo_h pkginfo_h; + + ret = pkgmgrinfo_pkginfo_get_pkginfo(packageId, &pkginfo_h); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get package info"); + } + + ret = pkgmgrinfo_pkginfo_get_version(pkginfo_h, &version); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get version"); + } + appInfo->setVersion(version); + + ret = pkgmgrinfo_pkginfo_get_total_size(pkginfo_h, &total_size); + if (ret == PMINFO_R_OK) { + appInfo->setInstallSize(total_size); + } + + ret = pkgmgrinfo_pkginfo_get_installed_time(pkginfo_h, &installed_time); + if (ret == PMINFO_R_OK) { + appInfo->setInstallDate(installed_time); + } + + pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo_h); + + appInfo->setInitialize(); + return true; +} + + + +} // Application +} // DeviceAPI diff --git a/src/Application/AppManagerWrapper.h b/src/Application/AppManagerWrapper.h new file mode 100644 index 0000000..344227f --- /dev/null +++ b/src/Application/AppManagerWrapper.h @@ -0,0 +1,99 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_PLATFORM_APPLICATION_APP_MANAGER_WRAPPER_H_ +#define TIZENAPIS_PLATFORM_APPLICATION_APP_MANAGER_WRAPPER_H_ + +#include +#include +#include +#include +#include + +#include +#include +#include "ApplicationInformation.h" + +// To get app size and installed time +#include + +namespace DeviceAPI { +namespace Application { + + +class IAppManagerAppListChangedCallbacks +{ +public: + friend class AppManagerWrapper; + + IAppManagerAppListChangedCallbacks() {} + ~IAppManagerAppListChangedCallbacks() {} + +protected: + virtual void onAppManagerEventInstalled(const char *appId) = 0; + virtual void onAppManagerEventUninstalled(const char *appId) = 0; + virtual void onAppManagerEventUpdated(const char *appId) = 0; +}; + +class AppManagerWrapper +{ +public: + AppManagerWrapper(); + virtual ~AppManagerWrapper(); + + // Can throw InvalidArgumentException or PlatformException + void registerAppListChangedCallbacks(IAppManagerAppListChangedCallbacks *callbacks); + + // No throws + void unregisterAppListChangedCallbacks(IAppManagerAppListChangedCallbacks *callbacks); + + long getWatchIdAndInc(); + + bool initializeAppInfo(ApplicationInformationPtr &appInfo); + +private: + // callback for app_manager_set_app_list_changed_cb + static void appListChangedCallback(app_manger_event_type_e event_type, + const char *package, + void *user_data); + + void appListChangedCallback(app_manger_event_type_e event_type, + const char *package); + + void appListAppInstalled(const char *appId); + void appListAppUninstalled(const char *appId); + void appListAppUpdated(const char *appId); + + void registerAppListChangedCallbacks(); + void unregisterAppListChangedCallbacks(); + + typedef std::set AppListChangedCallbacksSet; + AppListChangedCallbacksSet m_callbacks; + bool m_registeredCallback; + + long m_watchIdAcc; + +public: + friend class DPL::Singleton; +}; + +typedef DPL::Singleton AppManagerWrapperSingleton; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_PLATFORM_APPLICATION_APP_MANAGER_WRAPPER_H_ diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp new file mode 100644 index 0000000..629759c --- /dev/null +++ b/src/Application/Application.cpp @@ -0,0 +1,166 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 "Application.h" + +#include +#include +#include + +#include "ApplicationControlData.h" +#include "ApplicationControl.h" +#include "ApplicationManager.h" + +namespace DeviceAPI { +namespace Application { + +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; + +extern "C" int service_create_event(bundle *data, struct service_s **service); + +Application::Application() +{ +} + +Application::~Application() +{ +} + +std::string Application::getContextId() const +{ + return m_contextId; +} + +void Application::setContextId(const std::string &id) +{ + m_contextId = id; +} + +ApplicationInformationPtr Application::getAppInfo() const +{ + return m_appInfo; +} + +void Application::setAppInfo(ApplicationInformationPtr& appInfo) +{ + m_appInfo = appInfo; +} + +void Application::getRequestedAppControl(const EventApplicationGetRequestedAppControlPtr& event) +{ + LogDebug("entered"); + + Try + { + int ret = 0; + + std::string bundle_str = event->getEncodedBundle(); + LogDebug("bundle str : " << bundle_str); + + service_h service = NULL; + char* tmpStr = NULL; + + bundle *request_bundle = bundle_decode((bundle_raw*)bundle_str.c_str(), bundle_str.length()); + ret = service_create_event(request_bundle, &service); + if(ret != SERVICE_ERROR_NONE) + { + LogError("Fail to create event"); + event->setExceptionCode(Commons::ExceptionCodes::UnknownException); + bundle_free(request_bundle); + return; + } + bundle_free(request_bundle); + + ApplicationControlPtr appControl(new ApplicationControl()); + appControl->setService_h(service); + + ret = service_get_operation(service, &tmpStr); + if(ret == SERVICE_ERROR_NONE && tmpStr != NULL) + { + LogDebug(" operation : " << tmpStr); + appControl->setOperation(tmpStr); + free(tmpStr); + tmpStr = NULL; + } + + ret = service_get_uri(service, &tmpStr); + if(ret == SERVICE_ERROR_NONE && tmpStr != NULL) + { + LogDebug(" uri : " << tmpStr); + appControl->setUri(tmpStr); + free(tmpStr); + tmpStr = NULL; + } + + ret = service_get_mime(service, &tmpStr); + if(ret == SERVICE_ERROR_NONE && tmpStr != NULL) + { + LogDebug(" mime : " << tmpStr); + appControl->setMime(tmpStr); + free(tmpStr); + tmpStr = NULL; + } + + ret = service_get_category(service, &tmpStr); + if(ret == SERVICE_ERROR_NONE && tmpStr != NULL) + { + LogDebug(" category : " << tmpStr); + appControl->setCategory(tmpStr); + free(tmpStr); + tmpStr = NULL; + } + + std::vector appControlDataArray; + ret = service_foreach_extra_data(service, ApplicationManager::service_extra_data_callback, &appControlDataArray); + if (ret != SERVICE_ERROR_NONE) + { + LogError("service_foreach_extra_data fail"); + event->setExceptionCode(Commons::ExceptionCodes::UnknownException); + } + else + { + appControl->setAppControlDataArray(appControlDataArray); + } + + RequestedApplicationControlPtr appCtrMgr(new RequestedApplicationControl()); + appCtrMgr->setAppControl(appControl); + + // add caller id + ret = service_get_caller(service, &tmpStr); + if(ret == SERVICE_ERROR_NONE && tmpStr != NULL) + { + LogDebug(" caller App Id : " << tmpStr); + appCtrMgr->setCallerAppId(tmpStr); + free(tmpStr); + tmpStr = NULL; + } else { + LogError("caller id fail"); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } + event->setRequestedAppControl(appCtrMgr); + + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Error on getAppControl : " << _rethrown_exception.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } +} + +} +} diff --git a/src/Application/Application.h b/src/Application/Application.h new file mode 100644 index 0000000..bbc5f9e --- /dev/null +++ b/src/Application/Application.h @@ -0,0 +1,55 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_H_ +#define TIZENAPIS_API_APPLICATION_H_ + +#include +#include +#include +#include +#include "ApplicationInformation.h" +#include "EventApplicationGetRequestedAppControl.h" + +namespace DeviceAPI { +namespace Application { + +class Application; +typedef DPL::SharedPtr ApplicationPtr; + +class Application +{ + public: + Application(); + ~Application(); + + std::string getContextId() const; + void setContextId(const std::string &id); + ApplicationInformationPtr getAppInfo() const; + void setAppInfo(ApplicationInformationPtr &appInfo); + + void getRequestedAppControl(const EventApplicationGetRequestedAppControlPtr& event); + + private: + ApplicationInformationPtr m_appInfo; + std::string m_contextId; +}; + +} +} + +#endif diff --git a/src/Application/ApplicationAsyncCallbackManager.cpp b/src/Application/ApplicationAsyncCallbackManager.cpp new file mode 100755 index 0000000..0e3f98c --- /dev/null +++ b/src/Application/ApplicationAsyncCallbackManager.cpp @@ -0,0 +1,30 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 "ApplicationAsyncCallbackManager.h" +#include + +using namespace DPL; + +IMPLEMENT_SINGLETON(DeviceAPI::Application::ApplicationAsyncCallbackManager) + +namespace DeviceAPI { +namespace Application { + +} // Application +} // DeviceAPI diff --git a/src/Application/ApplicationAsyncCallbackManager.h b/src/Application/ApplicationAsyncCallbackManager.h new file mode 100644 index 0000000..e2cbc7a --- /dev/null +++ b/src/Application/ApplicationAsyncCallbackManager.h @@ -0,0 +1,46 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _TIZEN_APPLICATION_ASYNC_CALLBACK_MANAGER_H_ +#define _TIZEN_APPLICATION_ASYNC_CALLBACK_MANAGER_H_ + +#include +#include + +namespace DeviceAPI { +namespace Application { + +class ApplicationAsyncCallbackManager : public DeviceAPI::Common::AsyncCallbackManager +{ +public: + ApplicationAsyncCallbackManager() + { + } + + virtual ~ApplicationAsyncCallbackManager() + { + } + + friend class DPL::Singleton; +}; + +typedef DPL::Singleton ApplicationAsyncCallbackManagerSingleton; + +} // Application +} // DeviceAPI + +#endif // _TIZEN_APPLICATION_ASYNC_CALLBACK_MANAGER_H_ diff --git a/src/Application/ApplicationCert.cpp b/src/Application/ApplicationCert.cpp new file mode 100644 index 0000000..a68af99 --- /dev/null +++ b/src/Application/ApplicationCert.cpp @@ -0,0 +1,51 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 "ApplicationCert.h" + +namespace DeviceAPI { +namespace Application { +ApplicationCert::ApplicationCert() +{ +} + +ApplicationCert::~ApplicationCert() +{ +} + +std::string ApplicationCert::getType() const +{ + return m_type; +} + +void ApplicationCert::setType(const std::string &type) +{ + m_type = type; +} + +std::string ApplicationCert::getValue() const +{ + return m_value; +} + +void ApplicationCert::setValue(const std::string &value) +{ + m_value = value; +} + +} +} diff --git a/src/Application/ApplicationCert.h b/src/Application/ApplicationCert.h new file mode 100644 index 0000000..0d754d8 --- /dev/null +++ b/src/Application/ApplicationCert.h @@ -0,0 +1,53 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_CERT_H_ +#define TIZENAPIS_API_APPLICATION_CERT_H_ + +#include +#include +#include +#include + +namespace DeviceAPI { +namespace Application { + +class ApplicationCert; +typedef DPL::SharedPtr ApplicationCertPtr; + +typedef std::vector ApplicationCertArray; +typedef DPL::SharedPtr ApplicationCertArrayPtr; + + +class ApplicationCert +{ + public: + ApplicationCert(); + ~ApplicationCert(); + + std::string getType() const; + void setType(const std::string &type); + std::string getValue() const; + void setValue(const std::string &value); + + private: + std::string m_type; + std::string m_value; +}; +} +} +#endif diff --git a/src/Application/ApplicationContext.cpp b/src/Application/ApplicationContext.cpp new file mode 100755 index 0000000..8671a1a --- /dev/null +++ b/src/Application/ApplicationContext.cpp @@ -0,0 +1,50 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "ApplicationContext.h" + +namespace DeviceAPI { +namespace Application { +ApplicationContext::ApplicationContext() +{ +} + +ApplicationContext::~ApplicationContext() +{ +} + +std::string ApplicationContext::getAppId() const +{ + return m_appId; +} +void ApplicationContext::setAppId(const std::string &appId) +{ + m_appId = appId; +} + +std::string ApplicationContext::getContextId() const +{ + return m_contextId; +} +void ApplicationContext::setContextId(const std::string &contextId) +{ + m_contextId = contextId; +} + + +} +} diff --git a/src/Application/ApplicationContext.h b/src/Application/ApplicationContext.h new file mode 100755 index 0000000..97439d2 --- /dev/null +++ b/src/Application/ApplicationContext.h @@ -0,0 +1,54 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_CONTEXT_H_ +#define TIZENAPIS_API_APPLICATION_CONTEXT_H_ + +#include +#include +#include +#include + +namespace DeviceAPI { +namespace Application { + +class ApplicationContext; +typedef DPL::SharedPtr ApplicationContextPtr; + +typedef std::vector ApplicationContextArray; +typedef DPL::SharedPtr ApplicationContextArrayPtr; + +class ApplicationContext +{ + public: + ApplicationContext(); + ~ApplicationContext(); + + std::string getAppId() const; + void setAppId(const std::string &appId); + std::string getContextId() const; + void setContextId(const std::string &contextId); + + + private: + std::string m_appId; + std::string m_contextId; + +}; +} +} +#endif diff --git a/src/Application/ApplicationControl.cpp b/src/Application/ApplicationControl.cpp new file mode 100755 index 0000000..73d07c6 --- /dev/null +++ b/src/Application/ApplicationControl.cpp @@ -0,0 +1,172 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 ApplicationControl.cpp + * @author Youngkyeong Yun (yk.yun@samsung.com) + * @version 0.1 + */ + + +#include "ApplicationControl.h" + +namespace DeviceAPI { +namespace Application { + +ApplicationControl::ApplicationControl() : + m_appControl(NULL) +{ + LogDebug("entered"); +} + +ApplicationControl::ApplicationControl(const std::string &op, const std::string &uri, + const std::string &mime, const std::string &category, + std::vector &dataArray) : + m_appControl(NULL) +{ + LogDebug("entered"); + m_operation = op; + m_uri = uri; + m_mime = mime; + m_category = category; + m_appControlDataArray = dataArray; +} + +ApplicationControl::~ApplicationControl() +{ + LogDebug("entered"); +} + +std::string ApplicationControl::getOperation() const +{ + return m_operation; +} + +void ApplicationControl::setOperation(const std::string &operation) +{ + m_operation = operation; +} + +std::string ApplicationControl::getUri() const +{ + return m_uri; +} + +void ApplicationControl::setUri(const std::string &uri) +{ + m_uri = uri; +} + +std::string ApplicationControl::getMime() const +{ + return m_mime; +} + +void ApplicationControl::setMime(const std::string &mime) +{ + m_mime = mime; +} + +std::string ApplicationControl::getCategory() const +{ + return m_category; +} + +void ApplicationControl::setCategory(const std::string &category) +{ + m_category = category; +} + +std::vector ApplicationControl::getAppControlDataArray() const +{ + return m_appControlDataArray; +} + +void ApplicationControl::setAppControlDataArray(const std::vector &dataArray) +{ + m_appControlDataArray = dataArray; +} + +void ApplicationControl::addAppControlData(const ApplicationControlDataPtr &data) +{ + m_appControlDataArray.push_back(data); + +} + +service_h ApplicationControl::getService_h() const +{ + return m_appControl; +} + +void ApplicationControl::setService_h(const service_h service) +{ + m_appControl = service; +} + + +#if 0 +void ApplicationControl::replyResult(std::vector &appControlDataArray) +{ + service_h reply; + service_create(&reply); + + const char* key = NULL; + const char** arr = NULL; + + if (!appControlDataArray.empty()) + { + LogDebug("appControlDataArray.size() : "<getKey().c_str(); + std::vector valueArray = appControlDataArray.at(i)->getValue(); + + arr = (const char**) calloc (sizeof(char*), valueArray.size()); + + for (size_t j = 0; j < valueArray.size(); j++) { + arr[j] = valueArray.at(j).c_str(); + } + service_add_extra_data_array(reply, key, arr, valueArray.size()); + } + } else { + LogError("==[replyResult] appControlDataArray is empty"); + } + + service_reply_to_launch_request(reply, m_appControl, SERVICE_RESULT_SUCCEEDED); + + service_destroy(reply); + + if (arr) { + free (arr); + } + +} + +void ApplicationControl::replyFailure() +{ + service_h reply; + service_create(&reply); + + LogError("==[replyFailure] enter ApplicationControl::replyFailure"); + service_reply_to_launch_request(reply, m_appControl, SERVICE_RESULT_FAILED); + + service_destroy(reply); +} +#endif + +} +} diff --git a/src/Application/ApplicationControl.h b/src/Application/ApplicationControl.h new file mode 100755 index 0000000..fdd1ce1 --- /dev/null +++ b/src/Application/ApplicationControl.h @@ -0,0 +1,77 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_CONTROL_H_ +#define TIZENAPIS_API_APPLICATION_CONTROL_H_ + +#include +#include +#include +#include +#include +#include "ApplicationControlData.h" + +namespace DeviceAPI { +namespace Application { + +class ApplicationControl; +typedef DPL::SharedPtr ApplicationControlPtr; + +/* This object represents a single extra data for service request and reply */ +class ApplicationControl +{ + public: + ApplicationControl(); + ApplicationControl(const std::string &op, const std::string &uri, const std::string &mime, + const std::string &category, std::vector &dataArray) ; + ~ApplicationControl(); + + std::string getOperation() const; + void setOperation(const std::string &operation); + + std::string getUri() const; + void setUri(const std::string &uri); + + std::string getMime() const; + void setMime(const std::string &uri); + + std::string getCategory() const; + void setCategory(const std::string &category); + + std::vector getAppControlDataArray() const; + void setAppControlDataArray(const std::vector &dataArray); + void addAppControlData(const ApplicationControlDataPtr &data); + + service_h getService_h() const; + void setService_h(const service_h service); + +#if 0 + void replyResult(std::vector &appControlDataArray); + void replyFailure(); +#endif + + private: + std::string m_operation; + std::string m_uri; + std::string m_mime; + std::string m_category; + std::vector m_appControlDataArray; + service_h m_appControl; +}; +} +} +#endif diff --git a/src/Application/ApplicationControlData.cpp b/src/Application/ApplicationControlData.cpp new file mode 100755 index 0000000..5be9eb6 --- /dev/null +++ b/src/Application/ApplicationControlData.cpp @@ -0,0 +1,54 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 "ApplicationControlData.h" + +namespace DeviceAPI { +namespace Application { + +ApplicationControlData::ApplicationControlData() +{ + LogDebug("entered"); +} + +ApplicationControlData::~ApplicationControlData() +{ + //nothing to do in destructor + LogDebug("entered"); +} + +std::string ApplicationControlData::getKey() const +{ + return m_key; +} + +void ApplicationControlData::setKey(const std::string &key) +{ + m_key = key; +} + +std::vector ApplicationControlData::getValue() const +{ + return m_value; +} +void ApplicationControlData::setValue(const std::vector &value) +{ + m_value = value; +} + +} +} diff --git a/src/Application/ApplicationControlData.h b/src/Application/ApplicationControlData.h new file mode 100755 index 0000000..2e420c2 --- /dev/null +++ b/src/Application/ApplicationControlData.h @@ -0,0 +1,54 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_CONTROL_DATA_H_ +#define TIZENAPIS_API_APPLICATION_CONTROL_DATA_H_ + +#include +#include +#include +#include + +namespace DeviceAPI { +namespace Application { + +class ApplicationControlData; +typedef DPL::SharedPtr ApplicationControlDataPtr; + +typedef std::vector ApplicationControlDataArray; +typedef DPL::SharedPtr ApplicationControlDataArrayPtr; + +/* This object represents a single extra data for app control request and reply */ +class ApplicationControlData +{ + public: + ApplicationControlData(); + ~ApplicationControlData(); + + std::string getKey() const; + void setKey(const std::string &key); + + std::vector getValue() const; + void setValue(const std::vector &value); + + private: + std::string m_key; + std::vector m_value; +}; +} +} +#endif diff --git a/src/Application/ApplicationController.cpp b/src/Application/ApplicationController.cpp new file mode 100644 index 0000000..4535160 --- /dev/null +++ b/src/Application/ApplicationController.cpp @@ -0,0 +1,541 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include "ApplicationController.h" +#include "ApplicationConverter.h" +#include "JSApplicationEventCallbackManager.h" +#include "ApplicationAsyncCallbackManager.h" +#include "ApplicationInformationEventPrivateData.h" + +namespace DeviceAPI { +namespace Application { + +using namespace DeviceAPI::Common; +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; + +ApplicationController::ApplicationController(JSContextRef context, IApplicationManagerPtr application) : + EventApplicationLaunchEventAnswerReceiver(ThreadEnum::NULL_THREAD), + EventApplicationKillEventAnswerReceiver(ThreadEnum::NULL_THREAD), + EventApplicationLaunchAppControlEventAnswerReceiver(ThreadEnum::NULL_THREAD), + EventApplicationLaunchAppControlReplyEventAnswerReceiver(ThreadEnum::NULL_THREAD), + EventApplicationFindAppControlEventAnswerReceiver(ThreadEnum::NULL_THREAD), + EventApplicationGetAppsContextEventAnswerReceiver(ThreadEnum::NULL_THREAD), + EventApplicationGetAppsInfoEventAnswerReceiver(ThreadEnum::NULL_THREAD), + EventApplicationAppInfoEventListenerListener(ThreadEnum::NULL_THREAD), + ApplicationPrivObject(context, application) +{ + LogDebug("ApplicationController constructed : " << this); + if (!application) { + LogWarning("controller has no application object"); + } +} + +ApplicationController::~ApplicationController() +{ + LogDebug("ApplicationController destructed : " << this); +} + +void ApplicationController::OnAnswerReceived(const EventApplicationLaunchPtr &event) +{ + ApplicationAsyncAnswerHandler::launch(event); +} + +void ApplicationController::OnAnswerReceived(const EventApplicationKillPtr &event) +{ + ApplicationAsyncAnswerHandler::kill(event); +} + +void ApplicationController::OnAnswerReceived(const EventApplicationLaunchAppControlPtr &event) +{ + ApplicationAsyncAnswerHandler::launchAppControl(event); +} + +void ApplicationController::OnAnswerReceived(const EventApplicationLaunchAppControlReplyPtr &event) +{ + ApplicationAsyncAnswerHandler::launchAppControlReply(event); +} + +void ApplicationController::OnAnswerReceived(const EventApplicationFindAppControlPtr &event) +{ + ApplicationAsyncAnswerHandler::findAppControl(event); +} + +void ApplicationController::OnAnswerReceived(const EventApplicationGetAppsContextPtr &event) +{ + ApplicationAsyncAnswerHandler::getAppsContext(event); +} + +void ApplicationController::OnAnswerReceived(const EventApplicationGetAppsInfoPtr &event) +{ + ApplicationAsyncAnswerHandler::getAppsInfo(event); +} + +void ApplicationController::onAnswerReceived(const EventApplicationAppInfoEventListenerPtr &event) +{ + ApplicationAsyncAnswerHandler::eventListener(event); +} + +void ApplicationAsyncAnswerHandler::launch(const EventApplicationLaunchPtr &event) +{ + LogDebug("entered"); + JSCallbackManagerPtr callbackManager = + DPL::StaticPointerCast(event->getPrivateData()); + if (!callbackManager) { + LogError("no callback manager"); + return; + } + + ApplicationAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager); + + if(event->checkCancelled()) { + LogDebug("Operation cancelled"); + return; + } + + JSContextRef gContext = callbackManager->getContext(); + + JSValueRef error = NULL; + if (ExceptionCodes::None != event->getExceptionCode()) + { + switch (event->getExceptionCode()) + { + case ExceptionCodes::InvalidArgumentException: + case ExceptionCodes::NotFoundException: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::NOT_FOUND_ERROR, "given app id is not found"); + break; + case ExceptionCodes::PlatformException: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR, "platform exception"); + break; + default: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR,"unknown error"); + break; + } + + callbackManager->callOnError(error); + return; + } + + Try { + callbackManager->callOnSuccess(); + return; + } Catch(Exception) { + LogError("error during processing answer" << _rethrown_exception.GetMessage()); + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR, "Internal error"); + + callbackManager->callOnError(error); + return; + } +} + +void ApplicationAsyncAnswerHandler::kill(const EventApplicationKillPtr &event) +{ + LogDebug("entered"); + JSCallbackManagerPtr callbackManager = + DPL::StaticPointerCast(event->getPrivateData()); + if (!callbackManager) { + LogError("no callback manager"); + return; + } + + ApplicationAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager); + + if(event->checkCancelled()) { + LogDebug("Operation cancelled"); + return; + } + + JSContextRef gContext = callbackManager->getContext(); + + JSValueRef error = NULL; + if (ExceptionCodes::None != event->getExceptionCode()) + { + switch (event->getExceptionCode()) + { + case ExceptionCodes::NotFoundException: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::NOT_FOUND_ERROR,"given package is not found"); + break; + case ExceptionCodes::PlatformException: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR,"platform exception"); + break; + case ExceptionCodes::InvalidArgumentException: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::INVALID_VALUES_ERROR, "invalid value"); + break; + default: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR,"unknown error"); + break; + } + + callbackManager->callOnError(error); + return; + } + + Try { + callbackManager->callOnSuccess(); + return; + } Catch(Exception) { + LogError("error during processing answer" << _rethrown_exception.GetMessage()); + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR, "Internal error"); + + callbackManager->callOnError(error); + return; + } +} + +void ApplicationAsyncAnswerHandler::launchAppControl(const EventApplicationLaunchAppControlPtr &event) +{ + LogDebug("entered"); + JSCallbackManagerPtr callbackManager = + DPL::StaticPointerCast(event->getPrivateData()); + if (!callbackManager) { + LogError("no callback manager"); + return; + } + + ApplicationAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager); + + if(event->checkCancelled()) { + LogDebug("Operation cancelled"); + return; + } + + JSContextRef gContext = callbackManager->getContext(); + + JSValueRef error = NULL; + if (ExceptionCodes::None != event->getExceptionCode()) + { + switch (event->getExceptionCode()) + { + case ExceptionCodes::NotFoundException: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::NOT_FOUND_ERROR,"given package is not found"); + break; + case ExceptionCodes::PlatformException: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR,"platform exception"); + break; + default: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR,"unknown error"); + break; + } + + callbackManager->callOnError(error); + return; + } + + Try { + callbackManager->callOnSuccess(); + return; + } Catch(Exception) { + LogError("error during processing answer" << _rethrown_exception.GetMessage()); + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR, "Internal error"); + + callbackManager->callOnError(error); + return; + } +} + +void ApplicationAsyncAnswerHandler::launchAppControlReply(const EventApplicationLaunchAppControlReplyPtr &event) +{ + LogDebug("entered"); + JSCallbackManagerPtr callbackManager = + DPL::StaticPointerCast(event->getPrivateData()); + if (!callbackManager) { + LogError("no callback manager"); + return; + } + + ApplicationAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager); + + if(event->checkCancelled()) { + LogDebug("Operation cancelled"); + return; + } + + JSContextRef gContext = callbackManager->getContext(); + + if (ExceptionCodes::None != event->getExceptionCode()) + { + callbackManager->callOnError(); + return; + } + + Try { + ApplicationControlDataArrayPtr appControlDataArray = event->getAppControlDataArray(); + if(appControlDataArray == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::UnknownException, "No reply"); + } + + ApplicationConverterFactory::ConverterType converter = + ApplicationConverterFactory::getConverter(gContext); + JSValueRef result = converter->toJSValueRef(*appControlDataArray); + + LogDebug("replyCallbackManager onsuccess"); + + callbackManager->callOnSuccess(result); + return; + } Catch(Exception) { + callbackManager->callOnError(); + return; + } +} + +void ApplicationAsyncAnswerHandler::findAppControl(const EventApplicationFindAppControlPtr &event) +{ + LogDebug("entered"); + JSCallbackManagerPtr callbackManager = + DPL::StaticPointerCast(event->getPrivateData()); + if (!callbackManager) { + LogError("no callback manager"); + return; + } + + ApplicationAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager); + + if(event->checkCancelled()) { + LogDebug("Operation cancelled"); + return; + } + + JSContextRef gContext = callbackManager->getContext(); + + JSValueRef error = NULL; + if (ExceptionCodes::None != event->getExceptionCode()) + { + switch (event->getExceptionCode()) + { + case ExceptionCodes::NotFoundException: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::NOT_FOUND_ERROR,"given package is not found"); + break; + case ExceptionCodes::PlatformException: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR,"platform exception"); + break; + default: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR,"unknown error"); + break; + } + + callbackManager->callOnError(error); + return; + } + + Try { + ApplicationInformationArrayPtr appInfos = event->getAppInfos(); + ApplicationControlPtr appControl = event->getAppControl(); + + ApplicationConverterFactory::ConverterType converter = + ApplicationConverterFactory::getConverter(gContext); + + JSValueRef result[2]; + result[0] = converter->toJSValueRef(appInfos); + result[1] = converter->toJSValueRef(appControl); + + callbackManager->callOnSuccess(result, 2); + return; + } Catch(Exception) { + LogError("error during processing answer" << _rethrown_exception.GetMessage()); + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR, "Internal error"); + + callbackManager->callOnError(error); + return; + } +} + +void ApplicationAsyncAnswerHandler::getAppsContext(const EventApplicationGetAppsContextPtr &event) +{ + LogDebug("entered"); + JSCallbackManagerPtr callbackManager = + DPL::StaticPointerCast(event->getPrivateData()); + if (!callbackManager) { + LogError("no callback manager"); + return; + } + + ApplicationAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager); + + if(event->checkCancelled()) { + LogDebug("Operation cancelled"); + return; + } + + JSContextRef gContext = callbackManager->getContext(); + + JSValueRef error = NULL; + if (ExceptionCodes::None != event->getExceptionCode()) + { + switch (event->getExceptionCode()) + { + case ExceptionCodes::NotFoundException: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::NOT_FOUND_ERROR,"given package is not found"); + break; + case ExceptionCodes::PlatformException: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR,"platform exception"); + break; + default: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR,"unknown error"); + break; + } + + callbackManager->callOnError(error); + return; + } + + Try { + ApplicationContextArrayPtr appContextArray = event->getAppContextArray(); + + ApplicationConverterFactory::ConverterType converter = + ApplicationConverterFactory::getConverter(gContext); + + JSValueRef result = converter->toJSValueRef(appContextArray); + + callbackManager->callOnSuccess(result); + return; + } Catch(Exception) { + LogError("error during processing answer" << _rethrown_exception.GetMessage()); + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR, "Internal error"); + + callbackManager->callOnError(error); + return; + } +} + +void ApplicationAsyncAnswerHandler::getAppsInfo(const EventApplicationGetAppsInfoPtr &event) +{ + LogDebug("entered"); + JSCallbackManagerPtr callbackManager = + DPL::StaticPointerCast(event->getPrivateData()); + if (!callbackManager) { + LogError("no callback manager"); + return; + } + + ApplicationAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager); + + if(event->checkCancelled()) { + LogDebug("Operation cancelled"); + return; + } + + JSContextRef gContext = callbackManager->getContext(); + + JSValueRef error = NULL; + if (ExceptionCodes::None != event->getExceptionCode()) + { + switch (event->getExceptionCode()) + { + case ExceptionCodes::NotFoundException: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::NOT_FOUND_ERROR,"given package is not found"); + break; + case ExceptionCodes::PlatformException: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR,"platform exception"); + break; + default: + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR,"unknown error"); + break; + } + + callbackManager->callOnError(error); + return; + } + + Try { + ApplicationInformationArrayPtr appInfoArray = event->getAppInfoArray(); + + ApplicationConverterFactory::ConverterType converter = + ApplicationConverterFactory::getConverter(gContext); + + JSValueRef result = converter->toJSValueRef(appInfoArray); + + callbackManager->callOnSuccess(result); + return; + } Catch(Exception) { + LogError("error during processing answer" << _rethrown_exception.GetMessage()); + error = JSTizenExceptionFactory::makeErrorObject(gContext, JSTizenException::UNKNOWN_ERROR, "Internal error"); + + callbackManager->callOnError(error); + return; + } +} + + +void ApplicationAsyncAnswerHandler::eventListener(const EventApplicationAppInfoEventListenerPtr &event) +{ + LogDebug("entered"); + JSApplicationEventCallbackManagerPtr callbackManager = + DPL::StaticPointerCast(event->getPrivateData()); + if (!callbackManager) + { + LogError("no callback manager"); + return; + } + + JSContextRef gContext = callbackManager->getContext(); + + ApplicationConverterFactory::ConverterType converter = + ApplicationConverterFactory::getConverter(gContext); + + Try { + if(event->getType() == EventApplicationAppInfoEventListener::OnInstalled) + { + ApplicationInformationPtr appInfo = event->getAppInfo(); + if(appInfo == NULL) + { + LogError("AppInfo did not set."); + return; + } + JSValueRef result = converter->toJSValueRefFromApplicationInformation(appInfo); + callbackManager->callOnInstalled(result); + } + else if(event->getType() == EventApplicationAppInfoEventListener::OnUpdated) + { + ApplicationInformationPtr appInfo = event->getAppInfo(); + if(appInfo == NULL) + { + LogError("AppInfo did not set."); + return; + } + JSValueRef result = converter->toJSValueRefFromApplicationInformation(appInfo); + callbackManager->callOnUpdated(result); + } + else if(event->getType() == EventApplicationAppInfoEventListener::OnUninstalled) + { + ApplicationInformationPtr appInfo = event->getAppInfo(); + std::string appId = appInfo->getAppId(); + if(appId == "") + { + LogError("AppId did not set."); + return; + } + JSValueRef result = converter->toJSValueRef(appId); + callbackManager->callOnUninstalled(result); + } + else + { + LogError("Event callback type is wrong."); + return; + } + } Catch (Exception) { + LogError("Conversion error"); + return; + } +} + +} // Application +} // DeviceAPI diff --git a/src/Application/ApplicationController.h b/src/Application/ApplicationController.h new file mode 100755 index 0000000..b76b2a2 --- /dev/null +++ b/src/Application/ApplicationController.h @@ -0,0 +1,98 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _TIZEN_APPLICATION_APPLICATION_CONTROLLER_H_ +#define _TIZEN_APPLICATION_APPLICATION_CONTROLLER_H_ + +#include +#include +#include +#include +#include +#include +#include +#include "IApplicationManager.h" + +namespace DeviceAPI { +namespace Application { + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject ApplicationPrivObject; + +typedef WrtDeviceApis::Commons::EventAnswerReceiver + EventApplicationLaunchEventAnswerReceiver; +typedef WrtDeviceApis::Commons::EventAnswerReceiver + EventApplicationKillEventAnswerReceiver; +typedef WrtDeviceApis::Commons::EventAnswerReceiver + EventApplicationLaunchAppControlEventAnswerReceiver; +typedef WrtDeviceApis::Commons::EventAnswerReceiver + EventApplicationLaunchAppControlReplyEventAnswerReceiver; +typedef WrtDeviceApis::Commons::EventAnswerReceiver + EventApplicationFindAppControlEventAnswerReceiver; +typedef WrtDeviceApis::Commons::EventAnswerReceiver + EventApplicationGetAppsContextEventAnswerReceiver; +typedef WrtDeviceApis::Commons::EventAnswerReceiver + EventApplicationGetAppsInfoEventAnswerReceiver; +typedef WrtDeviceApis::Commons::EventListener + EventApplicationAppInfoEventListenerListener; + +class ApplicationController : + public EventApplicationLaunchEventAnswerReceiver, + public EventApplicationKillEventAnswerReceiver, + public EventApplicationLaunchAppControlEventAnswerReceiver, + public EventApplicationLaunchAppControlReplyEventAnswerReceiver, + public EventApplicationFindAppControlEventAnswerReceiver, + public EventApplicationGetAppsContextEventAnswerReceiver, + public EventApplicationGetAppsInfoEventAnswerReceiver, + public EventApplicationAppInfoEventListenerListener, + public ApplicationPrivObject +{ +public: + ApplicationController(JSContextRef context, + IApplicationManagerPtr application); + virtual ~ApplicationController(); +protected: + void OnAnswerReceived(const EventApplicationLaunchPtr &event); + void OnAnswerReceived(const EventApplicationKillPtr &event); + void OnAnswerReceived(const EventApplicationLaunchAppControlPtr &event); + void OnAnswerReceived(const EventApplicationLaunchAppControlReplyPtr &event); + void OnAnswerReceived(const EventApplicationFindAppControlPtr &event); + void OnAnswerReceived(const EventApplicationGetAppsContextPtr &event); + void OnAnswerReceived(const EventApplicationGetAppsInfoPtr &event); + void onAnswerReceived(const EventApplicationAppInfoEventListenerPtr &event); +}; + +typedef DPL::SharedPtr ApplicationControllerPtr; + +//common part +class ApplicationAsyncAnswerHandler +{ +public: + static void launch(const EventApplicationLaunchPtr &event); + static void kill(const EventApplicationKillPtr &event); + static void launchAppControl(const EventApplicationLaunchAppControlPtr &event); + static void launchAppControlReply(const EventApplicationLaunchAppControlReplyPtr &event); + static void findAppControl(const EventApplicationFindAppControlPtr &event); + static void getAppsContext(const EventApplicationGetAppsContextPtr &event); + static void getAppsInfo(const EventApplicationGetAppsInfoPtr &event); + static void eventListener(const EventApplicationAppInfoEventListenerPtr &event); +}; + +} // Application +} // DeviceAPI + +#endif // _TIZEN_APPLICATION_APPLICATION_CONTROLLER_H_ diff --git a/src/Application/ApplicationConverter.cpp b/src/Application/ApplicationConverter.cpp new file mode 100755 index 0000000..b17a301 --- /dev/null +++ b/src/Application/ApplicationConverter.cpp @@ -0,0 +1,360 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include + +#include "ApplicationConverter.h" +#include "JSApplication.h" +#include "JSApplicationInformation.h" +#include "JSApplicationContext.h" +#include "JSApplicationControlData.h" +#include "JSApplicationControlData.h" +#include "JSApplicationControl.h" +#include "JSRequestedApplicationControl.h" +#include "JSApplicationCert.h" + +namespace DeviceAPI { +namespace Application { + +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::CommonsJavaScript; + +ApplicationConverter::ApplicationConverter(JSContextRef context) : Converter(context) +{ +} + +ApplicationConverter::~ApplicationConverter() +{ +} + + +JSValueRef ApplicationConverter::toJSValueRefFromApplication(const ApplicationPtr &arg) +{ + LogDebug("entered to toJSValueRefFromApplication "); + if(arg == NULL) { + Throw(Commons::ConversionException); + } + return CommonsJavaScript::JSUtils::makeObject(m_context, JSApplication::getClassRef(), arg); +} + + +JSValueRef ApplicationConverter::toJSValueRefFromApplicationCert(const ApplicationCertPtr &arg) +{ + LogDebug("entered to toJSValueRefFromApplicationCert "); + if(arg == NULL) { + Throw(Commons::ConversionException); + } + return CommonsJavaScript::JSUtils::makeObject(m_context, JSApplicationCert::getClassRef(), arg); +} + + +JSValueRef ApplicationConverter::toJSValueRefFromeApplicationCerts(const ApplicationCertArrayPtr &arg) +{ + if(arg == NULL) { + Throw(Commons::InvalidArgumentException); + } + return toJSValueRef_(*arg, &ApplicationConverter::toJSValueRefFromApplicationCert, this); +} + + +JSValueRef ApplicationConverter::toJSValueRefFromApplicationInformation(const ApplicationInformationPtr &arg) +{ + if(arg == NULL) { + Throw(Commons::ConversionException); + } + return CommonsJavaScript::JSUtils::makeObject(m_context, JSApplicationInformation::getClassRef(), arg); +} + +ApplicationInformationPtr ApplicationConverter::toApplicationInformation(const JSValueRef &jsValue) +{ + if(JSApplicationInformation::isObjectOfClass(m_context, jsValue)) + return JSApplicationInformation::getApplicationInformation(m_context, jsValue); + + const ScopedJSStringRef nameStr(JSStringCreateWithUTF8CString(TIZEN_APPLICATION_INFORMATION_NAME)); + const ScopedJSStringRef appIdStr(JSStringCreateWithUTF8CString(TIZEN_APPLICATION_INFORMATION_ID)); + const ScopedJSStringRef iconPathStr(JSStringCreateWithUTF8CString(TIZEN_APPLICATION_INFORMATION_ICONPATH)); + const ScopedJSStringRef versionStr(JSStringCreateWithUTF8CString(TIZEN_APPLICATION_INFORMATION_VERSION)); + const ScopedJSStringRef showStr(JSStringCreateWithUTF8CString(TIZEN_APPLICATION_INFORMATION_SHOW)); + const ScopedJSStringRef categoriesStr(JSStringCreateWithUTF8CString(TIZEN_APPLICATION_INFORMATION_CATEGORIES)); + const ScopedJSStringRef installDateStr(JSStringCreateWithUTF8CString(TIZEN_APPLICATION_INFORMATION_INSTALL_DATE)); + const ScopedJSStringRef installSizeStr(JSStringCreateWithUTF8CString(TIZEN_APPLICATION_INFORMATION_INSTALL_SIZE)); + const ScopedJSStringRef packageIdStr(JSStringCreateWithUTF8CString(TIZEN_APPLICATION_INFORMATION_PACKAGE_ID)); + + JSObjectRef jsObject = toJSObjectRef(jsValue); + + JSValueRef nameData = JSObjectGetProperty(m_context, jsObject, nameStr.get(), NULL); + JSValueRef appIdStrData = JSObjectGetProperty(m_context, jsObject, appIdStr.get(), NULL); + JSValueRef iconPathData = JSObjectGetProperty(m_context, jsObject, iconPathStr.get(), NULL); + JSValueRef versionData = JSObjectGetProperty(m_context, jsObject, versionStr.get(), NULL); + JSValueRef showData = JSObjectGetProperty(m_context, jsObject, showStr.get(), NULL); + JSValueRef categoriesData = JSObjectGetProperty(m_context, jsObject, categoriesStr.get(), NULL); + JSValueRef installDateData = JSObjectGetProperty(m_context, jsObject, installDateStr.get(), NULL); + JSValueRef installSizeData = JSObjectGetProperty(m_context, jsObject, installSizeStr.get(), NULL); + JSValueRef pkgIdStrData = JSObjectGetProperty(m_context, jsObject, packageIdStr.get(), NULL); + + std::string name; + std::string appid; + std::string iconPath; + std::string version; + bool show; + std::vector categories; + time_t installDate; + long installSize; + std::string pkgid; + + ApplicationInformationPtr result(new ApplicationInformation()); + if (!result) { + Throw(Commons::ConversionException); + } + + if (!JSValueIsUndefined(m_context, nameData)) { + name = toString(nameData); + result->setName(name); + } + if (!JSValueIsUndefined(m_context, appIdStrData)) { + appid = toString(appIdStrData); + result->setAppId(appid); + } + if (!JSValueIsUndefined(m_context, iconPathData)) { + iconPath = toString(iconPathData); + result->setIconPath(iconPath); + } + if (!JSValueIsUndefined(m_context, versionData)) { + version = toString(versionData); + result->setVersion(version); + } + if (!JSValueIsUndefined(m_context, showData)) { + show = toBool(showData); + result->setShow(show); + } + if (!JSValueIsUndefined(m_context, categoriesData)) { + categories = toVectorOfStrings(categoriesData); + result->setCategories(categories); + } + if (!JSValueIsUndefined(m_context, installDateData)) { + installDate = toDateTimeT(installDateData); + result->setInstallDate(installDate); + } + if (!JSValueIsUndefined(m_context, installSizeData)) { + installSize = toDateTimeT(installSizeData); + result->setInstallSize(installSize); + } + if (!JSValueIsUndefined(m_context, pkgIdStrData)) { + pkgid = toString(pkgIdStrData); + result->setPackageId(pkgid); + } + return result; +} + +JSValueRef ApplicationConverter::toJSValueRef(const ApplicationInformationArrayPtr &arg) +{ + if(arg == NULL) { + Throw(Commons::InvalidArgumentException); + } + return toJSValueRef_(*arg, &ApplicationConverter::toJSValueRefFromApplicationInformation, this); +} + +ApplicationInformationArrayPtr ApplicationConverter::toApplicationInformationArray(const JSValueRef &jsValue) +{ + ApplicationInformationArrayPtr result(new ApplicationInformationArray()); + + JSObjectRef jsObject = toJSObjectRef(jsValue); + for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) { + JSValueRef element = JSGetArrayElement(m_context, jsObject, i); + result->push_back(toApplicationInformation(element)); + } + return result; +} + +JSValueRef ApplicationConverter::toJSValueRefFromApplicationContext(const ApplicationContextPtr &arg) +{ + if(arg == NULL) { + Throw(Commons::InvalidArgumentException); + } + return CommonsJavaScript::JSUtils::makeObject(m_context, JSApplicationContext::getClassRef(), arg); +} + +ApplicationContextPtr ApplicationConverter::toApplicationContext(const JSValueRef &jsValue) +{ + if(JSApplicationContext::isObjectOfClass(m_context, jsValue)) + return JSApplicationContext::getApplicationContext(m_context, jsValue); + + const ScopedJSStringRef appIdStr(JSStringCreateWithUTF8CString(TIZEN_APPLICATION_CONTEXT_APP_ID)); + const ScopedJSStringRef contextIdStr(JSStringCreateWithUTF8CString(TIZEN_APPLICATION_CONTEXT_ID)); + + JSObjectRef jsObject = toJSObjectRef(jsValue); + + JSValueRef appIdStrData = JSObjectGetProperty(m_context, jsObject, appIdStr.get(), NULL); + JSValueRef contextIdStrData = JSObjectGetProperty(m_context, jsObject, contextIdStr.get(), NULL); + + std::string appid; + std::string contextid; + + ApplicationContextPtr result(new ApplicationContext()); + if (!result) { + Throw(Commons::ConversionException); + } + + if (!JSValueIsUndefined(m_context, appIdStrData)) { + appid = toString(appIdStrData); + result->setAppId(appid); + } + if (!JSValueIsUndefined(m_context, contextIdStrData)) { + contextid = toString(contextIdStrData); + result->setContextId(contextid); + } + + return result; +} + +JSValueRef ApplicationConverter::toJSValueRef(const ApplicationContextArrayPtr &arg) +{ + if(arg == NULL) { + Throw(Commons::ConversionException); + } + return toJSValueRef_(*arg, &ApplicationConverter::toJSValueRefFromApplicationContext, this); +} + +ApplicationContextArrayPtr ApplicationConverter::toApplicationContextArray(const JSValueRef &jsValue) +{ + ApplicationContextArrayPtr result(new ApplicationContextArray()); + + JSObjectRef jsObject = toJSObjectRef(jsValue); + for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) { + JSValueRef element = JSGetArrayElement(m_context, jsObject, i); + result->push_back(toApplicationContext(element)); + } + return result; +} + + +JSValueRef ApplicationConverter::toJSValueRef(const RequestedApplicationControlPtr &arg) +{ + LogDebug("entered to toJSValueRefFromRequestedApplicationControl" ); + if(arg == NULL) { + Throw(Commons::InvalidArgumentException); + } + return CommonsJavaScript::JSUtils::makeObject(m_context, JSRequestedApplicationControl::getClassRef(), arg); +} + +RequestedApplicationControlPtr ApplicationConverter::toRequestedApplicationControl(const JSValueRef &jsValue) +{ + if(JSRequestedApplicationControl::isObjectOfClass(m_context, jsValue)) { + return JSRequestedApplicationControl::getRequestedApplicationControl(m_context, jsValue); + } else { + ThrowMsg(Commons::ConversionException, "Wrong parameter type."); + } +} + + +JSValueRef ApplicationConverter::toJSValueRef(const ApplicationControlPtr &arg) +{ + LogDebug("entered"); + if(arg == NULL) { + Throw(Commons::InvalidArgumentException); + } + return JSApplicationControl::createJSObject(m_context, arg); +} + +ApplicationControlPtr ApplicationConverter::toApplicationControl(const JSValueRef &jsValue) +{ + if(JSApplicationControl::isObjectOfClass(m_context, jsValue)) { + return JSApplicationControl::getApplicationControl(m_context, jsValue); + } else { + ThrowMsg(Commons::ConversionException, "Wrong parameter type."); + } +} + +JSValueRef ApplicationConverter::toJSValueRef(const ApplicationControlDataPtr &arg) +{ + LogDebug("entered"); + return CommonsJavaScript::JSUtils::makeObject(m_context, JSApplicationControlData::getClassRef(), arg); +} + +ApplicationControlDataPtr ApplicationConverter::toApplicationControlData(const JSValueRef &jsValue) +{ + if(JSApplicationControlData::isObjectOfClass(m_context, jsValue)) + return JSApplicationControlData::getApplicationControlData(m_context, jsValue); + + const ScopedJSStringRef appControlDataKeyStr(JSStringCreateWithUTF8CString(TIZEN_APPLICATION_CONTROL_DATA_KEY)); + const ScopedJSStringRef appControlDataValueStr(JSStringCreateWithUTF8CString(TIZEN_APPLICATION_CONTROL_DATA_VALUE)); + + JSObjectRef jsObject = toJSObjectRef(jsValue); + + JSValueRef appControlDataKeyData = JSObjectGetProperty(m_context, jsObject, appControlDataKeyStr.get(), NULL); + JSValueRef appControlDataValueData = JSObjectGetProperty(m_context, jsObject, appControlDataValueStr.get(), NULL); + + ApplicationControlDataPtr result(new ApplicationControlData()); + if (!result) { + Throw(Commons::ConversionException); + } + + if (!JSValueIsUndefined(m_context, appControlDataKeyData)) { + result->setKey(toString(appControlDataKeyData)); + } + + if (!JSValueIsUndefined(m_context, appControlDataValueData)) { + result->setValue(toVectorOfStrings(appControlDataValueData)); + } + return result; +} + +JSValueRef ApplicationConverter::toJSValueRef(const std::vector &arg) +{ + JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL); + + if (jsResult == NULL) { + ThrowMsg(Commons::ConversionException, "Could not create js array object"); + } + + for (std::size_t i = 0; i < arg.size(); ++i) { + JSValueRef tmpVal = toJSValueRef(arg[i]); + if (!JSSetArrayElement(m_context, jsResult, i, tmpVal)) { + ThrowMsg(Commons::ConversionException, "Could not insert value into js array"); + } + } + + return jsResult; +} + +std::vector ApplicationConverter::toApplicationControlDataArray(const JSValueRef &jsValue) +{ + if (JSValueIsNull(m_context, jsValue) || JSValueIsUndefined(m_context, jsValue)) { + return std::vector(); + } + + if (!JSIsArrayValue(m_context, jsValue)) { + ThrowMsg(Commons::ConversionException, "Argument is not an JS array."); + } + + std::vector result; + JSObjectRef objArg = toJSObjectRef(jsValue); + for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); ++i) { + JSValueRef element = JSGetArrayElement(m_context, objArg, i); + result.push_back(toApplicationControlData(element)); + } + return result; +} + +} +} diff --git a/src/Application/ApplicationConverter.h b/src/Application/ApplicationConverter.h new file mode 100755 index 0000000..d707f69 --- /dev/null +++ b/src/Application/ApplicationConverter.h @@ -0,0 +1,65 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_TIZEN_APPLICATION_CONVERTER_H_ +#define TIZENAPIS_TIZEN_APPLICATION_CONVERTER_H_ + +#include +#include +#include "IApplicationManager.h" +#include "ApplicationInformation.h" +#include "ApplicationContext.h" +#include "ApplicationControlData.h" +#include "ApplicationControl.h" +#include "ApplicationCert.h" + + +namespace DeviceAPI { +namespace Application { +class ApplicationConverter : public WrtDeviceApis::CommonsJavaScript::Converter +{ +public: + using WrtDeviceApis::CommonsJavaScript::Converter::toJSValueRef; +public: + explicit ApplicationConverter(JSContextRef context); + virtual ~ApplicationConverter(); + JSValueRef toJSValueRefFromApplication(const ApplicationPtr &arg); + JSValueRef toJSValueRefFromApplicationInformation(const ApplicationInformationPtr &arg); + JSValueRef toJSValueRefFromApplicationCert(const ApplicationCertPtr &arg); + JSValueRef toJSValueRefFromeApplicationCerts(const ApplicationCertArrayPtr &arg); + ApplicationInformationPtr toApplicationInformation(const JSValueRef &jsValue); + JSValueRef toJSValueRef(const ApplicationInformationArrayPtr &arg); + ApplicationInformationArrayPtr toApplicationInformationArray(const JSValueRef &jsValue); + JSValueRef toJSValueRefFromApplicationContext(const ApplicationContextPtr &arg); + ApplicationContextPtr toApplicationContext(const JSValueRef &jsValue); + JSValueRef toJSValueRef(const ApplicationContextArrayPtr &arg); + ApplicationContextArrayPtr toApplicationContextArray(const JSValueRef &jsValue); + JSValueRef toJSValueRef(const RequestedApplicationControlPtr &arg); + RequestedApplicationControlPtr toRequestedApplicationControl(const JSValueRef &jsValue); + JSValueRef toJSValueRef(const ApplicationControlPtr &arg); + ApplicationControlPtr toApplicationControl(const JSValueRef &jsValue); + JSValueRef toJSValueRef(const ApplicationControlDataPtr &arg); + ApplicationControlDataPtr toApplicationControlData(const JSValueRef &jsValue); + JSValueRef toJSValueRef(const std::vector &arg); + std::vector toApplicationControlDataArray(const JSValueRef &jsValue); +}; + +typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory ApplicationConverterFactory; +} +} +#endif diff --git a/src/Application/ApplicationFactory.cpp b/src/Application/ApplicationFactory.cpp new file mode 100755 index 0000000..968ad68 --- /dev/null +++ b/src/Application/ApplicationFactory.cpp @@ -0,0 +1,38 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 "ApplicationManager.h" +#include "ApplicationFactory.h" + +namespace DeviceAPI { +namespace Application { + +IApplicationManagerPtr ApplicationFactory::createApplication() { + return IApplicationManagerPtr(new ApplicationManager()); +} + +ApplicationFactory& ApplicationFactory::getInstance() { + static ApplicationFactory theInstance; + return theInstance; +} + +ApplicationFactory::ApplicationFactory() { +} + +} +} diff --git a/src/Application/ApplicationFactory.h b/src/Application/ApplicationFactory.h new file mode 100755 index 0000000..857295f --- /dev/null +++ b/src/Application/ApplicationFactory.h @@ -0,0 +1,40 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_API_APPLICATION_FACTORY_H_ +#define TIZENAPIS_API_APPLICATION_FACTORY_H_ + +#include +#include "IApplicationManager.h" + +namespace DeviceAPI { +namespace Application { + +class ApplicationFactory: DPL::Noncopyable { +public: + IApplicationManagerPtr createApplication(); + static ApplicationFactory& getInstance(); + +protected: + ApplicationFactory(); +}; + +} +} + +#endif diff --git a/src/Application/ApplicationInformation.cpp b/src/Application/ApplicationInformation.cpp new file mode 100755 index 0000000..395247e --- /dev/null +++ b/src/Application/ApplicationInformation.cpp @@ -0,0 +1,153 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 "ApplicationInformation.h" + +namespace DeviceAPI { +namespace Application { +ApplicationInformation::ApplicationInformation(const std::string &appId) +{ + m_show = false; + m_installDate = 0; + m_installSize = 0; + m_isInitialized = false; + m_appId = appId; +} + +ApplicationInformation::ApplicationInformation() +{ + m_show = false; + m_installDate = 0; + m_installSize = 0; + m_isInitialized = false; +} + +ApplicationInformation::~ApplicationInformation() +{ +} + +std::string ApplicationInformation::getName() const +{ + return m_name; +} + +void ApplicationInformation::setName(const std::string &name) +{ + m_name = name; +} + +std::string ApplicationInformation::getAppId() const +{ + return m_appId; +} + +void ApplicationInformation::setAppId(const std::string &appId) +{ + m_appId = appId; +} + +std::string ApplicationInformation::getIconPath() const +{ + return m_iconPath; +} + +void ApplicationInformation::setIconPath(const std::string &iconPath) +{ + m_iconPath = iconPath; +} + +std::string ApplicationInformation::getVersion() const +{ + return m_version; +} + +void ApplicationInformation::setVersion(const std::string &version) +{ + m_version = version; +} + +bool ApplicationInformation::getShow() const +{ + return m_show; +} + +void ApplicationInformation::setShow(const bool &show) +{ + m_show = show; +} + +std::vector ApplicationInformation::getCategories() const +{ + return m_categories; +} + +void ApplicationInformation::setCategories(const std::vector &categories) +{ + m_categories = categories; +} + +void ApplicationInformation::addCategories(const std::string &category) +{ + m_categories.push_back(category); +} + +time_t ApplicationInformation::getInstallDate() const +{ + return m_installDate; +} + +void ApplicationInformation::setInstallDate(const time_t &date) +{ + m_installDate = date; +} + +long ApplicationInformation::getInstallSize() const +{ + return m_installSize; +} + +void ApplicationInformation::setInstallSize(const long &size) +{ + m_installSize = size; +} + +std::string ApplicationInformation::getPackageId() const +{ + return m_pkgId; +} + +void ApplicationInformation::setPackageId(const std::string &pkgId) +{ + m_pkgId = pkgId; +} + + +// Temporal code. if package manager issue is solved, disable below code. +#if 1 +bool ApplicationInformation::isInitialized() const +{ + return m_isInitialized; +} + +void ApplicationInformation::setInitialize() +{ + m_isInitialized = true; +} +#endif + +} +} diff --git a/src/Application/ApplicationInformation.h b/src/Application/ApplicationInformation.h new file mode 100755 index 0000000..c0f5410 --- /dev/null +++ b/src/Application/ApplicationInformation.h @@ -0,0 +1,82 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_INFORMATION_H_ +#define TIZENAPIS_API_APPLICATION_INFORMATION_H_ + +#include +#include +#include +#include + +namespace DeviceAPI { +namespace Application { + +class ApplicationInformation; +typedef DPL::SharedPtr ApplicationInformationPtr; + +typedef std::vector ApplicationInformationArray; +typedef DPL::SharedPtr ApplicationInformationArrayPtr; + +class ApplicationInformation +{ + public: + ApplicationInformation(const std::string &appId); + ApplicationInformation(); + ~ApplicationInformation(); + + std::string getName() const; + void setName(const std::string &name); + std::string getAppId() const; + void setAppId(const std::string &appId); + std::string getIconPath() const; + void setIconPath(const std::string &iconPath); + std::string getVersion() const; + void setVersion(const std::string &version); + bool getShow() const; + void setShow(const bool &show); + std::vector getCategories() const; + void setCategories(const std::vector &categories); + void addCategories(const std::string &category); + time_t getInstallDate() const; + void setInstallDate(const time_t &date); + long getInstallSize() const; + void setInstallSize(const long &size); + std::string getPackageId() const; + void setPackageId(const std::string &pkgId); + // temporal code. if package manager issue is solved, disable below code. +#if 1 + bool isInitialized() const; + void setInitialize(); +#endif + + private: + std::string m_name; + std::string m_appId; + std::string m_iconPath; + std::string m_version; + bool m_show; + time_t m_installDate; + long m_installSize; + std::string m_pkgId; + // temporal code. if package manager issue is solved, disable below code. + bool m_isInitialized; + std::vector m_categories; +}; +} +} +#endif diff --git a/src/Application/ApplicationInformationEventPrivateData.h b/src/Application/ApplicationInformationEventPrivateData.h new file mode 100755 index 0000000..e3f9acf --- /dev/null +++ b/src/Application/ApplicationInformationEventPrivateData.h @@ -0,0 +1,65 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_TIZEN_APPLICATION_INFORMATION_EVENT_PRIVATE_DATA_H_ +#define TIZENAPIS_TIZEN_APPLICATION_INFORMATION_EVENT_PRIVATE_DATA_H_ + +#include +#include +#include + +namespace DeviceAPI { +namespace Application { + +using namespace WrtDeviceApis::CommonsJavaScript; + +class ApplicationInformationEventPrivateData : public WrtDeviceApis::Commons::IEventPrivateData +{ + public: + ApplicationInformationEventPrivateData(const JSCallbackManagerPtr& onInstalled, + const JSCallbackManagerPtr& onUpdated, + const JSCallbackManagerPtr& onUninstalled): + m_onInstalled(onInstalled), + m_onUpdated(onUpdated), + m_onUninstalled(onUninstalled) + { + } + + JSCallbackManagerPtr getOnInstalled() const + { + return m_onInstalled; + } + JSCallbackManagerPtr getOnUpdated() const + { + return m_onUpdated; + } + JSCallbackManagerPtr getOnUninstalled() const + { + return m_onUninstalled; + } + +private: + JSCallbackManagerPtr m_onInstalled; + JSCallbackManagerPtr m_onUpdated; + JSCallbackManagerPtr m_onUninstalled; +}; + +typedef DPL::SharedPtr ApplicationInformationEventPrivateDataPtr; +} +} +#endif diff --git a/src/Application/ApplicationListenerManager.cpp b/src/Application/ApplicationListenerManager.cpp new file mode 100755 index 0000000..2b082ca --- /dev/null +++ b/src/Application/ApplicationListenerManager.cpp @@ -0,0 +1,29 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 "ApplicationListenerManager.h" +#include + +using namespace DPL; + +IMPLEMENT_SINGLETON(DeviceAPI::Application::ApplicationListenerManager) + +namespace DeviceAPI { +namespace Application { + +} // Application +} // DeviceAPI diff --git a/src/Application/ApplicationListenerManager.h b/src/Application/ApplicationListenerManager.h new file mode 100644 index 0000000..e82cd83 --- /dev/null +++ b/src/Application/ApplicationListenerManager.h @@ -0,0 +1,97 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _TIZEN_APPLICATION_LISTENER_MANAGER_H_ +#define _TIZEN_APPLICATION_LISTENER_MANAGER_H_ + +#include +#include +#include +#include +#include +#include +#include "JSApplicationManager.h" +#include "ApplicationController.h" + +namespace DeviceAPI { +namespace Application { + +class ApplicationListenerManager : public DeviceAPI::Common::IListenerController +{ +public: + ApplicationListenerManager() + { + } + + virtual ~ApplicationListenerManager() + { + } +}; +typedef DPL::Singleton ApplicationListenerManagerSingleton; + +class ApplicationListenerCanceller : public DeviceAPI::Common::IListenerItem +{ +public: + ApplicationListenerCanceller(JSContextRef context, JSObjectRef object, long watchId) : + DeviceAPI::Common::IListenerItem(context, object, watchId) + { + } + + virtual ~ApplicationListenerCanceller() + { + } + + virtual void cancelListener() + { + ApplicationController *priv = static_cast(JSObjectGetPrivate(m_object)); + + if(!priv) + { + LogError("Object has no private object."); + return; + } + + IApplicationManagerPtr application(priv->getObject()); + + Try + { + LogDebug("Remove a listener"); + EventApplicationRemoveAppInfoEventListenerPtr event( + new EventApplicationRemoveAppInfoEventListener()); + + event->setWatchId(m_watchId); + event->setForSynchronousCall(); + + Try { + LogDebug("Remove change listener"); + application->removeAppInfoEventListener(event); + } Catch(WrtDeviceApis::Commons::Exception) { + LogError("Error on platform : " << _rethrown_exception.GetMessage()); + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("Error on platform : " << _rethrown_exception.GetMessage()); + } + } +}; +typedef DPL::SharedPtr ApplicationListenerCancellerPtr; + +} // Application +} // DeviceAPI + +#endif // _TIZEN_APPLICATION_LISTENER_MANAGER_H_ diff --git a/src/Application/ApplicationManager.cpp b/src/Application/ApplicationManager.cpp new file mode 100644 index 0000000..7c9ba47 --- /dev/null +++ b/src/Application/ApplicationManager.cpp @@ -0,0 +1,1654 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 "ApplicationManager.h" + +#include +#include +#include +#include +#include + +#include "ApplicationInformation.h" +#include "ApplicationContext.h" +#include "ApplicationControlData.h" +#include "ApplicationControl.h" +#include "ApplicationCert.h" +#include "Application.h" + +#include + +#include + +// to launch app by aul +#include + +// to get package name by appid +#include +#include + +// To get cert information from package +#include +#include + +// To get app size and installed time +#include + +// To get ppid +#include + +namespace DeviceAPI { +namespace Application { + +using namespace DPL; +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; + +namespace { + + typedef KeyMultiMap LaunchAppControlPendingEventMap; + static LaunchAppControlPendingEventMap gLaunchAppControlPendingEventMap; + + // Callback from 'app_manager_set_app_context_event_cb' + // Used by 'kill' + static void app_manager_app_context_event_callback(app_context_h app_context, + app_context_event_e event, void *user_data) + { + LogDebug("called"); + int ret = 0; + + if(event != APP_CONTEXT_EVENT_TERMINATED) + return; + + int pid = 0; + + ret = app_context_get_pid(app_context, &pid); + if(ret != APP_MANAGER_ERROR_NONE) + { + LogDebug("Fail to get pid of terminated app (" << ret << ")"); + return; + } + + ApplicationManager* appManager = (ApplicationManager*)(user_data); + appManager->invokeManualAnswerKill(pid); + } + + // get package name by id + static char* getPackageByAppId(const char* appId) + { + app_info_h handle; + char* pkgName; + int ret = 0; + + ret = app_manager_get_app_info(appId, &handle); + if (ret < 0) + { + LogDebug("Fail to get appinfo by " << appId); + return NULL; + } + + ret = app_info_get_package(handle, &pkgName); + if (ret < 0) + { + LogDebug("Fail to get pkgName by " << appId); + pkgName = NULL; + } + + ret = app_info_destroy(handle); + if (ret < 0) + { + LogDebug("Fail to get destory appinfo"); + return NULL; + } + + return pkgName; + } + + + // Callback of 'app_manager_foreach_app_context' + // Used by 'getAppsContext' + static bool app_manager_app_context_callback(app_context_h app_context, void *user_data) + { + int ret = 0; + + char *app_id = NULL; + int pid; + + std::string contextId; + + if (user_data == NULL) + { + return false; + } + + ret = app_context_get_app_id(app_context, &app_id); + if((ret != APP_MANAGER_ERROR_NONE) || (app_id == NULL)) + { + LogDebug("app_context_get_app_id error (" << ret << ")"); + return false; + } + + ret = app_context_get_pid(app_context, &pid); + if(ret != APP_MANAGER_ERROR_NONE) + { + LogDebug("app_context_get_app_id error (" << ret << ")"); + if (app_id) + free(app_id); + return false; + } + + std::stringstream sstream; + sstream << pid; + contextId = sstream.str(); + + ApplicationContextPtr appContext(new ApplicationContext()); + appContext->setAppId(app_id); + appContext->setContextId(contextId); + + ApplicationContextArray* appContextArray = (ApplicationContextArray*)user_data; + + appContextArray->push_back(appContext); + + if (app_id) + free(app_id); + + return true; + } + + // Callback of 'service_send_launch_request' + // Used by 'launchAppControl' + static void service_reply_callback(service_h request, service_h reply, + service_result_e result, void *user_data) + { + LogDebug("appControlResultCallback called"); + LaunchAppControlPendingEventMap::DataKeyType key = + (LaunchAppControlPendingEventMap::DataKeyType)user_data; + + LaunchAppControlPendingEvent *pendingEvent = gLaunchAppControlPendingEventMap.getData(key); + if(pendingEvent != NULL) + { + ApplicationManager *application = (ApplicationManager *)pendingEvent->getThisObject(); + EventApplicationLaunchAppControlReplyPtr event = pendingEvent->getEvent(); + application->invokeManualAnswerLaunchAppControl(request, reply, result, event); + + delete pendingEvent; + pendingEvent = NULL; + user_data = NULL; + + gLaunchAppControlPendingEventMap.eraseData(key); + } + } + + static bool package_cert_cb(package_info_h handle, package_cert_type_e cert_type, const char *cert_value, void *user_data) + { + ApplicationCertPtr cert(new ApplicationCert()); + const char* certName = NULL; + + switch(cert_type) { + case PACKAGE_INFO_AUTHOR_ROOT_CERT: + certName = "AUTHOR_ROOT"; + break; + case PACKAGE_INFO_AUTHOR_INTERMEDIATE_CERT: + certName = "AUTHOR_INTERMEDIATE"; + break; + case PACKAGE_INFO_AUTHOR_SIGNER_CERT: + certName = "AUTHOR_SIGNER"; + break; + case PACKAGE_INFO_DISTRIBUTOR_ROOT_CERT: + certName = "DISTRIBUTOR_ROOT"; + break; + case PACKAGE_INFO_DISTRIBUTOR_INTERMEDIATE_CERT: + certName = "DISTRIBUTOR_INTERMEDIATE"; + break; + case PACKAGE_INFO_DISTRIBUTOR_SIGNER_CERT: + certName = "DISTRIBUTOR_SIGNER"; + break; + case PACKAGE_INFO_DISTRIBUTOR2_ROOT_CERT: + certName = "DISTRIBUTOR2_ROOT"; + break; + case PACKAGE_INFO_DISTRIBUTOR2_INTERMEDIATE_CERT: + certName = "DISTRIBUTOR2_INTERMEDIATE"; + break; + case PACKAGE_INFO_DISTRIBUTOR2_SIGNER_CERT: + certName = "DISTRIBUTOR2_SIGNER"; + break; + default: + LogDebug("Unknow Cert type!!!"); + break; + } + + cert->setType(certName); + cert->setValue(cert_value); + + ApplicationCertArray *certs = (ApplicationCertArray *)user_data; + certs->push_back(cert); + + return true; + } + + + static int get_current_app_id(char** app_id) + { + LogDebug("get_current_app_id enter"); + int parent_pid = getppid(); + LogDebug("parent pid : " << parent_pid); + + int ret = app_manager_get_app_id(parent_pid, app_id); + + if ((ret != APP_MANAGER_ERROR_NONE) || (app_id == NULL)) + { + LogDebug("Cannot get app id from pid : " << parent_pid); + } + else + { + LogDebug("appid : " << *app_id); + } + + return ret; + } + + static int category_cb(const char *category, void *user_data) + { + //LogDebug("enter"); + if (category == NULL) + return true; + + ApplicationInformation* appInfo = (ApplicationInformation*)user_data; + appInfo->addCategories(category); + return true; + } + + // @20130125-wscho: current pkgmanager has a problem while db operation. + // So, if enable below code, foreach callback of "pkgmgrinfo_appinfo_get_installed_list" + // is not running. + // So, temporally, we get version, total size, installed time on first access for that attribute. + // See JSApplicationInformation.cpp + static void set_additional_app_info(ApplicationInformationPtr &appInfo, const char* packageId) + { + int ret = 0; + char *version = NULL; + int total_size = 0; + int installed_time = 0; + pkgmgrinfo_pkginfo_h pkginfo_h; + + ret = pkgmgrinfo_pkginfo_get_pkginfo(packageId, &pkginfo_h); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get package info"); + } + + ret = pkgmgrinfo_pkginfo_get_version(pkginfo_h, &version); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get version"); + } else { + appInfo->setVersion(version); + } + + ret = pkgmgrinfo_pkginfo_get_total_size(pkginfo_h, &total_size); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get total size"); + } else { + appInfo->setInstallSize(total_size); + } + + ret = pkgmgrinfo_pkginfo_get_installed_time(pkginfo_h, &installed_time); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get installed time"); + } else { + appInfo->setInstallDate(installed_time); + } + + ret = pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo_h); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get destroy pkginfo"); + } + LogDebug("6"); + } + + static ApplicationInformationPtr create_app_info(pkgmgrinfo_appinfo_h handle) + { + //LogDebug("enter"); + char* appId = NULL; + //char* packageId = NULL; + char* name = NULL; + char* iconPath = NULL; + bool noDisplay = false; + char* pkgId = NULL; + int ret = 0; + + ApplicationInformationPtr appInfo(new ApplicationInformation()); + ret = pkgmgrinfo_appinfo_get_appid(handle, &appId); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get name by " << appId); + } else { + appInfo->setAppId(appId); + } + + ret = pkgmgrinfo_appinfo_get_label(handle, &name); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get name by " << appId); + } else { + appInfo->setName(name); + } + + ret = pkgmgrinfo_appinfo_get_icon(handle, &iconPath); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get icon by " << appId); + } else { + appInfo->setIconPath(iconPath); + } + + ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &noDisplay); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get nodisplay by " << appId); + } else { + appInfo->setShow(!noDisplay); + } + + ret = pkgmgrinfo_appinfo_foreach_category(handle, category_cb, (void*)appInfo.Get()); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get categories " << appId); + } + + ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgId); + if (ret != PMINFO_R_OK) { + LogDebug("Fail to get pkg Id by " << appId); + } else { + appInfo->setPackageId(pkgId); + } + + +// @20130125-wscho: current pkgmanager has a problem while db operation. +// So, if enable below code, foreach callback of "pkgmgrinfo_appinfo_get_installed_list" +// is not running. +// So, temporally, we get version, total size, installed time on first access for that attribute. +// See JSApplicationInformation.cpp +#if 0 + ret = pkgmgrinfo_appinfo_get_pkgname(handle, &packageId); + if (ret != PMINFO_R_OK) + { + LogDebug("Fail to get package id with appId : " << appId); + return appInfo; + } + + LogDebug("package id : " << packageId); + + set_additional_app_info(appInfo, packageId); +#endif + + return appInfo; + + } + + + static int installed_app_info_cb(pkgmgrinfo_appinfo_h handle, void *user_data) + { + //LogDebug("enter"); + ApplicationInformationPtr appInfo = create_app_info(handle); + ApplicationInformationArray *appInfoArray = (ApplicationInformationArray*)user_data; + appInfoArray->push_back(appInfo); + return 0; + } + + // Callback from 'service_foreach_app_matched' + // Used by 'findAppControl' + static bool service_app_matched_callback(service_h service, const char *appid, void *user_data) + { + if(appid == NULL) + { + LogWarning("appid is NULL"); + return false; + } + //ApplicationInformationPtr appInfo(new ApplicationInformation(appid)); + pkgmgrinfo_appinfo_h handle; + int ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); + if (ret != PMINFO_R_OK) { + LogWarning("Fail to get appInfo from appId : " << appid); + } + ApplicationInformationPtr appInfo = create_app_info(handle); + pkgmgrinfo_appinfo_destroy_appinfo(handle); + + ApplicationInformationArray *appInfos = (ApplicationInformationArray *)user_data; + appInfos->push_back(appInfo); + + return true; + } + +} + +ApplicationManager::ApplicationManager() : + m_initialized(false), + m_app(NULL) +{ + +} + +ApplicationManager::~ApplicationManager() +{ + if(m_installedApplicationsEmitters.size() != 0) + { + AppManagerWrapperSingleton::Instance().unregisterAppListChangedCallbacks(this); + WatchIdMap::iterator iter = m_watchIdMap.begin(); + for(; iter != m_watchIdMap.end(); iter++) + { + m_installedApplicationsEmitters.detach(iter->second); + } + } + + LaunchAppControlPendingEventMap::DataPtrListType dataPtrList = + gLaunchAppControlPendingEventMap.getDataPtrList(this); + + LaunchAppControlPendingEventMap::DataPtrListType::iterator iter = dataPtrList.begin(); + for(; iter != dataPtrList.end(); iter++) + { + delete *iter; + } + + gLaunchAppControlPendingEventMap.eraseKey(this); +} + +void ApplicationManager::getCurrentApplication(const EventApplicationGetCurrAppPtr& event) +{ + if (m_initialized == false) { + initialize(); + } + + EventRequestReceiver::PostRequest(event); +} + +void ApplicationManager::launch(const EventApplicationLaunchPtr& event) +{ + if (m_initialized == false) { + initialize(); + } + + EventRequestReceiver::PostRequest(event); +} + +void ApplicationManager::kill(const EventApplicationKillPtr& event) +{ + if (m_initialized == false) { + initialize(); + } + + EventRequestReceiver::PostRequest(event); +} + +void ApplicationManager::launchAppControl(const EventApplicationLaunchAppControlPtr& event) +{ + if (m_initialized == false) { + initialize(); + } + + EventApplicationLaunchAppControlReplyPtr eventReply = event->getEventReply(); + if(eventReply != NULL) + EventRequestReceiver::PostRequest(eventReply); + + EventRequestReceiver::PostRequest(event); +} + +void ApplicationManager::findAppControl(const EventApplicationFindAppControlPtr& event) +{ + if (m_initialized == false) { + initialize(); + } + + EventRequestReceiver::PostRequest(event); +} + +void ApplicationManager::getAppsContext(const EventApplicationGetAppsContextPtr& event) +{ + if (m_initialized == false) { + initialize(); + } + + EventRequestReceiver::PostRequest(event); +} + +void ApplicationManager::getAppContext(const EventApplicationGetAppContextPtr& event) +{ + if (m_initialized == false) { + initialize(); + } + + EventRequestReceiver::PostRequest(event); +} + +void ApplicationManager::getAppsInfo(const EventApplicationGetAppsInfoPtr& event) +{ + if (m_initialized == false) { + initialize(); + } + + EventRequestReceiver::PostRequest(event); +} + +void ApplicationManager::getAppInfo(const EventApplicationGetAppInfoPtr& event) +{ + if (m_initialized == false) { + initialize(); + } + + EventRequestReceiver::PostRequest(event); +} + +void ApplicationManager::addAppInfoEventListener(const EventApplicationAddAppInfoEventListenerPtr& event) +{ + if (m_initialized == false) { + initialize(); + } + + EventRequestReceiver::PostRequest(event); +} + +void ApplicationManager::removeAppInfoEventListener(const EventApplicationRemoveAppInfoEventListenerPtr& event) +{ + if (m_initialized == false) { + initialize(); + } + + EventRequestReceiver::PostRequest(event); +} + +void ApplicationManager::getAppCerts(const EventApplicationGetAppCertsPtr& event) +{ + LogError("ApplicationManager::getAppCerts"); + if (m_initialized == false) { + initialize(); + } + + EventRequestReceiver::PostRequest(event); +} + + +void ApplicationManager::invokeManualAnswerLaunchAppControl(service_h request, service_h reply, + service_result_e result, + EventApplicationLaunchAppControlReplyPtr &event) +{ + if (event == NULL) { + return; + } + + if(result == SERVICE_RESULT_SUCCEEDED) + { + LogDebug("SERVICE_RESULT_SUCCEEDED in serviceResultCallback"); + + // create new service object to store result. + ApplicationControlDataArrayPtr appControlDataArray(new ApplicationControlDataArray()); + + int result = service_foreach_extra_data(reply, service_extra_data_callback, appControlDataArray.Get()); + if( result == SERVICE_ERROR_NONE) + { + event->setAppControlDataArray(appControlDataArray); + LogDebug("service_foreach_extra_data() success"); + } + else + { + LogDebug("service_foreach_extra_data() failed"); + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + } + } + else if(result == SERVICE_RESULT_FAILED || result == SERVICE_RESULT_CANCELED) + { + LogDebug("SERVICE_RESULT_FAILED in serviceResultCallback : " <setExceptionCode(Commons::ExceptionCodes::NotFoundException); + } + + EventRequestReceiver::ManualAnswer(event); +} + +void ApplicationManager::invokeManualAnswerKill(int pid) +{ + DPL::Mutex::ScopedLock lock(&m_killMapLock); + + std::map::iterator it = m_killEventMap.find(pid); + if (it == m_killEventMap.end()) + return; + + EventApplicationKillPtr event = it->second; + m_killEventMap.erase(it); + + LogDebug("Calling kill success callback for pid : " << pid); + + EventRequestReceiver::ManualAnswer(event); +} + + +bool ApplicationManager::service_extra_data_callback(service_h service, const char *key, void* user_data) +{ + int ret = 0; + + ApplicationControlDataArray* appControlDataArray = (ApplicationControlDataArray*)user_data; + LogDebug(" key : " << key); + + bool isArray = false; + ret = service_is_extra_data_array(service, key, &isArray); + if (ret != SERVICE_ERROR_NONE) + { + LogDebug("service_is_extra_data_array passes error"); + // fail to checking. go to next extra data. + return true; + } + + std::string keyStr(key); + + if(isArray) + { + int length = 0; + char **value = NULL; + + ret = service_get_extra_data_array(service, key, &value, &length); + switch(ret) + { + case SERVICE_ERROR_NONE: { + LogDebug("service_get_extra_data success"); + std::vector valArray; + LogDebug("value length : " << length); + for (int i = 0; i < length; i++) + { + LogDebug("value : " << value[i]); + if(value[i]) + { + valArray.push_back(value[i]); + } + } + + ApplicationControlDataPtr appControlData(new ApplicationControlData()); + appControlData->setKey(keyStr); + appControlData->setValue(valArray); + appControlDataArray->push_back(appControlData); + + for (int i = 0; i < length; i++) + { + if (value[i]) + free(value[i]); + } + if (value) + free(value); + break; + } + case SERVICE_ERROR_INVALID_PARAMETER: + LogDebug("service_get_extra_data retuns SERVICE_ERROR_INVALID_PARAMETER"); + break; + case SERVICE_ERROR_KEY_NOT_FOUND: + LogDebug("service_get_extra_data retuns SERVICE_ERROR_KEY_NOT_FOUND"); + break; + case SERVICE_ERROR_OUT_OF_MEMORY: + LogDebug("service_get_extra_data retuns SERVICE_ERROR_OUT_OF_MEMORY"); + break; + default: + LogDebug("service_get_extra_data retuns Error"); + break; + } + } + else // (!isArray) + { + char *value = NULL; + + ret = service_get_extra_data(service, key, &value); + switch (ret) + { + case SERVICE_ERROR_NONE: + { + if(value == NULL) + { + LogDebug("service_get_extra_data returns NULL"); + break; + } + LogDebug("service_get_extra_data success"); + LogDebug("key = "<setApp(m_app); + return; + } + + Try + { + std::string appId; + + // get package info of current app + { + char *app_id = NULL; + + //int ret = app_get_id(&app_id); + int ret = get_current_app_id(&app_id); + if((ret != APP_ERROR_NONE) || (app_id == NULL)) + { + LogError("Can not get app id from current pid (" << ret << ")"); + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + return; + } + appId = app_id; + + free(app_id); + } + + //ApplicationInformationPtr appinfo(new ApplicationInformation(appId)); + pkgmgrinfo_appinfo_h handle; + int ret = pkgmgrinfo_appinfo_get_appinfo(appId.c_str(), &handle); + if (ret != PMINFO_R_OK) { + LogWarning("Fail to get appInfo from appId : " << appId); + + } + ApplicationInformationPtr appInfo = create_app_info(handle); + pkgmgrinfo_appinfo_destroy_appinfo(handle); + + + ApplicationPtr app(new Application()); + app->setAppInfo(appInfo); + + LogDebug("set appinfo to application"); + { + //int pid = getpid(); + int pid = getppid(); + std::stringstream sstr; + sstr << pid; + app->setContextId(sstr.str()); + + LogError("set pid : " << pid); + } + + event->setApp(app); + LogDebug("set application to event "); + m_app = app; + + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Error on getAppInfo : " << _rethrown_exception.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } + +} + + +void ApplicationManager::OnRequestReceived(const EventApplicationLaunchPtr& event) +{ + LogDebug("entered"); + + Try + { + int ret; + int retry = 0; + + std::string appId = event->getAppId(); + if(appId.empty()) + { + LogError("App id is empty"); + event->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException); + return; + } + + LogDebug("Launching app id : " << appId); + +// if the application is running, send raise event to the app instead of reset the application. +#if 1 + // give a second chance to launch application to avoid platform issue. + // this retry code will be removed after platform code change. + while (retry < 3) { + ret = aul_open_app(appId.c_str()); + if (ret >= 0) { + break; + } + // delay 300ms for each retry + usleep(300 * 1000); + retry++; + LogDebug("retry launch request : " << retry); + } + + if (ret < 0) { + switch (ret) + { + case AUL_R_EINVAL: + case AUL_R_ERROR: + LogDebug("aul_open_app returns Not Found error"); + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + break; + case AUL_R_ECOMM: + LogDebug("aul_open_app returns internal IPC error"); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + break; + default: + LogDebug("aul_open_app returns Unknown error"); + event->setExceptionCode(Commons::ExceptionCodes::UnknownException); + break; + } + } else { + LogDebug("callee's pid " << ret); + } +#else + service_h service; + service_create(&service); + + service_set_operation(service, SERVICE_OPERATION_DEFAULT); + + service_set_app_id(service, appId.c_str()); + + // give a second chance to launch application to avoid platform issue. + // this retry code will be removed after platform code change. + while (retry < 3) { + ret = service_send_launch_request(service, NULL, this); + if (ret != SERVICE_ERROR_LAUNCH_REJECTED) { + break; + } + // delay 300ms for each retry + usleep(300 * 1000); + retry++; + LogDebug("retry launch request : " << retry); + } + + service_destroy(service); + + if(ret != SERVICE_ERROR_NONE) + { + switch (ret) + { + case SERVICE_ERROR_INVALID_PARAMETER: + LogDebug("service_send_launch_request returns SERVICE_ERROR_INVALID_PARAMETER"); + event->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException); + break; + case SERVICE_ERROR_OUT_OF_MEMORY: + LogDebug("service_send_launch_request returns SERVICE_ERROR_OUT_OF_MEMORY"); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + break; + case SERVICE_ERROR_LAUNCH_REJECTED: + case SERVICE_ERROR_APP_NOT_FOUND: + LogDebug("service_send_launch_request returns SERVICE_ERROR_APP_NOT_FOUND"); + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + break; + default: + LogDebug("service_send_launch_request returns UNKNOWN ERROR!!! (" << ret << ")"); + event->setExceptionCode(Commons::ExceptionCodes::UnknownException); + break; + } + } +#endif + + + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Error on launch : " << _rethrown_exception.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } +} + +void ApplicationManager::OnRequestReceived(const EventApplicationKillPtr& event) +{ + LogDebug("entered"); + + Try + { + int ret; + std::string contextId = event->getContextId(); + + if(contextId.empty()) + { + LogError("Context id is empty"); + event->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException); + return; + } + + LogDebug("Killing context id : " << contextId); + + int pid; + std::stringstream(contextId) >> pid; + if(pid <= 0) + { + LogError("Context id is wrong : " << pid); + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + return; + } + + char *appIdCStr = NULL; + ret = app_manager_get_app_id(pid, &appIdCStr); + if (ret != APP_MANAGER_ERROR_NONE) + { + LogError("Error while getting app id (" << ret << ")"); + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + return; + } + + std::string appId = appIdCStr; + free(appIdCStr); + + app_context_h appContext; + ret = app_manager_get_app_context (appId.c_str(), &appContext); + if (ret != APP_MANAGER_ERROR_NONE) + { + LogError("Error while getting app context (" << ret << ")"); + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + return; + } + + // TODO thread + ret = app_manager_set_app_context_event_cb(app_manager_app_context_event_callback, this); + if (ret != APP_MANAGER_ERROR_NONE) + { + LogError("Error while registering app context event (" << ret << ")"); + event->setExceptionCode(Commons::ExceptionCodes::UnknownException); + return; + } + + ret = app_manager_terminate_app(appContext); + if (ret != APP_MANAGER_ERROR_NONE) + { + LogError("Error while terminating app (" << ret << ")"); + event->setExceptionCode(Commons::ExceptionCodes::UnknownException); + return; + } + + DPL::Mutex::ScopedLock lock(&m_killMapLock); + m_killEventMap[pid] = event; + event->switchToManualAnswer(); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Error on kill : " << _rethrown_exception.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } +} + +void ApplicationManager::OnRequestReceived(const EventApplicationLaunchAppControlPtr& event) +{ + LogDebug("entered"); + + Try + { + int ret = 0; + int retry = 0; + + ApplicationControlPtr appControl = event->getAppControl(); + if(appControl == NULL) + { + LogError("appControl is NULL"); + event->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException); + return; + } + + std::string operation = appControl->getOperation(); + if(operation.empty()) + { + LogDebug("operation being madatory is empty"); + event->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException); + return; + } + + std::string appId = event->getAppId(); + + service_h service; + service_create(&service); + + if (!appId.empty()) + { + LogDebug(" app id : " << appId); + + service_set_app_id(service, appId.c_str()); + } + + service_set_operation(service, operation.c_str() ); + LogDebug(" operation : " << operation); + + std::string uri = appControl->getUri(); + if (!uri.empty()) + { + LogDebug(" uri : " << uri); + service_set_uri(service, uri.c_str() ); + } + + std::string mime = appControl->getMime(); + if (!mime.empty()) + { + LogDebug(" mime : " << mime); + service_set_mime(service, mime.c_str() ); + } + + std::string category = appControl->getCategory(); + if (!category.empty()) + { + LogDebug(" category : " << category); + service_set_category(service, category.c_str() ); + } + + std::vector appControlDataArray = appControl->getAppControlDataArray(); + + if(!appControlDataArray.empty()) + { + LogDebug(" datas : " << appControlDataArray.size()); + + ApplicationControlDataArray::iterator iter; + for(iter = appControlDataArray.begin(); iter != appControlDataArray.end(); iter++) + { + ApplicationControlDataPtr appControlData = *iter; + + std::string key = appControlData->getKey(); + LogDebug(" key : " << key); + + if(key.empty()) + { + event->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException); + continue; + } + + std::vector valueArray = appControlData->getValue(); + size_t size = valueArray.size(); + + const char **arr = (const char**)calloc(sizeof(char*), size); + + for (size_t j = 0; j < size; j++) + { + arr[j] = valueArray.at(j).c_str(); + LogDebug(" value : " << arr[j]); + } + + // @20121207-wscho: roll-back to return extra-data instead of extra-data array when the value size is one. + const char *keyCStr = key.c_str(); + if (size == 1) { + service_add_extra_data(service, keyCStr, arr[0]); + } else { + service_add_extra_data_array(service, keyCStr, arr, size); + } + + if (arr) + free(arr); + } + } + + LaunchAppControlPendingEvent *pendingEvent = NULL; + LaunchAppControlPendingEventMap::DataKeyType key = 0; + + EventApplicationLaunchAppControlReplyPtr eventReply = event->getEventReply(); + if(eventReply) + { + pendingEvent = new LaunchAppControlPendingEvent((void*)this, eventReply); + key = gLaunchAppControlPendingEventMap.insert(this, pendingEvent); + } + + // give a second chance to launch application to avoid platform issue. + // this retry code will be removed after platform code change. + while (retry < 3) { + ret = service_send_launch_request(service, service_reply_callback, (void *)key); + if (ret != SERVICE_ERROR_LAUNCH_REJECTED) { + break; + } + // delay 300ms for each retry + usleep(300 * 1000); + retry++; + LogDebug("retry launch request : " << retry); + } + + service_destroy(service); + + if(ret != SERVICE_ERROR_NONE) + { + switch (ret) + { + case SERVICE_ERROR_INVALID_PARAMETER: + LogDebug("service_send_launch_request returns SERVICE_ERROR_INVALID_PARAMETER"); + event->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException); + break; + case SERVICE_ERROR_OUT_OF_MEMORY: + LogDebug("service_send_launch_request returns SERVICE_ERROR_OUT_OF_MEMORY"); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + break; + case SERVICE_ERROR_LAUNCH_REJECTED: + case SERVICE_ERROR_APP_NOT_FOUND: + LogDebug("service_send_launch_request returns SERVICE_ERROR_APP_NOT_FOUND"); + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + break; + default: + LogDebug("service_send_launch_request returns UNKNOWN ERROR!!!"); + event->setExceptionCode(Commons::ExceptionCodes::UnknownException); + break; + } + + if(pendingEvent) + { + gLaunchAppControlPendingEventMap.eraseData(key); + + delete pendingEvent; + pendingEvent = NULL; + + eventReply->cancelRequest(); + EventRequestReceiver::ManualAnswer(eventReply); + } + } + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Error on launchAppControl : " << _rethrown_exception.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } +} + +void ApplicationManager::OnRequestReceived(const EventApplicationLaunchAppControlReplyPtr& event) +{ + LogDebug("entered"); + event->switchToManualAnswer(); +} + +void ApplicationManager::OnRequestReceived(const EventApplicationFindAppControlPtr& event) +{ + LogDebug("entered"); + + Try + { + ApplicationControlPtr appControl = event->getAppControl(); + if(appControl == NULL) + { + LogError("appControl is NULL"); + event->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException); + return; + } + + std::string operation = appControl->getOperation(); + if(operation.empty()) + { + LogDebug("operation being madatory is empty"); + event->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException); + return; + } + + service_h service; + service_create(&service); + + service_set_operation(service, operation.c_str() ); + LogDebug(" operation : " << operation); + + std::string uri = appControl->getUri(); + if (!uri.empty()) + { + LogDebug(" uri : " << uri); + service_set_uri(service, uri.c_str() ); + } + + std::string mime = appControl->getMime(); + if (!mime.empty()) + { + LogDebug(" mime : " << mime); + service_set_mime(service, mime.c_str() ); + } + + std::string category = appControl->getCategory(); + if (!category.empty()) + { + LogDebug(" category : " << category); + service_set_category(service, category.c_str() ); + } + + std::vector appControlDataArray = appControl->getAppControlDataArray(); + + if(!appControlDataArray.empty()) + { + LogDebug(" datas : " << appControlDataArray.size()); + + ApplicationControlDataArray::iterator iter; + for(iter = appControlDataArray.begin(); iter != appControlDataArray.end(); iter++) + { + ApplicationControlDataPtr appControlData = *iter; + + std::string key = appControlData->getKey(); + LogDebug(" key : " << key); + + if(key.empty()) + { + event->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException); + continue; + } + + std::vector valueArray = appControlData->getValue(); + size_t size = valueArray.size(); + + const char **arr = (const char**)calloc(sizeof(char*), size); + + for (size_t j = 0; j < size; j++) + { + arr[j] = valueArray.at(j).c_str(); + LogDebug(" value : " << arr[j]); + } + + // @20121207-wscho: roll-back to return extra-data instead of extra-data array when the value size is one. + const char *keyCStr = key.c_str(); + if (size == 1) { + service_add_extra_data(service, keyCStr, arr[0]); + } else { + service_add_extra_data_array(service, keyCStr, arr, size); + } + + if (arr) + free(arr); + } + } + + ApplicationInformationArrayPtr appInfos(new ApplicationInformationArray()); + + int result = service_foreach_app_matched(service, service_app_matched_callback, (void *)appInfos.Get()); + if (result != SERVICE_ERROR_NONE) + { + LogError("service_foreach_app_matched error (" << result << ")"); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + service_destroy(service); + return; + } + + service_destroy(service); + + event->setAppInfos(appInfos); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Error on findAppControl : " << _rethrown_exception.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } +} + + +void ApplicationManager::OnRequestReceived(const EventApplicationGetAppsContextPtr& event) +{ + LogDebug("entered"); + + Try + { + int ret = 0; + + ApplicationContextArrayPtr appContextArray = event->getAppContextArray(); + ret = app_manager_foreach_app_context(app_manager_app_context_callback, appContextArray.Get()); + if(ret != APP_MANAGER_ERROR_NONE) + { + LogError("app_manager_foreach_app_context error (" << ret << ")"); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Error on : " << _rethrown_exception.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } +} + +void ApplicationManager::OnRequestReceived(const EventApplicationGetAppContextPtr& event) +{ + LogDebug("entered"); + + Try + { + int ret = 0; + + std::string contextId = event->getAppContextId(); + int pid; + + if (contextId.empty()) + { + //pid = getpid(); + pid = getppid(); + + std::stringstream sstr; + sstr << pid; + contextId = sstr.str(); + } + else + { + std::stringstream(contextId) >> pid; + if (pid <= 0) + { + LogError("contextId is wrong : " << contextId); + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + return; + } + } + + char *app_id = NULL; + + ret = app_manager_get_app_id(pid, &app_id); + if(ret != APP_MANAGER_ERROR_NONE) + { + switch(ret) + { + case APP_MANAGER_ERROR_NO_SUCH_APP: + LogError("app_manager_get_app_id error : no such app"); + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + break; + case APP_MANAGER_ERROR_INVALID_PARAMETER: + LogError("app_manager_get_app_id error : invalid parameter"); + event->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException); + break; + default: + LogError("app_manager_get_app_id error (" << ret << ")"); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + break; + } + + if(app_id) + free(app_id); + + return; + } + + ApplicationContextPtr appContext(new ApplicationContext()); + appContext->setAppId(app_id); + appContext->setContextId(contextId); + + event->setAppContext(appContext); + + if(app_id) + free(app_id); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Error on getAppContext : " << _rethrown_exception.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } +} + +void ApplicationManager::OnRequestReceived(const EventApplicationGetAppsInfoPtr& event) +{ + LogDebug("entered"); + + Try + { + int ret = 0; + ApplicationInformationArrayPtr appInfoArray = event->getAppInfoArray(); + ret = pkgmgrinfo_appinfo_get_installed_list(installed_app_info_cb, (void*)appInfoArray.Get()); + if (ret != PMINFO_R_OK) { + LogError("Error on getAppsInfo : "); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Error on getAppsInfo : " << _rethrown_exception.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } +} + +void ApplicationManager::OnRequestReceived(const EventApplicationGetAppInfoPtr& event) +{ + LogDebug("entered"); + + Try + { + std::string appId = event->getAppId(); + // in case of no argument, get application information of current. + if (appId.empty()) + { + char *app_id = NULL; + + //int ret = app_get_id(&app_id); // webkit2 patch. + int ret = get_current_app_id(&app_id); + if((ret != APP_ERROR_NONE) || (app_id == NULL)) + { + LogError("Can not get app id from current pid (" << ret << ")"); + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + return; + } + appId = app_id; + free(app_id); + } + + pkgmgrinfo_appinfo_h handle; + int ret = pkgmgrinfo_appinfo_get_appinfo(appId.c_str(), &handle); + if (ret != PMINFO_R_OK) { + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + } + + ApplicationInformationPtr appInfo = create_app_info(handle); + event->setAppInfo(appInfo); + pkgmgrinfo_appinfo_destroy_appinfo(handle); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Error on getAppInfo : " << _rethrown_exception.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } +} + +void ApplicationManager::OnRequestReceived(const EventApplicationAddAppInfoEventListenerPtr& event) +{ + LogDebug("entered"); + + Try + { + EventApplicationAppInfoEventListenerEmitterPtr emitter = event->getEmitter(); + + if(m_installedApplicationsEmitters.size() == 0) + { + LogDebug("First time registering event listener to this application object."); + + // Below can throw Exception + AppManagerWrapperSingleton::Instance().registerAppListChangedCallbacks(this); + } + + m_installedApplicationsEmitters.attach(emitter); + + long watchId = AppManagerWrapperSingleton::Instance().getWatchIdAndInc(); + + m_watchIdMap[watchId] = emitter->getId(); + + event->setWatchId(watchId); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Error on addAppInfoEventListener : " << _rethrown_exception.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } +} + +void ApplicationManager::OnRequestReceived(const EventApplicationRemoveAppInfoEventListenerPtr& event) +{ + LogDebug("entered"); + + Try + { + long watchId = event->getWatchId(); + + if(m_watchIdMap.find(watchId) == m_watchIdMap.end()) + ThrowMsg(NotFoundException, "No watchId : " << watchId); + + EventApplicationAppInfoEventListenerEmitter::IdType emitterId = m_watchIdMap[watchId]; + + bool success = m_installedApplicationsEmitters.detach(emitterId); + if(!success) + ThrowMsg(NotFoundException, "No watchId : " << watchId); + + if(m_installedApplicationsEmitters.size() == 0) + { + LogDebug("No more event listener on this application object."); + + AppManagerWrapperSingleton::Instance().unregisterAppListChangedCallbacks(this); + } + } + Catch (WrtDeviceApis::Commons::NotFoundException) + { + LogError("Not found : " << _rethrown_exception.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Error on removeAppInfoEventListener : " << _rethrown_exception.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } +} + + +void ApplicationManager::OnRequestReceived(const EventApplicationGetAppCertsPtr& event) +{ + LogDebug("entered"); + + Try + { + std::string appId = event->getAppId(); + + // in case of no argument, get application information of current. + if (appId.empty()) + { + char *tmp = NULL; + + //int ret = app_get_id(&tmp); + int ret = get_current_app_id(&tmp); + if((ret != APP_ERROR_NONE) || (tmp == NULL)) + { + LogError("Can not get app id from current pid (" << ret << ")"); + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + return; + } + + appId = tmp; + if (tmp) + free(tmp); + } + + char* package = getPackageByAppId(appId.c_str()); + if (package == NULL) + { + LogError("Can not get package from appId (" << appId << ")"); + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + return; + } + + LogDebug("package : " << package); + package_info_h pkg_info; + int result = 0; + + result = package_manager_get_package_info(package, &pkg_info); + if (result != PACKAGE_MANAGER_ERROR_NONE) + { + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + return; + } + + ApplicationCertArrayPtr certArray(new ApplicationCertArray()); + + result = package_info_foreach_cert_info(pkg_info, package_cert_cb, (void*)certArray.Get()); + if (result != PACKAGE_MANAGER_ERROR_NONE) + { + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + return; + } + + event->setAppCerts(certArray); + + LogDebug("Finish to getting package cert info"); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Error on getAppInfo : " << _rethrown_exception.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } +} + + +void ApplicationManager::onAppManagerEventInstalled(const char *appId) +{ + LogDebug("APP_MANAGER_EVENT_INSTALLED, appId : "<< appId); + + EventApplicationAppInfoEventListenerPtr event(new EventApplicationAppInfoEventListener()); + + pkgmgrinfo_appinfo_h handle; + int ret = pkgmgrinfo_appinfo_get_appinfo(appId, &handle); + if (ret != PMINFO_R_OK) { + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + } + + ApplicationInformationPtr appInfo = create_app_info(handle); + event->setAppInfo(appInfo); + pkgmgrinfo_appinfo_destroy_appinfo(handle); + + event->setType(EventApplicationAppInfoEventListener::OnInstalled); + m_installedApplicationsEmitters.emit(event); +} + +void ApplicationManager::onAppManagerEventUninstalled(const char *appId) +{ + LogDebug("APP_MANAGER_EVENT_UNINSTALLED, appId : "<< appId); + + EventApplicationAppInfoEventListenerPtr event(new EventApplicationAppInfoEventListener()); + + ApplicationInformationPtr appInfo(new ApplicationInformation(appId)); + + event->setType(EventApplicationAppInfoEventListener::OnUninstalled); + event->setAppInfo(appInfo); + m_installedApplicationsEmitters.emit(event); +} + +void ApplicationManager::onAppManagerEventUpdated(const char *appId) +{ + LogDebug("APP_MANAGER_EVENT_UPDATED, appId : "<< appId); + + EventApplicationAppInfoEventListenerPtr event(new EventApplicationAppInfoEventListener()); + + pkgmgrinfo_appinfo_h handle; + int ret = pkgmgrinfo_appinfo_get_appinfo(appId, &handle); + if (ret != PMINFO_R_OK) { + event->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + } + + ApplicationInformationPtr appInfo = create_app_info(handle); + event->setAppInfo(appInfo); + pkgmgrinfo_appinfo_destroy_appinfo(handle); + + event->setType(EventApplicationAppInfoEventListener::OnUpdated); + m_installedApplicationsEmitters.emit(event); +} + +void ApplicationManager::initialize() +{ + if (!m_initialized) { + DPL::Mutex::ScopedLock lock(&m_initializationMutex); + if (!m_initialized) { + + } + } +} + +} +} diff --git a/src/Application/ApplicationManager.h b/src/Application/ApplicationManager.h new file mode 100644 index 0000000..d5bcaf6 --- /dev/null +++ b/src/Application/ApplicationManager.h @@ -0,0 +1,265 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_PLATFORM_APPLICATION_H_ +#define TIZENAPIS_PLATFORM_APPLICATION_H_ + +#include +#include +#include +#include +#include "IApplicationManager.h" +#include "ApplicationFactory.h" + +//#include +#include + +#include "AppManagerWrapper.h" + +namespace DeviceAPI { +namespace Application { + +class ApplicationManager: public IApplicationManager, public IAppManagerAppListChangedCallbacks { + friend class ApplicationFactory; + +public: + ApplicationManager(); + virtual ~ApplicationManager(); + virtual void getCurrentApplication(const EventApplicationGetCurrAppPtr& event); + virtual void launch(const EventApplicationLaunchPtr& event); + virtual void kill(const EventApplicationKillPtr& event); + virtual void launchAppControl(const EventApplicationLaunchAppControlPtr& event); + virtual void findAppControl(const EventApplicationFindAppControlPtr& event); + virtual void getAppsContext(const EventApplicationGetAppsContextPtr& event); + virtual void getAppContext(const EventApplicationGetAppContextPtr& event); + virtual void getAppsInfo(const EventApplicationGetAppsInfoPtr& event); + virtual void getAppInfo(const EventApplicationGetAppInfoPtr& event); + virtual void addAppInfoEventListener(const EventApplicationAddAppInfoEventListenerPtr& event); + virtual void removeAppInfoEventListener(const EventApplicationRemoveAppInfoEventListenerPtr& event); + virtual void getAppCerts(const EventApplicationGetAppCertsPtr& event); + + void invokeManualAnswerLaunchAppControl(service_h request, service_h reply, service_result_e result, + EventApplicationLaunchAppControlReplyPtr &event); + //void InstalledApplicationChanged(app_manger_event_type_e event_type,const char *package); + void invokeManualAnswerKill(int pid); + + static bool service_extra_data_callback(service_h service, const char *key, void* user_data); + +protected: + virtual void OnRequestReceived(const EventApplicationGetCurrAppPtr& event); + virtual void OnRequestReceived(const EventApplicationLaunchPtr& event); + virtual void OnRequestReceived(const EventApplicationKillPtr& event); + virtual void OnRequestReceived(const EventApplicationLaunchAppControlPtr& event); + virtual void OnRequestReceived(const EventApplicationLaunchAppControlReplyPtr& event); + virtual void OnRequestReceived(const EventApplicationFindAppControlPtr& event); + virtual void OnRequestReceived(const EventApplicationGetAppsContextPtr& event); + virtual void OnRequestReceived(const EventApplicationGetAppContextPtr& event); + virtual void OnRequestReceived(const EventApplicationGetAppsInfoPtr& event); + virtual void OnRequestReceived(const EventApplicationGetAppInfoPtr& event); + virtual void OnRequestReceived(const EventApplicationAddAppInfoEventListenerPtr& event); + virtual void OnRequestReceived(const EventApplicationRemoveAppInfoEventListenerPtr& event); + virtual void OnRequestReceived(const EventApplicationGetAppCertsPtr& event); + + // inherited from IAppManagerAppListChangedCallbacks + virtual void onAppManagerEventInstalled(const char *appId); + virtual void onAppManagerEventUninstalled(const char *appId); + virtual void onAppManagerEventUpdated(const char *appId); + +private: + void initialize(); + + DPL::Mutex m_initializationMutex; + bool m_initialized; + + std::map m_killEventMap; + mutable DPL::Mutex m_killMapLock; + + typedef WrtDeviceApis::Commons::Emitters EventApplicationAppInfoEventListenerEmitters; + typedef std::map WatchIdMap; + + EventApplicationAppInfoEventListenerEmitters m_installedApplicationsEmitters; + WatchIdMap m_watchIdMap; + + ApplicationPtr m_app; +}; + +class LaunchAppControlPendingEvent +{ +public: + LaunchAppControlPendingEvent(void *thisObject, const EventApplicationLaunchAppControlReplyPtr &event) : + m_thisObject(thisObject), + m_event(event) + { + } + + virtual ~LaunchAppControlPendingEvent() + { + } + + void* getThisObject() const { return m_thisObject; } + EventApplicationLaunchAppControlReplyPtr getEvent() const { return m_event; } + +private: + void *m_thisObject; + EventApplicationLaunchAppControlReplyPtr m_event; +}; + + +template +class KeyMultiMap +{ +public: + typedef unsigned int DataKeyType; + typedef DataType * DataPtrType; + typedef std::pair KeyDataPairType; + typedef std::map DataMapType; + typedef std::set DataKeySetType; + typedef std::map KeyMapType; + typedef std::list DataPtrListType; + + KeyMultiMap() : + m_keyAcc(0) + { + } + + DataKeyType insert(const KeyType &key, const DataPtrType &dataPtr) + { + DataKeyType dataKey = ++m_keyAcc; + + KeyDataPairType pair(key, dataPtr); + m_dataMap.insert(std::pair(dataKey, pair)); + + typename KeyMapType::iterator keyMapIter = m_keyMap.find(key); + if(keyMapIter == m_keyMap.end()) + { + DataKeySetType newKeySet; + m_keyMap.insert(std::pair(key, newKeySet)); + keyMapIter = m_keyMap.find(key); + } + + DataKeySetType &dataKeySet = keyMapIter->second; + + dataKeySet.insert(dataKey); + + return dataKey; + } + + DataPtrType getData(const DataKeyType &dataKey) const + { + typename DataMapType::const_iterator dataMapIter = m_dataMap.find(dataKey); + + if(dataMapIter == m_dataMap.end()) + return static_cast(NULL); + + return dataMapIter->second.second; + } + + DataPtrListType getDataPtrList(const KeyType &key) + { + DataPtrListType dataPtrList; + + typename KeyMapType::const_iterator keyMapIter = m_keyMap.find(key); + if(keyMapIter == m_keyMap.end()) + return dataPtrList; + + DataKeySetType keySet = keyMapIter->second; + DataKeySetType::iterator keySetIter = keySet.begin(); + for(; keySetIter != keySet.end(); keySetIter++) + { + DataPtrType dataPtr = getData(*keySetIter); + if(dataPtr == NULL) + { + LogWarning("No data for " << *keySetIter); + break; + } + + dataPtrList.push_back(dataPtr); + } + + return dataPtrList; + } + + void eraseData(const DataKeyType &dataKey) + { + typename DataMapType::iterator dataKeyIter = m_dataMap.find(dataKey); + + if(dataKeyIter == m_dataMap.end()) + { + LogDebug("No data for " << dataKey); + return; + } + + KeyType key = dataKeyIter->second.first; + + m_dataMap.erase(dataKeyIter); + + typename KeyMapType::iterator keyMapIter = m_keyMap.find(key); + if(keyMapIter == m_keyMap.end()) + { + LogWarning("No data for Key"); + return; + } + + DataKeySetType &keySet = keyMapIter->second; + DataKeySetType::iterator keySetIter = keySet.find(dataKey); + if(keySetIter == keySet.end()) + { + LogWarning("No data for " << dataKey); + return; + } + + keySet.erase(keySetIter); + } + + void eraseKey(const KeyType &key) + { + typename KeyMapType::iterator keyMapIter = m_keyMap.find(key); + if(keyMapIter == m_keyMap.end()) + { + LogDebug("No data to erase."); + return; + } + + DataKeySetType &keySet = keyMapIter->second; + DataKeySetType::iterator keySetIter = keySet.begin(); + for(; keySetIter != keySet.end(); keySetIter++) + { + typename DataMapType::iterator dataKeyIter = m_dataMap.find(*keySetIter); + if(dataKeyIter == m_dataMap.end()) + { + LogWarning("No data to erase."); + break; + } + + m_dataMap.erase(dataKeyIter); + } + + m_keyMap.erase(keyMapIter); + } + +private: + DataKeyType m_keyAcc; + + DataMapType m_dataMap; + KeyMapType m_keyMap; +}; + +} +} + +#endif diff --git a/src/Application/ApplicationUtil.cpp b/src/Application/ApplicationUtil.cpp new file mode 100755 index 0000000..a753c0f --- /dev/null +++ b/src/Application/ApplicationUtil.cpp @@ -0,0 +1,134 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 "ApplicationUtil.h" +#include + +namespace DeviceAPI { +namespace Application { + +using namespace WrtDeviceApis::CommonsJavaScript; + +ApplicationUtil::ApplicationUtil(JSContextRef context, + JSValueRef* exception) : + m_context(context), + m_exception(exception) +{ + Assert(NULL != m_context && "Context cannot be NULL."); +} + +ApplicationUtil::~ApplicationUtil() +{ +} + +bool ApplicationUtil::isObject(const JSValueRef& arg) +{ + return !JSValueIsNull(m_context, arg) && + !JSValueIsUndefined(m_context, arg) && + JSValueIsObject(m_context, arg); +} + +bool ApplicationUtil::isString(const JSValueRef& arg) +{ + return !JSValueIsNull(m_context, arg) && + !JSValueIsUndefined(m_context, arg) && + JSValueIsString(m_context, arg); +} + +bool ApplicationUtil::isFunction(const JSValueRef& arg) +{ + Converter converter(m_context); + return !JSValueIsNull(m_context, arg) && + !JSValueIsUndefined(m_context, arg) && + JSObjectIsFunction(m_context, converter.toJSObjectRef(arg)); +} + +bool ApplicationUtil::isArray(const JSValueRef& arg) +{ + Converter converter(m_context); + return !JSValueIsNull(m_context, arg) && + !JSValueIsUndefined(m_context, arg) && + JSIsArrayValue(m_context, arg); +} + +bool ApplicationUtil::isNullOrString(const JSValueRef& arg) +{ + return !JSValueIsUndefined(m_context, arg) && + (JSValueIsNull(m_context, arg) || + JSValueIsString(m_context, arg)); +} + +bool ApplicationUtil::isNullOrObject(const JSValueRef& arg) +{ + return !JSValueIsUndefined(m_context, arg) && + (JSValueIsNull(m_context, arg) || + JSValueIsObject(m_context, arg)); +} + +bool ApplicationUtil::isNullOrFunction(const JSValueRef& arg) +{ + Converter converter(m_context); + return !JSValueIsUndefined(m_context, arg) && + (JSValueIsNull(m_context, arg) || + JSObjectIsFunction(m_context, converter.toJSObjectRef(arg))); +} + +bool ApplicationUtil::isNullOrArray(const JSValueRef& arg) +{ + Converter converter(m_context); + return !JSValueIsUndefined(m_context, arg) && + (JSValueIsNull(m_context, arg) || + JSIsArrayValue(m_context, arg)); +} + +bool ApplicationUtil::isNullOrUndefined(const JSValueRef& arg) +{ + return (JSValueIsNull(m_context, arg) || + JSValueIsUndefined(m_context, arg)); +} + +bool ApplicationUtil::isNullOrUndefinedOrString(const JSValueRef& arg) +{ + return (JSValueIsNull(m_context, arg) || + JSValueIsUndefined(m_context, arg) || + JSValueIsString(m_context, arg)); +} + +bool ApplicationUtil::isNullOrUndefinedOrObject(const JSValueRef& arg) +{ + return (JSValueIsNull(m_context, arg) || + JSValueIsUndefined(m_context, arg) || + JSValueIsObject(m_context, arg)); +} + +bool ApplicationUtil::isNullOrUndefinedOrFunction(const JSValueRef& arg) +{ + Converter converter(m_context); + return (JSValueIsNull(m_context, arg) || + JSValueIsUndefined(m_context, arg) || + JSObjectIsFunction(m_context, converter.toJSObjectRef(arg))); +} + +bool ApplicationUtil::isNullOrUndefinedOrArray(const JSValueRef& arg) +{ + Converter converter(m_context); + return (JSValueIsNull(m_context, arg) || + JSValueIsUndefined(m_context, arg) || + JSIsArrayValue(m_context, arg)); +} + +} } diff --git a/src/Application/ApplicationUtil.h b/src/Application/ApplicationUtil.h new file mode 100755 index 0000000..8a6d693 --- /dev/null +++ b/src/Application/ApplicationUtil.h @@ -0,0 +1,55 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_PLATFORM_APPLICATION_UTIL_H_ +#define TIZENAPIS_PLATFORM_APPLICATION_UTIL_H_ + +#include + +namespace DeviceAPI { +namespace Application { +class ApplicationUtil +{ + public: + explicit ApplicationUtil(JSContextRef context, + JSValueRef* exception = NULL); + virtual ~ApplicationUtil(); + + bool isObject(const JSValueRef& arg); + bool isString(const JSValueRef& arg); + bool isFunction(const JSValueRef& arg); + bool isArray(const JSValueRef& arg); + bool isNullOrString(const JSValueRef& arg); + bool isNullOrObject(const JSValueRef& arg); + bool isNullOrFunction(const JSValueRef& arg); + bool isNullOrArray(const JSValueRef& arg); + bool isNullOrUndefined(const JSValueRef& arg); + bool isNullOrUndefinedOrString(const JSValueRef& arg); + bool isNullOrUndefinedOrObject(const JSValueRef& arg); + bool isNullOrUndefinedOrFunction(const JSValueRef& arg); + bool isNullOrUndefinedOrArray(const JSValueRef& arg); + + protected: + JSContextRef m_context; + JSValueRef* m_exception; +}; + +} +} // + +#endif + diff --git a/src/Application/CMakeLists.txt b/src/Application/CMakeLists.txt new file mode 100755 index 0000000..d759551 --- /dev/null +++ b/src/Application/CMakeLists.txt @@ -0,0 +1,94 @@ +SET(TARGET_NAME ${application_target}) +SET(DESTINATION_NAME ${application_dest}) +SET(TARGET_IMPL_NAME ${application_impl}) +SET(TARGET_CONFIG_NAME ${application_config}) + +PKG_SEARCH_MODULE(app-manager REQUIRED capi-appfw-app-manager) +PKG_SEARCH_MODULE(application REQUIRED capi-appfw-application) +PKG_SEARCH_MODULE(package-manager REQUIRED capi-appfw-package-manager) +PKG_SEARCH_MODULE(pkgmgr REQUIRED pkgmgr) +PKG_SEARCH_MODULE(pkgmgr-info REQUIRED pkgmgr-info) + +INCLUDE_DIRECTORIES( + ${TOP}/Common + ${TOP}/Application + ${app-manager_INCLUDE_DIRS} + ${application_INCLUDE_DIRS} + ${package-manager_INCLUDE_DIRS} + ${pkgmgr_INCLUDE_DIRS} + ${pkgmgr-info_INCLUDE_DIRS} +) + +SET(CMAKE_INSTALL_RPATH + ${CMAKE_INSTALL_RPATH} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME} +) + +SET(SRCS_IMPL + ApplicationContext.cpp + ApplicationControl.cpp + ApplicationControlData.cpp + RequestedApplicationControl.cpp + ApplicationFactory.cpp + ApplicationInformation.cpp + ApplicationCert.cpp + IApplicationManager.cpp + ApplicationManager.cpp + AppManagerWrapper.cpp + Application.cpp + ApplicationAsyncCallbackManager.cpp + ApplicationController.cpp + ApplicationConverter.cpp + ApplicationListenerManager.cpp + ApplicationUtil.cpp + JSApplication.cpp + JSApplicationManager.cpp + JSApplicationContext.cpp + JSApplicationControl.cpp + JSApplicationControlData.cpp + JSRequestedApplicationControl.cpp + JSApplicationEventCallbackManager.cpp + JSApplicationInformation.cpp + JSApplicationCert.cpp +) + +ADD_LIBRARY(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL}) + +TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME} + ${LIBS_COMMON} + ${app-manager_LIBRARIES} + ${application_LIBRARIES} + ${package-manager_LIBRARIES} + ${pkgmgr_LIBRARIES} + ${pkgmgr-info_LIBRARIES} +) + +SET(SRCS_CONFIG + plugin_config.cpp +) + +ADD_LIBRARY(${TARGET_CONFIG_NAME} SHARED ${SRCS_CONFIG}) + +TARGET_LINK_LIBRARIES(${TARGET_CONFIG_NAME} + ${LIBS_COMMON} +) + +SET(SRCS + plugin_initializer.cpp +) + +ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS}) + +TARGET_LINK_LIBRARIES(${TARGET_NAME} + ${TARGET_IMPL_NAME} + ${TARGET_CONFIG_NAME} + ${tizen_impl} +) + +INSTALL(TARGETS ${TARGET_NAME} ${TARGET_CONFIG_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) +INSTALL( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/application + FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE +) \ No newline at end of file diff --git a/src/Application/EventApplicationAddAppInfoEventListener.h b/src/Application/EventApplicationAddAppInfoEventListener.h new file mode 100755 index 0000000..2e23357 --- /dev/null +++ b/src/Application/EventApplicationAddAppInfoEventListener.h @@ -0,0 +1,65 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_ADD_APP_INFO_EVENT_LISTENER_H_ +#define TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_ADD_APP_INFO_EVENT_LISTENER_H_ + +#include +#include +#include "EventApplicationAppInfoEventListener.h" + +namespace DeviceAPI { +namespace Application { + +class EventApplicationAddAppInfoEventListener : public WrtDeviceApis::Commons::IEvent +{ +private: + /* parameter */ + EventApplicationAppInfoEventListenerEmitterPtr m_emitter; + + /* result */ + long m_watchId; + +public: + void setEmitter(EventApplicationAppInfoEventListenerEmitterPtr &value) + { + m_emitter = value; + } + + EventApplicationAppInfoEventListenerEmitterPtr getEmitter() const + { + return m_emitter; + } + + void setWatchId(long watchId) + { + m_watchId = watchId; + } + + long getWatchId() const + { + return m_watchId; + } +}; + +typedef DPL::SharedPtr EventApplicationAddAppInfoEventListenerPtr; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_ADD_APP_INFO_EVENT_LISTENER_H_ diff --git a/src/Application/EventApplicationAppInfoEventListener.h b/src/Application/EventApplicationAppInfoEventListener.h new file mode 100755 index 0000000..7da147a --- /dev/null +++ b/src/Application/EventApplicationAppInfoEventListener.h @@ -0,0 +1,94 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_APP_INFO_EVENT_LISTENER_H_ +#define TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_APP_INFO_EVENT_LISTENER_H_ + +#include +#include +#include +#include +#include +#include "ApplicationInformation.h" + +namespace DeviceAPI { +namespace Application { + +class EventApplicationAppInfoEventListener : public WrtDeviceApis::Commons::ListenerEvent +{ +public: + enum CallbackType + { + OnError, + OnInstalled, + OnUpdated, + OnUninstalled + }; + +private: + CallbackType m_type; + + std::string m_appId; + ApplicationInformationPtr m_appInfo; + +public: + void setAppId(const std::string &appId) + { + m_appId = appId; + } + + std::string getAppId() const + { + return m_appId; + } + + void setAppInfo(const ApplicationInformationPtr &appInfo) + { + m_appInfo = appInfo; + } + + ApplicationInformationPtr getAppInfo() const + { + return m_appInfo; + } + + void setType(CallbackType type) + { + m_type = type; + } + + int getType() const + { + return m_type; + } + + EventApplicationAppInfoEventListener() : + m_type(OnError), + m_appInfo(NULL) + { + } +}; + +typedef DPL::SharedPtr EventApplicationAppInfoEventListenerPtr; +typedef WrtDeviceApis::Commons::ListenerEventEmitter EventApplicationAppInfoEventListenerEmitter; +typedef DPL::SharedPtr EventApplicationAppInfoEventListenerEmitterPtr; +typedef WrtDeviceApis::Commons::Emitters EventApplicationAppInfoEventListenerEmitters; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_APP_INFO_EVENT_LISTENER_H_ diff --git a/src/Application/EventApplicationFindAppControl.h b/src/Application/EventApplicationFindAppControl.h new file mode 100755 index 0000000..0391ccc --- /dev/null +++ b/src/Application/EventApplicationFindAppControl.h @@ -0,0 +1,73 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_EVENT_FIND_APP_CONTROL_H_ +#define TIZENAPIS_API_APPLICATION_EVENT_FIND_APP_CONTROL_H_ + + +#include +#include +#include +#include "ApplicationInformation.h" +#include "ApplicationControl.h" + +namespace DeviceAPI { +namespace Application { + +class EventApplicationFindAppControl : public WrtDeviceApis::Commons::IEvent +{ +private: + /* parameter */ + ApplicationControlPtr m_appControl; + + /* result */ + ApplicationInformationArrayPtr m_appInfoArray; + +public: + void setAppControl(ApplicationControlPtr &appControl) + { + m_appControl = appControl; + } + + ApplicationControlPtr getAppControl() const + { + return m_appControl; + } + + void setAppInfos(ApplicationInformationArrayPtr &appInfos) + { + m_appInfoArray = appInfos; + } + + ApplicationInformationArrayPtr getAppInfos() const + { + return m_appInfoArray; + } + + EventApplicationFindAppControl() : + m_appControl(NULL), + m_appInfoArray(NULL) + { + } +}; + +typedef DPL::SharedPtr EventApplicationFindAppControlPtr; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_API_APPLICATION_EVENT_FIND_APP_CONTROL_H_ diff --git a/src/Application/EventApplicationGetAppCerts.h b/src/Application/EventApplicationGetAppCerts.h new file mode 100644 index 0000000..f1f701e --- /dev/null +++ b/src/Application/EventApplicationGetAppCerts.h @@ -0,0 +1,72 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_EVENT_GET_APP_CERTS_H_ +#define TIZENAPIS_API_APPLICATION_EVENT_GET_APP_CERTS_H_ + + +#include +#include +#include "ApplicationCert.h" + +namespace DeviceAPI { +namespace Application { + +class EventApplicationGetAppCerts : public WrtDeviceApis::Commons::IEvent +{ +private: + std::string m_appId; + ApplicationCertArrayPtr m_certs; + +public: + void setAppId(std::string appId) + { + m_appId = appId; + } + + std::string getAppId() + { + return m_appId; + } + + void setAppCerts(ApplicationCertArrayPtr &certs) + { + m_certs = certs; + } + + ApplicationCertArrayPtr getAppCerts() const + { + return m_certs; + } + + void addAppCert(ApplicationCertPtr cert) + { + m_certs->push_back(cert); + } + + EventApplicationGetAppCerts() : + m_certs(new ApplicationCertArray()) + { + } +}; + +typedef DPL::SharedPtr EventApplicationGetAppCertsPtr; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_API_APPLICATION_EVENT_GET_APP_CERTS_H_ \ No newline at end of file diff --git a/src/Application/EventApplicationGetAppContext.h b/src/Application/EventApplicationGetAppContext.h new file mode 100755 index 0000000..48aa441 --- /dev/null +++ b/src/Application/EventApplicationGetAppContext.h @@ -0,0 +1,70 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_EVENT_GET_APP_CONTEXT_H_ +#define TIZENAPIS_API_APPLICATION_EVENT_GET_APP_CONTEXT_H_ + + +#include +#include +#include "ApplicationContext.h" + +namespace DeviceAPI { +namespace Application { + +class EventApplicationGetAppContext : public WrtDeviceApis::Commons::IEvent +{ +private: + /* parameter */ + std::string m_appContextId; + + /* result */ + ApplicationContextPtr m_appContext; + +public: + void setAppContextId(std::string appContextId) + { + m_appContextId = appContextId; + } + + std::string getAppContextId() const + { + return m_appContextId; + } + + void setAppContext(const ApplicationContextPtr appContext) + { + m_appContext = appContext; + } + + ApplicationContextPtr getAppContext() const + { + return m_appContext; + } + + EventApplicationGetAppContext() : + m_appContext(NULL) + { + } +}; + +typedef DPL::SharedPtr EventApplicationGetAppContextPtr; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_API_APPLICATION_EVENT_GET_APP_CONTEXT_H_ diff --git a/src/Application/EventApplicationGetAppInfo.h b/src/Application/EventApplicationGetAppInfo.h new file mode 100755 index 0000000..4fa59c5 --- /dev/null +++ b/src/Application/EventApplicationGetAppInfo.h @@ -0,0 +1,70 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_EVENT_GET_APP_INFO_H_ +#define TIZENAPIS_API_APPLICATION_EVENT_GET_APP_INFO_H_ + + +#include +#include +#include "ApplicationInformation.h" + +namespace DeviceAPI { +namespace Application { + +class EventApplicationGetAppInfo : public WrtDeviceApis::Commons::IEvent +{ +private: + /* parameter */ + std::string m_appId; + + /* result */ + ApplicationInformationPtr m_appInfo; + +public: + void setAppId(std::string appId) + { + m_appId = appId; + } + + std::string getAppId() const + { + return m_appId; + } + + void setAppInfo(const ApplicationInformationPtr appInfo) + { + m_appInfo = appInfo; + } + + ApplicationInformationPtr getAppInfo() const + { + return m_appInfo; + } + + EventApplicationGetAppInfo() : + m_appInfo(NULL) + { + } +}; + +typedef DPL::SharedPtr EventApplicationGetAppInfoPtr; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_API_APPLICATION_EVENT_GET_APP_INFO_H_ diff --git a/src/Application/EventApplicationGetAppsContext.h b/src/Application/EventApplicationGetAppsContext.h new file mode 100755 index 0000000..bc89df9 --- /dev/null +++ b/src/Application/EventApplicationGetAppsContext.h @@ -0,0 +1,61 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_EVENT_GET_APPS_CONTEXT_H_ +#define TIZENAPIS_API_APPLICATION_EVENT_GET_APPS_CONTEXT_H_ + +#include +#include +#include "ApplicationContext.h" + +namespace DeviceAPI { +namespace Application { + +class EventApplicationGetAppsContext : public WrtDeviceApis::Commons::IEvent +{ +private: + /* result */ + ApplicationContextArrayPtr m_appContextArray; + +public: + void addAppContext(const ApplicationContextPtr appContext) + { + m_appContextArray->push_back(appContext); + } + + const ApplicationContextArrayPtr getAppContextArray() const + { + return m_appContextArray; + } + + void setAppContextArray(ApplicationContextArrayPtr appContextArray) + { + m_appContextArray = appContextArray; + } + + EventApplicationGetAppsContext() : + m_appContextArray(new ApplicationContextArray()) + { + } +}; + +typedef DPL::SharedPtr EventApplicationGetAppsContextPtr; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_API_APPLICATION_EVENT_GET_APPS_CONTEXT_H_ diff --git a/src/Application/EventApplicationGetAppsInfo.h b/src/Application/EventApplicationGetAppsInfo.h new file mode 100755 index 0000000..0216eef --- /dev/null +++ b/src/Application/EventApplicationGetAppsInfo.h @@ -0,0 +1,61 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_EVENT_GET_APPS_INFO_H_ +#define TIZENAPIS_API_APPLICATION_EVENT_GET_APPS_INFO_H_ + +#include +#include +#include "ApplicationInformation.h" + +namespace DeviceAPI { +namespace Application { + +class EventApplicationGetAppsInfo : public WrtDeviceApis::Commons::IEvent +{ +private: + /* result */ + ApplicationInformationArrayPtr m_appInfoArray; + +public: + void addAppInfo(const ApplicationInformationPtr appInfo) + { + m_appInfoArray->push_back(appInfo); + } + + const ApplicationInformationArrayPtr getAppInfoArray() const + { + return m_appInfoArray; + } + + void setAppInfoArray(ApplicationInformationArrayPtr appInfoArray) + { + m_appInfoArray = appInfoArray; + } + + EventApplicationGetAppsInfo() : + m_appInfoArray(new ApplicationInformationArray()) + { + } +}; + +typedef DPL::SharedPtr EventApplicationGetAppsInfoPtr; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_API_APPLICATION_EVENT_GET_APPS_INFO_H_ diff --git a/src/Application/EventApplicationGetCurrApp.h b/src/Application/EventApplicationGetCurrApp.h new file mode 100644 index 0000000..abedf93 --- /dev/null +++ b/src/Application/EventApplicationGetCurrApp.h @@ -0,0 +1,57 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_EVENT_GET_CURR_APP_H_ +#define TIZENAPIS_API_APPLICATION_EVENT_GET_CURR_APP_H_ + + +#include +#include +#include "Application.h" + +namespace DeviceAPI { +namespace Application { + +class EventApplicationGetCurrApp : public WrtDeviceApis::Commons::IEvent +{ +private: + /* result */ + ApplicationPtr m_app; + +public: + void setApp(const ApplicationPtr app) + { + m_app = app; + } + + ApplicationPtr getApp() const + { + return m_app; + } + + EventApplicationGetCurrApp() : + m_app(NULL) + { + } +}; + +typedef DPL::SharedPtr EventApplicationGetCurrAppPtr; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_API_APPLICATION_EVENT_GET_CURR_APP_H_ \ No newline at end of file diff --git a/src/Application/EventApplicationGetRequestedAppControl.h b/src/Application/EventApplicationGetRequestedAppControl.h new file mode 100644 index 0000000..d187f4b --- /dev/null +++ b/src/Application/EventApplicationGetRequestedAppControl.h @@ -0,0 +1,69 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_GET_REQUESTED_APP_CONTROL_H_ +#define TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_GET_REQUESTED_APP_CONTROL_H_ + +#include +#include +#include "RequestedApplicationControl.h" + +namespace DeviceAPI { +namespace Application { + +class EventApplicationGetRequestedAppControl : public WrtDeviceApis::Commons::IEvent +{ +private: + /* result */ + RequestedApplicationControlPtr m_reqAppControl; + + std::string m_encodedBundle; + +public: + void setRequestedAppControl(RequestedApplicationControlPtr &reqAppControl) + { + m_reqAppControl = reqAppControl; + } + + RequestedApplicationControlPtr getRequestedAppControl() const + { + return m_reqAppControl; + } + + void setEncodedBundle(std::string encodedBundle) + { + m_encodedBundle = encodedBundle; + } + + std::string getEncodedBundle() const + { + return m_encodedBundle; + } + + EventApplicationGetRequestedAppControl() : + m_reqAppControl(NULL) + { + } +}; + +typedef DPL::SharedPtr EventApplicationGetRequestedAppControlPtr; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_GET_REQUESTED_APP_CONTROL_H_ \ No newline at end of file diff --git a/src/Application/EventApplicationKill.h b/src/Application/EventApplicationKill.h new file mode 100755 index 0000000..5f8f0aa --- /dev/null +++ b/src/Application/EventApplicationKill.h @@ -0,0 +1,54 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_KILL_H_ +#define TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_KILL_H_ + +#include +#include + +namespace DeviceAPI { +namespace Application { + +class EventApplicationKill : public WrtDeviceApis::Commons::IEvent +{ +private: + /* parameter */ + std::string m_contextId; + +public: + void setContextId(std::string contextId) + { + m_contextId = contextId; + } + + std::string getContextId() const + { + return m_contextId; + } + + EventApplicationKill() + { + } +}; + +typedef DPL::SharedPtr EventApplicationKillPtr; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_KILL_H_ diff --git a/src/Application/EventApplicationLaunch.h b/src/Application/EventApplicationLaunch.h new file mode 100755 index 0000000..9666f92 --- /dev/null +++ b/src/Application/EventApplicationLaunch.h @@ -0,0 +1,51 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_LAUNCH_H_ +#define TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_LAUNCH_H_ + +#include +#include + +namespace DeviceAPI { +namespace Application { + +class EventApplicationLaunch : public WrtDeviceApis::Commons::IEvent +{ +private: + /* parameter */ + std::string m_appId; + +public: + void setAppId(std::string appId) + { + m_appId = appId; + } + + std::string getAppId() const + { + return m_appId; + } +}; + +typedef DPL::SharedPtr EventApplicationLaunchPtr; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_LAUNCH_H_ diff --git a/src/Application/EventApplicationLaunchAppControl.h b/src/Application/EventApplicationLaunchAppControl.h new file mode 100755 index 0000000..735f804 --- /dev/null +++ b/src/Application/EventApplicationLaunchAppControl.h @@ -0,0 +1,116 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_LAUNCH_APP_CONTROL_H_ +#define TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_LAUNCH_APP_CONTROL_H_ + +#include +#include +#include "ApplicationControl.h" +#include "ApplicationControlData.h" + +namespace DeviceAPI { +namespace Application { + +class EventApplicationLaunchAppControlReply; +typedef DPL::SharedPtr EventApplicationLaunchAppControlReplyPtr; + +class EventApplicationLaunchAppControl : public WrtDeviceApis::Commons::IEvent +{ +private: + /* parameters */ + ApplicationControlPtr m_appControl; + std::string m_appId; + + EventApplicationLaunchAppControlReplyPtr m_eventReply; + +public: + void setAppControl(ApplicationControlPtr &appControl) + { + m_appControl = appControl; + } + + ApplicationControlPtr getAppControl() const + { + return m_appControl; + } + + void setAppId(std::string appId) + { + m_appId = appId; + } + + std::string getAppId() + { + return m_appId; + } + + void setEventReply(EventApplicationLaunchAppControlReplyPtr &eventReply) + { + m_eventReply = eventReply; + } + + EventApplicationLaunchAppControlReplyPtr getEventReply() const + { + return m_eventReply; + } + + EventApplicationLaunchAppControl() : + m_appControl(NULL), + m_eventReply(NULL) + { + } +}; + +typedef DPL::SharedPtr EventApplicationLaunchAppControlPtr; + +class EventApplicationLaunchAppControlReply : public WrtDeviceApis::Commons::IEvent +{ +private: + ApplicationControlDataArrayPtr m_appControlDataArray; + +public: + void addAppControlData(std::string &key, std::vector &value) + { + ApplicationControlDataPtr appControlData(new ApplicationControlData()); + appControlData->setKey(key); + appControlData->setValue(value); + + m_appControlDataArray->push_back(appControlData); + } + + void setAppControlDataArray(ApplicationControlDataArrayPtr &appControlDataArray) + { + m_appControlDataArray = appControlDataArray; + } + + ApplicationControlDataArrayPtr getAppControlDataArray() const + { + return m_appControlDataArray; + } + + EventApplicationLaunchAppControlReply() : + m_appControlDataArray(new ApplicationControlDataArray()) + { + } +}; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_LAUNCH_APP_CONTROL_H_ diff --git a/src/Application/EventApplicationRemoveAppInfoEventListener.h b/src/Application/EventApplicationRemoveAppInfoEventListener.h new file mode 100755 index 0000000..a7dc2a4 --- /dev/null +++ b/src/Application/EventApplicationRemoveAppInfoEventListener.h @@ -0,0 +1,51 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_REMOVE_APP_INFO_EVENT_LISTENER_H_ +#define TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_REMOVE_APP_INFO_EVENT_LISTENER_H_ + +#include +#include + +namespace DeviceAPI { +namespace Application { + +class EventApplicationRemoveAppInfoEventListener : public WrtDeviceApis::Commons::IEvent +{ +private: + /* result */ + long m_watchId; + +public: + void setWatchId(long watchId) + { + m_watchId = watchId; + } + + long getWatchId() const + { + return m_watchId; + } +}; + +typedef DPL::SharedPtr EventApplicationRemoveAppInfoEventListenerPtr; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_API_APPLICATION_EVENT_APPLICATION_ADD_APP_INFO_EVENT_LISTENER_H_ diff --git a/src/Application/IApplicationManager.cpp b/src/Application/IApplicationManager.cpp new file mode 100644 index 0000000..1bb66fb --- /dev/null +++ b/src/Application/IApplicationManager.cpp @@ -0,0 +1,47 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 "IApplicationManager.h" + +namespace DeviceAPI { +namespace Application{ + +using namespace WrtDeviceApis::Commons; + +IApplicationManager::IApplicationManager() : + EventRequestReceiver(ThreadEnum::APPLICATION_THREAD), + EventRequestReceiver(ThreadEnum::APPLICATION_THREAD), + EventRequestReceiver(ThreadEnum::APPLICATION_THREAD), + EventRequestReceiver(ThreadEnum::APPLICATION_THREAD), + EventRequestReceiver(ThreadEnum::APPLICATION_THREAD), + EventRequestReceiver(ThreadEnum::APPLICATION_THREAD), + EventRequestReceiver(ThreadEnum::APPLICATION_THREAD), + EventRequestReceiver(ThreadEnum::APPLICATION_THREAD), + EventRequestReceiver(ThreadEnum::APPLICATION_THREAD), + EventRequestReceiver(ThreadEnum::APPLICATION_THREAD), + EventRequestReceiver(ThreadEnum::APPLICATION_THREAD), + EventRequestReceiver(ThreadEnum::APPLICATION_THREAD), + EventRequestReceiver(ThreadEnum::APPLICATION_THREAD) +{ +} + +IApplicationManager::~IApplicationManager() +{ +} + +} // Application +} // DeviceAPI diff --git a/src/Application/IApplicationManager.h b/src/Application/IApplicationManager.h new file mode 100644 index 0000000..c1ba391 --- /dev/null +++ b/src/Application/IApplicationManager.h @@ -0,0 +1,92 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_APPLICATION_IAPPLICATION_MANAGER_H_ +#define TIZENAPIS_API_APPLICATION_IAPPLICATION_MANAGER_H_ + +#include +#include +#include "EventApplicationGetCurrApp.h" +#include "EventApplicationLaunch.h" +#include "EventApplicationKill.h" +#include "EventApplicationLaunchAppControl.h" +#include "EventApplicationFindAppControl.h" +#include "EventApplicationGetAppsContext.h" +#include "EventApplicationGetAppContext.h" +#include "EventApplicationGetAppsInfo.h" +#include "EventApplicationGetAppInfo.h" +#include "EventApplicationAddAppInfoEventListener.h" +#include "EventApplicationRemoveAppInfoEventListener.h" +#include "EventApplicationGetAppCerts.h" + +namespace DeviceAPI { +namespace Application { + +class IApplicationManager : + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver +{ +public: + virtual ~IApplicationManager(); + virtual void getCurrentApplication(const EventApplicationGetCurrAppPtr& event) = 0; + virtual void launch(const EventApplicationLaunchPtr& event) = 0; + virtual void kill(const EventApplicationKillPtr& event) = 0; + virtual void launchAppControl(const EventApplicationLaunchAppControlPtr& event) = 0; + virtual void findAppControl(const EventApplicationFindAppControlPtr& event) = 0; + virtual void getAppsContext(const EventApplicationGetAppsContextPtr& event) = 0; + virtual void getAppContext(const EventApplicationGetAppContextPtr& event) = 0; + virtual void getAppsInfo(const EventApplicationGetAppsInfoPtr& event) = 0; + virtual void getAppInfo(const EventApplicationGetAppInfoPtr& event) = 0; + virtual void addAppInfoEventListener(const EventApplicationAddAppInfoEventListenerPtr& event) = 0; + virtual void removeAppInfoEventListener(const EventApplicationRemoveAppInfoEventListenerPtr& event) = 0; + virtual void getAppCerts(const EventApplicationGetAppCertsPtr& event) = 0; + +protected: + IApplicationManager(); + + virtual void OnRequestReceived(const EventApplicationGetCurrAppPtr& event) = 0; + virtual void OnRequestReceived(const EventApplicationLaunchPtr& event) = 0; + virtual void OnRequestReceived(const EventApplicationKillPtr& event) = 0; + virtual void OnRequestReceived(const EventApplicationLaunchAppControlPtr& event) = 0; + virtual void OnRequestReceived(const EventApplicationLaunchAppControlReplyPtr& event) = 0; + virtual void OnRequestReceived(const EventApplicationFindAppControlPtr& event) = 0; + virtual void OnRequestReceived(const EventApplicationGetAppsContextPtr& event) = 0; + virtual void OnRequestReceived(const EventApplicationGetAppContextPtr& event) = 0; + virtual void OnRequestReceived(const EventApplicationGetAppsInfoPtr& event) = 0; + virtual void OnRequestReceived(const EventApplicationGetAppInfoPtr& event) = 0; + virtual void OnRequestReceived(const EventApplicationAddAppInfoEventListenerPtr& event) = 0; + virtual void OnRequestReceived(const EventApplicationRemoveAppInfoEventListenerPtr& event) = 0; + virtual void OnRequestReceived(const EventApplicationGetAppCertsPtr& event) = 0; + }; + +typedef DPL::SharedPtr IApplicationManagerPtr; + +} // Application +} // DeviceAPI + +#endif // TIZENAPIS_API_APPLICATION_IAPPLICATION_MANAGER_H_ \ No newline at end of file diff --git a/src/Application/JSApplication.cpp b/src/Application/JSApplication.cpp new file mode 100644 index 0000000..9b8bb2e --- /dev/null +++ b/src/Application/JSApplication.cpp @@ -0,0 +1,249 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ApplicationController.h" +#include "ApplicationConverter.h" +#include "plugin_config.h" +#include "JSApplicationManager.h" +#include "JSApplication.h" + +namespace DeviceAPI { +namespace Application { + +using namespace DeviceAPI::Common; + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; + +JSClassRef JSApplication::m_classRef = NULL; + +JSClassDefinition JSApplication::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_INTERFACE_APPLICATION, + 0, + m_property, + m_function, + initialize, + finalize, + NULL, //HasProperty, + getProperty, //GetProperty, + NULL, //SetProperty, + NULL, //DeleteProperty, + NULL, //GetPropertyNames, + NULL, //CallAsFunction, + NULL, //CallAsConstructor, + NULL, + NULL, //ConvertToType +}; + + +JSStaticValue JSApplication::m_property[] = { + { TIZEN_APPLICATION_APP_INFO, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_APPLICATION_APP_CONTEXT_ID, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSApplication::m_function[] = { + { APPLICATION_FUNCTION_API_EXIT, JSApplication::exit, kJSPropertyAttributeNone }, + { APPLICATION_FUNCTION_API_HIDE, JSApplication::hide, kJSPropertyAttributeNone }, + { APPLICATION_FUNCTION_API_GET_REQUESTED_APP_CONTROL, JSApplication::getRequestedAppControl, kJSPropertyAttributeNone }, + { 0, 0, 0 } +}; + + +JSClassRef JSApplication::getClassRef() { + if (!m_classRef) { + m_classRef = JSClassCreate(&m_classInfo); + } + return m_classRef; +} + +void JSApplication::initialize(JSContextRef context, JSObjectRef object) +{ + LogInfo(">> initialize"); +} + +void JSApplication::finalize(JSObjectRef object) +{ + LogInfo(">> finalize"); + JSApplicationPriv* priv = static_cast(JSObjectGetPrivate(object)); + JSObjectSetPrivate(object, NULL); + LogDebug("Deleting JSApplication object"); + delete priv; +} + +bool JSApplication::isObjectOfClass(JSContextRef context, JSValueRef value) +{ + return JSValueIsObjectOfClass(context, value, getClassRef()); +} + +ApplicationPtr JSApplication::getPrivData(JSObjectRef object) +{ + JSApplicationPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + ApplicationPtr result = priv->getObject(); + if (!result) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + return result; +} + +JSValueRef JSApplication::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try { + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + ApplicationPtr privateData = getPrivData(object); + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_APP_INFO)) { + return converter->toJSValueRefFromApplicationInformation(privateData->getAppInfo()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_APP_CONTEXT_ID)) { + return converter->toJSValueRef(privateData->getContextId()); + } + } Catch(WrtDeviceApis::Commons::Exception) { + LogError("Exception: " << _rethrown_exception.GetMessage()); + JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error"); + } + + return NULL; +} + + +JSValueRef JSApplication::exit(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + + Try { + JSApplicationManager::setTitleProperty(context, "tizen://exit"); + } Catch (UnsupportedException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } Catch (Exception) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return JSValueMakeUndefined(context); +} + +JSValueRef JSApplication::hide(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + + Try { + JSApplicationManager::setTitleProperty(context, "tizen://hide"); + } Catch (UnsupportedException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } Catch (Exception) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return JSValueMakeUndefined(context); +} + + +JSValueRef JSApplication::getRequestedAppControl(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + + JSApplicationPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + + + Try { + if (!priv) { + ThrowMsg(ConversionException, "Object is null."); + } + + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + EventApplicationGetRequestedAppControlPtr event(new EventApplicationGetRequestedAppControl()); + ApplicationPtr app = priv->getObject(); + + JSObjectRef windowObject = JSContextGetGlobalObject(context); + JSValueRef encodedBundle = JSObjectGetProperty(context, + windowObject, + ScopedJSStringRef(JSStringCreateWithUTF8CString("__bundle")).get(), + exception); + if (JSValueIsUndefined(context, encodedBundle) || JSValueIsNull(context, encodedBundle)) { + LogError("encodedBundle"+converter->toString(encodedBundle)); + return JSValueMakeNull(context); + } + + event->setEncodedBundle(converter->toString(encodedBundle)); + app->getRequestedAppControl(event); + + if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) { + ThrowMsg(NotFoundException, "No application control request found."); + } else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::UnknownException) { + return JSValueMakeNull(context); + } + + return converter->toJSValueRef(event->getRequestedAppControl()); + + } Catch (NotFoundException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } Catch (ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } 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) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +} +} diff --git a/src/Application/JSApplication.h b/src/Application/JSApplication.h new file mode 100644 index 0000000..2884abf --- /dev/null +++ b/src/Application/JSApplication.h @@ -0,0 +1,124 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_TIZEN_JS_APPLICATION_H_ +#define TIZENAPIS_TIZEN_JS_APPLICATION_H_ + +#include +#include +#include +#include "Application.h" + +namespace DeviceAPI { +namespace Application { + +#define TIZEN_INTERFACE_APPLICATION "Application" + +#define TIZEN_APPLICATION_APP_INFO "appInfo" +#define TIZEN_APPLICATION_APP_CONTEXT_ID "contextId" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject JSApplicationPriv; + +class JSApplication { +public: + /* + * This initializes this JS class in the JS Engine. + */ + static JSClassRef getClassRef(); + +/* + static JSValueRef createJSObject(JSContextRef context, + const std::string &name, + const std::string &package, + const std::string &iconPath, + const std::string &version, + const bool &show, + const std::vector &categories, + const time_t &installDate, + const long &installSize); +*/ + static bool isObjectOfClass(JSContextRef context, JSValueRef value); + +/* + static ApplicationInformationPtr + getApplicationInformation(JSContextRef context, JSValueRef value); +*/ + /** + * hide the application based on application context. + */ + static JSValueRef hide(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + /** + * exit current application + */ + static JSValueRef exit(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + /** + * get request application control + */ + static JSValueRef getRequestedAppControl(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + +private: + /** + * The callback invoked when an object is first created. + */ + static void initialize(JSContextRef context, JSObjectRef object); + + /** + * The callback invoked when an object is finalized. + */ + static void finalize(JSObjectRef object); + + /** + * 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[]; + + /** + * This structure describes a statically declared function property. + */ + static JSStaticFunction m_function[]; + + static JSClassRef m_classRef; + + static ApplicationPtr getPrivData(JSObjectRef object); + + static JSValueRef getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + +}; + +} +} +#endif //TIZENAPIS_TIZEN_JS_APPLICATION_H_ diff --git a/src/Application/JSApplicationCert.cpp b/src/Application/JSApplicationCert.cpp new file mode 100644 index 0000000..bde258d --- /dev/null +++ b/src/Application/JSApplicationCert.cpp @@ -0,0 +1,131 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include "ApplicationCert.h" +#include "JSApplicationCert.h" + +namespace DeviceAPI { +namespace Application { + +using namespace WrtDeviceApis; +using namespace DeviceAPI::Common; + + +JSClassRef JSApplicationCert::m_classRef = NULL; + +JSClassDefinition JSApplicationCert::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_INTERFACE_APPLICATION_CERT, + 0, + m_property, + 0, + initialize, + finalize, + NULL, //HasProperty, + getProperty, //GetProperty, + NULL, //SetProperty, + NULL, //DeleteProperty, + NULL, //GetPropertyNames, + NULL, //CallAsFunction, + NULL, //CallAsConstructor, + NULL, + NULL, //ConvertToType +}; + +JSStaticValue JSApplicationCert::m_property[] = { + { TIZEN_APPLICATION_CERT_TYPE, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_APPLICATION_CERT_VALUE, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +JSClassRef JSApplicationCert::getClassRef() { + if (!m_classRef) { + m_classRef = JSClassCreate(&m_classInfo); + } + return m_classRef; +} + + +void JSApplicationCert::initialize(JSContextRef context, JSObjectRef object) +{ + LogInfo(">> initialize"); +} + +void JSApplicationCert::finalize(JSObjectRef object) +{ + LogInfo(">> finalize"); + JSApplicationCertPriv* priv = static_cast(JSObjectGetPrivate(object)); + JSObjectSetPrivate(object, NULL); + LogDebug("Deleting JSApplicationCert object"); + delete priv; +} + +bool JSApplicationCert::isObjectOfClass(JSContextRef context, JSValueRef value) +{ + return JSValueIsObjectOfClass(context, value, getClassRef()); +} + +ApplicationCertPtr JSApplicationCert::getPrivData(JSObjectRef object) +{ + JSApplicationCertPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + ApplicationCertPtr result = priv->getObject(); + if (!result) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + return result; +} + + +JSValueRef JSApplicationCert::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try { + CommonsJavaScript::Converter converter(context); + ApplicationCertPtr privateData = getPrivData(object); + + LogError("JSApplicationCert::getProperty = " << propertyName); + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CERT_TYPE)) { + return converter.toJSValueRef(privateData->getType()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CERT_VALUE)) { + return converter.toJSValueRef(privateData->getValue()); + } + } Catch(WrtDeviceApis::Commons::Exception) { + LogError("Exception: " << _rethrown_exception.GetMessage()); + JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error"); + } + + return JSValueMakeUndefined(context); +} + +} +} diff --git a/src/Application/JSApplicationCert.h b/src/Application/JSApplicationCert.h new file mode 100644 index 0000000..f838bd2 --- /dev/null +++ b/src/Application/JSApplicationCert.h @@ -0,0 +1,81 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_TIZEN_JS_APPLICATION_CERT_H_ +#define TIZENAPIS_TIZEN_JS_APPLICATION_CERT_H_ + +#include +#include +#include + +namespace DeviceAPI { +namespace Application { + +#define TIZEN_INTERFACE_APPLICATION_CERT "ApplicationCert" + +#define TIZEN_APPLICATION_CERT_TYPE "type" +#define TIZEN_APPLICATION_CERT_VALUE "value" + + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject JSApplicationCertPriv; + +class JSApplicationCert { +public: + /* + * This initializes this JS class in the JS Engine. + */ + static JSClassRef getClassRef(); + + static bool isObjectOfClass(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 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 ApplicationCertPtr getPrivData(JSObjectRef object); + + static JSValueRef getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + +}; + +} +} +#endif diff --git a/src/Application/JSApplicationContext.cpp b/src/Application/JSApplicationContext.cpp new file mode 100644 index 0000000..de6e681 --- /dev/null +++ b/src/Application/JSApplicationContext.cpp @@ -0,0 +1,169 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include "ApplicationContext.h" +#include "JSApplicationContext.h" + +namespace DeviceAPI { +namespace Application { + +using namespace WrtDeviceApis; +using namespace DeviceAPI::Common; + +JSClassRef JSApplicationContext::m_classRef = NULL; + +JSClassDefinition JSApplicationContext::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_INTERFACE_APPLICATION_CONTEXT, + 0, + m_property, + 0, + initialize, + finalize, + NULL, //HasProperty, + getProperty, //GetProperty, + NULL, //SetProperty, + NULL, //DeleteProperty, + NULL, //GetPropertyNames, + NULL, //CallAsFunction, + NULL, //CallAsConstructor, + NULL, + NULL, //ConvertToType +}; + +JSStaticValue JSApplicationContext::m_property[] = { + { TIZEN_APPLICATION_CONTEXT_ID, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_APPLICATION_CONTEXT_APP_ID, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +JSClassRef JSApplicationContext::getClassRef() { + if (!m_classRef) { + m_classRef = JSClassCreate(&m_classInfo); + } + return m_classRef; +} + +JSValueRef JSApplicationContext::createJSObject(JSContextRef context, + const std::string &appId, + const std::string &contextId) +{ + ApplicationContextPtr privateData = ApplicationContextPtr(new ApplicationContext()); + privateData->setAppId(appId); + privateData->setContextId(contextId); + + JSApplicationContextPriv *priv = new JSApplicationContextPriv(context, privateData); + + JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast(priv)); + if (NULL == jsValueRef) { + LogError("object creation error"); + return JSValueMakeUndefined(context); + } + + return jsValueRef; +} + +void JSApplicationContext::initialize(JSContextRef context, JSObjectRef object) +{ + LogInfo(">> initialize"); +} + +void JSApplicationContext::finalize(JSObjectRef object) +{ + LogInfo(">> finalize"); + JSApplicationContextPriv* priv = static_cast(JSObjectGetPrivate(object)); + JSObjectSetPrivate(object, NULL); + LogDebug("Deleting JSApplicationContext object"); + delete priv; +} + +bool JSApplicationContext::isObjectOfClass(JSContextRef context, JSValueRef value) +{ + return JSValueIsObjectOfClass(context, value, getClassRef()); +} + +ApplicationContextPtr JSApplicationContext::getPrivData(JSObjectRef object) +{ + JSApplicationContextPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + + ApplicationContextPtr result = priv->getObject(); + if (!result) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + + return result; +} + +ApplicationContextPtr JSApplicationContext::getApplicationContext(JSContextRef context, JSValueRef value) +{ + if (!isObjectOfClass(context, value)) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + + JSObjectRef object = JSValueToObject(context, value, NULL); + if (!object) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + + JSApplicationContextPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + + return priv->getObject(); +} + + +JSValueRef JSApplicationContext::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try { + CommonsJavaScript::Converter converter(context); + ApplicationContextPtr privateData = getPrivData(object); + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTEXT_APP_ID)) { + return converter.toJSValueRef(privateData->getAppId()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTEXT_ID)) { + return converter.toJSValueRef(privateData->getContextId()); + } + + } Catch(WrtDeviceApis::Commons::Exception) { + LogError("Exception: " << _rethrown_exception.GetMessage()); + JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error"); + } + + return JSValueMakeUndefined(context); +} + + +} +} diff --git a/src/Application/JSApplicationContext.h b/src/Application/JSApplicationContext.h new file mode 100755 index 0000000..037a616 --- /dev/null +++ b/src/Application/JSApplicationContext.h @@ -0,0 +1,91 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_TIZEN_JS_APPLICATION_CONTEXT_H_ +#define TIZENAPIS_TIZEN_JS_APPLICATION_CONTEXT_H_ + +#include +#include +#include +#include "ApplicationContext.h" + +namespace DeviceAPI { +namespace Application { + +#define TIZEN_INTERFACE_APPLICATION_CONTEXT "ApplicationContext" + +#define TIZEN_APPLICATION_CONTEXT_ID "id" +#define TIZEN_APPLICATION_CONTEXT_APP_ID "appId" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject JSApplicationContextPriv; + +class JSApplicationContext { +public: + /* + * This initializes this JS class in the JS Engine. + */ + static JSClassRef getClassRef(); + + static JSValueRef createJSObject(JSContextRef context, + const std::string &appId, + const std::string &contextId); + + static bool isObjectOfClass(JSContextRef context, JSValueRef value); + + static ApplicationContextPtr getApplicationContext(JSContextRef context, JSValueRef value); + +private: + /** + * The callback invoked when an object is first created. + */ + static void initialize(JSContextRef context, JSObjectRef object); + + /** + * The callback invoked when an object is finalized. + */ + static void finalize(JSObjectRef object); + + /** + * This structure contains properties and callbacks that define a type of object. + */ + static JSClassDefinition m_classInfo; + + /** + * This structure describes a statically declared function property. + */ + static JSStaticFunction m_functions[]; + + /** + * This member variable contains the initialization values for the static properties of this class. + * The values are given according to the data structure JSPropertySpec + */ + static JSStaticValue m_property[]; + + static JSClassRef m_classRef; + + static ApplicationContextPtr getPrivData(JSObjectRef object); + + static JSValueRef getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + +}; + +} +} +#endif diff --git a/src/Application/JSApplicationControl.cpp b/src/Application/JSApplicationControl.cpp new file mode 100644 index 0000000..df68460 --- /dev/null +++ b/src/Application/JSApplicationControl.cpp @@ -0,0 +1,293 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "plugin_config.h" + +#include "ApplicationConverter.h" +#include "ApplicationUtil.h" +#include "JSApplicationControl.h" + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + +namespace DeviceAPI { +namespace Application { + +JSClassRef JSApplicationControl::m_jsClassRef = NULL; + +JSClassDefinition JSApplicationControl::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_INTERFACE_APPLICATION_CONTROL, + 0, + m_property, + NULL, + initialize, + finalize, + NULL, //HasProperty, + getProperty, + setProperty, //SetProperty, + NULL, //DeleteProperty, + NULL, //GetPropertyNames, + NULL, //CallAsFunction, + constructor, //CallAsConstructor, + hasInstance, + NULL, //ConvertToType +}; + +JSStaticValue JSApplicationControl::m_property[] = { + { TIZEN_APPLICATION_CONTROL_OPERATION, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_APPLICATION_CONTROL_URI, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_APPLICATION_CONTROL_MIME, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_APPLICATION_CONTROL_CATEGORY, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_APPLICATION_CONTROL_DATA, getProperty, setProperty, kJSPropertyAttributeNone }, + { 0, 0, 0, 0 } +}; + +const JSClassDefinition* JSApplicationControl::getClassInfo() +{ + return &m_classInfo; +} + +const JSClassRef JSApplicationControl::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + + return m_jsClassRef; +} + +JSObjectRef JSApplicationControl::createJSObject(JSContextRef context, const ApplicationControlPtr &appsvc) +{ + LogInfo(">> createJSObject"); + JSApplicationControlPriv *priv = new JSApplicationControlPriv(context, appsvc); + + if (!priv) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Can not new an object"); + } + + return JSObjectMake(context, getClassRef(), priv); +} + + +ApplicationControlPtr JSApplicationControl::getApplicationControl(JSContextRef context, JSValueRef value) +{ + if (!isObjectOfClass(context, value)) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + + JSObjectRef object = JSValueToObject(context, value, NULL); + if (!object) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + + JSApplicationControlPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + return priv->getObject(); +} + +ApplicationControlPtr JSApplicationControl::getPrivateData(JSObjectRef object) +{ + JSApplicationControlPriv* priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + + return priv->getObject(); +} + + +void JSApplicationControl::initialize(JSContextRef context,JSObjectRef object) +{ + LogInfo(">> initialize"); +} + +void JSApplicationControl::finalize(JSObjectRef object) +{ + LogInfo(">> finalize"); + JSApplicationControlPriv* priv = static_cast(JSObjectGetPrivate(object)); + JSObjectSetPrivate(object, NULL); + LogDebug("Deleting ApplicationControl object"); + delete priv; +} + +JSObjectRef JSApplicationControl::constructor(JSContextRef context, + JSObjectRef constructor, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + if (argumentCount == 0) { + LogError("Wrong parameters"); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch"); + return NULL; + } + + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + + Try { + std::string operation = ""; + std::string uri = ""; + std::string mime = ""; + std::string category = ""; + std::vector appControlDataArray; + + operation = converter->toString(arguments[0]); + ApplicationUtil util(context, exception); + if ((argumentCount > 1) && !util.isNullOrUndefined(arguments[1])) { + uri = converter->toString(arguments[1]); + } + if ((argumentCount > 2) && !util.isNullOrUndefined(arguments[2])) { + mime = converter->toString(arguments[2]); + } + if ((argumentCount > 3) && !util.isNullOrUndefined(arguments[3])) { + category = converter->toString(arguments[3]); + } + if (argumentCount > 4) { + appControlDataArray = converter->toApplicationControlDataArray(arguments[4]); + } + + ApplicationControlPtr appsvc = ApplicationControlPtr(new ApplicationControl(operation, uri, mime, category, appControlDataArray)); + if (!appsvc) { + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "unknow error on constructor"); + return NULL; + } + + return createJSObject(context, appsvc); + + } Catch (WrtDeviceApis::Commons::Exception) { + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch"); + return NULL; + + } +} + + +bool JSApplicationControl::isObjectOfClass(JSContextRef context, JSValueRef value) +{ + return JSValueIsObjectOfClass(context, value, getClassRef()); +} + +ApplicationControlPtr JSApplicationControl::getPrivData(JSObjectRef object) +{ + LogDebug("entered"); + JSApplicationControlPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + ApplicationControlPtr result = priv->getObject(); + if (!result) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + return result; +} + + +JSValueRef JSApplicationControl::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) +{ + JSApplicationControlPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error."); + } + + Try { + ApplicationControlPtr appsvc = priv->getObject(); + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_OPERATION)) { + LogDebug("JSApplicationControl::getProperty::operation " << appsvc->getOperation()); + return converter->toJSValueRef(appsvc->getOperation()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_URI)) { + LogDebug("JSApplicationControl::getProperty::uri " << appsvc->getUri()); + return converter->toJSValueRef(appsvc->getUri()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_MIME)) { + LogDebug("JSApplicationControl::getProperty::mime " << appsvc->getMime()); + return converter->toJSValueRef(appsvc->getMime()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_CATEGORY)) { + LogDebug("JSApplicationControl::getProperty::category " << appsvc->getCategory()); + return converter->toJSValueRef(appsvc->getCategory()); + }else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_DATA)) { + LogDebug("JSApplicationControl::getProperty::extraData "); + return converter->toJSValueRef(appsvc->getAppControlDataArray()); + } + + } Catch(WrtDeviceApis::Commons::Exception) { + LogError("Exception: " << _rethrown_exception.GetMessage()); + return JSDOMExceptionFactory::UnknownException.make(context, exception); + } + + /* do not return undefined object to find method */ + return NULL; +} + +bool JSApplicationControl::setProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + Try { + ApplicationControlPtr privateData = getPrivData(object); + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_OPERATION)) { + privateData->setOperation(converter->toString(value)); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_URI)) { + privateData->setUri(converter->toString(value)); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_MIME)) { + privateData->setMime(converter->toString(value)); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_CATEGORY)) { + privateData->setCategory(converter->toString(value)); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_DATA)) { + privateData->setAppControlDataArray(converter->toApplicationControlDataArray(value)); + return true; + } + + } Catch(WrtDeviceApis::Commons::Exception) { + LogError("Exception: " << _rethrown_exception.GetMessage()); + JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error"); + } + + return false; +} + + +bool JSApplicationControl::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) +{ + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + + +} +} diff --git a/src/Application/JSApplicationControl.h b/src/Application/JSApplicationControl.h new file mode 100755 index 0000000..d85b0a2 --- /dev/null +++ b/src/Application/JSApplicationControl.h @@ -0,0 +1,129 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_TIZEN_JS_APPLICATION_CONTROL_H_ +#define TIZENAPIS_TIZEN_JS_APPLICATION_CONTROL_H_ + +#include +#include +#include "ApplicationControl.h" +#include "JSApplicationControlData.h" + +namespace DeviceAPI { +namespace Application { + +#define TIZEN_INTERFACE_APPLICATION_CONTROL "ApplicationControl" + +#define TIZEN_APPLICATION_CONTROL_OPERATION "operation" +#define TIZEN_APPLICATION_CONTROL_URI "uri" +#define TIZEN_APPLICATION_CONTROL_MIME "mime" +#define TIZEN_APPLICATION_CONTROL_CATEGORY "category" +#define TIZEN_APPLICATION_CONTROL_DATA "data" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSApplicationControlPriv; + +class JSApplicationControl { +public: + static const JSClassDefinition* getClassInfo(); + + static const JSClassRef getClassRef(); + + /** + * create an JSObject for callback function(onAnswerReceived). + */ + static JSObjectRef createJSObject(JSContextRef context, + const ApplicationControlPtr &appsvc); + + /** + * The Constructor of ApplicationControl + */ + static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + + + static bool isObjectOfClass(JSContextRef context, JSValueRef value); + + static ApplicationControlPtr getApplicationControl(JSContextRef context, JSValueRef value); + /** + * return private data + */ + static ApplicationControlPtr getPrivateData(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 ApplicationControlPtr getPrivData(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 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[]; + + /** + * This structure describes a statically declared function property. + */ + static JSStaticFunction m_function[]; + + + static JSClassRef m_jsClassRef; + +}; + +} // +} //TizenApis + +#endif diff --git a/src/Application/JSApplicationControlData.cpp b/src/Application/JSApplicationControlData.cpp new file mode 100644 index 0000000..a626aab --- /dev/null +++ b/src/Application/JSApplicationControlData.cpp @@ -0,0 +1,226 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include + +#include "JSApplicationControlData.h" +#include "ApplicationConverter.h" +#include "ApplicationUtil.h" + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + +namespace DeviceAPI { +namespace Application { + +JSClassRef JSApplicationControlData::m_classRef = NULL; + +JSClassDefinition JSApplicationControlData::m_classInfo = +{ + 0, + kJSClassAttributeNone, + TIZEN_INTERFACE_APPLICATION_CONTROL_DATA, + NULL, + m_property, + m_functions, + initialize, + finalize, + NULL, //hasProperty, + getProperty, //GetProperty, + setProperty, //SetProperty, + NULL, //DeleteProperty, + NULL, //getPropertyNames, + NULL, + constructor, + NULL, + NULL, //ConvertToType, +}; + +JSStaticValue JSApplicationControlData::m_property[] = { + { TIZEN_APPLICATION_CONTROL_DATA_KEY, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_APPLICATION_CONTROL_DATA_VALUE, getProperty, setProperty, kJSPropertyAttributeNone }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSApplicationControlData::m_functions[] = +{ + { 0, 0, 0 } +}; + +JSClassRef JSApplicationControlData::getClassRef() { + if (!m_classRef) { + m_classRef = JSClassCreate(&m_classInfo); + } + return m_classRef; +} + +JSValueRef JSApplicationControlData::createJSObject(JSContextRef context, + const std::string &key, + const std::vector &value) +{ + ApplicationControlDataPtr privateData = ApplicationControlDataPtr(new ApplicationControlData()); + + privateData->setKey(key); + privateData->setValue(value); + JSApplicationControlDataPriv *priv = new JSApplicationControlDataPriv(context, privateData); + + JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast(priv)); + if (NULL == jsValueRef) { + LogError("object creation error"); + return JSValueMakeUndefined(context); + } + + return jsValueRef; +} + +JSObjectRef JSApplicationControlData::constructor(JSContextRef context, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + if (argumentCount == 0) { + LogError("Wrong parameters"); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch"); + return NULL; + } + + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + Try { + std::string key; + std::vector value; + + if (argumentCount > 0) { + key = converter->toString(arguments[0]); + } + if (argumentCount > 1) { + if (JSIsArrayValue(context, arguments[1])) { + value = converter->toVectorOfStrings(arguments[1]); + } else { + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch"); + return NULL; + } + } + return JSValueToObject(context, createJSObject(context, key, value), exception); + } Catch (WrtDeviceApis::Commons::Exception) { + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch"); + return NULL; + } +} + +void JSApplicationControlData::initialize(JSContextRef context, JSObjectRef object) +{ + LogInfo(">> initialize"); +} + +void JSApplicationControlData::finalize(JSObjectRef object) +{ + LogInfo(">> finalize"); + JSApplicationControlDataPriv* priv = static_cast(JSObjectGetPrivate(object)); + JSObjectSetPrivate(object, NULL); + LogDebug("Deleting ApplicationControl object"); + delete priv; +} + +bool JSApplicationControlData::isObjectOfClass(JSContextRef context, JSValueRef value) +{ + return JSValueIsObjectOfClass(context, value, getClassRef()); +} + +ApplicationControlDataPtr JSApplicationControlData::getPrivData(JSObjectRef object) +{ + LogDebug("entered"); + JSApplicationControlDataPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + ApplicationControlDataPtr result = priv->getObject(); + if (!result) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + return result; +} + +ApplicationControlDataPtr JSApplicationControlData::getApplicationControlData(JSContextRef context, JSValueRef value) +{ + if (!isObjectOfClass(context, value)) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + JSObjectRef object = JSValueToObject(context, value, NULL); + if (!object) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + JSApplicationControlDataPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + return priv->getObject(); +} + + +JSValueRef JSApplicationControlData::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try { + WrtDeviceApis::CommonsJavaScript::Converter converter(context); + ApplicationControlDataPtr privateData = getPrivData(object); + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_DATA_KEY)) { + return converter.toJSValueRef(privateData->getKey()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_DATA_VALUE)) { + return converter.toJSValueRef(privateData->getValue()); + } + } Catch(WrtDeviceApis::Commons::Exception) { + LogError("Exception: " << _rethrown_exception.GetMessage()); + return JSDOMExceptionFactory::UnknownException.make(context, exception); + } + + return JSValueMakeUndefined(context); +} + +bool JSApplicationControlData::setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try { + WrtDeviceApis::CommonsJavaScript::Converter converter(context); + ApplicationControlDataPtr privateData = getPrivData(object); + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_DATA_KEY)) { + privateData->setKey(converter.toString(value)); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_DATA_VALUE)) { + privateData->setValue(converter.toVectorOfStrings(value)); + return true; + } + } Catch(WrtDeviceApis::Commons::Exception) { + LogError("Exception: " << _rethrown_exception.GetMessage()); + JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error"); + } + + return false; +} + +} +} diff --git a/src/Application/JSApplicationControlData.h b/src/Application/JSApplicationControlData.h new file mode 100755 index 0000000..672b911 --- /dev/null +++ b/src/Application/JSApplicationControlData.h @@ -0,0 +1,106 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_TIZEN_JS_APPLICATION_CONTROL_DATA_H_ +#define TIZENAPIS_TIZEN_JS_APPLICATION_CONTROL_DATA_H_ + +#include +#include +#include +#include +#include "ApplicationControlData.h" + +namespace DeviceAPI { +namespace Application { + +#define TIZEN_INTERFACE_APPLICATION_CONTROL_DATA "ApplicationControlData" + +#define TIZEN_APPLICATION_CONTROL_DATA_KEY "key" +#define TIZEN_APPLICATION_CONTROL_DATA_VALUE "value" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject JSApplicationControlDataPriv; + +class JSApplicationControlData { +public: + /* + * This initializes this JS class in the JS Engine. + */ + static JSClassRef getClassRef(); + + static JSValueRef createJSObject(JSContextRef context, + const std::string &key, + const std::vector &value); + + static JSObjectRef constructor(JSContextRef ctx, + JSObjectRef constructor, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + static bool isObjectOfClass(JSContextRef context, JSValueRef value); + + static ApplicationControlDataPtr + getApplicationControlData(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 ApplicationControlDataPtr 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); + +}; + +} +} + +#endif diff --git a/src/Application/JSApplicationEventCallbackManager.cpp b/src/Application/JSApplicationEventCallbackManager.cpp new file mode 100755 index 0000000..c26797c --- /dev/null +++ b/src/Application/JSApplicationEventCallbackManager.cpp @@ -0,0 +1,247 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 "JSApplicationEventCallbackManager.h" +#include + +namespace DeviceAPI { +namespace Application { + +JSApplicationEventCallbackManagerPtr JSApplicationEventCallbackManager::createObject(JSContextRef context) +{ + return JSApplicationEventCallbackManagerPtr( new JSApplicationEventCallbackManager(context) ); +} + +JSApplicationEventCallbackManager::JSApplicationEventCallbackManager(JSContextRef context, + JSObjectRef onInstalled, + JSObjectRef onUpdated, + JSObjectRef onUninstalled, + JSObjectRef onError ) : + m_onInstalled(NULL), + m_onUpdated(NULL), + m_onUninstalled(NULL), + m_onError(NULL), + m_context(context), + m_object(NULL) +{ + setOnInstalled(onInstalled); + setOnUpdated(onUpdated); + setOnUninstalled(onUninstalled); + setOnError(onError); +} + +JSApplicationEventCallbackManager::~JSApplicationEventCallbackManager() +{ + if(m_onInstalled) + { + JSValueUnprotect(m_context, m_onInstalled); + } + + if(m_onUpdated) + { + JSValueUnprotect(m_context, m_onUpdated); + } + + if(m_onUninstalled) + { + JSValueUnprotect(m_context, m_onUninstalled); + } + + if(m_onError) + { + JSValueUnprotect(m_context, m_onError); + } +} + +void JSApplicationEventCallbackManager::setOnInstalled( JSValueRef onInstalled ) +{ + if (onInstalled) + { + if (m_onInstalled != NULL) + { + JSValueUnprotect(m_context, m_onInstalled); + } + + m_onInstalled = JSValueToObject( m_context, onInstalled, NULL ); + + if (m_onInstalled != NULL) + { + JSValueProtect(m_context, m_onInstalled); + } + } +} + +JSValueRef JSApplicationEventCallbackManager::getOnInstalled() const +{ + return m_onInstalled; +} + +void JSApplicationEventCallbackManager::setOnUpdated( JSValueRef onUpdated ) +{ + if (onUpdated) + { + if (m_onUpdated != NULL) + { + JSValueUnprotect(m_context, m_onUpdated); + } + + m_onUpdated = JSValueToObject( m_context, onUpdated, NULL ); + + if (m_onUpdated != NULL) + { + JSValueProtect(m_context, m_onUpdated); + } + } +} + +JSValueRef JSApplicationEventCallbackManager::getOnUpdated() const +{ + return m_onUpdated; +} + +void JSApplicationEventCallbackManager::setOnUninstalled( JSValueRef onUninstalled ) +{ + if (onUninstalled) + { + if (m_onUninstalled != NULL) + { + JSValueUnprotect(m_context, m_onUninstalled); + } + + m_onUninstalled = JSValueToObject( m_context, onUninstalled, NULL ); + + if (m_onUninstalled != NULL) + { + JSValueProtect(m_context, m_onUninstalled); + } + } +} + +JSValueRef JSApplicationEventCallbackManager::getOnUninstalled() const +{ + return m_onUninstalled; +} + +void JSApplicationEventCallbackManager::setOnError( JSValueRef onError ) +{ + if (onError) + { + if (m_onError != NULL) + { + JSValueUnprotect(m_context, m_onError); + } + + m_onError = JSValueToObject( m_context, onError, NULL ); + + if (m_onError != NULL) + { + JSValueProtect(m_context, m_onError); + } + } +} + +JSValueRef JSApplicationEventCallbackManager::getOnError() const +{ + return m_onError; +} + +void JSApplicationEventCallbackManager::setContext( JSContextRef context ) +{ + m_context = context; +} + +void JSApplicationEventCallbackManager::setObject( JSObjectRef object ) +{ + m_object = object; +} + +JSObjectRef JSApplicationEventCallbackManager::getObject() const +{ + return m_object; +} + +void JSApplicationEventCallbackManager::callOnInstalled( JSValueRef appInfo ) +{ + if ( m_onInstalled == NULL ) + { + //LogDebug("oninstalled callback is not set"); + return; + } + JSValueRef objParam[1] = { appInfo }; + makeCallback( m_context, NULL, m_onInstalled, "oninstalled", objParam, 1 ); +} + +void JSApplicationEventCallbackManager::callOnUpdated( JSValueRef appInfo ) +{ + if ( m_onUpdated == NULL ) + { + //LogDebug("onupdated callback is not set"); + return; + } + JSValueRef objParam[1] = { appInfo }; + makeCallback( m_context, NULL, m_onUpdated, "onupdated", objParam, 1 ); +} + +void JSApplicationEventCallbackManager::callOnUninstalled( JSValueRef appId ) +{ + if ( m_onUninstalled == NULL ) + { + //LogDebug("onuninstalled callback is not set"); + return; + } + JSValueRef objParam[1] = { appId }; + makeCallback( m_context, NULL, m_onUninstalled, "onuninstalled", objParam, 1 ); +} + +void JSApplicationEventCallbackManager::callOnError( JSValueRef error ) +{ + if ( m_onError == NULL ) + { + //LogDebug("Error callback is not set"); + return; + } + JSValueRef objParam[1] = { error }; + makeCallback( m_context, NULL, m_onError, "onerror", objParam, 1 ); +} + +void JSApplicationEventCallbackManager::makeCallback(JSContextRef context, JSObjectRef object, JSObjectRef callback, const char *szName, JSValueRef argv[], unsigned argc) +{ + + if (callback == NULL) + { + LogError("callback is NULL"); + return; + } + + if (JSObjectIsFunction(context, callback)) + { + if (argc == 0) + { + //LogDebug("Calling object directly, no arguments"); + JSObjectCallAsFunction(context, callback, object, 0, NULL, NULL); + } + else + { + //LogDebug("Calling object directly, one argument"); + JSObjectCallAsFunction(context, callback, object, argc, argv, NULL); + } + return; + } +} + +} // Application +} // DeviceAPI diff --git a/src/Application/JSApplicationEventCallbackManager.h b/src/Application/JSApplicationEventCallbackManager.h new file mode 100755 index 0000000..823608a --- /dev/null +++ b/src/Application/JSApplicationEventCallbackManager.h @@ -0,0 +1,84 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _TIZEN_APPLICATION_JS_APPLICATION_EVENT_CALLBACK_MANAGER_H_ +#define _TIZEN_APPLICATION_JS_APPLICATION_EVENT_CALLBACK_MANAGER_H_ + +#include +#include +#include + +namespace DeviceAPI { +namespace Application { + +class JSApplicationEventCallbackManager; +typedef DPL::SharedPtr JSApplicationEventCallbackManagerPtr; + +class JSApplicationEventCallbackManager : public WrtDeviceApis::Commons::IEventPrivateData +{ +private: + JSApplicationEventCallbackManager() {} + JSApplicationEventCallbackManager( JSContextRef context, + JSObjectRef onInstalled = NULL, + JSObjectRef onUpdated = NULL, + JSObjectRef onUninstalled = NULL, + JSObjectRef onError = NULL ); + +public: + static JSApplicationEventCallbackManagerPtr createObject(JSContextRef context); + + virtual ~JSApplicationEventCallbackManager(); + + void setContext( JSContextRef context ); + JSContextRef getContext() const { return m_context; } + + void setOnInstalled( JSValueRef onInstalled ); + JSValueRef getOnInstalled() const; + void setOnUpdated( JSValueRef onUpdated ); + JSValueRef getOnUpdated() const; + void setOnUninstalled( JSValueRef onUninstalled ); + JSValueRef getOnUninstalled() const; + void setOnError( JSValueRef onError ); + JSValueRef getOnError() const; + void setObject( JSObjectRef object ); + JSObjectRef getObject() const; + + void callOnInstalled( JSValueRef contacts ); + void callOnUpdated( JSValueRef contacts ); + void callOnUninstalled( JSValueRef contactIds ); + void callOnError( JSValueRef error ); + +private: + void makeCallback(JSContextRef context, + JSObjectRef object, + JSObjectRef callback, + const char *szName, + JSValueRef argv[], + unsigned argc); + + JSObjectRef m_onInstalled; + JSObjectRef m_onUpdated; + JSObjectRef m_onUninstalled; + JSObjectRef m_onError; + JSContextRef m_context; + JSObjectRef m_object; +}; + +} // Application +} // DeviceAPI + +#endif // _TIZEN_APPLICATION_JS_APPLICATION_EVENT_CALLBACK_MANAGER_H_ diff --git a/src/Application/JSApplicationInformation.cpp b/src/Application/JSApplicationInformation.cpp new file mode 100644 index 0000000..00705bc --- /dev/null +++ b/src/Application/JSApplicationInformation.cpp @@ -0,0 +1,210 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include "ApplicationInformation.h" +#include "JSApplicationInformation.h" +#include "AppManagerWrapper.h" + +namespace DeviceAPI { +namespace Application { + +using namespace WrtDeviceApis; +using namespace DeviceAPI::Common; + + +JSClassRef JSApplicationInformation::m_classRef = NULL; + +JSClassDefinition JSApplicationInformation::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_INTERFACE_APPLICATION_INFORMATION, + 0, + m_property, + 0, + initialize, + finalize, + NULL, //HasProperty, + getProperty, //GetProperty, + NULL, //SetProperty, + NULL, //DeleteProperty, + NULL, //GetPropertyNames, + NULL, //CallAsFunction, + NULL, //CallAsConstructor, + NULL, + NULL, //ConvertToType +}; + +JSStaticValue JSApplicationInformation::m_property[] = { + { TIZEN_APPLICATION_INFORMATION_ID, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_APPLICATION_INFORMATION_NAME, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_APPLICATION_INFORMATION_ICONPATH, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_APPLICATION_INFORMATION_VERSION, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_APPLICATION_INFORMATION_SHOW, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_APPLICATION_INFORMATION_CATEGORIES, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_APPLICATION_INFORMATION_INSTALL_DATE, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_APPLICATION_INFORMATION_INSTALL_SIZE, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_APPLICATION_INFORMATION_PACKAGE_ID, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +JSClassRef JSApplicationInformation::getClassRef() { + if (!m_classRef) { + m_classRef = JSClassCreate(&m_classInfo); + } + return m_classRef; +} + +JSValueRef JSApplicationInformation::createJSObject(JSContextRef context, + const std::string &name, + const std::string &appId, + const std::string &iconPath, + const std::string &version, + const bool &show, + const std::vector &categories, + const time_t &installDate, + const long &installSize, + const std::string &pkgId) +{ + ApplicationInformationPtr privateData = ApplicationInformationPtr(new ApplicationInformation()); + privateData->setName(name); + privateData->setAppId(appId); + privateData->setIconPath(iconPath); + privateData->setVersion(version); + privateData->setShow(show); + privateData->setCategories(categories); + privateData->setInstallDate(installDate); + privateData->setInstallSize(installSize); + privateData->setPackageId(pkgId); + + JSApplicationInformationPriv *priv = new JSApplicationInformationPriv(context, privateData); + + JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast(priv)); + if (NULL == jsValueRef) { + LogError("object creation error"); + return JSValueMakeUndefined(context); + } + + return jsValueRef; +} + +void JSApplicationInformation::initialize(JSContextRef context, JSObjectRef object) +{ + //LogInfo(">> initialize"); +} + +void JSApplicationInformation::finalize(JSObjectRef object) +{ + LogInfo(">> finalize"); + JSApplicationInformationPriv* priv = static_cast(JSObjectGetPrivate(object)); + JSObjectSetPrivate(object, NULL); + LogDebug("Deleting JSApplicationInformation object"); + delete priv; +} + +bool JSApplicationInformation::isObjectOfClass(JSContextRef context, JSValueRef value) +{ + return JSValueIsObjectOfClass(context, value, getClassRef()); +} + +ApplicationInformationPtr JSApplicationInformation::getPrivData(JSObjectRef object) +{ + JSApplicationInformationPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + ApplicationInformationPtr result = priv->getObject(); + if (!result) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + return result; +} + +ApplicationInformationPtr JSApplicationInformation::getApplicationInformation(JSContextRef context, JSValueRef value) +{ + if (!isObjectOfClass(context, value)) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + + JSObjectRef object = JSValueToObject(context, value, NULL); + if (!object) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + + JSApplicationInformationPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + + return priv->getObject(); +} + +JSValueRef JSApplicationInformation::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try { + CommonsJavaScript::Converter converter(context); + ApplicationInformationPtr privateData = getPrivData(object); + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_ID)) { + return converter.toJSValueRef(privateData->getAppId()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_NAME)) { + return converter.toJSValueRef(privateData->getName()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_ICONPATH)) { + return converter.toJSValueRef(privateData->getIconPath()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_SHOW)) { + return converter.toJSValueRef(privateData->getShow()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_CATEGORIES)) { + return converter.toJSValueRef(privateData->getCategories()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_PACKAGE_ID)) { + return converter.toJSValueRef(privateData->getPackageId()); + } else { +// below code is temporal. if package manager issue is solved, rollback this code. +#if 1 // below code is used to fill attribute lazy + if (!privateData->isInitialized()) { + //LogInfo(">> is Not Initialized"); + AppManagerWrapperSingleton::Instance().initializeAppInfo(privateData); + } +#endif + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_VERSION)) { + return converter.toJSValueRef(privateData->getVersion()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_INSTALL_DATE)) { + return converter.toJSValueRef(privateData->getInstallDate()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_INSTALL_SIZE)) { + return converter.toJSValueRefLong(privateData->getInstallSize()); + } + } + } Catch(WrtDeviceApis::Commons::Exception) { + LogError("Exception: " << _rethrown_exception.GetMessage()); + JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error"); + } + + return JSValueMakeUndefined(context); +} + +} +} diff --git a/src/Application/JSApplicationInformation.h b/src/Application/JSApplicationInformation.h new file mode 100755 index 0000000..8a4be87 --- /dev/null +++ b/src/Application/JSApplicationInformation.h @@ -0,0 +1,107 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_TIZEN_JS_APPLICATION_INFORMATION_H_ +#define TIZENAPIS_TIZEN_JS_APPLICATION_INFORMATION_H_ + +#include +#include +#include +#include "ApplicationInformation.h" + +namespace DeviceAPI { +namespace Application { + +#define TIZEN_INTERFACE_APPLICATION_INFORMATION "ApplicationInformation" + +#define TIZEN_APPLICATION_INFORMATION_ID "id" +#define TIZEN_APPLICATION_INFORMATION_NAME "name" +#define TIZEN_APPLICATION_INFORMATION_ICONPATH "iconPath" +#define TIZEN_APPLICATION_INFORMATION_VERSION "version" +#define TIZEN_APPLICATION_INFORMATION_SHOW "show" +#define TIZEN_APPLICATION_INFORMATION_CATEGORIES "categories" +#define TIZEN_APPLICATION_INFORMATION_INSTALL_DATE "installDate" +#define TIZEN_APPLICATION_INFORMATION_INSTALL_SIZE "size" +#define TIZEN_APPLICATION_INFORMATION_PACKAGE_ID "packageId" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject JSApplicationInformationPriv; + +class JSApplicationInformation { +public: + /* + * This initializes this JS class in the JS Engine. + */ + static JSClassRef getClassRef(); + + static JSValueRef createJSObject(JSContextRef context, + const std::string &name, + const std::string &package, + const std::string &iconPath, + const std::string &version, + const bool &show, + const std::vector &categories, + const time_t &installDate, + const long &installSize, + const std::string &pkgId); + + static bool isObjectOfClass(JSContextRef context, JSValueRef value); + + static ApplicationInformationPtr + getApplicationInformation(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 ApplicationInformationPtr getPrivData(JSObjectRef object); + + static JSValueRef getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + +}; + +} +} +#endif diff --git a/src/Application/JSApplicationManager.cpp b/src/Application/JSApplicationManager.cpp new file mode 100644 index 0000000..ebade08 --- /dev/null +++ b/src/Application/JSApplicationManager.cpp @@ -0,0 +1,1171 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ApplicationFactory.h" +#include "plugin_config.h" +#include "ApplicationController.h" +#include "JSApplicationManager.h" +#include "ApplicationConverter.h" +#include "ApplicationUtil.h" +#include "JSApplicationControl.h" +#include "ApplicationAsyncCallbackManager.h" +#include "ApplicationListenerManager.h" +#include "ApplicationInformationEventPrivateData.h" +#include "JSApplicationEventCallbackManager.h" +#include + +namespace DeviceAPI { +namespace Application { + +using namespace DeviceAPI::Common; + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; + +JSClassRef JSApplicationManager::m_jsClassRef = NULL; + +JSClassDefinition JSApplicationManager::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_INTERFACE_APPLICATION_MANAGER, + NULL, + NULL, + m_function, + initialize, + finalize, + NULL, //hasProperty, + NULL, //getProperty, + NULL, //setProperty, + NULL, //deleteProperty, + NULL, //getPropertyNames, + NULL, + NULL, + hasInstance, + NULL +}; + +JSStaticFunction JSApplicationManager::m_function[] = { + { APPLICATION_FUNCTION_API_GET_CURRENT_APP, JSApplicationManager::getCurrentApplication, kJSPropertyAttributeNone }, + { APPLICATION_FUNCTION_API_LAUNCH, JSApplicationManager::launch, kJSPropertyAttributeNone }, + { APPLICATION_FUNCTION_API_KILL, JSApplicationManager::kill, kJSPropertyAttributeNone }, + { APPLICATION_FUNCTION_API_SET_USER_AGENT, JSApplicationManager::setUserAgent, kJSPropertyAttributeNone }, + { APPLICATION_FUNCTION_API_GET_APPS_INFO, JSApplicationManager::getAppsInfo, kJSPropertyAttributeNone }, + { APPLICATION_FUNCTION_API_GET_APPS_CONTEXT, JSApplicationManager::getAppsContext, kJSPropertyAttributeNone }, + { APPLICATION_FUNCTION_API_GET_APP_INFO, JSApplicationManager::getAppInfo, kJSPropertyAttributeNone }, + { APPLICATION_FUNCTION_API_GET_APP_CONTEXT, JSApplicationManager::getAppContext, kJSPropertyAttributeNone }, + { APPLICATION_FUNCTION_API_ADD_APP_INFO_EVENT_LISTENER, JSApplicationManager::addAppInfoEventListener, kJSPropertyAttributeNone }, + { APPLICATION_FUNCTION_API_REMOVE_APP_INFO_EVENT_LISTENER, JSApplicationManager::removeAppInfoEventListener, kJSPropertyAttributeNone }, + { APPLICATION_FUNCTION_API_LAUNCH_APP_CONTROL, JSApplicationManager::launchAppControl, kJSPropertyAttributeNone }, + { APPLICATION_FUNCTION_API_FIND_APP_CONTROL, JSApplicationManager::findAppControl, kJSPropertyAttributeNone }, + { APPLICATION_FUNCTION_API_GET_APP_CERTS, JSApplicationManager::getAppCerts, kJSPropertyAttributeNone }, + { 0, 0, 0 } +}; + +const JSClassRef JSApplicationManager::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + + return m_jsClassRef; +} + +const JSClassDefinition* JSApplicationManager::getClassInfo() +{ + return &m_classInfo; +} + +void JSApplicationManager::initialize(JSContextRef context, JSObjectRef object) +{ + LogDebug(">>> JSApplicationManager::initialize"); + ApplicationController* priv = static_cast(JSObjectGetPrivate(object)); + + if (!priv) { + IApplicationManagerPtr applications(ApplicationFactory::getInstance().createApplication()); + priv = new ApplicationController(context, applications); + + if (!JSObjectSetPrivate(object, static_cast(priv))) { + LogError("Object can't store private data."); + delete priv; + } + } else { + LogDebug("private date is already exist"); + } +} + +void JSApplicationManager::finalize(JSObjectRef object) +{ + ApplicationController* priv = static_cast (JSObjectGetPrivate(object)); + JSObjectSetPrivate(object, NULL); + delete priv; +} + +bool JSApplicationManager::hasInstance(JSContextRef context, + JSObjectRef constructor, + JSValueRef possibleInstance, + JSValueRef* exception) +{ + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + + +JSValueRef JSApplicationManager::getCurrentApplication(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + IApplicationManagerPtr appmgr; + ApplicationController *controller; + + Try { + controller = static_cast(JSObjectGetPrivate(thisObject)); + if (!controller) { + ThrowMsg(InvalidArgumentException, "No private object."); + } + appmgr = controller->getObject(); + } Catch(Exception) { + LogError("No private object"); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object"); + } + + Try { + EventApplicationGetCurrAppPtr event(new EventApplicationGetCurrApp()); + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + + event->setForSynchronousCall(); + appmgr->getCurrentApplication(event); + + if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) { + ThrowMsg(NotFoundException, "Given package not found."); + } else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::UnknownException) { + ThrowMsg(Exception, "Unknown error occurred."); + } + + LogError("get Current Application Successfully. convert application to JSValue"); + + return converter->toJSValueRefFromApplication(event->getApp()); + } Catch (NotFoundException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } Catch (ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } 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) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + + + +JSValueRef JSApplicationManager::launch(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + IApplicationManagerPtr appmgr; + JSContextRef gContext; + ApplicationController *controller; + + Try { + controller = static_cast(JSObjectGetPrivate(thisObject)); + if (!controller) { + ThrowMsg(InvalidArgumentException, "No private object."); + } + appmgr = controller->getObject(); + gContext = controller->getContext(); + } Catch(Exception) { + LogError("No private object"); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object"); + } + + AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_LAUNCH); + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext); + Try { + ApplicationUtil util(context, exception); + if (argumentCount > 1) { + if (util.isFunction(arguments[1])) { + callbackManager->setOnSuccess(arguments[1]); + } else if (!util.isNullOrUndefined(arguments[1])) { + ThrowMsg(ConversionException, "Wrong second parameter type."); + } + } + + if (argumentCount > 2) { + if (util.isFunction(arguments[2])) { + callbackManager->setOnError(arguments[2]); + } else if (!util.isNullOrUndefined(arguments[2])) { + ThrowMsg(ConversionException, "Wrong third parameter type."); + } + } + + callbackManager->setObject(thisObject); + ApplicationAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, gContext); + + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + + EventApplicationLaunchPtr event(new EventApplicationLaunch()); + + if (argumentCount > 0) { + event->setAppId(converter->toString(arguments[0])); + } else { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + event->setPrivateData(DPL::StaticPointerCast(callbackManager)); + event->setForAsynchronousCall(controller); + + appmgr->launch(event); + } Catch (ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } 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()); + callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage())); + return JSValueMakeNull(context); + } Catch (Exception) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage())); + return JSValueMakeNull(context); + } + + return JSValueMakeUndefined(context); +} + +JSValueRef JSApplicationManager::kill(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + IApplicationManagerPtr appmgr; + JSContextRef gContext; + ApplicationController *controller; + + Try { + controller = static_cast(JSObjectGetPrivate(thisObject)); + if (!controller) { + ThrowMsg(InvalidArgumentException, "No private object."); + } + appmgr = controller->getObject(); + gContext = controller->getContext(); + } Catch(Exception) { + LogError("No private object"); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object"); + } + + AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_KILL); + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext); + Try{ + ApplicationUtil util(context, exception); + if (argumentCount > 1) { + if (util.isFunction(arguments[1])) { + callbackManager->setOnSuccess(arguments[1]); + } else if (!util.isNullOrUndefined(arguments[1])) { + ThrowMsg(ConversionException, "Wrong second parameter type."); + } + } + + if (argumentCount > 2) { + if (util.isFunction(arguments[2])) { + callbackManager->setOnError(arguments[2]); + } else if (!util.isNullOrUndefined(arguments[2])) { + ThrowMsg(ConversionException, "Wrong third parameter type."); + } + } + + callbackManager->setObject(thisObject); + + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + EventApplicationKillPtr event(new EventApplicationKill()); + + std::string appContextId; + if (argumentCount > 0) { + appContextId = converter->toString(arguments[0]); + } else { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + + event->setContextId(appContextId); + event->setPrivateData(DPL::StaticPointerCast(callbackManager)); + event->setForAsynchronousCall(controller); + + appmgr->kill(event); + + ApplicationAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, gContext); + } Catch (ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } 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()); + callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage())); + return JSValueMakeNull(context); + } Catch (Exception) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage())); + return JSValueMakeNull(context); + } + + return JSValueMakeUndefined(context); +} + + +JSValueRef JSApplicationManager::setUserAgent(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + IApplicationManagerPtr appmgr; + ApplicationController *controller; + + Try { + controller = static_cast(JSObjectGetPrivate(thisObject)); + if (!controller) { + ThrowMsg(InvalidArgumentException, "No private object."); + } + appmgr = controller->getObject(); + } Catch(Exception) { + LogError("No private object"); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object"); + } + + if (argumentCount < 1) { + LogError("Wrong parameters"); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error"); + } + + Try { + std::string propertyValue; + ApplicationUtil util(context, exception); + if (util.isString(arguments[0])) { + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + propertyValue = "tizen://changeUA?ua=" + converter->toString(arguments[0]); + }else{ + LogError("TYPE_MISMATCH_ERROR"); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "First parameter should be a DOMString"); + } + + setTitleProperty(context, propertyValue); + + } Catch (WrtDeviceApis::Commons::UnsupportedException) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported"); + } Catch (WrtDeviceApis::Commons::Exception) { + LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error"); + } + + LogDebug(">>>"); + return JSValueMakeUndefined(context); +} + +JSValueRef JSApplicationManager::launchAppControl(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + IApplicationManagerPtr appmgr; + JSContextRef gContext; + ApplicationController *controller; + + Try { + controller = static_cast(JSObjectGetPrivate(thisObject)); + if (!controller) { + ThrowMsg(InvalidArgumentException, "No private object."); + } + appmgr = controller->getObject(); + gContext = controller->getContext(); + } Catch(Exception) { + LogError("No private object"); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object"); + } + + AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_LAUNCH_APP_CONTROL); + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext); + Try { + + ApplicationUtil util(context, exception); + + + if (argumentCount > 2) { + if (util.isFunction(arguments[2])) { + callbackManager->setOnSuccess(arguments[2]); + } else if (!util.isNullOrUndefined(arguments[2])) { + ThrowMsg(ConversionException, "Wrong third parameter type."); + } + } + + if (argumentCount > 3) { + if (util.isFunction(arguments[3])) { + callbackManager->setOnError(arguments[3]); + } else if (!util.isNullOrUndefined(arguments[3])) { + ThrowMsg(ConversionException, "Wrong fourth parameter type."); + } + } + + callbackManager->setObject(thisObject); + + JSCallbackManagerPtr callbackManagerReply; + if (argumentCount > 4) { + if (util.isObject(arguments[4])) { + JSObjectRef cbObj = JSValueToObject(context, arguments[4], exception); + JSValueRef onsuccess = JSUtils::getJSPropertyOrUndefined(context, cbObj, "onsuccess"); + JSValueRef onfail = JSUtils::getJSPropertyOrUndefined(context, cbObj, "onfailure"); + + if (!util.isFunction(onsuccess) || !util.isFunction(onfail)) { + ThrowMsg(ConversionException, "Wrong fifth parameter type."); + } + + callbackManagerReply = JSCallbackManager::createObject(gContext, onsuccess, onfail); + callbackManagerReply->setObject(thisObject); + + } else if (!util.isNullOrUndefined(arguments[4])) { + ThrowMsg(ConversionException, "Wrong fifth parameter type."); + } + } + + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + EventApplicationLaunchAppControlPtr event(new EventApplicationLaunchAppControl()); + + ApplicationControlPtr appControl; + if (argumentCount > 0) { + appControl = converter->toApplicationControl(arguments[0]); + } else { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + + std::string appId = ""; + if ((argumentCount > 1) && !util.isNullOrUndefined(arguments[1])) { + appId = converter->toString(arguments[1]); + } + + event->setAppId(appId); + event->setAppControl(appControl); + + event->setPrivateData(DPL::StaticPointerCast(callbackManager)); + event->setForAsynchronousCall(controller); + + if(callbackManagerReply != NULL) + { + EventApplicationLaunchAppControlReplyPtr eventReply(new EventApplicationLaunchAppControlReply()); + eventReply->setPrivateData(DPL::StaticPointerCast(callbackManagerReply)); + eventReply->setForAsynchronousCall(controller); + + event->setEventReply(eventReply); + } + + appmgr->launchAppControl(event); + + if(callbackManagerReply != NULL) + ApplicationAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManagerReply, gContext); + + ApplicationAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, gContext); + + } Catch (ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } 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()); + callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage())); + return JSValueMakeNull(context); + } Catch (Exception) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage())); + return JSValueMakeNull(context); + } + + return JSValueMakeUndefined(context); +} + +JSValueRef JSApplicationManager::findAppControl(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + IApplicationManagerPtr appmgr; + JSContextRef gContext; + ApplicationController *controller; + + Try { + controller = static_cast(JSObjectGetPrivate(thisObject)); + if (!controller) { + ThrowMsg(InvalidArgumentException, "No private object."); + } + appmgr = controller->getObject(); + gContext = controller->getContext(); + } Catch(Exception) { + LogError("No private object"); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object"); + } + + JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext); + Try { + + if (argumentCount <= 1) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + ApplicationUtil util(context, exception); + if ((argumentCount > 1) && util.isFunction(arguments[1])) { + callbackManager->setOnSuccess(arguments[1]); + } else { + ThrowMsg(ConversionException, "Wrong second parameter type."); + } + + if (argumentCount > 2) { + if (util.isFunction(arguments[2])) { + callbackManager->setOnError(arguments[2]); + } else if (!util.isNullOrUndefined(arguments[2])) { + ThrowMsg(ConversionException, "Wrong third parameter type."); + } + } + + callbackManager->setObject(thisObject); + + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + EventApplicationFindAppControlPtr event(new EventApplicationFindAppControl()); + + ApplicationControlPtr appControl; + if (argumentCount > 0) { + appControl = converter->toApplicationControl(arguments[0]); + } else { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + + event->setPrivateData(DPL::StaticPointerCast(callbackManager)); + event->setAppControl(appControl); + event->setForAsynchronousCall(controller); + + appmgr->findAppControl(event); + ApplicationAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, gContext); + + } Catch (ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } 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()); + callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage())); + return JSValueMakeNull(context); + } Catch (Exception) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage())); + return JSValueMakeNull(context); + } + + return JSValueMakeUndefined(context); +} + +JSValueRef JSApplicationManager::getAppsContext(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + IApplicationManagerPtr appmgr; + JSContextRef gContext; + ApplicationController *controller; + + Try { + controller = static_cast(JSObjectGetPrivate(thisObject)); + if (!controller) { + ThrowMsg(InvalidArgumentException, "No private object."); + } + appmgr = controller->getObject(); + gContext = controller->getContext(); + } Catch(Exception) { + LogError("No private object"); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object"); + } + + JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext); + Try { + if (argumentCount == 0) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + ApplicationUtil util(context, exception); + if ((argumentCount > 0) && util.isFunction(arguments[0])) { + callbackManager->setOnSuccess(arguments[0]); + } else { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + + if (argumentCount > 1) { + if (util.isFunction(arguments[1])) { + callbackManager->setOnError(arguments[1]); + } else if (!util.isNullOrUndefined(arguments[1])) { + ThrowMsg(ConversionException, "Wrong second parameter type."); + } + } + + callbackManager->setObject(thisObject); + + EventApplicationGetAppsContextPtr event(new EventApplicationGetAppsContext()); + + event->setPrivateData(DPL::StaticPointerCast(callbackManager)); + event->setForAsynchronousCall(controller); + + appmgr->getAppsContext(event); + ApplicationAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, gContext); + } Catch (ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } 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()); + callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage())); + return JSValueMakeNull(context); + } Catch (Exception) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage())); + return JSValueMakeNull(context); + } + + return JSValueMakeUndefined(context); +} + +JSValueRef JSApplicationManager::getAppContext(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + IApplicationManagerPtr appmgr; + ApplicationController *controller; + + Try { + controller = static_cast(JSObjectGetPrivate(thisObject)); + if (!controller) { + ThrowMsg(InvalidArgumentException, "No private object."); + } + appmgr = controller->getObject(); + } Catch(Exception) { + LogError("No private object"); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object"); + } + + Try { + EventApplicationGetAppContextPtr event(new EventApplicationGetAppContext()); + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + + event->setForSynchronousCall(); + ApplicationUtil util(context, exception); + if (argumentCount > 0 && !util.isNullOrUndefined(arguments[0])) { + event->setAppContextId(converter->toString(arguments[0])); + } + appmgr->getAppContext(event); + + if (event->getExceptionCode() != ExceptionCodes::None) + { + switch (event->getExceptionCode()) + { + case ExceptionCodes::NotFoundException: + case ExceptionCodes::InvalidArgumentException: + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "Watch id not found"); + break; + case ExceptionCodes::PlatformException: + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error"); + break; + default: + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error"); + break; + } + } + + return converter->toJSValueRefFromApplicationContext(event->getAppContext()); + + } Catch (NotFoundException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } Catch (ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } 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) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +JSValueRef JSApplicationManager::getAppsInfo(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + IApplicationManagerPtr appmgr; + JSContextRef gContext; + ApplicationController *controller; + + Try { + controller = static_cast(JSObjectGetPrivate(thisObject)); + if (!controller) { + ThrowMsg(InvalidArgumentException, "No private object."); + } + appmgr = controller->getObject(); + gContext = controller->getContext(); + } Catch(Exception) { + LogError("No private object"); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object"); + } + + JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext); + Try{ + if (argumentCount == 0) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + ApplicationUtil util(context, exception); + if ((argumentCount > 0) && util.isFunction(arguments[0])) { + callbackManager->setOnSuccess(arguments[0]); + } else { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + + if (argumentCount > 1) { + if (util.isFunction(arguments[1])) { + callbackManager->setOnError(arguments[1]); + } else if (!util.isNullOrUndefined(arguments[1])) { + ThrowMsg(ConversionException, "Wrong second parameter type."); + } + } + + callbackManager->setObject(thisObject); + ApplicationAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, gContext); + + EventApplicationGetAppsInfoPtr event(new EventApplicationGetAppsInfo()); + + event->setPrivateData(DPL::StaticPointerCast(callbackManager)); + event->setForAsynchronousCall(controller); + appmgr->getAppsInfo(event); + } Catch (ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } 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()); + callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage())); + return JSValueMakeNull(context); + } Catch (Exception) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage())); + return JSValueMakeNull(context); + } + + return JSValueMakeUndefined(context); +} + +JSValueRef JSApplicationManager::getAppInfo(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + IApplicationManagerPtr appmgr; + ApplicationController *controller; + + Try { + controller = static_cast(JSObjectGetPrivate(thisObject)); + if (!controller) { + ThrowMsg(InvalidArgumentException, "No private object."); + } + appmgr = controller->getObject(); + } Catch(Exception) { + LogError("No private object"); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object"); + } + + Try { + EventApplicationGetAppInfoPtr event(new EventApplicationGetAppInfo()); + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + + event->setForSynchronousCall(); + ApplicationUtil util(context, exception); + if (argumentCount > 0 && !util.isNullOrUndefined(arguments[0])) { + event->setAppId(converter->toString(arguments[0])); + } + appmgr->getAppInfo(event); + + if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) { + ThrowMsg(NotFoundException, "Given package not found."); + } else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::UnknownException) { + ThrowMsg(Exception, "Unknown error occurred."); + } + + return converter->toJSValueRefFromApplicationInformation(event->getAppInfo()); + } Catch (NotFoundException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } Catch (ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } 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) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +JSValueRef JSApplicationManager::addAppInfoEventListener(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + IApplicationManagerPtr appmgr; + JSContextRef gContext; + ApplicationController *controller; + + Try { + controller = static_cast(JSObjectGetPrivate(thisObject)); + if (!controller) { + ThrowMsg(InvalidArgumentException, "No private object."); + } + appmgr = controller->getObject(); + gContext = controller->getContext(); + } Catch(Exception) { + LogError("No private object"); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object"); + } + + Try { + if (argumentCount == 0) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + + JSObjectRef cbObj = converter->toJSObjectRef(arguments[0]); + JSValueRef onInstalled = JSUtils::getJSPropertyOrUndefined(context, cbObj, "oninstalled"); + JSValueRef onUpdated = JSUtils::getJSPropertyOrUndefined(context, cbObj, "onupdated"); + JSValueRef onUninstalled = JSUtils::getJSPropertyOrUndefined(context, cbObj, "onuninstalled"); + + ApplicationUtil util(context, exception); + if (!util.isFunction(onInstalled) || !util.isFunction(onUpdated) || !util.isFunction(onUninstalled)) { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + + JSApplicationEventCallbackManagerPtr callbackManager = + JSApplicationEventCallbackManager::createObject(gContext); + callbackManager->setOnInstalled(onInstalled); + callbackManager->setOnUpdated(onUpdated); + callbackManager->setOnUninstalled(onUninstalled); + EventApplicationAppInfoEventListenerEmitterPtr emitter(new EventApplicationAppInfoEventListenerEmitter()); + + emitter->setEventPrivateData(DPL::StaticPointerCast(callbackManager)); + emitter->setListener(controller); + + EventApplicationAddAppInfoEventListenerPtr event(new EventApplicationAddAppInfoEventListener()); + + event->setEmitter(emitter); + event->setForSynchronousCall(); + + appmgr->addAppInfoEventListener(event); + + if (event->getExceptionCode() != ExceptionCodes::None) + { + switch (event->getExceptionCode()) + { + case ExceptionCodes::InvalidArgumentException: + case ExceptionCodes::PlatformException: + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error"); + break; + default: + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error"); + break; + } + } + + unsigned long id = event->getWatchId(); + + if (id == 0) { + ThrowMsg(UnsupportedException, "Only one event listener can be registered."); + } + + ApplicationListenerCancellerPtr canceller = ApplicationListenerCancellerPtr(new ApplicationListenerCanceller(gContext, thisObject, id)); + DeviceAPI::Common::IListenerItemPtr listenerItem = DPL::StaticPointerCast(canceller); + ApplicationListenerManagerSingleton::Instance().registerListener(listenerItem, gContext); + + return converter->toJSValueRef(id); + } Catch (WrtDeviceApis::Commons::ConversionException) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error"); + } Catch (WrtDeviceApis::Commons::UnsupportedException) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported"); + } Catch (WrtDeviceApis::Commons::InvalidArgumentException) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error"); + } Catch (WrtDeviceApis::Commons::Exception) { + LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error"); + } +} + +JSValueRef JSApplicationManager::removeAppInfoEventListener(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + IApplicationManagerPtr appmgr; + JSContextRef gContext; + ApplicationController *controller; + + Try { + controller = static_cast(JSObjectGetPrivate(thisObject)); + if (!controller) { + ThrowMsg(InvalidArgumentException, "No private object."); + } + appmgr = controller->getObject(); + gContext = controller->getContext(); + } Catch(Exception) { + LogError("No private object"); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object"); + } + + Try { + if (argumentCount == 0) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + + EventApplicationRemoveAppInfoEventListenerPtr event(new EventApplicationRemoveAppInfoEventListener()); + + event->setForSynchronousCall(); + + long id = converter->toLong(arguments[0]); + event->setWatchId(id); + + appmgr->removeAppInfoEventListener(event); + + if (event->getExceptionCode() != ExceptionCodes::None) + { + switch (event->getExceptionCode()) + { + case ExceptionCodes::NotFoundException: + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "Watch id not found"); + break; + case ExceptionCodes::InvalidArgumentException: + case ExceptionCodes::PlatformException: + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error"); + break; + default: + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error"); + break; + } + } + + ApplicationListenerCancellerPtr canceller = ApplicationListenerCancellerPtr(new ApplicationListenerCanceller(gContext, thisObject, id)); + DeviceAPI::Common::IListenerItemPtr listenerItem = DPL::StaticPointerCast(canceller); + ApplicationListenerManagerSingleton::Instance().unregisterListener(listenerItem); + + } Catch (NotFoundException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } Catch (ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } 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) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return JSValueMakeUndefined(context); +} + + +JSValueRef JSApplicationManager::getAppCerts(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + IApplicationManagerPtr appmgr; + ApplicationController *controller; + + LogError("JSApplicationManager::getAppCerts"); + + + Try { + controller = static_cast(JSObjectGetPrivate(thisObject)); + if (!controller) { + ThrowMsg(InvalidArgumentException, "No private object."); + } + appmgr = controller->getObject(); + } Catch(Exception) { + LogError("No private object"); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object"); + } + + AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_GET_APP_CERTS); + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try { + EventApplicationGetAppCertsPtr event(new EventApplicationGetAppCerts()); + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + + event->setForSynchronousCall(); + ApplicationUtil util(context, exception); + if (argumentCount > 0 && !util.isNullOrUndefined(arguments[0])) { + event->setAppId(converter->toString(arguments[0])); + } + appmgr->getAppCerts(event); + + if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) { + ThrowMsg(NotFoundException, "Given package not found."); + } else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::UnknownException) { + ThrowMsg(Exception, "Unknown error occurred."); + } + + return converter->toJSValueRefFromeApplicationCerts(event->getAppCerts()); + } Catch (NotFoundException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } Catch (ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } 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) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + +} + + +void JSApplicationManager::setTitleProperty(JSContextRef context, std::string propertyValue){ + LogDebug("<<>>"); +} + +} +} diff --git a/src/Application/JSApplicationManager.h b/src/Application/JSApplicationManager.h new file mode 100644 index 0000000..4c6b0fe --- /dev/null +++ b/src/Application/JSApplicationManager.h @@ -0,0 +1,152 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_TIZEN_JS_APPLICATION_MANAGER_H_ +#define TIZENAPIS_TIZEN_JS_APPLICATION_MANAGER_H_ + +#include +#include +#include "IApplicationManager.h" + +namespace DeviceAPI { +namespace Application { + +#define TIZEN_INTERFACE_APPLICATION_MANAGER "ApplicationManager" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject + JSApplicationManagerPriv; + +class JSApplicationManager { +public: + static const JSClassDefinition* getClassInfo(); + + static const JSClassRef getClassRef(); + + static void setTitleProperty(JSContextRef context, std::string propertyValue); + +private: + /** + * The callback invoked when an object is first created. + */ + static void initialize(JSContextRef context, JSObjectRef object); + + /** + * The callback invoked when an object is finalized. + */ + static void finalize(JSObjectRef object); + + /** + * The callback invoked when an object is used as the target of an 'instanceof' expression. + */ + static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); + + /** + * Gets a current application + */ + static JSValueRef getCurrentApplication(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + /** + * Launches a application with given application id + */ + static JSValueRef launch(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + /** + * Kills the application based on application context. + */ + static JSValueRef kill(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + + /** + * exit current application + */ + static JSValueRef setUserAgent(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + /** + * Gets the list of installed packages. + */ + static JSValueRef getAppsInfo(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + /** + * Gets the list of running packages. + */ + static JSValueRef getAppsContext(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + /** + * Gets the application information of based on the package name. + */ + static JSValueRef getAppInfo(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + /** + * Gets the current application Context + */ + static JSValueRef getAppContext(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + /** + * Watch for changes on installed applicaiton. + */ + static JSValueRef addAppInfoEventListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + /** + * Unset installed Applications listener + */ + static JSValueRef removeAppInfoEventListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + /** + * Launch a application control + */ + static JSValueRef launchAppControl(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + /** + * Find application info list with application control + */ + static JSValueRef findAppControl(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + /** + * Get certificate information of given application + */ + static JSValueRef getAppCerts(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + + /** + * This structure contains properties and callbacks that define a type of object. + */ + static JSClassDefinition m_classInfo; + + /** + * This structure describes a statically declared function property. + */ + static JSStaticFunction m_function[]; + + static JSClassRef m_jsClassRef; +}; + +} +} +#endif diff --git a/src/Application/JSRequestedApplicationControl.cpp b/src/Application/JSRequestedApplicationControl.cpp new file mode 100644 index 0000000..4bc55a4 --- /dev/null +++ b/src/Application/JSRequestedApplicationControl.cpp @@ -0,0 +1,264 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "plugin_config.h" + +#include "ApplicationConverter.h" +#include "ApplicationUtil.h" +#include "JSRequestedApplicationControl.h" + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + +namespace DeviceAPI { +namespace Application { + +JSClassRef JSRequestedApplicationControl::m_jsClassRef = NULL; + +JSClassDefinition JSRequestedApplicationControl::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_INTERFACE_REQUESTED_APPLICATION_CONTROL, + 0, + m_property, + m_function, + initialize, + finalize, + NULL, //HasProperty, + getProperty, + NULL, //SetProperty, + NULL, //DeleteProperty, + NULL, //GetPropertyNames, + NULL, //CallAsFunction, + NULL, //CallAsConstructor, + hasInstance, + NULL, //ConvertToType +}; + +JSStaticValue JSRequestedApplicationControl::m_property[] = { + { TIZEN_APPLICATION_CONTROL, getProperty, NULL, kJSPropertyAttributeNone }, + { TIZEN_CALLER_APP_ID, getProperty, NULL, kJSPropertyAttributeNone }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSRequestedApplicationControl::m_function[] = { + { APPLICATION_FUNCTION_API_REPLY_RESULT, JSRequestedApplicationControl::replyResult, kJSPropertyAttributeNone }, + { APPLICATION_FUNCTION_API_REPLY_FAILURE, JSRequestedApplicationControl::replyFailure,kJSPropertyAttributeNone }, + { 0, 0, 0 } +}; + +const JSClassDefinition* JSRequestedApplicationControl::getClassInfo() +{ + return &m_classInfo; +} + +JSClassRef JSRequestedApplicationControl::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + + return m_jsClassRef; +} + +JSObjectRef JSRequestedApplicationControl::createJSObject(JSContextRef context, const RequestedApplicationControlPtr &appsvc) +{ + LogInfo(">> createJSObject"); + JSRequestedApplicationControlPriv *priv = new JSRequestedApplicationControlPriv(context, appsvc); + + if (!priv) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Can not new an object"); + } + + return JSObjectMake(context, getClassRef(), priv); +} + + + +void JSRequestedApplicationControl::initialize(JSContextRef context,JSObjectRef object) +{ + LogInfo(">> initialize"); +} + +void JSRequestedApplicationControl::finalize(JSObjectRef object) +{ + LogInfo(">> finalize"); + JSRequestedApplicationControlPriv* priv = static_cast(JSObjectGetPrivate(object)); + JSObjectSetPrivate(object, NULL); + LogDebug("Deleting ApplicationControl object"); + delete priv; +} + + +bool JSRequestedApplicationControl::isObjectOfClass(JSContextRef context, JSValueRef value) +{ + return JSValueIsObjectOfClass(context, value, getClassRef()); +} + +RequestedApplicationControlPtr JSRequestedApplicationControl::getRequestedApplicationControl(JSContextRef context, JSValueRef value) +{ + if (!isObjectOfClass(context, value)) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + + JSObjectRef object = JSValueToObject(context, value, NULL); + if (!object) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + + JSRequestedApplicationControlPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + return priv->getObject(); +} + + +RequestedApplicationControlPtr JSRequestedApplicationControl::getPrivData(JSObjectRef object) +{ + LogDebug("entered"); + JSRequestedApplicationControlPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + RequestedApplicationControlPtr result = priv->getObject(); + if (!result) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + return result; +} + +JSValueRef JSRequestedApplicationControl::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) +{ + JSRequestedApplicationControlPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error."); + } + + Try { + RequestedApplicationControlPtr providerMgr = priv->getObject(); + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL)) { + LogDebug("JSRequestedApplicationControl::getProperty::appControl " << providerMgr->getAppControl()); + return converter->toJSValueRef(providerMgr->getAppControl()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALLER_APP_ID)) { + LogDebug("JSRequestedApplicationControl::getProperty::callerAppId " << providerMgr->getCallerAppId()); + return converter->toJSValueRef(providerMgr->getCallerAppId()); + } + } Catch(WrtDeviceApis::Commons::Exception) { + LogError("Exception: " << _rethrown_exception.GetMessage()); + return JSDOMExceptionFactory::UnknownException.make(context, exception); + } + + /* do not return undefined object to find method */ + return NULL; +} + + +bool JSRequestedApplicationControl::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) +{ + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + +JSValueRef JSRequestedApplicationControl::replyResult(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + JSRequestedApplicationControlPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + + Try { + if (!priv) { + ThrowMsg(ConversionException, "Object is null."); + } + + ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context); + + RequestedApplicationControlPtr providerMgr = priv->getObject(); + std::vector resultArray; + if (argumentCount > 0) { + resultArray = converter->toApplicationControlDataArray(arguments[0]); + } + providerMgr->replyResult(resultArray); + } Catch (ConversionException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception,JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } Catch (NotFoundException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception,JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } Catch (NullPointerException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception,JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } Catch (Exception) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception,JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return JSValueMakeUndefined(context); +} + +JSValueRef JSRequestedApplicationControl::replyFailure(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("entered"); + JSRequestedApplicationControlPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + + Try { + if (!priv) { + ThrowMsg(ConversionException, "Object is null."); + } + + RequestedApplicationControlPtr providerMgr = priv->getObject(); + providerMgr->replyFailure(); + } Catch (NotFoundException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception,JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } Catch (NullPointerException) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception,JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } Catch (Exception) { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception,JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return JSValueMakeUndefined(context); +} + +} +} diff --git a/src/Application/JSRequestedApplicationControl.h b/src/Application/JSRequestedApplicationControl.h new file mode 100644 index 0000000..736aa3b --- /dev/null +++ b/src/Application/JSRequestedApplicationControl.h @@ -0,0 +1,136 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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_REQUESTED_APPLICATION_CONTROL_H_ +#define TIZENAPIS_TIZEN_JS_REQUESTED_APPLICATION_CONTROL_H_ + +#include +#include +#include "ApplicationControl.h" +#include "RequestedApplicationControl.h" +#include "JSApplicationControl.h" +#include "JSApplicationControlData.h" + +namespace DeviceAPI { +namespace Application { + +#define TIZEN_INTERFACE_REQUESTED_APPLICATION_CONTROL "RequestedApplicationControl" +#define TIZEN_APPLICATION_CONTROL "appControl" +#define TIZEN_CALLER_APP_ID "callerAppId" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSRequestedApplicationControlPriv; + +class JSRequestedApplicationControl { +public: + static const JSClassDefinition* getClassInfo(); + + static JSClassRef getClassRef(); + + /** + * create an JSObject for callback function(onAnswerReceived). + */ + static JSObjectRef createJSObject(JSContextRef context, + const RequestedApplicationControlPtr &appsvc); + + /** + * The Constructor of ApplicationControl + */ + static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + + + static bool isObjectOfClass(JSContextRef context, JSValueRef value); + + /** + * Send Success Result + */ + static JSValueRef replyResult(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + /** + * Send Failure Result + */ + static JSValueRef replyFailure(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception); + + static RequestedApplicationControlPtr getRequestedApplicationControl(JSContextRef context, JSValueRef value); + + +private: + /** + * The callback invoked when an object is first created. + */ + static void initialize(JSContextRef context, JSObjectRef object); + + /** + * The callback invoked when an object is finalized. + */ + static void finalize(JSObjectRef object); + + static RequestedApplicationControlPtr getPrivData(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 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[]; + + /** + * This structure describes a statically declared function property. + */ + static JSStaticFunction m_function[]; + + + static JSClassRef m_jsClassRef; + +}; + +} // +} //TizenApis + +#endif diff --git a/src/Application/RequestedApplicationControl.cpp b/src/Application/RequestedApplicationControl.cpp new file mode 100644 index 0000000..543a3f5 --- /dev/null +++ b/src/Application/RequestedApplicationControl.cpp @@ -0,0 +1,142 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include "RequestedApplicationControl.h" + +namespace DeviceAPI { +namespace Application { + +using namespace WrtDeviceApis::Commons; + +RequestedApplicationControl::RequestedApplicationControl() : + m_appControl(NULL), + m_appService(NULL) +{ + LogDebug("entered"); +} + + +RequestedApplicationControl::~RequestedApplicationControl() +{ + LogDebug("entered"); +} + +ApplicationControlPtr RequestedApplicationControl::getAppControl() const +{ + return m_appControl; +} + + +// TODO: Should I add & or not? +void RequestedApplicationControl::setAppControl(ApplicationControlPtr &appControl) +{ + m_appControl = appControl; +} + +std::string RequestedApplicationControl::getCallerAppId() const +{ + return m_callerAppId; +} + +void RequestedApplicationControl::setCallerAppId(const std::string &id) +{ + m_callerAppId = id; +} + +void RequestedApplicationControl::replyResult(std::vector &appControlDataArray) +{ + service_h reply; + service_create(&reply); + + if (!appControlDataArray.empty()) + { + const char** arr = NULL; + + LogDebug("appControlDataArray.size() : "< valueArray = appControlDataArray.at(i)->getValue(); + + arr = (const char**) calloc (sizeof(char*), valueArray.size()); + + if (arr != NULL) { + for (size_t j = 0; j < valueArray.size(); j++) { + arr[j] = valueArray.at(j).c_str(); + LogDebug("== value : " << arr[j]); + } + } + service_add_extra_data_array(reply, appControlDataArray.at(i)->getKey().c_str(), arr, valueArray.size()); + if (arr) { + free (arr); + } + } + } else { + LogError("[replyResult] appControlDataArray is empty"); + } + + // temporal code to check caller liveness + if (m_callerAppId.empty()) { + LogDebug("m_callerAppId is empty. means caller is dead"); + ThrowMsg(NotFoundException, "Cannot find caller"); + } else { + bool running = false; + int ret = app_manager_is_running(m_callerAppId.c_str(), &running); + if ((ret != APP_MANAGER_ERROR_NONE) || !running) { + LogDebug("caller is not running"); + ThrowMsg(NotFoundException, "Cannot find caller"); + } + } + + if (service_reply_to_launch_request(reply, m_appControl->getService_h(), SERVICE_RESULT_SUCCEEDED) != SERVICE_ERROR_NONE) { + ThrowMsg(NotFoundException, "Cannot find caller"); + } + + service_destroy(reply); +} + +void RequestedApplicationControl::replyFailure() +{ + service_h reply; + service_create(&reply); + + LogError("[replyFailure] enter RequestedApplicationControl::replyFailure"); + + // temporal code to check caller liveness + if (m_callerAppId.empty()) { + LogDebug("m_callerAppId is empty. means caller is dead"); + ThrowMsg(NotFoundException, "Cannot find caller"); + } else { + bool running = false; + int ret = app_manager_is_running(m_callerAppId.c_str(), &running); + if ((ret != APP_MANAGER_ERROR_NONE) || !running) { + LogDebug("caller is not running"); + ThrowMsg(NotFoundException, "Cannot find caller"); + } + } + + if (service_reply_to_launch_request(reply, m_appControl->getService_h(), SERVICE_RESULT_FAILED) != SERVICE_ERROR_NONE) { + ThrowMsg(NotFoundException, "Cannot find caller"); + } + + service_destroy(reply); +} + +} +} diff --git a/src/Application/RequestedApplicationControl.h b/src/Application/RequestedApplicationControl.h new file mode 100644 index 0000000..e91e850 --- /dev/null +++ b/src/Application/RequestedApplicationControl.h @@ -0,0 +1,59 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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_REQUESTED_APPLICATION_CONTROL_H_ +#define TIZENAPIS_API_REQUESTED_APPLICATION_CONTROL_H_ + +#include +#include +#include +#include + +#include "ApplicationControl.h" +#include "ApplicationControlData.h" + +namespace DeviceAPI { +namespace Application { + +class RequestedApplicationControl; +typedef DPL::SharedPtr RequestedApplicationControlPtr; + +/* This object represents a single extra data for service request and reply */ +class RequestedApplicationControl +{ + public: + RequestedApplicationControl(); + ~RequestedApplicationControl(); + + ApplicationControlPtr getAppControl() const; + void setAppControl(ApplicationControlPtr &appControl); + + std::string getCallerAppId() const; + void setCallerAppId(const std::string &id); + + void replyResult(std::vector &appControlDataArray); + void replyFailure(); + + private: + ApplicationControlPtr m_appControl; + service_h m_appService; + std::string m_callerAppId; +}; +} +} +#endif + diff --git a/src/Application/config.xml b/src/Application/config.xml new file mode 100755 index 0000000..022f496 --- /dev/null +++ b/src/Application/config.xml @@ -0,0 +1,35 @@ + + + + libwrt-plugins-tizen-application.so + application.install.uri + SAMSUNG plugin group + SAMSUNG certificate authority + AAAABBBBCCCCDDDEEEE0000 + + + http://tizen.org/privilege/application.launch + application.launch + + + + http://tizen.org/privilege/application.kill + appmanager.kill + + + + http://tizen.org/privilege/appmanager.kill + appmanager.kill + + + + http://tizen.org/privilege/appmanager.certificate + appmanager.certificate + + + + http://tizen.org/privilege/application.read + appmanager.certificate + + + diff --git a/src/Application/plugin_config.cpp b/src/Application/plugin_config.cpp new file mode 100755 index 0000000..e2a4acb --- /dev/null +++ b/src/Application/plugin_config.cpp @@ -0,0 +1,290 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include + +#include "plugin_config.h" + +#define APPLICATION_FEATURE_API_LAUNCH "http://tizen.org/privilege/application.launch" +#define APPLICATION_FEATURE_API_KILL "http://tizen.org/privilege/application.kill" +#define APPLICATION_FEATURE_API_KILL2 "http://tizen.org/privilege/appmanager.kill" +#define APPLICATION_FEATURE_API_CERT "http://tizen.org/privilege/appmanager.certificate" + +// for backword compatibility +#define APPLICATION_FEATURE_API_READ "http://tizen.org/privilege/application.read" +//#define APPLICATION_FEATURE_API_INSTALL "http://tizen.org/privilege/application.install" + +#define APPLICATION_DEVICE_CAP_LAUNCH "application.launch" +#define APPLICATION_DEVICE_CAP_KILL "appmanager.kill" +#define APPLICATION_DEVICE_CAP_CERT "appmanager.certificate" + +//#define APPLICATION_DEVICE_CAP_READ "application.read" +//#define APPLICATION_DEVICE_CAP_INSTALL "application.install" + +using namespace WrtDeviceApis::Commons; + +namespace DeviceAPI { +namespace Application { + +static FunctionMapping createApplicationFunctions(); + +static FunctionMapping ApplicationFunctions = + createApplicationFunctions(); + +DEFINE_FUNCTION_GETTER(Application, ApplicationFunctions); + +static FunctionMapping createApplicationFunctions() +{ + /** + * Device capabilities + */ + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_APPLICATION_LAUNCH, APPLICATION_DEVICE_CAP_LAUNCH); + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_APPLICATION_KILL, APPLICATION_DEVICE_CAP_KILL); + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_APPLICATION_CERT, APPLICATION_DEVICE_CAP_CERT); + + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_APPLICATION_LAUNCH); + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_APPLICATION_KILL); + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_APPLICATION_CERT); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_APPLICATION_LAUNCH, DEVICE_CAP_APPLICATION_LAUNCH); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_APPLICATION_KILL, DEVICE_CAP_APPLICATION_KILL); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_APPLICATION_CERT, DEVICE_CAP_APPLICATION_CERT); + +#if 0 + ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST); + + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_APPLICATION_READ, APPLICATION_DEVICE_CAP_READ); + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_APPLICATION_INSTALL, APPLICATION_DEVICE_CAP_INSTALL); + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_APPLICATION_READ); + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_APPLICATION_INSTALL); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_APPLICATION_READ, DEVICE_CAP_APPLICATION_READ); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_APPLICATION_INSTALL, DEVICE_CAP_APPLICATION_INSTALL); +#endif + + /** + * Api Features + */ + ACE_CREATE_FEATURE(FEATURE_APPLICATION_LAUNCH, APPLICATION_FEATURE_API_LAUNCH); + ACE_CREATE_FEATURE(FEATURE_APPLICATION_KILL, APPLICATION_FEATURE_API_KILL); + ACE_CREATE_FEATURE(FEATURE_APPLICATION_KILL2, APPLICATION_FEATURE_API_KILL2); + ACE_CREATE_FEATURE(FEATURE_APPLICATION_CERT, APPLICATION_FEATURE_API_CERT); + ACE_CREATE_FEATURE(FEATURE_APPLICATION_READ, APPLICATION_FEATURE_API_READ); + + + ACE_CREATE_FEATURE_LIST(APPLICATION_FEATURES_APPLICATION_LAUNCH); + ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_LAUNCH, FEATURE_APPLICATION_LAUNCH); + + ACE_CREATE_FEATURE_LIST(APPLICATION_FEATURES_APPLICATION_KILL); + ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_KILL, FEATURE_APPLICATION_KILL); + ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_KILL, FEATURE_APPLICATION_KILL2); + + ACE_CREATE_FEATURE_LIST(APPLICATION_FEATURES_APPLICATION_CERT); + ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_CERT, FEATURE_APPLICATION_CERT); + ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_CERT, FEATURE_APPLICATION_READ); + +#if 0 + ACE_CREATE_FEATURE(FEATURE_APPLICATION_READ, APPLICATION_FEATURE_API_READ); + ACE_CREATE_FEATURE(FEATURE_APPLICATION_INSTALL, APPLICATION_FEATURE_API_INSTALL); + + ACE_CREATE_FEATURE_LIST(APPLICATION_FEATURES_APPLICATION_READ); + ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_READ, FEATURE_APPLICATION_READ); + + ACE_CREATE_FEATURE_LIST(APPLICATION_FEATURES_APPLICATION_INSTALL); + ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_INSTALL, FEATURE_APPLICATION_INSTALL); +#endif + + /** + * Functions + */ + FunctionMapping applicationMapping; + + // launch + AceFunction launchFunc = ACE_CREATE_FUNCTION( + FUNCTION_LAUNCH, + APPLICATION_FUNCTION_API_LAUNCH, + APPLICATION_FEATURES_APPLICATION_LAUNCH, + DEVICE_LIST_APPLICATION_LAUNCH); + + applicationMapping.insert(std::make_pair( + APPLICATION_FUNCTION_API_LAUNCH, + launchFunc)); + + // launchAppControl + AceFunction launchAppControlFunc = ACE_CREATE_FUNCTION( + FUNCTION_LAUNCH_APP_CONTROL, + APPLICATION_FUNCTION_API_LAUNCH_APP_CONTROL, + APPLICATION_FEATURES_APPLICATION_LAUNCH, + DEVICE_LIST_APPLICATION_LAUNCH); + + applicationMapping.insert(std::make_pair( + APPLICATION_FUNCTION_API_LAUNCH_APP_CONTROL, + launchAppControlFunc)); + + // kill + AceFunction killFunc = ACE_CREATE_FUNCTION( + FUNCTION_KILL, + APPLICATION_FUNCTION_API_KILL, + APPLICATION_FEATURES_APPLICATION_KILL, + DEVICE_LIST_APPLICATION_KILL); + + applicationMapping.insert(std::make_pair( + APPLICATION_FUNCTION_API_KILL, + killFunc)); + + + // getAppCerts + AceFunction getAppCertsFunc = ACE_CREATE_FUNCTION( + FUNCTION_GET_APP_CERTS, + APPLICATION_FUNCTION_API_GET_APP_CERTS, + APPLICATION_FEATURES_APPLICATION_CERT, + DEVICE_LIST_APPLICATION_CERT); + + applicationMapping.insert(std::make_pair( + APPLICATION_FUNCTION_API_GET_APP_CERTS, + getAppCertsFunc)); + + +#if 0 + + // setUserAgent + AceFunction setUserAgentFunc = ACE_CREATE_FUNCTION( + FUNCTION_SET_USER_AGENT, + APPLICATION_FUNCTION_API_SET_USER_AGENT, + APPLICATION_FEATURES_APPLICATION_READ, + EMPTY_DEVICE_LIST); + + applicationMapping.insert(std::make_pair( + APPLICATION_FUNCTION_API_SET_USER_AGENT, + setUserAgentFunc)); + + // getAppsInfo + AceFunction getAppsInfoFunc = ACE_CREATE_FUNCTION( + FUNCTION_GET_APPLICATION_INFORMATIONS, + APPLICATION_FUNCTION_API_GET_APPS_INFO, + APPLICATION_FEATURES_APPLICATION_READ, + DEVICE_LIST_APPLICATION_READ); + + applicationMapping.insert(std::make_pair( + APPLICATION_FUNCTION_API_GET_APPS_INFO, + getAppsInfoFunc)); + + // getAppInfo + AceFunction getAppInfoFunc = ACE_CREATE_FUNCTION( + FUNCTION_GET_APPLICATION_INFORMATION, + APPLICATION_FUNCTION_API_GET_APP_INFO, + APPLICATION_FEATURES_APPLICATION_READ, + DEVICE_LIST_APPLICATION_READ); + + applicationMapping.insert(std::make_pair( + APPLICATION_FUNCTION_API_GET_APP_INFO, + getAppInfoFunc)); + + // getAppsContext + AceFunction getAppsContextFunc = ACE_CREATE_FUNCTION( + FUNCTION_GET_RUNNING_APPLICATION_CONTEXTS, + APPLICATION_FUNCTION_API_GET_APPS_CONTEXT, + APPLICATION_FEATURES_APPLICATION_READ, + DEVICE_LIST_APPLICATION_READ); + + applicationMapping.insert(std::make_pair( + APPLICATION_FUNCTION_API_GET_APPS_CONTEXT, + getAppsContextFunc)); + + // getAppContext + AceFunction getAppContextFunc = ACE_CREATE_FUNCTION( + FUNCTION_GET_CURRENT_APPLICATION_CONTEXT, + APPLICATION_FUNCTION_API_GET_APP_CONTEXT, + APPLICATION_FEATURES_APPLICATION_READ, + DEVICE_LIST_APPLICATION_READ); + + applicationMapping.insert(std::make_pair( + APPLICATION_FUNCTION_API_GET_APP_CONTEXT, + getAppContextFunc)); + + // getAppsContext + AceFunction findAppControlFunc = ACE_CREATE_FUNCTION( + FUNCTION_GET_RUNNING_APPLICATION_CONTEXTS, + APPLICATION_FUNCTION_API_FIND_APP_CONTROL, + APPLICATION_FEATURES_APPLICATION_READ, + DEVICE_LIST_APPLICATION_READ); + + applicationMapping.insert(std::make_pair( + APPLICATION_FUNCTION_API_FIND_APP_CONTROL, + findAppControlFunc)); + + // addAppInfoEventListener + AceFunction addAppInfoEventListenerFunc = ACE_CREATE_FUNCTION( + FUNCTION_ADD_APPLICATION_INFORMATION_EVENT_LISTENER, + APPLICATION_FUNCTION_API_ADD_APP_INFO_EVENT_LISTENER, + APPLICATION_FEATURES_APPLICATION_READ, + DEVICE_LIST_APPLICATION_READ); + + applicationMapping.insert(std::make_pair( + APPLICATION_FUNCTION_API_ADD_APP_INFO_EVENT_LISTENER, + addAppInfoEventListenerFunc)); + + // removeAppInfoEventListener + AceFunction removeAppInfoEventListenerFunc = ACE_CREATE_FUNCTION( + FUNCTION_REMOVE_APPLICATION_INFORMATION_EVENT_LISTENER, + APPLICATION_FUNCTION_API_REMOVE_APP_INFO_EVENT_LISTENER, + APPLICATION_FEATURES_APPLICATION_READ, + DEVICE_LIST_APPLICATION_READ); + + applicationMapping.insert(std::make_pair( + APPLICATION_FUNCTION_API_REMOVE_APP_INFO_EVENT_LISTENER, + removeAppInfoEventListenerFunc)); + + // install + AceFunction installFunc = ACE_CREATE_FUNCTION( + FUNCTION_INSTALL_APP, + APPLICATION_FUNCTION_API_INSTALL_APP, + APPLICATION_FEATURES_APPLICATION_INSTALL, + DEVICE_LIST_APPLICATION_INSTALL); + applicationMapping.insert(std::make_pair( + APPLICATION_FUNCTION_API_INSTALL_APP, + installFunc)); + + // uninstall + AceFunction uninstallFunc = ACE_CREATE_FUNCTION( + FUNCTION_UNINSTALL_APP, + APPLICATION_FUNCTION_API_UNINSTALL_APP, + APPLICATION_FEATURES_APPLICATION_INSTALL, + DEVICE_LIST_APPLICATION_INSTALL); + applicationMapping.insert(std::make_pair( + APPLICATION_FUNCTION_API_UNINSTALL_APP, + uninstallFunc)); + + // update + AceFunction updateFunc = ACE_CREATE_FUNCTION( + FUNCTION_UPDATE_APP, + APPLICATION_FUNCTION_API_UPDATE_APP, + APPLICATION_FEATURES_APPLICATION_INSTALL, + DEVICE_LIST_APPLICATION_INSTALL); + applicationMapping.insert(std::make_pair( + APPLICATION_FUNCTION_API_UPDATE_APP, + updateFunc)); +#endif + return applicationMapping; +} + +} +} diff --git a/src/Application/plugin_config.h b/src/Application/plugin_config.h new file mode 100755 index 0000000..014fdc6 --- /dev/null +++ b/src/Application/plugin_config.h @@ -0,0 +1,66 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 _APPLICATOIN_PLUGIN_CONFIG_H_ +#define _APPLICATOIN_PLUGIN_CONFIG_H_ + +#include +#include + +// feature : launch +#define APPLICATION_FUNCTION_API_LAUNCH "launch" +#define APPLICATION_FUNCTION_API_LAUNCH_APP_CONTROL "launchAppControl" + +// feature : kill - public candidate +#define APPLICATION_FUNCTION_API_KILL "kill" + +// feature : read +#define APPLICATION_FUNCTION_API_GET_APPS_INFO "getAppsInfo" +#define APPLICATION_FUNCTION_API_GET_APP_INFO "getAppInfo" +#define APPLICATION_FUNCTION_API_GET_APPS_CONTEXT "getAppsContext" +#define APPLICATION_FUNCTION_API_GET_APP_CONTEXT "getAppContext" +#define APPLICATION_FUNCTION_API_FIND_APP_CONTROL "findAppControl" +#define APPLICATION_FUNCTION_API_ADD_APP_INFO_EVENT_LISTENER "addAppInfoEventListener" +#define APPLICATION_FUNCTION_API_REMOVE_APP_INFO_EVENT_LISTENER "removeAppInfoEventListener" + +// feature : certificate - public candidate +#define APPLICATION_FUNCTION_API_GET_APP_CERTS "getAppCerts" + +// no feature required +#define APPLICATION_FUNCTION_API_GET_CURRENT_APP "getCurrentApplication" +#define APPLICATION_FUNCTION_API_GET_REQUESTED_APP_CONTROL "getRequestedAppControl" +#define APPLICATION_FUNCTION_API_EXIT "exit" +#define APPLICATION_FUNCTION_API_HIDE "hide" +#define APPLICATION_FUNCTION_API_REPLY_RESULT "replyResult" +#define APPLICATION_FUNCTION_API_REPLY_FAILURE "replyFailure" +#define APPLICATION_FUNCTION_API_SET_USER_AGENT "setUserAgent" + +namespace DeviceAPI { +namespace Application { + +DECLARE_FUNCTION_GETTER(Application); + +#define APPLICATION_CHECK_ACCESS(functionName) \ + aceCheckAccess >( \ + getApplicationFunctionData, \ + functionName) + +} +} +#endif + diff --git a/src/Application/plugin_initializer.cpp b/src/Application/plugin_initializer.cpp new file mode 100755 index 0000000..ec067b4 --- /dev/null +++ b/src/Application/plugin_initializer.cpp @@ -0,0 +1,92 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT 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 +#include +#include +#include "JSApplicationManager.h" +#include "JSApplicationControl.h" +#include "ApplicationAsyncCallbackManager.h" +#include "ApplicationListenerManager.h" + +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; + +namespace DeviceAPI { +namespace Application { + +void on_widget_start_callback(int widgetId) { + LogDebug("[Tizen1_0\\Application] on_widget_start_callback ("<(context)); + DeviceAPI::Application::ApplicationListenerManagerSingleton::Instance().unregisterContext(static_cast(context)); +} + +PLUGIN_ON_WIDGET_START(on_widget_start_callback) +PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback) +PLUGIN_ON_FRAME_LOAD(on_frame_load_callback) +PLUGIN_ON_FRAME_UNLOAD(on_frame_unload_callback) + +PLUGIN_CLASS_MAP_BEGIN + PLUGIN_CLASS_MAP_ADD_CLASS( + WRT_JS_EXTENSION_OBJECT_TIZEN, + "application", + (js_class_template_getter)DeviceAPI::Application::JSApplicationManager::getClassRef, + NULL) + + PLUGIN_CLASS_MAP_ADD_CLASS( + WRT_JS_EXTENSION_OBJECT_TIZEN, + TIZEN_INTERFACE_APPLICATION_CONTROL, + (js_class_template_getter)DeviceAPI::Application::JSApplicationControl::getClassRef, + NULL) + + PLUGIN_CLASS_MAP_ADD_CLASS( + WRT_JS_EXTENSION_OBJECT_TIZEN, + TIZEN_INTERFACE_APPLICATION_CONTROL_DATA, + (js_class_template_getter)DeviceAPI::Application::JSApplicationControlData::getClassRef, + NULL) + +PLUGIN_CLASS_MAP_END + +} //Application +} //DeviceAPI + diff --git a/src/Bluetooth/BTDevice.h b/src/Bluetooth/BTDevice.h new file mode 100644 index 0000000..ed4504b --- /dev/null +++ b/src/Bluetooth/BTDevice.h @@ -0,0 +1,65 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_BT_DEVICE_H_ +#define TIZENAPIS_API_BT_DEVICE_H_ + +#include +#include + +namespace DeviceAPI { +namespace Bluetooth { + +struct BluetoothDeviceDataClass +{ + unsigned short major; + unsigned short minor; + int majorServiceMask; +}; + +class BluetoothDeviceData +{ +public: + std::string name; + std::string address; + BluetoothDeviceDataClass btClass; + bool isBonded; + bool isTrusted; + bool isConnected; + std::vector uuids; + + BluetoothDeviceData() { btClass.major = 0; btClass.minor = 0; btClass.majorServiceMask = 0; isBonded = false; isTrusted = false; isConnected = false; }; + ~BluetoothDeviceData() {}; +}; + +typedef DPL::SharedPtr BluetoothDeviceDataPtr; + +struct BluetoothSocketData +{ + std::string uuid; + bool isServer; + unsigned short int protocol; + unsigned short int state; + int connectedSocket; + int registeredSocket; + BluetoothDeviceData peerDevice; +}; + +} +} + +#endif diff --git a/src/Bluetooth/BluetoothAdapterListener.cpp b/src/Bluetooth/BluetoothAdapterListener.cpp new file mode 100644 index 0000000..d263af6 --- /dev/null +++ b/src/Bluetooth/BluetoothAdapterListener.cpp @@ -0,0 +1,370 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include "BluetoothAdapterListener.h" +#include "JSBluetoothDevice.h" +#include "BluetoothFactory.h" +#include +#include "BluetoothMultiCallback.h" +#include "JSBluetoothSocket.h" +#include "JSBluetoothServiceHandler.h" +#include "JSBluetoothAdapter.h" +#include "BluetoothConverter.h" +#include +#include + +using namespace DeviceAPI::Common; + +namespace DeviceAPI { +namespace Bluetooth { + + +BluetoothAdapterListener::~BluetoothAdapterListener() +{ + LogDebug("entered"); +} + +BluetoothAdapterListener::BluetoothAdapterListener() : + EventBTCreateDestroyBondingAnswerReceiver(ThreadEnum::NULL_THREAD), + EventBTGetKnownDevicesAnswerReceiver(ThreadEnum::NULL_THREAD), + EventBTGetDeviceAnswerReceiver(ThreadEnum::NULL_THREAD), + EventBTSetPoweredAnswerReceiver(ThreadEnum::NULL_THREAD), + EventBTSetVisibleAnswerReceiver(ThreadEnum::NULL_THREAD), + EventBTOnDiscoveryDevicesListener(ThreadEnum::NULL_THREAD), + EventBTRegisterRFCOMMAnswerReceiver(ThreadEnum::NULL_THREAD), + EventBTUnregisterRFCOMMServiceAnswerReceiver(ThreadEnum::NULL_THREAD), + EventBTStopDiscoveryAnswerReceiver(ThreadEnum::NULL_THREAD), + EventBTSetNameAnswerReceiver(ThreadEnum::NULL_THREAD), + EventBTServiceOnConnectListener(ThreadEnum::NULL_THREAD) +{ + LogDebug("entered"); +} + + +BluetoothAdapterListener& BluetoothAdapterListener::getInstance() +{ + static BluetoothAdapterListener instance; + return instance; + +} + +void BluetoothAdapterListener::MakeErrorJSCallBack(JSCallbackManagerPtr cbm, JSContextRef globalContext, unsigned short error) +{ + LogDebug("Enter"); + JSValueRef err = 0; + + switch (error) + { + case ExceptionCodes::SecurityException: + err = JSTizenExceptionFactory::makeErrorObject(globalContext, + JSTizenException::PERMISSION_DENIED_ERROR, "permission denied error"); + break; + case ExceptionCodes::UnsupportedException: + err = JSTizenExceptionFactory::makeErrorObject(globalContext, + JSTizenException::NOT_SUPPORTED_ERROR, "unsupport error"); + break; + case ExceptionCodes::NotFoundException: + err = JSTizenExceptionFactory::makeErrorObject(globalContext, + JSTizenException::NOT_FOUND_ERROR, "not found error"); + break; + case ExceptionCodes::AlreadyInUseException: + err = JSTizenExceptionFactory::makeErrorObject(globalContext, + JSTizenException::SERVICE_NOT_AVAILABLE, "service not available"); + break; + case ExceptionCodes::EventCancelledException: + LogDebug("Enter - Event was cancled, callback will be silently discarded"); + return; + case ExceptionCodes::UnknownException: + default: + err = JSTizenExceptionFactory::makeErrorObject(globalContext, + JSTizenException::UNKNOWN_ERROR, "unknown error"); + break; + } + cbm->callOnError(err); +} + +void BluetoothAdapterListener::OnAnswerReceived(const EventBTCreateDestroyBondingPtr& event) +{ + LogDebug("Enter - EventBTCreateDestroyBondingPtr"); +// JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast (event->getPrivateData()); + + BluetoothCreateBondingPrivateDataPtr privData; + JSCallbackManagerPtr callbackManager; + + if (event->isCreateBonding() == true) + { + privData = DPL::StaticPointerCast (event->getPrivateData()); + callbackManager = privData->getCallbackManager(); + } + else + { + callbackManager = DPL::StaticPointerCast (event->getPrivateData()); + } + + JSContextRef l_globalContext = callbackManager->getContext(); + + if (event->getExceptionCode() == ExceptionCodes::None) + { + 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) +{ + LogDebug("Enter - EventBTGetKnownDevicesPtr"); + JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast (event->getPrivateData()); + JSContextRef l_globalContext = callbackManager->getContext(); + + if (event->getExceptionCode() == ExceptionCodes::None) + { + std::vector devices = event->getDevices(); + BluetoothConverter converter(l_globalContext); + JSObjectRef result = converter.toBluetoothDevices(devices); + callbackManager->callOnSuccess(result); + } + else + { + MakeErrorJSCallBack(callbackManager, l_globalContext, event->getExceptionCode()); + } + + + } + + +void BluetoothAdapterListener::OnAnswerReceived(const EventBTSetPoweredPtr& event) +{ + LogDebug("Enter - EventBTSetPoweredPtr"); + JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast (event->getPrivateData()); + JSContextRef l_globalContext = callbackManager->getContext(); + + + if (event->getExceptionCode() == ExceptionCodes::None) + { + callbackManager->callOnSuccess(); + } + else + { + MakeErrorJSCallBack(callbackManager, l_globalContext, event->getExceptionCode()); + } +} + +void BluetoothAdapterListener::OnAnswerReceived(const EventBTGetDevicePtr& event) +{ + LogDebug("Enter - EventBTGetDevicePtr"); + JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast (event->getPrivateData()); + JSContextRef l_globalContext = callbackManager->getContext(); + + if (event->getExceptionCode() == ExceptionCodes::None) + { + BluetoothDeviceData device = event->getDevice(); + LogDebug("Enter" << device.name << " " << device.address << "major: " << device.btClass.major << "minor: " << device.btClass.minor); + JSObjectRef adapterObject = JSBluetoothDevice::createJSObject(callbackManager->getContext(), device); + callbackManager->callOnSuccess(adapterObject); + } + else + { + MakeErrorJSCallBack(callbackManager, l_globalContext, event->getExceptionCode()); + } + +} + + +void BluetoothAdapterListener::OnAnswerReceived(const EventBTSetVisiblePtr& event) +{ + LogDebug("Enter - EventBTSetVisiblePtr"); + JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast (event->getPrivateData()); + JSContextRef l_globalContext = callbackManager->getContext(); + + if (event->getExceptionCode() == ExceptionCodes::None) + { + callbackManager->callOnSuccess(); + } + else + { + MakeErrorJSCallBack(callbackManager, l_globalContext, event->getExceptionCode()); + } +} + +void BluetoothAdapterListener::OnAnswerReceived(const EventBTUnregisterRFCOMMServicePtr& event) +{ + LogDebug("Enter - EventBTUnregisterRFCOMMServicePtr"); + JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast (event->getPrivateData()); + JSContextRef l_globalContext = callbackManager->getContext(); + + if (event->getExceptionCode() == ExceptionCodes::None) + { + callbackManager->callOnSuccess(); + } + else + { + MakeErrorJSCallBack(callbackManager, l_globalContext, event->getExceptionCode()); + } +} + + +void BluetoothAdapterListener::onAnswerReceived(const EventBTOnDiscoveryDevicesPtr& event) +{ + LogDebug("Enter"); + + EventBTOnDiscoveryDevicesPrivateDataPtr multiCallbacks = + DPL::DynamicPointerCast(event->getPrivateData()); + JSCallbackManagerPtr defaultCbm = multiCallbacks->getOnSuccess(); + std::vector devices; + +/* assert(multiCallbacks != NULL); + assert(defaultCbm != NULL); + assert(multiCallbacks->getOnFound() != NULL); + assert(multiCallbacks->getOnFinished() != NULL);*/ + + if (event->getExceptionCode() == ExceptionCodes::None) + { + switch(event->getDiscoveryState()) + { + case EventBTOnDiscoveryDevices::STARTED: + multiCallbacks->getOnSuccess()->callOnSuccess(); + break; + case EventBTOnDiscoveryDevices::DISCOVERYING: + { + JSObjectRef adapterObject; + devices = event->getDevices(); + defaultCbm = multiCallbacks->getOnFound(); + adapterObject = JSBluetoothDevice::createJSObject(defaultCbm->getContext(), devices[0]); + defaultCbm->callOnSuccess(adapterObject); + } + break; + + case EventBTOnDiscoveryDevices::FINISHED: + { + devices = event->getDevices(); + defaultCbm = multiCallbacks->getOnFinished(); + + BluetoothConverter converter(defaultCbm->getContext()); + JSObjectRef result = converter.toBluetoothDevices(devices); + defaultCbm->callOnSuccess(result); + } + break; + default: + MakeErrorJSCallBack(defaultCbm, defaultCbm->getContext(), event->getExceptionCode()); + break; + + } + } + else + { + MakeErrorJSCallBack(defaultCbm, defaultCbm->getContext(), event->getExceptionCode()); + } +} + +void BluetoothAdapterListener::OnAnswerReceived(const EventBTRegisterRFCOMMPtr& event) +{ + + LogDebug("Enter - EventBTRegisterRFCOMMPtr"); + + JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast (event->getPrivateData()); + JSContextRef l_globalContext = callbackManager->getContext(); + + if (event->getExceptionCode() == ExceptionCodes::None) + { + 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(callbackManager, l_globalContext, event->getExceptionCode()); + } + + +} + +void BluetoothAdapterListener::OnAnswerReceived(const EventBTStopDiscoveryPtr& event) +{ + LogDebug("Enter - EventBTStopDiscoveryPtr"); + JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast (event->getPrivateData()); + JSContextRef l_globalContext = callbackManager->getContext(); + + if (event->getExceptionCode() == ExceptionCodes::None) + { + callbackManager->callOnSuccess(); + } + else + { + MakeErrorJSCallBack(callbackManager, l_globalContext, event->getExceptionCode()); + } +} + +void BluetoothAdapterListener::OnAnswerReceived(const EventBTSetNamePtr& event) +{ + LogDebug("Enter - EventBTSetNamePtr"); + JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast (event->getPrivateData()); + JSContextRef l_globalContext = callbackManager->getContext(); + + if (event->getExceptionCode() == ExceptionCodes::None) + { + callbackManager->callOnSuccess(); + } + else + { + MakeErrorJSCallBack(callbackManager, l_globalContext, event->getExceptionCode()); + } +} + +void BluetoothAdapterListener::onAnswerReceived(const EventBTServiceOnConnectPtr& event) +{ + LogDebug("Enter - EventBTServiceOnConnectPtr"); + + JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast (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()); + } + +} + + + +} +} diff --git a/src/Bluetooth/BluetoothAdapterListener.h b/src/Bluetooth/BluetoothAdapterListener.h new file mode 100644 index 0000000..bf7532c --- /dev/null +++ b/src/Bluetooth/BluetoothAdapterListener.h @@ -0,0 +1,94 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_BLUETOOTH_ADAPTER_LISTENER_H_ +#define TIZENAPIS_TIZEN_BLUETOOTH_ADAPTER_LISTENER_H_ + +#include +#include +#include +#include "IBluetoothAdapterManager.h" +#include +#include "EventBTServiceOnConnect.h" +#include "EventBTUnregisterRFCOMM.h" + + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; + +namespace DeviceAPI { +namespace Bluetooth { + + +typedef EventAnswerReceiver EventBTCreateDestroyBondingAnswerReceiver; +typedef EventAnswerReceiver EventBTGetKnownDevicesAnswerReceiver; +typedef EventAnswerReceiver EventBTGetDeviceAnswerReceiver; +typedef EventAnswerReceiver EventBTSetPoweredAnswerReceiver; +typedef EventAnswerReceiver EventBTSetVisibleAnswerReceiver; +typedef EventListener EventBTOnDiscoveryDevicesListener; +typedef EventAnswerReceiver EventBTRegisterRFCOMMAnswerReceiver; +typedef EventAnswerReceiver EventBTUnregisterRFCOMMServiceAnswerReceiver; +typedef EventAnswerReceiver EventBTStopDiscoveryAnswerReceiver; +typedef EventAnswerReceiver EventBTSetNameAnswerReceiver; +typedef EventListener EventBTServiceOnConnectListener; + + + +class BluetoothAdapterListener : + public EventBTCreateDestroyBondingAnswerReceiver, + public EventBTGetKnownDevicesAnswerReceiver, + public EventBTGetDeviceAnswerReceiver, + public EventBTSetPoweredAnswerReceiver, + public EventBTSetVisibleAnswerReceiver, + public EventBTOnDiscoveryDevicesListener, + public EventBTRegisterRFCOMMAnswerReceiver, + public EventBTUnregisterRFCOMMServiceAnswerReceiver, + public EventBTStopDiscoveryAnswerReceiver, + public EventBTSetNameAnswerReceiver, + public EventBTServiceOnConnectListener +{ + +private: + BluetoothAdapterListener(); + void MakeErrorJSCallBack(JSCallbackManagerPtr cbm, JSContextRef globalContext, unsigned short error); +public: + static BluetoothAdapterListener& getInstance(); + virtual void onAnswerReceived(const EventBTOnDiscoveryDevicesPtr& event); + virtual void onAnswerReceived(const EventBTServiceOnConnectPtr& event); + + virtual ~BluetoothAdapterListener(); +protected: + + virtual void OnAnswerReceived(const EventBTCreateDestroyBondingPtr& event); + virtual void OnAnswerReceived(const EventBTGetKnownDevicesPtr& event); + virtual void OnAnswerReceived(const EventBTGetDevicePtr& event); + virtual void OnAnswerReceived(const EventBTSetPoweredPtr& event); + virtual void OnAnswerReceived(const EventBTSetVisiblePtr& event); + virtual void OnAnswerReceived(const EventBTUnregisterRFCOMMServicePtr& event); + virtual void OnAnswerReceived(const EventBTStopDiscoveryPtr& event); + virtual void OnAnswerReceived(const EventBTSetNamePtr& event); + virtual void OnAnswerReceived(const EventBTRegisterRFCOMMPtr& event); + + +}; + +typedef DPL::SharedPtr BluetoothAdapterListenerPtr; + +} +} + +#endif diff --git a/src/Bluetooth/BluetoothAdapterManager.cpp b/src/Bluetooth/BluetoothAdapterManager.cpp new file mode 100755 index 0000000..f5fa479 --- /dev/null +++ b/src/Bluetooth/BluetoothAdapterManager.cpp @@ -0,0 +1,1086 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include "BluetoothAdapterManager.h" +#include "BluetoothCBManager.h" +#include "BluetoothProperty.h" + + + + +using namespace WrtDeviceApis; +using namespace DPL; + + +namespace DeviceAPI { +namespace Bluetooth { + +bool BluetoothAdapterManager::m_btPowered = false; +bool BluetoothAdapterManager::m_btGetDeviceEvent = false; +int BluetoothAdapterManager::m_currentServiceSocket = -1; +std::vector BluetoothAdapterManager::m_Devices; + + +namespace { + +// put only sync capi callback to this. +// others shuld be moved to BluetoothCBManager.cpp + +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 bool capi_callback_bt_adapter_check_connected_profile(bt_profile_e profile, void *user_data) +{ + + if (profile == BT_PROFILE_RFCOMM) + { + LogDebug("Rfcomm connected"); + + + if( user_data != NULL ) + { + *(bool*)user_data = true; + } + return false; + } + + return true; +} + +} + +BluetoothAdapterManager::BluetoothAdapterManager() +{ + LogDebug("Enter"); + Init(); + m_btPowered = canUseBluetooth(); +} + +BluetoothAdapterManager::~BluetoothAdapterManager() +{ + LogDebug("Enter"); + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_SETPOWERED); + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_SETNAME); + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_DISCOVERY); + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_CREATEBOND); + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_DESTROYBOND); + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_SERVICESEARCH); +} + + +void BluetoothAdapterManager::Init() +{ + LogDebug("Enter"); + + if (bt_initialize() != BT_ERROR_NONE) + { + LogDebug("init error"); + } +} + +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, NULL) == BT_ERROR_NONE) + { + if (mode != BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE) + { + return true; + } + } + return false; +} + +void BluetoothAdapterManager::setPowered(const EventBTSetPoweredPtr& event) +{ + LogDebug("Enter"); + BluetoothCBManagerSingleton::Instance().addAdapterCallback(BluetoothCBManager::ADAPTER_SETPOWERED, (void*)this); + EventRequestReceiver::PostRequest(event); +} + +void BluetoothAdapterManager::setPoweredManualAnswer() +{ + LogDebug("Enter"); + + m_btPowered = canUseBluetooth(); + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_SETPOWERED); + + if(m_EventBTSetPoweredPtr != NULL) + { + 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); + BluetoothCBManagerSingleton::Instance().clearAll(); + } + else + { + m_EventBTSetPoweredPtr->setExceptionCode(Commons::ExceptionCodes::PlatformException); + + } + } + EventRequestReceiver::ManualAnswer(m_EventBTSetPoweredPtr); + } + else + LogDebug("Ignore unexpected event"); +} + +void BluetoothAdapterManager::setVisible(const EventBTSetVisiblePtr& event) +{ + LogDebug("Enter"); + EventRequestReceiver::PostRequest(event); +} + + +void BluetoothAdapterManager::discoveryDevicesEmitter(const EventBTOnDiscoveryDevicesEmitterPtr& emitter) + +{ + LogDebug("Enter"); + + int ret = 0; + bool status = false; + + try + { + if (m_btPowered == false) + { + ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off"); + } + + + if ((ret = bt_adapter_is_discovering(&status)) != BT_ERROR_NONE) + { + ThrowMsg(Commons::UnknownException, "platform exception error" << ret); + } + + if (status) + { + ThrowMsg(Commons::AlreadyInUseException, "now discover devices progressing"); + } + + BluetoothCBManagerSingleton::Instance().addAdapterCallback(BluetoothCBManager::ADAPTER_DISCOVERY, (void*)this); + + if ((ret = bt_adapter_start_device_discovery() != BT_ERROR_NONE)) + { + ThrowMsg(Commons::UnknownException, "device discovery fail" << ret); + } + m_discoverDevicesEmitter = emitter; + LogDebug("OK Discovery Start"); + } + catch (const Commons::Exception& ex) + { + LogError("Exception: " << ex.GetMessage()); + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_DISCOVERY); + EventBTOnDiscoveryDevicesPtr event(new EventBTOnDiscoveryDevices()); + event->setExceptionCode(ex.getCode()); + emitter->emit(event); + } +} + + +void BluetoothAdapterManager::discoveryDevicesCallbackEmit(int 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; + + if (discovery_info->remote_name == NULL) + { + device.name = ""; + } + else + { + device.name = discovery_info->remote_name; + } + + device.btClass.major = discovery_info->bt_class.major_device_class; + device.btClass.minor = discovery_info->bt_class.minor_device_class; + device.btClass.majorServiceMask = discovery_info->bt_class.major_service_class_mask; + } + + 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]); + } + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_DISCOVERY); + + 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()); + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_DISCOVERY); + + m_discoverDevicesEmitter->emit(event); + } +} + +void BluetoothAdapterManager::getKownDevices(const EventBTGetKnownDevicesPtr& event) +{ + LogDebug("Enter"); + EventRequestReceiver::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) + { + m_Devices[i].name = device.name; + m_Devices[i].isBonded = device.isBonded; + m_Devices[i].isConnected = device.isConnected; + m_Devices[i].isTrusted = device.isTrusted; + m_Devices[i].btClass = device.btClass; + m_Devices[i].uuids = device.uuids; + } + } + + 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; + + if (device_info->remote_name == NULL) + { + device.name = ""; + } + else + { + device.name = device_info->remote_name; + } + + device.btClass.major = device_info->bt_class.major_device_class; + device.btClass.minor = device_info->bt_class.minor_device_class; + device.btClass.majorServiceMask = device_info->bt_class.major_service_class_mask; + + bool connected = false; + bt_device_foreach_connected_profiles(device.address.c_str(), + capi_callback_bt_adapter_check_connected_profile, (void*)&connected); + + + device.isBonded = device_info->is_bonded; + device.isConnected = 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"); + BluetoothCBManagerSingleton::Instance().addAdapterCallback(BluetoothCBManager::ADAPTER_SERVICESEARCH, + (void*)this, event->getAddress().data()); + EventRequestReceiver::PostRequest(event); +} + +void BluetoothAdapterManager::serviceSearchManualAnswer(int error) +{ + try + { + int ret = 0; + m_btGetDeviceEvent = true; + + if (error != BT_ERROR_NONE) + { + ThrowMsg(Commons::NotFoundException, "service search failed"); + } + + if ((bt_adapter_foreach_bonded_device(capi_callback_bt_adapter_bonded_device_find, (void*)this))!= BT_ERROR_NONE) + { + ThrowMsg(Commons::NotFoundException, "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()); + } + + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_SERVICESEARCH, + m_EventBTGetDevicePtr->getAddress()); + EventRequestReceiver::ManualAnswer(m_EventBTGetDevicePtr); +} + +bool BluetoothAdapterManager::getDeviceManualAnswer(bt_device_info_s *device_info) +{ + std::string address = ""; + + if (device_info == NULL) + { + return false; + } + + address = device_info->remote_address; + + + BluetoothDeviceData device; + int index = 0; + + device.address = device_info->remote_address; + + if (device_info->remote_name == NULL) + { + device.name = ""; + } + else + { + device.name = device_info->remote_name; + } + + device.btClass.major = device_info->bt_class.major_device_class; + device.btClass.minor = device_info->bt_class.minor_device_class; + device.btClass.majorServiceMask = device_info->bt_class.major_service_class_mask; + + + bool connected = false; + bt_device_foreach_connected_profiles(device.address.c_str(), + capi_callback_bt_adapter_check_connected_profile, (void*)&connected); + + + device.isBonded = device_info->is_bonded; + device.isConnected = connected; + //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 EventBTCreate"); + BluetoothCBManagerSingleton::Instance().addAdapterCallback(BluetoothCBManager::ADAPTER_CREATEBOND, (void*)this); + EventRequestReceiver::PostRequest(event); +} + +void BluetoothAdapterManager::createBondingManualAnswer(int error, bt_device_info_s *device_info) +{ + int index = 0; + + if(m_EventBTCreateDestroyBondingPtr != NULL) + { + if (error == BT_ERROR_CANCELLED) + { + LogDebug("createBondingManualAnswer cancel"); + m_EventBTCreateDestroyBondingPtr->setExceptionCode(Commons::ExceptionCodes::EventCancelledException); + } + else if (error == BT_ERROR_NONE) + { + LogDebug("createBondingManualAnswer"); + + BluetoothDeviceData device; + device.address = device_info->remote_address; + + if (device_info->remote_name == NULL) + { + device.name = ""; + } + else + { + device.name = device_info->remote_name; + } + + bool connected = false; + bt_device_foreach_connected_profiles(device.address.c_str(), + capi_callback_bt_adapter_check_connected_profile, (void*)&connected); + + device.isBonded = device_info->is_bonded; + device.isConnected = 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 if (error == BT_ERROR_REMOTE_DEVICE_NOT_FOUND) + { + m_EventBTCreateDestroyBondingPtr->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + } + else + { + m_EventBTCreateDestroyBondingPtr->setExceptionCode(Commons::ExceptionCodes::UnknownException); + } + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_CREATEBOND); + EventRequestReceiver::ManualAnswer(m_EventBTCreateDestroyBondingPtr); + } + else + LogDebug("Ignore unexpected event"); +} + +bool BluetoothAdapterManager::createBondingCancel() +{ + int ret = bt_device_cancel_bonding(); + + LogDebug("Cancel returned" << ret); + + return (ret == BT_ERROR_NONE); +} + + +void BluetoothAdapterManager::destroyBonding(const EventBTCreateDestroyBondingPtr& event) +{ + LogDebug("Post Event DestroyBonding"); + BluetoothCBManagerSingleton::Instance().addAdapterCallback(BluetoothCBManager::ADAPTER_DESTROYBOND, (void*)this); + EventRequestReceiver::PostRequest(event); +} + +void BluetoothAdapterManager::destroyBondingManualAnswer(int error) +{ + if(m_EventBTCreateDestroyBondingPtr != NULL) + { + if (error == BT_ERROR_NONE) + { + m_EventBTCreateDestroyBondingPtr->setExceptionCode(Commons::ExceptionCodes::None); + } + else if (error == BT_ERROR_REMOTE_DEVICE_NOT_FOUND) + { + m_EventBTCreateDestroyBondingPtr->setExceptionCode(Commons::ExceptionCodes::NotFoundException); + } + else + { + m_EventBTCreateDestroyBondingPtr->setExceptionCode(Commons::ExceptionCodes::UnknownException); + } + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_DESTROYBOND); + EventRequestReceiver::ManualAnswer(m_EventBTCreateDestroyBondingPtr); + } + else + LogDebug("Ignore unexpected event"); +} + + +void BluetoothAdapterManager::registerRFCOMMServiceByUUID(const EventBTRegisterRFCOMMPtr& event) +{ + LogDebug("EventBTRegisterRFCOMMPtr"); + BluetoothCBManagerSingleton::Instance().checkUUIDAvailable(event->getUuid()); + + EventRequestReceiver::PostRequest(event); +} + + +void BluetoothAdapterManager::setAdapterName(const EventBTSetNamePtr& event) +{ + LogDebug("EventBTSetNamePtr"); + BluetoothCBManagerSingleton::Instance().addAdapterCallback(BluetoothCBManager::ADAPTER_SETNAME, (void*)this); + EventRequestReceiver::PostRequest(event); + +} + +void BluetoothAdapterManager::setAdapterNameManualAnswer(char* deviceName) +{ + LogDebug("Enter"); + + if(m_EventBTSetNamePtr != NULL) + { + 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); + } + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_SETNAME); + EventRequestReceiver::ManualAnswer(m_EventBTSetNamePtr); + } + else + LogDebug("Ignore unexpected event"); +} + + + +void BluetoothAdapterManager::stopDiscovery(const EventBTStopDiscoveryPtr& event) +{ + LogDebug("EventBTStopDiscoveryPtr"); + EventRequestReceiver::PostRequest(event); + +} + +void BluetoothAdapterManager::OnRequestReceived(const EventBTSetPoweredPtr& event) +{ + int ret = 0; + + try + { + event->switchToManualAnswer(); + m_EventBTSetPoweredPtr = event; + + 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(); + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_SETPOWERED); + EventRequestReceiver::ManualAnswer(event); + break; + case BT_ERROR_NOT_INITIALIZED: + ThrowMsg(Commons::UnknownException, "bt is not initialized"); + break; + case BT_ERROR_RESOURCE_BUSY: + default: + ThrowMsg(Commons::AlreadyInUseException, "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()); + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_SETPOWERED); + EventRequestReceiver::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; + + try + { + if (m_btPowered == false) + { + ThrowMsg(Commons::AlreadyInUseException, "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; + + } + + 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); + } + event->setExceptionCode(Commons::ExceptionCodes::None); + } + catch (const Commons::Exception& ex) + { + LogError("Exception: " << ex.GetMessage()); + event->setExceptionCode(ex.getCode()); + + } +} + + +void BluetoothAdapterManager::OnRequestReceived(const EventBTGetKnownDevicesPtr& event) +{ + LogDebug("EventBTGetKnownDevicesPtr Enter"); + + try + { + m_EventBTGetKnownDevicesPtr = event; + + if (m_btPowered == false) + { + ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off"); + } + + 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"); + } + + LogDebug("Get Konwn device OK"); + + } + catch (const Commons::Exception& ex) + { + LogError("Exception: " << ex.GetMessage()); + event->setExceptionCode(ex.getCode()); + + } +} + +void BluetoothAdapterManager::OnRequestReceived(const EventBTGetDevicePtr& event) +{ + LogDebug("EventBTGetDevicePtr Enter"); + + try + { + m_EventBTGetDevicePtr = event; + event->switchToManualAnswer(); + + if (m_btPowered == false) + { + ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off"); + } + 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::ManualAnswer(event); + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_SERVICESEARCH); + + } +} + +void BluetoothAdapterManager::OnRequestReceived(const EventBTCreateDestroyBondingPtr& event) +{ + LogDebug("Enter"); + + int ret = 0; + std::string addressFromEvent = event->getAddress(); + const char *device_addr = addressFromEvent.c_str(); + + try + { + m_EventBTCreateDestroyBondingPtr = event; + event->switchToManualAnswer(); + + + if (m_btPowered == false) + { + ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off"); + } + + if ((event->getAddress()).length() == 0) + { + ThrowMsg(Commons::PlatformException, "address error" << ret); + } + + if (event->isCreateBonding()) + { + 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_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()); + event->setExceptionCode(ex.getCode()); + + + if (event->isCreateBonding()) + { + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_CREATEBOND); + } + else + { + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_DESTROYBOND); + } + + EventRequestReceiver::ManualAnswer(event); + } +} + +void BluetoothAdapterManager::OnRequestReceived(const EventBTSetNamePtr& event) +{ + LogDebug("Enter"); + try + { + m_EventBTSetNamePtr = event; + event->switchToManualAnswer(); + std::string adapterName = event->getName(); + + + if (m_btPowered == false) + { + ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off"); + } + + if (adapterName.length() == 0) + { + ThrowMsg(Commons::PlatformException, "set name parameter error"); + } + + if (bt_adapter_set_name(adapterName.c_str()) != BT_ERROR_NONE ) + { + ThrowMsg(Commons::PlatformException, "set name error"); + } + + + } + catch (const Commons::Exception& ex) + { + LogError("Exception: " << ex.GetMessage()); + event->setExceptionCode(ex.getCode()); + EventRequestReceiver::ManualAnswer(event); + bt_adapter_unset_name_changed_cb(); + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_SETNAME); + } +} + + +void BluetoothAdapterManager::OnRequestReceived(const EventBTStopDiscoveryPtr& event) +{ + LogDebug("Enter"); + bool state = false; + try + { + if (m_btPowered == false) + { + ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off"); + } + + if (bt_adapter_is_discovering(&state) != BT_ERROR_NONE) + { + ThrowMsg(Commons::PlatformException, "device discovery stop fail"); + } + + if (state == false) + { + ThrowMsg(Commons::PlatformException, "device discovery stop fail"); + } + + if (bt_adapter_stop_device_discovery() != BT_ERROR_NONE) + { + ThrowMsg(Commons::PlatformException, "device discovery stop fail"); + } + event->setExceptionCode(Commons::ExceptionCodes::None); + } + catch (const Commons::Exception &ex) + { + LogError("Exception: " << ex.GetMessage()); + event->setExceptionCode(ex.getCode()); + } + BluetoothCBManagerSingleton::Instance().removeAdapterCallback(BluetoothCBManager::ADAPTER_DISCOVERY); +} + + +void BluetoothAdapterManager::OnRequestReceived(const EventBTRegisterRFCOMMPtr& event) +{ + + try + { + int ret = 0; + std::string uuid = event->getUuid(); + int serviceSocket = -1; + + if (m_btPowered == false) + { + ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off"); + } + + BluetoothCBManagerSingleton::Instance().checkUUIDAvailable(uuid); + + 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, 1) != BT_ERROR_NONE ) + { + ThrowMsg(Commons::UnknownException, "service socket register error"); + } + event->setSocketFd(serviceSocket); + event->setExceptionCode(Commons::ExceptionCodes::None); + BluetoothCBManagerSingleton::Instance().registerSocket(uuid, serviceSocket); + + } + catch (const Commons::Exception& ex) + { + LogError("Exception: " << ex.GetMessage()); + + event->setExceptionCode(ex.getCode()); + } +} + +} +} + + diff --git a/src/Bluetooth/BluetoothAdapterManager.h b/src/Bluetooth/BluetoothAdapterManager.h new file mode 100644 index 0000000..f20adf6 --- /dev/null +++ b/src/Bluetooth/BluetoothAdapterManager.h @@ -0,0 +1,106 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_PLATFORM_BLUETOOTH_ADAPTER_MANAGER_H_ +#define TIZENAPIS_PLATFORM_BLUETOOTH_ADAPTER_MANAGER_H_ + +#include +#include +#include +#include "IBluetoothAdapterManager.h" +#include "BluetoothFactory.h" +#include +#include +#include "BluetoothProperty.h" + +namespace DeviceAPI { +namespace Bluetooth { + +class BluetoothAdapterManager : public IBluetoothAdapterManager +{ + friend class BluetoothFactory; + +public: + virtual ~BluetoothAdapterManager(); + virtual void setPowered(const EventBTSetPoweredPtr& event) ; + virtual void setVisible(const EventBTSetVisiblePtr& event) ; + virtual void getKownDevices(const EventBTGetKnownDevicesPtr& event) ; + virtual void getDevice(const EventBTGetDevicePtr& event) ; + virtual void createBonding(const EventBTCreateDestroyBondingPtr& event) ; + virtual bool createBondingCancel(); + virtual void destroyBonding(const EventBTCreateDestroyBondingPtr& event) ; + virtual void registerRFCOMMServiceByUUID(const EventBTRegisterRFCOMMPtr& event); + virtual void discoveryDevicesEmitter(const EventBTOnDiscoveryDevicesEmitterPtr& emitter); + virtual void stopDiscovery(const EventBTStopDiscoveryPtr& event); + + virtual void setAdapterName(const EventBTSetNamePtr& event); + + virtual std::string getName(); + virtual std::string getAddress(); + virtual bool getPowered(); + virtual bool getVisibility(); + + void Init(); + void Test(); + bool canUseBluetooth(); + void setPoweredManualAnswer(); + void createBondingManualAnswer(int error, bt_device_info_s *device_info); + void destroyBondingManualAnswer(int error); + void getKnownDevicesManualAnswer(bt_device_info_s *discovery_info); + void serviceSearchManualAnswer(int error); + bool getDeviceManualAnswer(bt_device_info_s *device_info); + void discoveryDevicesCallbackEmit(int error, unsigned short state, bt_adapter_device_discovery_info_s *discovery_info); + void updateDevice(BluetoothDeviceData &device); + int findDevice(std::string address, BluetoothDeviceData &device); + void setAdapterNameManualAnswer(char* deviceName); +protected: + BluetoothAdapterManager(); + + 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 EventBTStopDiscoveryPtr& event); + virtual void OnRequestReceived(const EventBTRegisterRFCOMMPtr& event); + +private: + static bool m_btPowered; + static bool m_btGetDeviceEvent; + static int m_currentServiceSocket; + static std::vector m_Devices; + + std::string m_uuid; + std::string m_name; + std::map m_socketMap; + EventBTSetPoweredPtr m_EventBTSetPoweredPtr; + EventBTGetKnownDevicesPtr m_EventBTGetKnownDevicesPtr; + EventBTGetDevicePtr m_EventBTGetDevicePtr; + EventBTCreateDestroyBondingPtr m_EventBTCreateDestroyBondingPtr; + EventBTRegisterRFCOMMPtr m_EventBTRegisterRFCOMMPtr; + EventBTOnDiscoveryDevicesEmitterPtr m_discoverDevicesEmitter; + EventBTSetNamePtr m_EventBTSetNamePtr; + +}; + +} +} + + +#endif diff --git a/src/Bluetooth/BluetoothCBManager.cpp b/src/Bluetooth/BluetoothCBManager.cpp new file mode 100644 index 0000000..82c88dd --- /dev/null +++ b/src/Bluetooth/BluetoothCBManager.cpp @@ -0,0 +1,587 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include "BluetoothCBManager.h" +#include "BluetoothAdapterManager.h" +#include "BluetoothDeviceManager.h" +#include "BluetoothSocketManager.h" +#include "BluetoothServiceHandlerManager.h" +#include +#include + +#include +#include + +using namespace DPL; +IMPLEMENT_SINGLETON(DeviceAPI::Bluetooth::BluetoothCBManager); + +namespace DeviceAPI { +namespace Bluetooth { + +namespace { + +static void capi_callback_bt_state_changed(int result, bt_adapter_state_e adapter_state, void* user_data) +{ + if( result == BT_ERROR_NONE && user_data != NULL) + { + LogDebug("State Changed" << adapter_state); + ((BluetoothAdapterManager*)user_data)->setPoweredManualAnswer(); + + } + else + { + LogDebug("Error from platform"); + } +} + +static void capi_callback_bt_name_changed(char *device_name, void *user_data) +{ + ((BluetoothAdapterManager*)user_data)->setAdapterNameManualAnswer(device_name); +} + +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); + + if (user_data != NULL) + { + ((BluetoothAdapterManager*)user_data)->discoveryDevicesCallbackEmit(result, discovery_state, discovery_info); + } + else + { + LogDebug("Error from platform"); + } + +} + +static void capi_callback_bt_device_bond_created(int result, bt_device_info_s *device_info, void *user_data) +{ + if (user_data != NULL) + { + ((BluetoothAdapterManager*)user_data)->createBondingManualAnswer(result, device_info); + } + else + { + LogDebug("Error from platform"); + } + +} + +static void capi_callback_bt_device_bond_destroyed(int result, char* remote_address, void *user_data) +{ + if (user_data != NULL) + { + ((BluetoothAdapterManager*)user_data)->destroyBondingManualAnswer(result); + } + else + { + LogDebug("Error from platform"); + } +} + +static void capi_bt_device_service_searched(int result, bt_device_sdp_info_s* sdp_info, void* user_data) +{ + if (user_data != NULL && sdp_info != NULL && sdp_info->remote_address != NULL) + { + ((BluetoothCBManager*)user_data)->serviceSearchRouter(result, sdp_info, user_data); + } + else + { + LogDebug("Error from platform"); + } + +} + +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) +{ + if (user_data != NULL && connection != NULL && connection->remote_address != NULL) + { + ((BluetoothCBManager*)user_data)->connectionStateRouter(result, connection_state, connection); + } + else + { + LogDebug("Error from platform"); + } + +} + +static void capi_callback_bt_data_received(bt_socket_received_data_s *data, void *user_data) +{ + if (user_data != NULL && data != NULL) + { + ((BluetoothCBManager*)(user_data))->socketDataReceivedRouter(data); + } + else + { + LogDebug("Error from platform"); + } +} + + + +} + + + + +BluetoothCBManager::BluetoothCBManager() +{ + LogDebug("BluetoothCBManager singleton"); + +} + +BluetoothCBManager::~BluetoothCBManager() +{ + LogDebug("BluetoothCBManager singleton removed"); + disconnectAllSockets(); + + +} + + +void BluetoothCBManager::addAdapterCallback(adapterCallback cb, void *passData, std::string address) +{ + std::vector::iterator it; + + for (it = m_adapterCallback.begin(); it < m_adapterCallback.end(); ++it) + { + if (*it == cb) + break; + } + + if (cb == ADAPTER_DESTROYBOND) + { + LogDebug("ADAPTER_DESTROYBOND"); + } + + if (it == m_adapterCallback.end()) + { + + switch (cb) + { + case ADAPTER_SETPOWERED: + if( bt_adapter_set_state_changed_cb(capi_callback_bt_state_changed, passData) != BT_ERROR_NONE ) + { + ThrowMsg(WrtDeviceApis::Commons::PlatformException, "call back set error"); + } + break; + case ADAPTER_SETNAME: + if (bt_adapter_set_name_changed_cb(capi_callback_bt_name_changed, passData) != BT_ERROR_NONE) + { + ThrowMsg(WrtDeviceApis::Commons::PlatformException, "callback set error"); + } + break; + case ADAPTER_DISCOVERY: + if (bt_adapter_set_device_discovery_state_changed_cb(capi_callback_bt_discovery_state_changed, + passData)!= BT_ERROR_NONE) + { + ThrowMsg(WrtDeviceApis::Commons::PlatformException, "callback set error"); + } + break; + case ADAPTER_SERVICESEARCH: + addServiceSearchCallback(address, passData, FROM_ADAPTER); + break; + case ADAPTER_CREATEBOND: + if (bt_device_set_bond_created_cb(capi_callback_bt_device_bond_created, passData) != BT_ERROR_NONE ) + { + ThrowMsg(WrtDeviceApis::Commons::PlatformException, "callback set error"); + } + break; + case ADAPTER_DESTROYBOND: + if (bt_device_set_bond_destroyed_cb (capi_callback_bt_device_bond_destroyed, passData) != BT_ERROR_NONE ) + { + ThrowMsg(WrtDeviceApis::Commons::PlatformException, "callback set error"); + } + break; + case ADAPTER_REGISTER: + LogDebug("do nothing to set callback"); + break; + } + + m_adapterCallback.push_back(cb); + LogDebug("operation call back is set successfully"); + } + else + { + LogDebug("same operation now, throws error"); + ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "same operation now"); + } + + +} + +void BluetoothCBManager::removeAdapterCallback(adapterCallback cb, std::string address) +{ + std::vector::iterator it; + + for (it = m_adapterCallback.begin(); it != m_adapterCallback.end(); ++it) + { + if (*it == cb) + { + break; + } + } + + if (it == m_adapterCallback.end()) + { + LogDebug("there is no such callback"); + } + else + { + m_adapterCallback.erase(it); + LogDebug("operation call back is unset successfully"); + + switch (cb) + { + case ADAPTER_SETPOWERED: + bt_adapter_unset_state_changed_cb(); + break; + case ADAPTER_SETNAME: + bt_adapter_unset_name_changed_cb(); + break; + case ADAPTER_DISCOVERY: + bt_adapter_unset_device_discovery_state_changed_cb(); + break; + case ADAPTER_SERVICESEARCH: + removeServiceSearchCallback(address); + break; + case ADAPTER_CREATEBOND: + bt_device_unset_bond_created_cb(); + break; + case ADAPTER_DESTROYBOND: + bt_device_unset_bond_destroyed_cb(); + break; + case ADAPTER_REGISTER: + LogDebug("do nothing to set callback"); + break; + + } + + } +} + +void BluetoothCBManager::registerSocket(std::string uuid, int socket) +{ + std::map::iterator it = m_serverSocketUuidMap.find(uuid); + + if (it != m_serverSocketUuidMap.end()) + { + ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "same uuid exist"); + } + + m_serverSocketUuidMap[uuid] = socket; +} + +void BluetoothCBManager::checkUUIDAvailable(std::string uuid) +{ + std::map::iterator it = m_serverSocketUuidMap.find(uuid); + + if (it != m_serverSocketUuidMap.end()) + { + ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "same uuid exist"); + } +} + +void BluetoothCBManager::unregisterSocket(std::string uuid) +{ + std::map::iterator it = m_serverSocketUuidMap.find(uuid); + + if (it != m_serverSocketUuidMap.end()) + { + LogDebug("no such uuid"); + } + + m_serverSocketUuidMap.erase (uuid); + +} + +void BluetoothCBManager::serviceSearchRouter(int result, bt_device_sdp_info_s* sdp_info, void* user_data) +{ + std::map::iterator it = + m_serviceSearchMap.find(sdp_info->remote_address); + std::map::iterator managerIt = + m_serviceSearchManagerMap.find(sdp_info->remote_address); + + LogDebug(sdp_info->remote_address); + + if (it != m_serviceSearchMap.end() && managerIt != m_serviceSearchManagerMap.end()) + { + if (managerIt->second == FROM_DEVICE) + { + ((BluetoothDeviceManager*)(it->second))->serviceSearchManualAnswer(result); + } + else if(managerIt->second == FROM_ADAPTER) + { + ((BluetoothAdapterManager*)(it->second))->serviceSearchManualAnswer(result); + } + } + else + { + LogDebug("manager is not registered"); + } +} + +void BluetoothCBManager::connectionStateRouter(int result, bt_socket_connection_state_e connection_state, + bt_socket_connection_s *connection) +{ + std::map::iterator it; + std::map::iterator managerIt; + + if (connection->service_uuid == NULL) + { + LogDebug("Error service uuid NULL"); + return; + } + + LogDebug(connection->service_uuid); + + std::string uuid = connection->service_uuid; + + if (connection->local_role == BT_SOCKET_SERVER) + { + LogDebug("Route servicehandler"); + + it = m_devicePrivateObjectMap.find(uuid); + managerIt = m_devicePrivateObjectManagerMap.find(uuid); + + if (it != m_devicePrivateObjectMap.end() && managerIt != m_devicePrivateObjectManagerMap.end()) + { + if(managerIt->second == FROM_SERVICE) + { + ((BluetoothServiceHandlerManager*)(it->second))->connectionStateChangedEmit(result, connection_state, connection); + } + } + + } + + it = m_devicePrivateObjectMap.find(connection->remote_address); + managerIt = m_devicePrivateObjectManagerMap.find(connection->remote_address); + + if (it != m_devicePrivateObjectMap.end() && managerIt != m_devicePrivateObjectManagerMap.end()) + { + if (managerIt->second == FROM_DEVICE) + { + LogDebug("Route device"); + ((BluetoothDeviceManager*)(it->second))->connectToServiceByUUIDManualAnswer(result, connection_state, connection); + } + else if(managerIt->second == FROM_SOCKET) + { + LogDebug("Route socket"); + ((BluetoothSocketManager*)(it->second))->connectionStateChangedEmit(result, connection_state, connection); + } + } + +} + +void BluetoothCBManager::socketDataReceivedRouter(bt_socket_received_data_s *data) +{ + std::map::iterator it = m_socketPrivateObjectMap.find(data->socket_fd); + + if (it != m_socketPrivateObjectMap.end()) + { + ((BluetoothSocketManager*)(it->second))->setDataReceivedEmit(data); + } + else + { + LogDebug("manager is not registered"); + } + +} + +void BluetoothCBManager::addServiceSearchCallback(std::string deviceAddress, void *data, managerType type) +{ + if (m_serviceSearchMap.size() != 0) + { + ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "same operation now"); + } + + std::map::iterator it = + m_serviceSearchMap.find(deviceAddress); + + if (it != m_serviceSearchMap.end()) + { + ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "searvice search same device address"); + } + + if (bt_device_set_service_searched_cb(capi_bt_device_service_searched, this) != BT_ERROR_NONE) + { + ThrowMsg(WrtDeviceApis::Commons::UnknownException, "callback set error"); + } + + LogDebug(deviceAddress); + + m_serviceSearchMap[deviceAddress] = data; + m_serviceSearchManagerMap[deviceAddress] = type; + +} + +void BluetoothCBManager::removeServiceSearchCallback(std::string deviceAddress) +{ + std::map::iterator it = + m_serviceSearchMap.find(deviceAddress); + + if (it == m_serviceSearchMap.end()) + { + LogDebug("there is no such address"); + return; + } + + + m_serviceSearchMap.erase(deviceAddress); + m_serviceSearchManagerMap.erase(deviceAddress); + + if (m_serviceSearchMap.size() == 0) + { + bt_device_unset_service_searched_cb(); + } +} + +void BluetoothCBManager::addConnectionStateCallback(std::string deviceAddress, void *data, managerType type) +{ + std::map::iterator it = + m_devicePrivateObjectMap.find(deviceAddress); + + if (it != m_devicePrivateObjectMap.end()) + { + ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "connecting to same device address"); + } + + if (m_devicePrivateObjectMap.size() == 0) + { + if (bt_socket_set_connection_state_changed_cb(capi_callback_bt_socket_connection_state_changed, this) != BT_ERROR_NONE) + { + LogDebug("callback set error"); + ThrowMsg(WrtDeviceApis::Commons::UnknownException, "callback set error"); + } + } + LogDebug("connection callback for " << deviceAddress); + m_devicePrivateObjectMap[deviceAddress] = data; + m_devicePrivateObjectManagerMap[deviceAddress] = type; +} + +void BluetoothCBManager::removeConnectionStateCallback(std::string deviceAddress, managerType type) +{ + std::map::iterator it = + m_devicePrivateObjectMap.find(deviceAddress); + + if (it == m_devicePrivateObjectMap.end()) + { + LogDebug("there is no such address"); + return; + } + + if (type == m_devicePrivateObjectManagerMap[deviceAddress]) + { + m_devicePrivateObjectMap.erase(deviceAddress); + m_devicePrivateObjectManagerMap.erase(deviceAddress); + LogDebug("remove connection" << deviceAddress); + } + else + { + LogDebug("type different"); + } + + if (m_devicePrivateObjectMap.size() == 0) + { + LogDebug("remove connection state call back"); + bt_socket_unset_connection_state_changed_cb(); + } +} + +void BluetoothCBManager::addSocketDataReceivedCallback(int socket, void *data) +{ + std::map::iterator it = m_socketPrivateObjectMap.find(socket); + + if (it != m_socketPrivateObjectMap.end()) + { + ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "there is same socket"); + } + + if (m_socketPrivateObjectMap.size() == 0) + { + LogDebug("set data receive call back"); + if (bt_socket_set_data_received_cb(capi_callback_bt_data_received, this) != BT_ERROR_NONE) + { + LogDebug("callback set error"); + ThrowMsg(WrtDeviceApis::Commons::UnknownException, "callback set error"); + } + } + + m_socketPrivateObjectMap[socket] = data; + LogDebug(socket << "add socket (" << data << ")"); + +} + +void BluetoothCBManager::removeSocketDataReceivedCallback(int socket) +{ + std::map::iterator it = m_socketPrivateObjectMap.find(socket); + + if (it == m_socketPrivateObjectMap.end()) + { + LogDebug("there is no such socket"); + return; + } + + LogDebug(socket << "remove socket " << m_socketPrivateObjectMap[socket] ); + m_socketPrivateObjectMap.erase(socket); + + if (m_socketPrivateObjectMap.size() == 0) + { + LogDebug("remove data receive call back"); + bt_socket_unset_data_received_cb(); + } +} + +void BluetoothCBManager::clearAll() +{ + m_adapterCallback.clear(); + m_serverSocketUuidMap.clear(); + m_devicePrivateObjectMap.clear(); + m_devicePrivateObjectManagerMap.clear(); + m_serviceSearchMap.clear(); + m_serviceSearchManagerMap.clear(); + m_socketPrivateObjectMap.clear(); +} +void BluetoothCBManager::disconnectAllSockets() +{ + // close connection socket + for (std::map::iterator it = m_socketPrivateObjectMap.begin(); it != m_socketPrivateObjectMap.end(); ++it) + { + bt_socket_disconnect_rfcomm((*it).first); + } + + // close server socket + for (std::map::iterator it = m_serverSocketUuidMap.begin(); it != m_serverSocketUuidMap.end(); ++it) + { + bt_socket_destroy_rfcomm((*it).second); + } + +} + +} +} diff --git a/src/Bluetooth/BluetoothCBManager.h b/src/Bluetooth/BluetoothCBManager.h new file mode 100644 index 0000000..bd0c483 --- /dev/null +++ b/src/Bluetooth/BluetoothCBManager.h @@ -0,0 +1,95 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_CALLBACK_MANAGER_H_ +#define TIZENAPIS_PLATFROM_BLUETOOTH_CALLBACK_MANAGER_H_ + +#include +#include +#include + +namespace DeviceAPI { +namespace Bluetooth { + +class BluetoothCBManager +{ +public: + typedef enum + { + ADAPTER_SETPOWERED, + ADAPTER_SETNAME, + ADAPTER_DISCOVERY, + ADAPTER_CREATEBOND, + ADAPTER_DESTROYBOND, + ADAPTER_SERVICESEARCH, + ADAPTER_REGISTER + } adapterCallback; + + typedef enum + { + FROM_ADAPTER, + FROM_DEVICE, + FROM_SERVICE, + FROM_SOCKET + } managerType; + + BluetoothCBManager(); + virtual ~BluetoothCBManager(); + + void addAdapterCallback(adapterCallback cb, void *passData, std::string address=""); + void removeAdapterCallback(adapterCallback cb, std::string address=""); + void registerSocket(std::string uuid, int socket); // for server socket + void unregisterSocket(std::string uuid); // for server socket + void serviceSearchRouter(int result, bt_device_sdp_info_s* sdp_info, void* user_data); + void connectionStateRouter(int result, bt_socket_connection_state_e connection_state, + bt_socket_connection_s *connection); + + void addServiceSearchCallback(std::string deviceAddress, void *data, managerType type); + void removeServiceSearchCallback(std::string deviceAddress); + void addConnectionStateCallback(std::string deviceAddress, void *data, managerType type); + void removeConnectionStateCallback(std::string deviceAddress, managerType type); + void socketDataReceivedRouter(bt_socket_received_data_s *data); + void addSocketDataReceivedCallback(int socket, void *data); + void removeSocketDataReceivedCallback(int socket); + void checkUUIDAvailable(std::string uuid); + void clearAll(); + +private: + void disconnectAllSockets(); + + std::vector m_adapterCallback; + std::map m_serverSocketUuidMap; + + std::map m_devicePrivateObjectMap; + std::map m_devicePrivateObjectManagerMap; + + std::map m_serviceSearchMap; + std::map m_serviceSearchManagerMap; + + std::map m_socketPrivateObjectMap; + +}; + +typedef DPL::Singleton BluetoothCBManagerSingleton; + + +} +} + +#endif + diff --git a/src/Bluetooth/BluetoothClass.cpp b/src/Bluetooth/BluetoothClass.cpp new file mode 100644 index 0000000..29c9576 --- /dev/null +++ b/src/Bluetooth/BluetoothClass.cpp @@ -0,0 +1,258 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "BluetoothClass.h" +#include + +using namespace DPL; + +namespace DeviceAPI { +namespace Bluetooth { + +std::map BluetoothClass::m_serviceConstants; + +BluetoothClass::BluetoothClass() +{ + initConstants(); + m_readOnly = false; +} + +BluetoothClass::~BluetoothClass() +{ + +} + +void BluetoothClass::setReadOnly() +{ + m_readOnly = true; +} + +bool BluetoothClass::getReadOnly() +{ + return m_readOnly; +} + +bool BluetoothClass::find(const std::string key, int &value) +{ + if (m_serviceConstants.find(key) == m_serviceConstants.end()) + { + LogDebug("fetch error"); + return false; + } + + value = m_serviceConstants[key]; + LogDebug(key << ":" << value); + return true; +} + +int BluetoothClass::getMajor() +{ + return m_major; +} + +void BluetoothClass::setMajor(int major) +{ + m_major = major; +} + +int BluetoothClass::getMinor() +{ + return m_minor; +} + +void BluetoothClass::setMinor(int minor) +{ + m_minor = minor; +} + +std::vector BluetoothClass::getServices() +{ + return m_services; +} + +void BluetoothClass::setServices(int device) +{ + if (m_services.size() != 0) + { + m_services.clear(); + } + + std::map::iterator it; + int service = SERVICE_MASK_SHIFT(device); + + it = m_serviceConstants.find("LIMITED_DISCOVERABILITY"); + + if (it == m_serviceConstants.end()) + { + LogDebug("Invalid Service Mask Passed"); + return; + } + + for (; it != m_serviceConstants.end(); ++it) + { + if (service & (*it).second) + { + LogDebug("SERVICE " << (*it).first << " " << std::hex << (*it).second); + m_services.push_back((*it).second); + } + } + + if (m_services.size() == 0) + { + LogDebug("Invalid Service Mask Passed"); + } + +} + +unsigned long BluetoothClass::toInt() +{ + unsigned long uuid = 0; + + uuid = (m_major << MAJOR_SHIFT | m_minor << MINOR_SHIFT); + + LogDebug("major&minor" << std::hex << uuid); + + for (size_t index = 0; index < m_services.size(); index++) + { + uuid |= (m_services[index] << SERVICE_SHIFT); + } + + LogDebug("service" << std::hex << uuid); + + return uuid; +} +void BluetoothClass::fromInt(unsigned long device) +{ + if (m_readOnly) + { + LogDebug("static function, set error"); + return; + } + + LogDebug("device:" << std::hex << device); + + m_major = MAJOR_MASK_SHIFT(device); + m_minor = MINOR_MASK_SHIFT(device); + + LogDebug("major:" << std::hex << m_major << "minor:" << std::hex << m_minor); + + setServices(device); + +} + +void BluetoothClass::initConstants() +{ + if (m_serviceConstants.find("MISC") != m_serviceConstants.end()) + return; + + m_serviceConstants.insert(std::pair("MISC", 0x00)); + m_serviceConstants.insert(std::pair("COMPUTER", 0x01)); + m_serviceConstants.insert(std::pair("PHONE", 0x02)); + m_serviceConstants.insert(std::pair("NETWORK", 0x03)); + m_serviceConstants.insert(std::pair("AUDIO_VIDEO", 0x04)); + m_serviceConstants.insert(std::pair("PERIPHERAL", 0x05)); + m_serviceConstants.insert(std::pair("IMAGING", 0x06)); + m_serviceConstants.insert(std::pair("WEARABLE", 0x07)); + m_serviceConstants.insert(std::pair("TOY", 0x08)); + m_serviceConstants.insert(std::pair("HEALTH", 0x09)); + m_serviceConstants.insert(std::pair("UNCATEGORIZED", 0x1F)); + m_serviceConstants.insert(std::pair("COMPUTER_UNCATEGORIZED", 0x00)); + m_serviceConstants.insert(std::pair("COMPUTER_DESKTOP", 0x01)); + m_serviceConstants.insert(std::pair("COMPUTER_SERVER", 0x02)); + m_serviceConstants.insert(std::pair("COMPUTER_LAPTOP", 0x03)); + m_serviceConstants.insert(std::pair("COMPUTER_HANDHELD_PC_OR_PDA", 0x04)); + m_serviceConstants.insert(std::pair("COMPUTER_PALM_PC_OR_PDA", 0x5)); + m_serviceConstants.insert(std::pair("COMPUTER_WEARABLE", 0x06)); + m_serviceConstants.insert(std::pair("PHONE_UNCATEGORIZED", 0x00)); + m_serviceConstants.insert(std::pair("PHONE_CELLULAR", 0x01)); + m_serviceConstants.insert(std::pair("PHONE_CORDLESS", 0x02)); + m_serviceConstants.insert(std::pair("PHONE_SMARTPHONE", 0x03)); + m_serviceConstants.insert(std::pair("PHONE_MODEM_OR_GATEWAY", 0x04)); + m_serviceConstants.insert(std::pair("PHONE_ISDN", 0x05)); + m_serviceConstants.insert(std::pair("AV_UNRECOGNIZED", 0x00)); + m_serviceConstants.insert(std::pair("AV_WEARABLE_HEADSET", 0x01)); + m_serviceConstants.insert(std::pair("AV_HANDSFREE", 0x02)); + m_serviceConstants.insert(std::pair("AV_MICROPHONE", 0x04)); + m_serviceConstants.insert(std::pair("AV_LOUDSPEAKER", 0x05)); + m_serviceConstants.insert(std::pair("AV_HEADPHONES", 0x06)); + m_serviceConstants.insert(std::pair("AV_PORTABLE_AUDIO", 0x07)); + m_serviceConstants.insert(std::pair("AV_CAR_AUDIO", 0x08)); + m_serviceConstants.insert(std::pair("AV_SETTOP_BOX", 0x09)); + m_serviceConstants.insert(std::pair("AV_HIFI", 0x0a)); + m_serviceConstants.insert(std::pair("AV_VCR", 0x0b)); + m_serviceConstants.insert(std::pair("AV_VIDEO_CAMERA", 0x0c)); + m_serviceConstants.insert(std::pair("AV_CAMCORDER", 0x0d)); + m_serviceConstants.insert(std::pair("AV_MONITOR", 0x0e)); + m_serviceConstants.insert(std::pair("AV_DISPLAY_AND_LOUDSPEAKER", 0x0f)); + m_serviceConstants.insert(std::pair("AV_VIDEO_CONFERENCING", 0x10)); + m_serviceConstants.insert(std::pair("AV_GAMING_TOY", 0x12)); + m_serviceConstants.insert(std::pair("PERIPHERAL_UNCATEGORIZED", 0)); + m_serviceConstants.insert(std::pair("PERIPHERAL_KEYBOARD", 0x10)); + m_serviceConstants.insert(std::pair("PERIPHERAL_POINTING_DEVICE", 0x20)); + m_serviceConstants.insert(std::pair("PERIPHERAL_KEYBOARD_AND_POINTING_DEVICE", 0x30)); + m_serviceConstants.insert(std::pair("PERIPHERAL_JOYSTICK", 0x01)); + m_serviceConstants.insert(std::pair("PERIPHERAL_GAMEPAD", 0x02)); + m_serviceConstants.insert(std::pair("PERIPHERAL_REMOTE_CONTROL", 0x03)); + m_serviceConstants.insert(std::pair("PERIPHERAL_SENSING_DEVICE", 0x04)); + m_serviceConstants.insert(std::pair("PERIPHERAL_DEGITIZER_TABLET", 0x05)); + m_serviceConstants.insert(std::pair("PERIPHERAL_CARD_READER", 0x06)); + m_serviceConstants.insert(std::pair("PERIPHERAL_DIGITAL_PEN", 0x07)); + m_serviceConstants.insert(std::pair("PERIPHERAL_HANDHELD_SCANNER", 0x08)); + m_serviceConstants.insert(std::pair("PERIPHERAL_HANDHELD_INPUT_DEVICE", 0x09)); + m_serviceConstants.insert(std::pair("IMAGING_UNCATEGORIZED", 0x00)); + m_serviceConstants.insert(std::pair("IMAGING_DISPLAY", 0x04)); + m_serviceConstants.insert(std::pair("IMAGING_CAMERA", 0x08)); + m_serviceConstants.insert(std::pair("IMAGING_SCANNER", 0x10)); + m_serviceConstants.insert(std::pair("IMAGING_PRINTER", 0x20)); + m_serviceConstants.insert(std::pair("WEARABLE_WRITST_WATCH", 0x01)); + m_serviceConstants.insert(std::pair("WEARABLE_PAGER", 0x02)); + m_serviceConstants.insert(std::pair("WEARABLE_JACKET", 0x03)); + m_serviceConstants.insert(std::pair("WEARABLE_HELMET", 0x04)); + m_serviceConstants.insert(std::pair("WEARABLE_GLASSES", 0x05)); + m_serviceConstants.insert(std::pair("TOY_ROBOT", 0x01)); + m_serviceConstants.insert(std::pair("TOY_VEHICLE", 0x02)); + m_serviceConstants.insert(std::pair("TOY_DOLL", 0x03)); + m_serviceConstants.insert(std::pair("TOY_CONTROLLER", 0x04)); + m_serviceConstants.insert(std::pair("TOY_GAME", 0x05)); + m_serviceConstants.insert(std::pair("HEALTH_UNDEFINED", 0x00)); + m_serviceConstants.insert(std::pair("HEALTH_BLOOD_PRESSURE_MONITOR", 0x01)); + m_serviceConstants.insert(std::pair("HEALTH_THERMOMETER", 0x02)); + m_serviceConstants.insert(std::pair("HEALTH_WEIGHING_SCALE", 0x03)); + m_serviceConstants.insert(std::pair("HEALTH_GLUCOSE_METER", 0x04)); + m_serviceConstants.insert(std::pair("HEALTH_PULSE_OXIMETER", 0x05)); + m_serviceConstants.insert(std::pair("HEALTH_PULSE_RATE_MONITOR", 0x06)); + m_serviceConstants.insert(std::pair("HEALTH_DATA_DISPLAY", 0x07)); + m_serviceConstants.insert(std::pair("HEALTH_STEP_COUNTER", 0x08)); + m_serviceConstants.insert(std::pair("HEALTH_BODY_COMPOSITION_ANALYZER", 0x09)); + m_serviceConstants.insert(std::pair("HEALTH_PEAK_FLOW_MONITOR", 0x0a)); + m_serviceConstants.insert(std::pair("HEALTH_MEDICATION_MONITOR", 0x0b)); + m_serviceConstants.insert(std::pair("HEALTH_KNEE_PROSTHESIS", 0x0c)); + m_serviceConstants.insert(std::pair("HEALTH_ANKLE_PROSTHESIS", 0x0d)); + m_serviceConstants.insert(std::pair("LIMITED_DISCOVERABILITY", 0x0001)); + m_serviceConstants.insert(std::pair("POSITIONING", 0x0008)); + m_serviceConstants.insert(std::pair("NETWORKING", 0x0010)); + m_serviceConstants.insert(std::pair("RENDERING", 0x0020)); + m_serviceConstants.insert(std::pair("CAPTURING", 0x0040)); + m_serviceConstants.insert(std::pair("OBJECT_TRANSFER", 0x0080)); + m_serviceConstants.insert(std::pair("AUDIO", 0x0100)); + m_serviceConstants.insert(std::pair("TELEPHONY", 0x0200)); + m_serviceConstants.insert(std::pair("INFORMATION", 0x0400)); +} +} +} + diff --git a/src/Bluetooth/BluetoothClass.h b/src/Bluetooth/BluetoothClass.h new file mode 100644 index 0000000..124b200 --- /dev/null +++ b/src/Bluetooth/BluetoothClass.h @@ -0,0 +1,68 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_BLUETOOTH_CLASS_H_ +#define TIZENAPIS_TIZEN_BLUETOOTH_CLASS_H_ + +#include +#include +#include +#include + +namespace DeviceAPI { +namespace Bluetooth { + +class BluetoothClass; +typedef DPL::SharedPtr BluetoothClassPtr; + +#define MAJOR_SHIFT 7 +#define MINOR_SHIFT 1 +#define SERVICE_SHIFT 12 + +#define MAJOR_MASK_SHIFT(A) ((A & 0x00000F80) >> MAJOR_SHIFT) +#define MINOR_MASK_SHIFT(A) ((A & 0x0000007E) >> MINOR_SHIFT) +#define SERVICE_MASK_SHIFT(A) ((A & 0x007FF000) >> SERVICE_SHIFT) + + +class BluetoothClass +{ +public: + bool find(const std::string key, int &value); + int getMajor(); + int getMinor(); + std::vector getServices(); + void setServices(int device); + void setMajor(int major); + void setMinor(int minor); + void fromInt(unsigned long value); + void setReadOnly(); + bool getReadOnly(); + unsigned long toInt(); + BluetoothClass(); + ~BluetoothClass(); +private: + void initConstants(); + static std::map m_serviceConstants; + std::vector m_services; + bool m_readOnly; + int m_major; + int m_minor; +}; +} +} +#endif diff --git a/src/Bluetooth/BluetoothConverter.cpp b/src/Bluetooth/BluetoothConverter.cpp new file mode 100644 index 0000000..b6ab9c0 --- /dev/null +++ b/src/Bluetooth/BluetoothConverter.cpp @@ -0,0 +1,362 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include "BluetoothProperty.h" +#include "BluetoothConverter.h" +#include "JSBluetoothDevice.h" + +#include + +using namespace std; +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; + + +namespace DeviceAPI { +namespace Bluetooth { + +BluetoothConverter::BluetoothConverter(JSContextRef context) : + Converter(context) +{ +} + +BluetoothConverter::~BluetoothConverter() +{ +} + + + +JSValueRef BluetoothConverter::toFunctionOrNull(const JSValueRef& arg) +{ + if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg)) + { + LogDebug("null."); + + return NULL; + } + else if (JSValueIsObject(m_context, arg) == false) + { + LogDebug("undefined, not object"); + ThrowMsg(ConversionException, "Not a function nor JS null."); + } + else if (Validator(m_context).isCallback(arg)) + { + LogDebug("Function OK"); + return arg; + } + + ThrowMsg(ConversionException, "Not a function nor JS null."); + return NULL; +} + +JSValueRef BluetoothConverter::toFunction(const JSValueRef& arg) +{ + if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg) + || !JSValueIsObject(m_context, arg)) + { + ThrowMsg(ConversionException, "JS null passed as function."); + } + else if (Validator(m_context).isCallback(arg)) + { + LogDebug("Function OK"); + return arg; + } + + ThrowMsg(ConversionException, "Not a function nor JS null."); + return NULL; +} + + +EventBTOnDiscoveryDevicesPrivateDataPtr + BluetoothConverter::toEventBTOnDiscoveryDevicesPrivateData(JSObjectRef thisObject, JSValueRef successParam, JSValueRef errorParam) +{ + JSValueRef errorCalback; + if (JSValueIsNull(m_context, successParam) || JSValueIsUndefined(m_context, successParam) + || !JSValueIsObject(m_context, successParam)) + { + LogError("not a object"); + Throw(ConversionException); + } + + JSObjectRef objectCallbacks = toJSObjectRef(successParam); + Validator validator(m_context); + BluetoothDiscoveryDevicesSuccessCallback result; + + errorCalback = toFunctionOrNull(errorParam); + + result.onSuccess = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onstarted"); + result.onFound = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "ondevicefound"); + /* bluez doesn't support device disappeared, we don't care onDeviceDisappeared */ + result.onFinished = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onfinished"); + + if (!validator.isCallback(result.onSuccess) || !validator.isCallback(result.onFound) || + !validator.isCallback(result.onFinished)) + { + LogError("java script call back set error"); + Throw(ConversionException); + } + + JSCallbackManagerPtr onSuccessCbm = JSCallbackManager::createObject(m_context, result.onSuccess, NULL); + JSCallbackManagerPtr onFoundCbm = JSCallbackManager::createObject(m_context, result.onFound, NULL); + JSCallbackManagerPtr onFinishedCbm = JSCallbackManager::createObject(m_context, result.onFinished, NULL); + + onSuccessCbm->setOnError(errorCalback); + onFoundCbm->setOnError(errorCalback); + onFinishedCbm->setOnError(errorCalback); + + return EventBTOnDiscoveryDevicesPrivateDataPtr( + new EventBTOnDiscoveryDevicesPrivateData(onSuccessCbm, onFoundCbm, onFinishedCbm)); +} + +BluetoothSocketNotifierPrivateDataPtr + 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); + + return BluetoothSocketNotifierPrivateDataPtr( + new BluetoothSocketNotifierPrivateData(onMessageCbm, onErrorCbm, onCloseCbm)); + +} + +void BluetoothConverter::setBluetoothSocketNotifierCallback(JSStringRef propertyName, JSValueRef value, + JSObjectRef object, BluetoothSocketNotifierPrivateDataPtr& privData) +{ + JSValueRef successCallback = toFunction(value); + + if(JSStringIsEqualToUTF8CString(propertyName, "onclose")) + { + privData->getOnClose()->setOnSuccess(successCallback); + } + else if(JSStringIsEqualToUTF8CString(propertyName, "onerror")) + { + privData->getOnError()->setOnSuccess(successCallback); + } + else if(JSStringIsEqualToUTF8CString(propertyName, "onmessage")) + { + privData->getOnMessage()->setOnSuccess(successCallback); + privData->setObject(object); + } + else + { + ThrowMsg(ConversionException, "unknown property"); + } + +} + +JSObjectRef BluetoothConverter::toBluetoothDevices(const std::vector& devices) +{ + int count = devices.size(); + int index = 0; + JSObjectRef adapterObject[count]; + + for (index = 0; index < count; index++) + { + adapterObject[index] = JSBluetoothDevice::createJSObject(m_context, devices[index]); + } + JSObjectRef result = JSObjectMakeArray(m_context, count, adapterObject, NULL); + return result; +} + +JSObjectRef BluetoothConverter::toBluetoothByteArray(std::vector& data) +{ + JSObjectRef result = JSCreateArrayObject(m_context, 0, NULL); + int length = data.size(); + + if (!result) + { + 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]); + + if (!JSSetArrayElement(m_context, result, i, value)) + { + ThrowMsg(WrtDeviceApis::Commons::UnknownException, "Could not fill array."); + } + } + return result; +} +std::string BluetoothConverter::toBluetoothDeviceAddress(JSValueRef deviceAddress) +{ + std::string address = toString(deviceAddress); + pcrecpp::RE re("(([0-9a-zA-Z]+):)+([0-9a-zA-Z]+)"); + std::string compareAddress = "00:12:47:08:9A:A6"; + + if (!re.FullMatch(address)) + { + ThrowMsg(InvalidArgumentException, "not a bluetooth device address"); + } + + if (address.size() != compareAddress.size()) + { + ThrowMsg(InvalidArgumentException, "too long or too short parameter"); + } + + return address; +} + +std::string BluetoothConverter::toBluetoothUUIDString(JSValueRef uuidString) +{ + std::string uuid = toString(uuidString); + pcrecpp::RE re("(([0-9a-zA-Z]+)-)+([0-9a-zA-Z]+)"); + std::string compareUUID = "00001101-0000-1000-8000-00805F9B34FB"; + + if (!re.FullMatch(uuid)) + { + LogDebug("not a bluetooth service uuid"); + ThrowMsg(InvalidArgumentException, "not a bluetooth service uuid"); + } + + if (uuid.size() != compareUUID.size()) + { + LogDebug("too long or too short parameter"); + ThrowMsg(InvalidArgumentException, "too long or too short parameter"); + } + + return uuid; +} + + + +unsigned short BluetoothConverter::toBluetoothSecurityLevelInt(JSValueRef level) +{ + unsigned short securityLevel= SECURITY_LEVEL_HIGH_VALUE_INT; + + if (!JSValueIsNull(m_context, level) && !JSValueIsUndefined(m_context, level)) + { + std::string securityLevelStr = toString(level); + + if(strcmp(securityLevelStr.c_str(), SECURITY_LEVEL_HIGH_VALUE) == 0) + { + securityLevel = SECURITY_LEVEL_HIGH_VALUE_INT; + } + else + { + if (strcmp(securityLevelStr.c_str(), SECURITY_LEVEL_MEDIUM_VALUE) == 0 || + strcmp(securityLevelStr.c_str(), SECURITY_LEVEL_LOW_VALUE) == 0) + { + Throw(UnsupportedException); + } + else + { + Throw(ConversionException); + } + } + } + return securityLevel; +} + + +unsigned short BluetoothConverter::toBluetoothProtocolInt(JSValueRef protocol) +{ + unsigned short bluetoothProtocol = PROTOCOL_TYPE_RFCOMM_VALUE_INT; + std::string protocolString; + + if (JSValueIsNull(m_context, protocol) == true || JSValueIsUndefined(m_context, protocol) == true) + { + bluetoothProtocol = PROTOCOL_TYPE_RFCOMM_VALUE_INT; + } + else + { + protocolString = toString(protocol); + LogDebug(protocolString.c_str()); + + if (strcmp(protocolString.c_str(), PROTOCOL_TYPE_RFCOMM_VALUE) == 0) + { + bluetoothProtocol = PROTOCOL_TYPE_RFCOMM_VALUE_INT; + } + else if (strcmp(protocolString.c_str(), PROTOCOL_TYPE_L2CAP_VALUE) == 0) + { + LogError("Not support protocol"); + Throw(UnsupportedException); + } + else + { + Throw(InvalidArgumentException); + } + } + return bluetoothProtocol; +} +JSValueRef BluetoothConverter::toBluetoothSecurityLevelJSValueRef(unsigned short level) +{ + JSValueRef result; + + switch (level) + { + case SECURITY_LEVEL_HIGH_VALUE_INT: + result = toJSValueRef(SECURITY_LEVEL_HIGH_VALUE); + break; + case SECURITY_LEVEL_MEDIUM_VALUE_INT: + result = toJSValueRef(SECURITY_LEVEL_MEDIUM_VALUE); + break; + case SECURITY_LEVEL_LOW_VALUE_INT: + result = toJSValueRef(SECURITY_LEVEL_LOW_VALUE); + break; + default: + ThrowMsg(InvalidArgumentException, "Not a security level value"); + } + return result; +} + +JSValueRef BluetoothConverter::toBluetoothProtocolJSValue(unsigned short int protocol) +{ + if (protocol == PROTOCOL_TYPE_RFCOMM_VALUE_INT) + { + return toJSValueRef(PROTOCOL_TYPE_RFCOMM_VALUE); + + } + else if (protocol == PROTOCOL_TYPE_L2CAP_VALUE_INT) + { + return toJSValueRef(PROTOCOL_TYPE_L2CAP_VALUE); + } + else + { + ThrowMsg(InvalidArgumentException, "Not a protocol value"); + } +} + +JSValueRef BluetoothConverter::toBluetoothStateJSValue(unsigned short int state) +{ + if (state == SOCKET_STATE_CLOSED_VALUE_INT) + { + return toJSValueRef(SOCKET_STATE_CLOSED_VALUE); + + } + else if (state == SOCKET_STATE_OPEN_VALUE_INT) + { + return toJSValueRef(SOCKET_STATE_OPEN_VALUE); + } + else + { + ThrowMsg(InvalidArgumentException, "Not a state value"); + } +} + +} +} + diff --git a/src/Bluetooth/BluetoothConverter.h b/src/Bluetooth/BluetoothConverter.h new file mode 100644 index 0000000..9b8fd44 --- /dev/null +++ b/src/Bluetooth/BluetoothConverter.h @@ -0,0 +1,60 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include "BTDevice.h" +#include "BluetoothMultiCallback.h" + +#ifndef TIZENAPIS_TIZEN_BLUETOOTH_CONVERTER_H_ +#define TIZENAPIS_TIZEN_BLUETOOTH_CONVERTER_H_ + +namespace DeviceAPI { +namespace Bluetooth { + +class BluetoothConverter : public WrtDeviceApis::CommonsJavaScript::Converter +{ + public: + using WrtDeviceApis::CommonsJavaScript::Converter::toJSValueRef; + + explicit BluetoothConverter(JSContextRef context); + virtual ~BluetoothConverter(); + + JSValueRef toFunctionOrNull(const JSValueRef& arg); + JSValueRef toFunction(const JSValueRef& arg); + EventBTOnDiscoveryDevicesPrivateDataPtr + toEventBTOnDiscoveryDevicesPrivateData(JSObjectRef thisObject, + JSValueRef successParam, JSValueRef errorParam); + BluetoothSocketNotifierPrivateDataPtr getInitalBluetoothSocketNotifierPrivateData(); + void setBluetoothSocketNotifierCallback(JSStringRef propertyName, JSValueRef value, + JSObjectRef object, BluetoothSocketNotifierPrivateDataPtr& privData); + JSObjectRef toBluetoothDevices(const std::vector& devices); + JSObjectRef toBluetoothByteArray(std::vector& data); + unsigned short toBluetoothSecurityLevelInt(JSValueRef level); + unsigned short toBluetoothProtocolInt(JSValueRef protocol); + JSValueRef toBluetoothSecurityLevelJSValueRef(unsigned short level); + std::string toBluetoothDeviceAddress(JSValueRef deviceAddress); + std::string toBluetoothUUIDString(JSValueRef uuidString); + JSValueRef toBluetoothProtocolJSValue(unsigned short int protocol); + JSValueRef toBluetoothStateJSValue(unsigned short int state); +}; +} +} + +#endif + diff --git a/src/Bluetooth/BluetoothDeviceManager.cpp b/src/Bluetooth/BluetoothDeviceManager.cpp new file mode 100644 index 0000000..25c98c1 --- /dev/null +++ b/src/Bluetooth/BluetoothDeviceManager.cpp @@ -0,0 +1,338 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "BluetoothDeviceManager.h" +#include "BluetoothCBManager.h" + +using namespace WrtDeviceApis; + + +namespace DeviceAPI { +namespace Bluetooth { + +BluetoothDeviceManager::BluetoothDeviceManager() +{ + m_serviceSocket= -1; + m_cancelRequest = false; +} + +BluetoothDeviceManager::~BluetoothDeviceManager() +{ + BluetoothCBManagerSingleton::Instance().removeServiceSearchCallback(m_device.address); + BluetoothCBManagerSingleton::Instance().removeConnectionStateCallback(m_device.address, BluetoothCBManager::FROM_DEVICE); +} + +namespace { + + +static bool capi_callback_bt_device_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 = ((BluetoothDeviceManager*)user_data)->deviceFoundAnswer(device_info); + } + + return ret; +} + +static bool capi_callback_bt_device_check_connected_profile(bt_profile_e profile, void *user_data) +{ + + if (profile == BT_PROFILE_RFCOMM) + { + LogDebug("Rfcomm connected"); + + + if( user_data != NULL ) + { + *(bool*)user_data = true; + } + return false; + } + + return true; +} + + +} + + + + +bool BluetoothDeviceManager::deviceFoundAnswer(bt_device_info_s *device_info) +{ + std::string remoteAddress = device_info->remote_address; + int index = 0; + + if (m_remoteAddress == remoteAddress) + { + LogDebug("Got Device : Major Class:" << device_info->bt_class.major_device_class); + LogDebug("Minor Class:" << device_info->bt_class.minor_device_class); + + m_remoteDevice.address = device_info->remote_address; + + if (device_info->remote_name == NULL) + { + m_remoteDevice.name = ""; + } + else + { + m_remoteDevice.name = device_info->remote_name; + } + + m_remoteDevice.btClass.major = device_info->bt_class.major_device_class; + m_remoteDevice.btClass.minor = device_info->bt_class.minor_device_class; + m_remoteDevice.btClass.majorServiceMask = device_info->bt_class.major_service_class_mask; + + bool connected = false; + bt_device_foreach_connected_profiles(remoteAddress.c_str(), + capi_callback_bt_device_check_connected_profile, (void*)&connected); + + m_remoteDevice.isBonded = device_info->is_bonded; + m_remoteDevice.isConnected = connected; + m_remoteDevice.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) + { + m_remoteDevice.uuids.push_back(device_info->service_uuid[index]); + } + } + } + else + { + LogDebug("service uuid is null"); + } + return false; + } + return true; +} +void BluetoothDeviceManager::connectToServiceByUUID(const EventBTConnectToServiceByUUIDPtr& event) +{ + LogDebug("Enter"); + EventRequestReceiver::PostRequest(event); +} + +void BluetoothDeviceManager::setDevice(const BluetoothDeviceData device) +{ + m_device = device; +} + +BluetoothDeviceDataClass BluetoothDeviceManager::getClass() +{ + return m_device.btClass; +} + +void BluetoothDeviceManager::setNameProperty(const std::string name) +{ + LogDebug("Enter"); + m_device.name = name; +} + +void BluetoothDeviceManager::setAddressProperty(const std::string address) +{ + LogDebug("Enter"); + m_device.address = address; +} + +void BluetoothDeviceManager::setBondProperty(const bool bonded) +{ + LogDebug("Enter"); + m_device.isBonded = bonded; +} + +void BluetoothDeviceManager::setTrustProperty(const bool trusted) +{ + LogDebug("Enter"); + m_device.isTrusted = trusted; +} + +void BluetoothDeviceManager::setConnectProperty(const bool connected) +{ + LogDebug("Enter"); + m_device.isConnected= connected; +} + +void BluetoothDeviceManager::setUuidsProperty(const std::vector uuids) +{ + LogDebug("Enter"); + m_device.uuids = uuids; +} + +std::string BluetoothDeviceManager::getNameProperty(void) +{ + LogDebug("Enter" << m_device.name); + return m_device.name; +} +std::string BluetoothDeviceManager::getAddressProperty(void) +{ + LogDebug("Enter" << m_device.address); + return m_device.address; +} +bool BluetoothDeviceManager::getBondProperty(void) +{ + LogDebug("Enter" << m_device.isBonded); + return m_device.isBonded; +} +bool BluetoothDeviceManager::getTrustProperty(void) +{ + LogDebug("Enter" << m_device.isTrusted); + return m_device.isTrusted; +} +bool BluetoothDeviceManager::getConnectProperty(void) +{ + LogDebug("Enter" << m_device.isConnected); + return m_device.isConnected; +} +std::vector BluetoothDeviceManager::getUuidsProperty(void) +{ + LogDebug("Enter"); + return m_device.uuids; +} + +void BluetoothDeviceManager::cancelConnectToServiceByUUID() +{ + m_cancelRequest = true; +} + +void BluetoothDeviceManager::serviceSearchManualAnswer(unsigned short error) +{ + BluetoothSocketData socketData = m_EventBTConnectToServiceByUUIDPtr->getSocketData(); + + try + { + if (error != BT_ERROR_NONE) + { + ThrowMsg(Commons::NotFoundException, "service search error"); + } + + BluetoothCBManagerSingleton::Instance().removeServiceSearchCallback(socketData.peerDevice.address.data()); + BluetoothCBManagerSingleton::Instance().addConnectionStateCallback(socketData.peerDevice.address.data(), + this, BluetoothCBManager::FROM_DEVICE); + + if (bt_socket_connect_rfcomm(socketData.peerDevice.address.data(), + socketData.uuid.data()) != BT_ERROR_NONE) + { + 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()); + BluetoothCBManagerSingleton::Instance().removeConnectionStateCallback(socketData.peerDevice.address.data(), BluetoothCBManager::FROM_DEVICE); + EventRequestReceiver::ManualAnswer(m_EventBTConnectToServiceByUUIDPtr); + } +} + + +void BluetoothDeviceManager::connectToServiceByUUIDManualAnswer(unsigned short error, + bt_socket_connection_state_e connectionState, bt_socket_connection_s *connection) + +{ + LogDebug("Enter" << connectionState); + + if (error == BT_ERROR_NONE) + { + if (m_cancelRequest) + { + if (connection->socket_fd > 0) + { + LogDebug("Cancel connect, try to disconnect"); + bt_socket_disconnect_rfcomm(connection->socket_fd); + BluetoothCBManagerSingleton::Instance().removeConnectionStateCallback(m_remoteAddress, BluetoothCBManager::FROM_DEVICE); + } + return; + } + + BluetoothSocketData socketData = m_EventBTConnectToServiceByUUIDPtr->getSocketData(); + m_remoteAddress = connection->remote_address; + LogDebug("address" << m_remoteAddress << "-" << socketData.peerDevice.address); + + if ((bt_adapter_foreach_bonded_device(capi_callback_bt_device_bonded_device_find, (void*)this)) != BT_ERROR_NONE) + { + m_remoteDevice.address = m_remoteAddress; + } + + m_remoteDevice.isConnected = true; + socketData.peerDevice = m_remoteDevice; + socketData.connectedSocket = connection->socket_fd; + socketData.protocol = PROTOCOL_TYPE_RFCOMM_VALUE_INT; + socketData.state = SOCKET_STATE_OPEN_VALUE_INT; + + if (connection->local_role == BT_SOCKET_SERVER) + { + socketData.isServer = true; + } + else + { + socketData.isServer = false; + } + + m_EventBTConnectToServiceByUUIDPtr->setExceptionCode(Commons::ExceptionCodes::None); + m_EventBTConnectToServiceByUUIDPtr->setSocketData(socketData); + } + else + { + m_EventBTConnectToServiceByUUIDPtr->setExceptionCode(Commons::ExceptionCodes::PlatformException); + + } + BluetoothCBManagerSingleton::Instance().removeConnectionStateCallback(m_remoteAddress, BluetoothCBManager::FROM_DEVICE); + EventRequestReceiver::ManualAnswer(m_EventBTConnectToServiceByUUIDPtr); +} + +void BluetoothDeviceManager::OnRequestReceived(const EventBTConnectToServiceByUUIDPtr& event) +{ + LogDebug("Enter"); + + m_EventBTConnectToServiceByUUIDPtr = event; + event->switchToManualAnswer(); + BluetoothSocketData socketData = event->getSocketData(); + socketData.peerDevice = m_device; + event->setSocketData(socketData); + m_cancelRequest = false; + + try + { + BluetoothCBManagerSingleton::Instance().addServiceSearchCallback(socketData.peerDevice.address.data(), + this, BluetoothCBManager::FROM_DEVICE); + + if (bt_device_start_service_search(socketData.peerDevice.address.data()) != BT_ERROR_NONE) + { + ThrowMsg(Commons::UnknownException, "service search failed" ); + } + } + catch (const Commons::Exception& ex) + { + LogError("Exception: " << ex.GetMessage()); + event->setExceptionCode(ex.getCode()); + BluetoothCBManagerSingleton::Instance().removeServiceSearchCallback(socketData.peerDevice.address.data()); + EventRequestReceiver::ManualAnswer(event); + } + +} + +} +} diff --git a/src/Bluetooth/BluetoothDeviceManager.h b/src/Bluetooth/BluetoothDeviceManager.h new file mode 100644 index 0000000..c135331 --- /dev/null +++ b/src/Bluetooth/BluetoothDeviceManager.h @@ -0,0 +1,77 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_BLUETOOTH_DEVICE_MANAGER_H_ +#define TIZENAPIS_TIZEN_BLUETOOTH_DEVICE_MANAGER_H_ + +#include +#include "IBluetoothDeviceManager.h" +#include "BluetoothFactory.h" +#include +#include "BluetoothProperty.h" + +namespace DeviceAPI { +namespace Bluetooth { + +class BluetoothDeviceManager : public IBluetoothDeviceManager +{ + friend class BluetoothFactory; + +private: + BluetoothDeviceData m_device; + BluetoothDeviceData m_remoteDevice; + int m_serviceSocket; + std::string m_remoteAddress; + EventBTConnectToServiceByUUIDPtr m_EventBTConnectToServiceByUUIDPtr; + bool m_cancelRequest; +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) ; + + virtual void setNameProperty(const std::string name) ; + virtual void setAddressProperty(const std::string address) ; + virtual void setBondProperty(const bool bonded) ; + virtual void setTrustProperty(const bool trused) ; + virtual void setConnectProperty(const bool connected) ; + virtual void setUuidsProperty(const std::vector uuids) ; + virtual void cancelConnectToServiceByUUID(); + + virtual std::string getNameProperty(void) ; + virtual std::string getAddressProperty(void) ; + virtual bool getBondProperty(void) ; + virtual bool getTrustProperty(void) ; + virtual bool getConnectProperty(void) ; + virtual std::vector getUuidsProperty(void) ; + virtual void setDevice(const BluetoothDeviceData device) ; + virtual BluetoothDeviceDataClass getClass(); +protected: + BluetoothDeviceManager(); + virtual void OnRequestReceived(const EventBTConnectToServiceByUUIDPtr& event) ; + +}; + +} +} + +#endif + diff --git a/src/Bluetooth/BluetoothDeviceManagerListener.cpp b/src/Bluetooth/BluetoothDeviceManagerListener.cpp new file mode 100644 index 0000000..043b490 --- /dev/null +++ b/src/Bluetooth/BluetoothDeviceManagerListener.cpp @@ -0,0 +1,84 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include "BluetoothDeviceManagerListener.h" +#include "JSBluetoothSocket.h" + +using namespace DeviceAPI::Common; + +namespace DeviceAPI { +namespace Bluetooth { + +BluetoothDeviceManagerListener::~BluetoothDeviceManagerListener() +{ + LogDebug("entered"); +} +BluetoothDeviceManagerListener::BluetoothDeviceManagerListener() : + EventBTConnectedAnswerReceiver(ThreadEnum::NULL_THREAD) +{ + LogDebug("entered"); +} + + +BluetoothDeviceManagerListener& BluetoothDeviceManagerListener::getInstance() +{ + static BluetoothDeviceManagerListener instance; + return instance; +} + +void BluetoothDeviceManagerListener::OnAnswerReceived(const EventBTConnectToServiceByUUIDPtr& event) +{ + LogDebug("Enter"); + JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast (event->getPrivateData()); + + if (event->getExceptionCode() == ExceptionCodes::None) + { + BluetoothSocketData socketData = event->getSocketData(); + socketData = event->getSocketData(); + JSObjectRef adapterObject = JSBluetoothSocket::createJSObject(callbackManager->getContext(), socketData); + callbackManager->callOnSuccess(adapterObject); + } + else if (event->getExceptionCode() == ExceptionCodes::NotFoundException) + { + callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(callbackManager->getContext(), + JSTizenException::UNKNOWN_ERROR, "service search failed")); + + } + else if (event->getExceptionCode() == ExceptionCodes::AlreadyInUseException) + { + callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(callbackManager->getContext(), + JSTizenException::SERVICE_NOT_AVAILABLE, "already connected")); + } + else + { + callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(callbackManager->getContext(), + JSTizenException::UNKNOWN_ERROR, "unknown error")); + } +} + +} +} + diff --git a/src/Bluetooth/BluetoothDeviceManagerListener.h b/src/Bluetooth/BluetoothDeviceManagerListener.h new file mode 100644 index 0000000..3e2a570 --- /dev/null +++ b/src/Bluetooth/BluetoothDeviceManagerListener.h @@ -0,0 +1,56 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_BLUETOOTH_DEVICE_MANAGER_LISTENER_H_ +#define TIZENAPIS_TIZEN_BLUETOOTH_DEVICE_MANAGER_LISTENER_H_ + +#include +#include +#include +#include "IBluetoothDeviceManager.h" + +using namespace WrtDeviceApis::Commons; + + +namespace DeviceAPI { +namespace Bluetooth { + +typedef EventAnswerReceiver EventBTConnectedAnswerReceiver; + + +class BluetoothDeviceManagerListener : + public EventBTConnectedAnswerReceiver +{ +private: + BluetoothDeviceManagerListener(); +public: + static BluetoothDeviceManagerListener& getInstance(); + virtual ~BluetoothDeviceManagerListener(); +protected: + + virtual void OnAnswerReceived(const EventBTConnectToServiceByUUIDPtr& event); +}; + +typedef DPL::SharedPtr BluetoothDeviceManagerListenerPtr; + +} +} + +#endif + diff --git a/src/Bluetooth/BluetoothFactory.cpp b/src/Bluetooth/BluetoothFactory.cpp new file mode 100644 index 0000000..dd66c5c --- /dev/null +++ b/src/Bluetooth/BluetoothFactory.cpp @@ -0,0 +1,68 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "BluetoothAdapterManager.h" +#include "BluetoothDeviceManager.h" +#include "BluetoothSocketManager.h" +#include "BluetoothServiceHandlerManager.h" +#include "BluetoothFactory.h" + + +namespace DeviceAPI { +namespace Bluetooth { + + +IBluetoothAdapterManagerPtr BluetoothFactory::getBluetoothAdapterManager() +{ + return IBluetoothAdapterManagerPtr(new BluetoothAdapterManager()); +} + +IBluetoothDeviceManagerPtr BluetoothFactory::getBluetoothDeviceManager() +{ + return IBluetoothDeviceManagerPtr( new BluetoothDeviceManager() ); +} + +IBluetoothSocketManagerPtr BluetoothFactory::getBluetoothSocketManager() +{ + return IBluetoothSocketManagerPtr( new BluetoothSocketManager() ); +} + +IBluetoothServiceHandlerManagerPtr BluetoothFactory::getBluetoothServiceHandlerManager() +{ + return IBluetoothServiceHandlerManagerPtr( new BluetoothServiceHandlerManager() ); +} + + +BluetoothFactory& BluetoothFactory::getInstance() +{ + static BluetoothFactory theInstance; + return theInstance; +} + +BluetoothFactory::BluetoothFactory() +{ +} + +BluetoothFactory::~BluetoothFactory() +{ +} + +} +} diff --git a/src/Bluetooth/BluetoothFactory.h b/src/Bluetooth/BluetoothFactory.h new file mode 100644 index 0000000..9af2ff5 --- /dev/null +++ b/src/Bluetooth/BluetoothFactory.h @@ -0,0 +1,51 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_FACTORY_H_ +#define TIZENAPIS_API_BLUETOOTH_FACTORY_H_ + +#include +#include "IBluetoothAdapterManager.h" +#include "IBluetoothDeviceManager.h" +#include "IBluetoothSocketManager.h" +#include "IBluetoothServiceHandlerManager.h" + +namespace DeviceAPI { +namespace Bluetooth { + +class BluetoothFactory : DPL::Noncopyable +{ +public: + IBluetoothAdapterManagerPtr getBluetoothAdapterManager(); + IBluetoothDeviceManagerPtr getBluetoothDeviceManager(); + IBluetoothSocketManagerPtr getBluetoothSocketManager(); + IBluetoothServiceHandlerManagerPtr getBluetoothServiceHandlerManager(); + + static BluetoothFactory& getInstance(); + +protected: + BluetoothFactory(); + ~BluetoothFactory(); +}; + +} +} + +#endif + diff --git a/src/Bluetooth/BluetoothMultiCallback.cpp b/src/Bluetooth/BluetoothMultiCallback.cpp new file mode 100644 index 0000000..5fcc299 --- /dev/null +++ b/src/Bluetooth/BluetoothMultiCallback.cpp @@ -0,0 +1,97 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "BluetoothMultiCallback.h" + + +namespace DeviceAPI { +namespace Bluetooth { + +EventBTOnDiscoveryDevicesPrivateData::EventBTOnDiscoveryDevicesPrivateData + (const JSCallbackManagerPtr& onSuccess, const JSCallbackManagerPtr& onFound, + const JSCallbackManagerPtr& onFinished) : + m_onSuccess(onSuccess), m_onFound(onFound), m_onFinished(onFinished) {} + +JSCallbackManagerPtr EventBTOnDiscoveryDevicesPrivateData::getOnSuccess() const +{ + return m_onSuccess; +} + +JSCallbackManagerPtr EventBTOnDiscoveryDevicesPrivateData::getOnFound() const +{ + return m_onFound; +} + +JSCallbackManagerPtr EventBTOnDiscoveryDevicesPrivateData::getOnFinished() const +{ + return m_onFinished; +} + + +BluetoothSocketNotifierPrivateData::BluetoothSocketNotifierPrivateData + (const JSCallbackManagerPtr& onMessage, const JSCallbackManagerPtr& onError, + const JSCallbackManagerPtr& onClose) : + m_onMessage(onMessage), m_onError(onError), m_onClose(onClose){ m_object = NULL;} + +JSCallbackManagerPtr BluetoothSocketNotifierPrivateData::getOnMessage() const +{ + return m_onMessage; +} + +JSCallbackManagerPtr BluetoothSocketNotifierPrivateData::getOnError() const +{ + return m_onError; +} + +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) : + m_onSuccess(onSuccess), m_onConnected(onConnected) {} + + +JSCallbackManagerPtr BluetoothRegisterServiceSuccessCallbackPrivateData::getOnSuccess() const +{ + return m_onSuccess; +} + +JSCallbackManagerPtr BluetoothRegisterServiceSuccessCallbackPrivateData::getOnConnected() const +{ + return m_onConnected; +} + +} +} + + + + diff --git a/src/Bluetooth/BluetoothMultiCallback.h b/src/Bluetooth/BluetoothMultiCallback.h new file mode 100644 index 0000000..440e8c4 --- /dev/null +++ b/src/Bluetooth/BluetoothMultiCallback.h @@ -0,0 +1,133 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_BLUETOOTH_MULTI_CALLBACK_H_ +#define TIZENAPIS_TIZEN_BLUETOOTH_MULTI_CALLBACK_H_ + +#include +#include +#include +#include + +using namespace WrtDeviceApis::CommonsJavaScript; + +namespace DeviceAPI { +namespace Bluetooth { + +struct BluetoothDiscoveryDevicesSuccessCallback +{ + JSValueRef onSuccess; + JSValueRef onFound; + JSValueRef onFinished; + + BluetoothDiscoveryDevicesSuccessCallback() + : onSuccess(NULL), + onFound(NULL), + onFinished(NULL) + { } +}; + +struct BluetoothSocketNotifier +{ + JSValueRef onMessage; + JSValueRef onError; + JSValueRef onClose; + + BluetoothSocketNotifier() + : onMessage(NULL), + onError(NULL), + onClose(NULL) + { } + +}; + +struct BluetoothRegisterServiceSuccessCallback +{ + JSValueRef onSuccess; + JSValueRef onConnected; + + BluetoothRegisterServiceSuccessCallback() + : onSuccess(NULL), + onConnected(NULL) + { } +}; + + +class EventBTOnDiscoveryDevicesPrivateData : public WrtDeviceApis::Commons::IEventPrivateData +{ +public: + EventBTOnDiscoveryDevicesPrivateData(const JSCallbackManagerPtr& onSuccess, + const JSCallbackManagerPtr& onFound, + const JSCallbackManagerPtr& onFinished); + + JSCallbackManagerPtr getOnSuccess() const; + JSCallbackManagerPtr getOnFound() const; + JSCallbackManagerPtr getOnFinished() const; + +private: + JSCallbackManagerPtr m_onSuccess; + JSCallbackManagerPtr m_onFound; + JSCallbackManagerPtr m_onFinished; +}; + +typedef DPL::SharedPtr EventBTOnDiscoveryDevicesPrivateDataPtr; + + +class BluetoothSocketNotifierPrivateData : public WrtDeviceApis::Commons::IEventPrivateData +{ +public: + BluetoothSocketNotifierPrivateData + (const JSCallbackManagerPtr& onMessage, + const JSCallbackManagerPtr& onError, + const JSCallbackManagerPtr& onClose); + + 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 BluetoothSocketNotifierPrivateDataPtr; + + +class BluetoothRegisterServiceSuccessCallbackPrivateData : public WrtDeviceApis::Commons::IEventPrivateData +{ +public: + BluetoothRegisterServiceSuccessCallbackPrivateData + (const JSCallbackManagerPtr& onSuccess, const JSCallbackManagerPtr& onConnected); + + JSCallbackManagerPtr getOnSuccess() const; + JSCallbackManagerPtr getOnConnected() const; + +private: + JSCallbackManagerPtr m_onSuccess; + JSCallbackManagerPtr m_onConnected; +}; + +typedef DPL::SharedPtr BluetoothRegisterServiceSuccessCallbackPrivateDataPtr; +} +} + +#endif diff --git a/src/platform/API/Bluetooth/BluetoothProperty.h b/src/Bluetooth/BluetoothProperty.h similarity index 100% rename from src/platform/API/Bluetooth/BluetoothProperty.h rename to src/Bluetooth/BluetoothProperty.h diff --git a/src/Bluetooth/BluetoothServiceHandlerManager.cpp b/src/Bluetooth/BluetoothServiceHandlerManager.cpp new file mode 100644 index 0000000..81b21b4 --- /dev/null +++ b/src/Bluetooth/BluetoothServiceHandlerManager.cpp @@ -0,0 +1,167 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "BluetoothCBManager.h" +#include +#include "BluetoothProperty.h" +#include "BTDevice.h" + + +namespace DeviceAPI { +namespace Bluetooth { + +BluetoothServiceHandlerManager::BluetoothServiceHandlerManager() +{ + LogDebug("Enter"); +} + +BluetoothServiceHandlerManager::~BluetoothServiceHandlerManager() +{ + LogDebug("Enter"); + + BluetoothCBManagerSingleton::Instance().removeConnectionStateCallback(m_Uuid, BluetoothCBManager::FROM_SERVICE); +} + + + +void BluetoothServiceHandlerManager::connectionStateChangedEmit(int result, + bt_socket_connection_state_e connection_state, bt_socket_connection_s *connection) +{ + LogDebug("OK" << connection_state); + + EventBTServiceOnConnectPtr event(new EventBTServiceOnConnect()); + + if (result == BT_ERROR_NONE) + { + if (connection_state == BT_SOCKET_CONNECTED) + { + + 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 = m_registerSocket; + socketdata.peerDevice.address = connection->remote_address; + socketdata.peerDevice.isConnected = true; + m_Connected = true; + event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None); + event->setSocketData(socketdata); + } + else + { + m_Connected = false; + return; + } + } + 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; +} + +void BluetoothServiceHandlerManager::setServiceHandlerListener( + const EventBTServiceOnConnectEmitterPtr& emitter) +{ + // pass uuid for server socket + BluetoothCBManagerSingleton::Instance().addConnectionStateCallback(m_Uuid, + (void*)this, BluetoothCBManager::FROM_SERVICE); + + LogDebug("setServiceHandlerListener - OK"); + m_emitter = emitter; +} + + +std::string BluetoothServiceHandlerManager::getUUID() +{ + return m_Uuid; +} + +void BluetoothServiceHandlerManager::setUUID(std::string uuid) +{ + m_Uuid = uuid; +} + +void BluetoothServiceHandlerManager::unRegister(const EventBTUnregisterRFCOMMServicePtr &event) +{ + LogDebug("Enter"); + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(event); +} + +void BluetoothServiceHandlerManager::OnRequestReceived(const EventBTUnregisterRFCOMMServicePtr& event) +{ + LogDebug("Enter"); + + try + { + std::map::iterator it; + + if (m_registerSocket < 0) + { + ThrowMsg(WrtDeviceApis::Commons::UnknownException, "no service socket"); + } + + if (bt_socket_destroy_rfcomm(m_registerSocket) != BT_ERROR_NONE) + { + ThrowMsg(WrtDeviceApis::Commons::UnknownException, "socket destroy error"); + } + event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None); + + BluetoothCBManagerSingleton::Instance().unregisterSocket(m_Uuid); + BluetoothCBManagerSingleton::Instance().removeConnectionStateCallback(m_Uuid, BluetoothCBManager::FROM_SERVICE); + + } + catch (const WrtDeviceApis::Commons::Exception& ex) + { + LogError("Exception: " << ex.GetMessage()); + event->setExceptionCode(ex.getCode()); + } + bt_adapter_unset_state_changed_cb(); + +} + +} +} diff --git a/src/Bluetooth/BluetoothServiceHandlerManager.h b/src/Bluetooth/BluetoothServiceHandlerManager.h new file mode 100644 index 0000000..1f2048f --- /dev/null +++ b/src/Bluetooth/BluetoothServiceHandlerManager.h @@ -0,0 +1,65 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include "IBluetoothServiceHandlerManager.h" +#include "BluetoothFactory.h" +#include +#include +#include +#include + +namespace DeviceAPI { +namespace Bluetooth { + +class BluetoothServiceHandlerManager : public IBluetoothServiceHandlerManager +{ + friend class BluetoothFactory; +public: + virtual ~BluetoothServiceHandlerManager(); + virtual void unRegister(const EventBTUnregisterRFCOMMServicePtr &event); + virtual void setServiceHandlerListener(const 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; + EventBTServiceOnConnectEmitterPtr m_emitter; +protected: + BluetoothServiceHandlerManager(); + virtual void OnRequestReceived(const EventBTUnregisterRFCOMMServicePtr& event) ; +}; + +} +} + +#endif + diff --git a/src/Bluetooth/BluetoothSocketListener.cpp b/src/Bluetooth/BluetoothSocketListener.cpp new file mode 100644 index 0000000..a2f44c4 --- /dev/null +++ b/src/Bluetooth/BluetoothSocketListener.cpp @@ -0,0 +1,97 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include "BluetoothSocketListener.h" +#include "BluetoothMultiCallback.h" +#include "JSBluetoothSocket.h" + +using namespace DeviceAPI::Common; + +namespace DeviceAPI { +namespace Bluetooth { + +BluetoothSocketListener::~BluetoothSocketListener() +{ + LogDebug("entered"); +} +BluetoothSocketListener::BluetoothSocketListener() : + EventBTSocketNotificationListener(ThreadEnum::NULL_THREAD) +{ + LogDebug("entered"); + +} + +BluetoothSocketListener& BluetoothSocketListener::getInstance() +{ + static BluetoothSocketListener instance; + return instance; + +} + +void BluetoothSocketListener::onAnswerReceived(const EventBTSocketNotificationPtr& event) +{ + LogDebug("Enter-Socket notification"); + + BluetoothSocketNotifierPrivateDataPtr multiCallbacks = + DPL::DynamicPointerCast(event->getPrivateData()); + + switch(event->getConnectionState()) + { + case EventBTSocketNotification::DISCONNECTED: + multiCallbacks->getOnClose()->callOnSuccess(); + break; + case EventBTSocketNotification::DATARECEIVED: + { + EventBTReadDataType readData; + + if (multiCallbacks->getObject() == NULL) + { + multiCallbacks->getOnError()->callOnSuccess(JSTizenExceptionFactory::makeErrorObject(multiCallbacks->getOnError()->getContext(), + JSTizenException::UNKNOWN_ERROR, "socket object is not set")); + return; + } + + JSBluetoothSocketPriv *priv = + static_cast(JSObjectGetPrivate(multiCallbacks->getObject())); + IBluetoothSocketManagerPtr BluetoothSocketManager(priv->getObject()); + + readData = event->getReadData(); + LogDebug("Size" << readData.size()); + BluetoothSocketManager->setReadData(readData); + multiCallbacks->getOnMessage()->callOnSuccess(); + } + break; + case EventBTSocketNotification::SOCKETERROR: + default: + multiCallbacks->getOnError()->callOnSuccess(JSTizenExceptionFactory::makeErrorObject(multiCallbacks->getOnError()->getContext(), + JSTizenException::UNKNOWN_ERROR, "unknown error")); + break; + } +} + +} +} diff --git a/src/Bluetooth/BluetoothSocketListener.h b/src/Bluetooth/BluetoothSocketListener.h new file mode 100644 index 0000000..fb96c71 --- /dev/null +++ b/src/Bluetooth/BluetoothSocketListener.h @@ -0,0 +1,53 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_BLUETOOTH_SOCKET_LISTENER_H_ +#define TIZENAPIS_TIZEN_BLUETOOTH_SOCKET_LISTENER_H_ + +#include +#include +#include "IBluetoothSocketManager.h" +#include +#include "EventBTSocketNotification.h" +#include + + +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; + +namespace DeviceAPI { +namespace Bluetooth { + +typedef EventListener EventBTSocketNotificationListener; +class BluetoothSocketListener : + public EventBTSocketNotificationListener +{ +public: + BluetoothSocketListener(); + static BluetoothSocketListener& getInstance(); + virtual void onAnswerReceived(const EventBTSocketNotificationPtr& event); + virtual ~BluetoothSocketListener(); +}; + +typedef DPL::SharedPtr BluetoothSocketListenerPtr; + +} +} + +#endif diff --git a/src/Bluetooth/BluetoothSocketManager.cpp b/src/Bluetooth/BluetoothSocketManager.cpp new file mode 100644 index 0000000..d7ae8fd --- /dev/null +++ b/src/Bluetooth/BluetoothSocketManager.cpp @@ -0,0 +1,181 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "BluetoothSocketManager.h" +#include "BluetoothCBManager.h" +#include + +namespace DeviceAPI { +namespace Bluetooth { + +BluetoothSocketManager::BluetoothSocketManager() +{ + LogDebug("Enter"); + m_socketData.connectedSocket = -1; + m_socketData.registeredSocket = -1; +} + +BluetoothSocketManager::~BluetoothSocketManager() +{ + LogDebug("Enter"); + + close(); + + BluetoothCBManagerSingleton::Instance().removeConnectionStateCallback(m_socketData.peerDevice.address, BluetoothCBManager::FROM_SOCKET); + BluetoothCBManagerSingleton::Instance().removeSocketDataReceivedCallback(m_socketData.connectedSocket); +} + + + +void BluetoothSocketManager::setReadData(EventBTReadDataType readData) +{ + DPL::Mutex::ScopedLock lock(&m_mtx); + m_readData = readData; +} + +void BluetoothSocketManager::setDataReceivedEmit(bt_socket_received_data_s *data) +{ + LogDebug("OK" << data->data[0] << data->data[1] << " :" << data->data_size); + + DPL::Mutex::ScopedLock lock(&m_mtx); + + EventBTSocketNotificationPtr event(new EventBTSocketNotification()); + event->setSocketData(m_socketData); + event->setReadData(data->data, data->data_size); + event->setConnectionState(EventBTSocketNotification::DATARECEIVED); + m_EventBTSocketNotificationEmitterPtr->emit(event); +} + +void BluetoothSocketManager::connectionStateChangedEmit(int result, + bt_socket_connection_state_e connection_state, bt_socket_connection_s *connection) +{ + + LogDebug("OK"); + + EventBTSocketNotificationPtr event(new EventBTSocketNotification()); + event->setConnectionState(EventBTSocketNotification::SOCKETERROR); + + if (result == BT_ERROR_NONE) + { + if (connection_state == BT_SOCKET_DISCONNECTED) + { + event->setConnectionState(EventBTSocketNotification::DISCONNECTED); + BluetoothCBManagerSingleton::Instance().removeConnectionStateCallback(m_socketData.peerDevice.address, BluetoothCBManager::FROM_SOCKET); + BluetoothCBManagerSingleton::Instance().removeSocketDataReceivedCallback(m_socketData.connectedSocket); + } + } + + event->setSocketData(m_socketData); + m_EventBTSocketNotificationEmitterPtr->emit(event); + +} +void BluetoothSocketManager::setSocketData(BluetoothSocketData socketData) +{ + m_socketData = socketData; +} + + +int BluetoothSocketManager::setSocketNotifier(EventBTSocketNotificationEmitterPtr emitter) +{ + try + { + + BluetoothCBManagerSingleton::Instance().addConnectionStateCallback(m_socketData.peerDevice.address, + (void*)this, BluetoothCBManager::FROM_SOCKET); + BluetoothCBManagerSingleton::Instance().addSocketDataReceivedCallback(m_socketData.connectedSocket, (void*)this); + + m_EventBTSocketNotificationEmitterPtr = emitter; + return BT_ERROR_NONE; + } + catch (const WrtDeviceApis::Commons::Exception& ex) + { + LogDebug("callback set error"); + return BT_ERROR_NOT_INITIALIZED; + } +} + +EventBTSocketNotificationEmitterPtr BluetoothSocketManager::getSocketNotifier() +{ + return m_EventBTSocketNotificationEmitterPtr; +} + +int BluetoothSocketManager::writeData(const char *data, const unsigned int length) +{ + LogDebug(length); + + if (m_socketData.connectedSocket < 0) + { + return BT_ERROR_NOT_INITIALIZED; + } + + + if (data == NULL || length == 0) + { + return BT_ERROR_INVALID_PARAMETER; + } + + + return bt_socket_send_data(m_socketData.connectedSocket, data, length); +} + +EventBTReadDataType BluetoothSocketManager::readData() +{ + DPL::Mutex::ScopedLock lock(&m_mtx); + + return m_readData; +} + + +int BluetoothSocketManager::close() +{ + DPL::Mutex::ScopedLock lock(&m_mtx); + int ret = 0; + + + if (m_socketData.isServer == true) + { + ret = bt_socket_destroy_rfcomm(m_socketData.registeredSocket); + } + else + { + ret = bt_socket_disconnect_rfcomm(m_socketData.connectedSocket); + } + BluetoothCBManagerSingleton::Instance().removeConnectionStateCallback(m_socketData.peerDevice.address, BluetoothCBManager::FROM_SOCKET); + BluetoothCBManagerSingleton::Instance().removeSocketDataReceivedCallback(m_socketData.connectedSocket); + return ret; +} + +std::string BluetoothSocketManager::getUUID() +{ + return m_socketData.uuid; +} +unsigned int BluetoothSocketManager::getProtocol() +{ + return m_socketData.protocol; +} +unsigned int BluetoothSocketManager::getState() +{ + return m_socketData.state; +} +BluetoothDeviceData BluetoothSocketManager::getPeer() +{ + return m_socketData.peerDevice; +} + +} +} diff --git a/src/Bluetooth/BluetoothSocketManager.h b/src/Bluetooth/BluetoothSocketManager.h new file mode 100644 index 0000000..b888746 --- /dev/null +++ b/src/Bluetooth/BluetoothSocketManager.h @@ -0,0 +1,67 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_SOCKET_MANAGER_H_ +#define TIZENAPIS_PLATFROM_BLUETOOTH_SOCKET_MANAGER_H_ + +#include +#include +#include "IBluetoothSocketManager.h" +#include "BluetoothFactory.h" +#include +#include +#include + +namespace DeviceAPI { +namespace Bluetooth { + + +class BluetoothSocketManager : public IBluetoothSocketManager +{ + friend class BluetoothFactory; +public: + virtual ~BluetoothSocketManager(); + virtual std::string getUUID(); + virtual unsigned int getProtocol(); + 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(); + virtual void setSocketData(BluetoothSocketData socketData); + virtual void setReadData(EventBTReadDataType readData); + void setDataReceivedEmit(bt_socket_received_data_s *data); + void connectionStateChangedEmit(int result, bt_socket_connection_state_e connection_state, + bt_socket_connection_s *connection); +private: + EventBTReadDataType m_readData; + DPL::Mutex m_mtx; + BluetoothSocketData m_socketData; + EventBTSocketNotificationEmitterPtr m_EventBTSocketNotificationEmitterPtr; +protected: + BluetoothSocketManager(); + +}; + +} +} + +#endif /* WRTPLUGINS_API_BluetoothSocketManager_H_ */ + diff --git a/src/Bluetooth/CMakeLists.txt b/src/Bluetooth/CMakeLists.txt new file mode 100755 index 0000000..335e38f --- /dev/null +++ b/src/Bluetooth/CMakeLists.txt @@ -0,0 +1,79 @@ +SET(TARGET_NAME ${bluetooth_target}) +SET(DESTINATION_NAME ${bluetooth_dest}) +SET(TARGET_IMPL_NAME ${bluetooth_impl}) + +SET(CMAKE_INSTALL_RPATH + ${CMAKE_INSTALL_RPATH} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME} +) + +PKG_SEARCH_MODULE(capi-network-bluetooth REQUIRED capi-network-bluetooth) + +INCLUDE_DIRECTORIES(${capi-network-bluetooth_INCLUDE_DIRS} + ${TOP}/Common +) + +SET(SRCS_PLATFORM_API_BLUETOOTH + BluetoothFactory.cpp + EventBTGetKnownDevices.cpp + EventBTGetDevice.cpp + EventBTOnDiscoveryDevices.cpp + EventBTSocketNotification.cpp + EventBTCreateDestroyBonding.cpp + IBluetoothAdapterManager.cpp + IBluetoothDeviceManager.cpp + IBluetoothSocketManager.cpp + IBluetoothServiceHandlerManager.cpp + IBluetoothSocketManager.cpp +) +SET(SRCS_PLATFORM_IMPLEMENTATION_BLUETOOTH + BluetoothAdapterManager.cpp + BluetoothDeviceManager.cpp + BluetoothSocketManager.cpp + BluetoothServiceHandlerManager.cpp + BluetoothCBManager.cpp +) +SET(SRCS_IMPL + ${SRCS_PLATFORM_IMPLEMENTATION_BLUETOOTH} + ${SRCS_PLATFORM_API_BLUETOOTH} + BluetoothAdapterListener.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 + JSBluetoothSocket.cpp + JSBluetoothDevice.cpp +) +SET(SRCS + plugin_config.cpp + plugin_initializer.cpp +) + +ADD_LIBRARY(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL}) + +TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME} + ${LIBS_COMMON} + ${capi-network-bluetooth_LIBRARIES} +) + +ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS}) + +TARGET_LINK_LIBRARIES(${TARGET_NAME} + ${TARGET_IMPL_NAME} +) + +INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) +INSTALL( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/bluetooth + FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE +) \ No newline at end of file diff --git a/src/Bluetooth/EventBTConnectToServiceByUUID.h b/src/Bluetooth/EventBTConnectToServiceByUUID.h new file mode 100644 index 0000000..ec76384 --- /dev/null +++ b/src/Bluetooth/EventBTConnectToServiceByUUID.h @@ -0,0 +1,46 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_CONNECTED_TO_SERVICE_BY_UUID_H_ +#define TIZENAPIS_API_BLUETOOTH_CONNECTED_TO_SERVICE_BY_UUID_H_ + +#include +#include +#include "BTDevice.h" + +namespace DeviceAPI { +namespace Bluetooth { + +class EventBTConnectToServiceByUUID : public WrtDeviceApis::Commons::IEvent +{ +private : + BluetoothSocketData m_socketData; + bool m_result; +public: + EventBTConnectToServiceByUUID() { LogDebug("entered"); } + ~EventBTConnectToServiceByUUID() { } + void setSocketData(BluetoothSocketData socketData) { m_socketData = socketData;} + BluetoothSocketData getSocketData() { return m_socketData;} +}; + +typedef DPL::SharedPtr EventBTConnectToServiceByUUIDPtr; + +} +} + +#endif diff --git a/src/Bluetooth/EventBTCreateDestroyBonding.cpp b/src/Bluetooth/EventBTCreateDestroyBonding.cpp new file mode 100644 index 0000000..66b3300 --- /dev/null +++ b/src/Bluetooth/EventBTCreateDestroyBonding.cpp @@ -0,0 +1,61 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "EventBTCreateDestroyBonding.h" +#include "IBluetoothAdapterManager.h" +#include +#include "JSBluetoothAdapter.h" + +namespace DeviceAPI { +namespace Bluetooth { + +EventBTCreateDestroyBonding::EventBTCreateDestroyBonding() +{ + LogDebug("entered"); +} +EventBTCreateDestroyBonding::~EventBTCreateDestroyBonding() +{ + +} + + +bool EventBTCreateDestroyBonding::cancelRequest() +{ + LogDebug("OK"); + bool result = false; + + BluetoothCreateBondingPrivateDataPtr privData = + DPL::StaticPointerCast(IEvent::getPrivateData()); + JSBluetoothAdapterPriv *priv = static_cast(JSObjectGetPrivate(privData->getObject())); + IBluetoothAdapterManagerPtr BluetoothAdapter(priv->getObject()); + + if (m_cancelled) { + LogDebug("Already canceleed"); + return false; + } + + if (m_state) { + LogDebug("cancelling"); + result = BluetoothAdapter->createBondingCancel(); + return result; + } + + return result; +} + +} +} diff --git a/src/Bluetooth/EventBTCreateDestroyBonding.h b/src/Bluetooth/EventBTCreateDestroyBonding.h new file mode 100644 index 0000000..44df41b --- /dev/null +++ b/src/Bluetooth/EventBTCreateDestroyBonding.h @@ -0,0 +1,54 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_CREATE_DESTROY_BONDING_H_ +#define TIZENAPIS_API_BLUETOOTH_CREATE_DESTROY_BONDING_H_ + + +#include +#include +#include "BTDevice.h" + +namespace DeviceAPI { +namespace Bluetooth { + +class EventBTCreateDestroyBonding : public WrtDeviceApis::Commons::IEvent +{ +private: + std::string m_address; + bool m_operation; + BluetoothDeviceData m_device; +public: + EventBTCreateDestroyBonding() ; + ~EventBTCreateDestroyBonding() ; + void setAddress(std::string address) { m_address = address;} + std::string getAddress() { return m_address;} + void setCreateBonding(void) { m_operation = true; } + void setDestroyBonding(void) { m_operation = false; } + bool isCreateBonding(void) { return m_operation == true;} + bool isDestroyBonding(void) { return m_operation == true;} + BluetoothDeviceData getDevice() { return m_device;} + void setDevice(BluetoothDeviceData device) { m_device = device;} + virtual bool cancelRequest(); +}; + +typedef DPL::SharedPtr EventBTCreateDestroyBondingPtr; + +} +} + +#endif diff --git a/src/Bluetooth/EventBTGetAdapter.h b/src/Bluetooth/EventBTGetAdapter.h new file mode 100644 index 0000000..42a3bf9 --- /dev/null +++ b/src/Bluetooth/EventBTGetAdapter.h @@ -0,0 +1,42 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_BT_GET_ADAPTER_H_ +#define TIZENAPIS_API_BLUETOOTH_BT_GET_ADAPTER_H_ + +#include +#include + + +namespace DeviceAPI { +namespace Bluetooth { + +class EventBTGetAdapter : public WrtDeviceApis::Commons::IEvent +{ +private: + bool m_result; +public: + EventBTGetAdapter() { m_result = false;} + ~EventBTGetAdapter() { } + +}; +typedef DPL::SharedPtr EventBTGetAdapterPtr; + +} +} + +#endif diff --git a/src/Bluetooth/EventBTGetDevice.cpp b/src/Bluetooth/EventBTGetDevice.cpp new file mode 100644 index 0000000..737f37e --- /dev/null +++ b/src/Bluetooth/EventBTGetDevice.cpp @@ -0,0 +1,46 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "EventBTGetDevice.h" + +namespace DeviceAPI { +namespace Bluetooth { + + +void EventBTGetDevice::setDevice(BluetoothDeviceData device) +{ + m_Device = device; +} + +void EventBTGetDevice::setAddress(std::string address) +{ + m_address = address; +} + +std::string EventBTGetDevice::getAddress() +{ + return m_address; +} + + +BluetoothDeviceData EventBTGetDevice::getDevice() +{ + return m_Device; +} + +} +} diff --git a/src/Bluetooth/EventBTGetDevice.h b/src/Bluetooth/EventBTGetDevice.h new file mode 100644 index 0000000..9d01a3c --- /dev/null +++ b/src/Bluetooth/EventBTGetDevice.h @@ -0,0 +1,49 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_GET_DEVICE_H_ +#define TIZENAPIS_API_BLUETOOTH_GET_DEVICE_H_ + +#include +#include +#include "BTDevice.h" + +namespace DeviceAPI { +namespace Bluetooth { + +class EventBTGetDevice : public WrtDeviceApis::Commons::IEvent +{ +private: + BluetoothDeviceData m_Device; + std::string m_address; +public: + EventBTGetDevice() { LogDebug("entered"); } + ~EventBTGetDevice() { } + + void setDevice(BluetoothDeviceData device); + void setAddress(std::string address) ; + std::string getAddress() ; + BluetoothDeviceData getDevice(); + + +}; + +typedef DPL::SharedPtr EventBTGetDevicePtr; + +} +} +#endif diff --git a/src/Bluetooth/EventBTGetKnownDevices.cpp b/src/Bluetooth/EventBTGetKnownDevices.cpp new file mode 100644 index 0000000..9755b9f --- /dev/null +++ b/src/Bluetooth/EventBTGetKnownDevices.cpp @@ -0,0 +1,34 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "EventBTGetKnownDevices.h" + +namespace DeviceAPI { +namespace Bluetooth { + +void EventBTGetKnownDevices::addDevice(BluetoothDeviceData device) +{ + m_Devices.push_back(device); +} + +std::vector EventBTGetKnownDevices::getDevices() +{ + return m_Devices; +} + +} +} diff --git a/src/Bluetooth/EventBTGetKnownDevices.h b/src/Bluetooth/EventBTGetKnownDevices.h new file mode 100644 index 0000000..6fe472b --- /dev/null +++ b/src/Bluetooth/EventBTGetKnownDevices.h @@ -0,0 +1,48 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_GET_KNOWN_DEVICES_H_ +#define TIZENAPIS_API_BLUETOOTH_GET_KNOWN_DEVICES_H_ + +#include +#include +#include "BTDevice.h" + +namespace DeviceAPI { +namespace Bluetooth { + +class EventBTGetKnownDevices : public WrtDeviceApis::Commons::IEvent +{ +private: +public: + +private: + std::vector m_Devices; + +public: + EventBTGetKnownDevices() { LogDebug("entered"); } + ~EventBTGetKnownDevices() { } + + void addDevice(BluetoothDeviceData device); + std::vector getDevices(); +}; + +typedef DPL::SharedPtr EventBTGetKnownDevicesPtr; + +} +} +#endif diff --git a/src/Bluetooth/EventBTOnDiscoveryDevices.cpp b/src/Bluetooth/EventBTOnDiscoveryDevices.cpp new file mode 100644 index 0000000..e532cc6 --- /dev/null +++ b/src/Bluetooth/EventBTOnDiscoveryDevices.cpp @@ -0,0 +1,49 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "EventBTOnDiscoveryDevices.h" + +namespace DeviceAPI { +namespace Bluetooth { + +EventBTOnDiscoveryDevices::EventBTOnDiscoveryDevices() +{ + LogDebug("entered"); +} + +EventBTOnDiscoveryDevices::~EventBTOnDiscoveryDevices() +{ + LogDebug("entered"); +} + +void EventBTOnDiscoveryDevices::addDevice(BluetoothDeviceData device) +{ + m_Devices.push_back(device); +} + +std::vector EventBTOnDiscoveryDevices::getDevices() +{ + return m_Devices; +} + +void EventBTOnDiscoveryDevices::setDiscoveryState(DiscoveryStates state) +{ + m_discoveryState = state; +} + +} +} diff --git a/src/Bluetooth/EventBTOnDiscoveryDevices.h b/src/Bluetooth/EventBTOnDiscoveryDevices.h new file mode 100644 index 0000000..73ad7c1 --- /dev/null +++ b/src/Bluetooth/EventBTOnDiscoveryDevices.h @@ -0,0 +1,59 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_ON_DISCOVERY_DEVICES_H_ +#define TIZENAPIS_API_BLUETOOTH_ON_DISCOVERY_DEVICES_H_ + +#include +#include +#include +#include +#include +#include "BTDevice.h" + +namespace DeviceAPI { +namespace Bluetooth { + +class EventBTOnDiscoveryDevices : public WrtDeviceApis::Commons::ListenerEvent +{ +public: + typedef enum + { + STARTED, + DISCOVERYING, + FINISHED + } DiscoveryStates; +private: + DiscoveryStates m_discoveryState; + std::vector m_Devices; +public: + EventBTOnDiscoveryDevices(); + ~EventBTOnDiscoveryDevices(); + void setDiscoveryState(DiscoveryStates state); + DiscoveryStates getDiscoveryState() { return m_discoveryState;} + void addDevice(BluetoothDeviceData device); + std::vector getDevices(); +}; + +typedef DPL::SharedPtr EventBTOnDiscoveryDevicesPtr; +typedef WrtDeviceApis::Commons::ListenerEventEmitter EventBTOnDiscoveryDevicesEmitter; +typedef DPL::SharedPtr EventBTOnDiscoveryDevicesEmitterPtr; + +} +} +#endif diff --git a/src/Bluetooth/EventBTRegisterRFCOMM.h b/src/Bluetooth/EventBTRegisterRFCOMM.h new file mode 100644 index 0000000..0f478f2 --- /dev/null +++ b/src/Bluetooth/EventBTRegisterRFCOMM.h @@ -0,0 +1,54 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_REGISTER_RFCOMM_H_ +#define TIZENAPIS_API_BLUETOOTH_REGISTER_RFCOMM_H_ + +#include +#include +#include "BTDevice.h" + +namespace DeviceAPI { +namespace Bluetooth { + +class EventBTRegisterRFCOMM : + public WrtDeviceApis::Commons::IEvent +{ +private: + std::string m_uuid; + std::string m_name; + int m_registerSocket; + int m_securityLevel; +public: + 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 EventBTRegisterRFCOMMPtr; + +} +} + +#endif diff --git a/src/Bluetooth/EventBTServiceOnConnect.cpp b/src/Bluetooth/EventBTServiceOnConnect.cpp new file mode 100644 index 0000000..d3144cc --- /dev/null +++ b/src/Bluetooth/EventBTServiceOnConnect.cpp @@ -0,0 +1,50 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include "EventBTServiceOnConnect.h" +#include "BTDevice.h" + +namespace DeviceAPI { +namespace Bluetooth { + +EventBTServiceOnConnect::EventBTServiceOnConnect() +{ + +} + +EventBTServiceOnConnect::~EventBTServiceOnConnect() +{ +} + +void EventBTServiceOnConnect::setSocketData(BluetoothSocketData socketData) +{ + m_socketData = socketData; +} + +BluetoothSocketData EventBTServiceOnConnect::getSocketData() +{ + return m_socketData; +} + + + +} +} + diff --git a/src/Bluetooth/EventBTServiceOnConnect.h b/src/Bluetooth/EventBTServiceOnConnect.h new file mode 100644 index 0000000..1b0cf31 --- /dev/null +++ b/src/Bluetooth/EventBTServiceOnConnect.h @@ -0,0 +1,58 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include "BTDevice.h" + +namespace DeviceAPI { +namespace Bluetooth { + +class EventBTServiceOnConnect : public WrtDeviceApis::Commons::ListenerEvent +{ +private: + BluetoothSocketData m_socketData; +public: + EventBTServiceOnConnect() {} + ~EventBTServiceOnConnect() {} + + void setSocketData(BluetoothSocketData socketData) + { + m_socketData = socketData; + } + + BluetoothSocketData getSocketData() + { + return m_socketData; + } + +}; + +typedef DPL::SharedPtr EventBTServiceOnConnectPtr; +typedef WrtDeviceApis::Commons::ListenerEventEmitter EventBTServiceOnConnectEmitter; +typedef DPL::SharedPtr EventBTServiceOnConnectEmitterPtr; + +} +} + +#endif diff --git a/src/Bluetooth/EventBTSetName.h b/src/Bluetooth/EventBTSetName.h new file mode 100644 index 0000000..5f6b920 --- /dev/null +++ b/src/Bluetooth/EventBTSetName.h @@ -0,0 +1,49 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_SET_NAME_H +#define TIZENAPIS_API_BLUETOOTH_SET_NAME_H + +#include +#include +#include + +namespace DeviceAPI { +namespace Bluetooth { + +class EventBTSetName; + +typedef DPL::SharedPtr EventBTSetNamePtr; + +class EventBTSetName : + public WrtDeviceApis::Commons::IEvent +{ +public: + EventBTSetName(){} + ~EventBTSetName(){} + void setName(std::string name) { m_name = name;} + std::string getName() { return m_name;} +private: + std::string m_name; +}; + + +} +} +#endif + diff --git a/src/Bluetooth/EventBTSetPowered.h b/src/Bluetooth/EventBTSetPowered.h new file mode 100644 index 0000000..f530e7c --- /dev/null +++ b/src/Bluetooth/EventBTSetPowered.h @@ -0,0 +1,53 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_SET_POWERED_H_ +#define TIZENAPIS_API_BLUETOOTH_SET_POWERED_H_ + +#include +#include + + +namespace DeviceAPI { +namespace Bluetooth { + +class EventBTSetPowered : public WrtDeviceApis::Commons::IEvent +{ +private: + bool m_operation; + bool m_result; + unsigned short m_error; +public: + EventBTSetPowered() + { + LogDebug("entered"); + m_operation = false; + } + + ~EventBTSetPowered() { } + + void setEnable() { m_operation = true;} + void setDisable() { m_operation = false;} + bool isEnableRequested() { return m_operation;} +}; + +typedef DPL::SharedPtr EventBTSetPoweredPtr; + +} +} +#endif diff --git a/src/Bluetooth/EventBTSetVisible.h b/src/Bluetooth/EventBTSetVisible.h new file mode 100644 index 0000000..5c26dfe --- /dev/null +++ b/src/Bluetooth/EventBTSetVisible.h @@ -0,0 +1,49 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_SET_VISIBLE_H_ +#define TIZENAPIS_API_BLUETOOTH_SET_VISIBLE_H_ + +#include +#include + +namespace DeviceAPI { +namespace Bluetooth { + +class EventBTSetVisible : public WrtDeviceApis::Commons::IEvent +{ +private: + bool m_visible; + unsigned short m_timeout; +public: + EventBTSetVisible() { LogDebug("entered"); m_timeout = 120;} + ~EventBTSetVisible() { } + + void setVisible() { m_visible = true;} + void setInvisible() { m_visible = false;} + void setTimeout(unsigned short timeout) { m_timeout = timeout;} + unsigned short getTimeout() { return m_timeout;} + bool isVisibleRequested() { return m_visible;} + +}; + +typedef DPL::SharedPtr EventBTSetVisiblePtr; + +} +} + +#endif diff --git a/src/Bluetooth/EventBTSocketNotification.cpp b/src/Bluetooth/EventBTSocketNotification.cpp new file mode 100644 index 0000000..d6c3ed0 --- /dev/null +++ b/src/Bluetooth/EventBTSocketNotification.cpp @@ -0,0 +1,61 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "EventBTSocketNotification.h" + +namespace DeviceAPI { +namespace Bluetooth { + +EventBTSocketNotification::EventBTSocketNotification() +{ +} + +EventBTSocketNotification::~EventBTSocketNotification() +{ +} + +void EventBTSocketNotification::setSocketData(BluetoothSocketData socket) +{ + m_socketData = socket; +} + +BluetoothSocketData& EventBTSocketNotification::getSocketData() +{ + return m_socketData; +} + +void EventBTSocketNotification::setReadData(char *data, int length) +{ +/* Assert(data != NULL); + Assert(length != 0);*/ + + for (int i = 0; i < length; i++) + { + m_readData.push_back(data[i]); + } +} + +EventBTReadDataType EventBTSocketNotification::getReadData() +{ + return m_readData; +} + +} +} + + diff --git a/src/Bluetooth/EventBTSocketNotification.h b/src/Bluetooth/EventBTSocketNotification.h new file mode 100644 index 0000000..3c110c0 --- /dev/null +++ b/src/Bluetooth/EventBTSocketNotification.h @@ -0,0 +1,66 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_SOCKET_NOTIFICATION_H_ +#define TIZENAPIS_API_BLUETOOTH_SOCKET_NOTIFICATION_H_ + +#include +#include +#include +#include +#include "BTDevice.h" + +namespace DeviceAPI { +namespace Bluetooth { + +typedef std::vector EventBTReadDataType; + +class EventBTSocketNotification : public WrtDeviceApis::Commons::ListenerEvent +{ +public : + typedef enum + { + CONNECTED, + DISCONNECTED, + DATARECEIVED, + SOCKETERROR + } EventBTSoncketState; + +private: + EventBTSoncketState m_State; + BluetoothSocketData m_socketData; + std::vector m_readData; +public: + EventBTSocketNotification(); + ~EventBTSocketNotification(); + void setSocketData(BluetoothSocketData socket); + BluetoothSocketData& getSocketData(); + void setReadData(char* data, int length); + EventBTReadDataType getReadData(); + void setConnectionState(EventBTSoncketState state) {m_State = state;} + EventBTSoncketState getConnectionState() { return m_State;} + +}; + +typedef DPL::SharedPtr EventBTSocketNotificationPtr; +typedef WrtDeviceApis::Commons::ListenerEventEmitter EventBTSocketNotificationEmitter; +typedef DPL::SharedPtr EventBTSocketNotificationEmitterPtr; + +} +} + +#endif diff --git a/src/Bluetooth/EventBTStopDiscovery.h b/src/Bluetooth/EventBTStopDiscovery.h new file mode 100644 index 0000000..97ece66 --- /dev/null +++ b/src/Bluetooth/EventBTStopDiscovery.h @@ -0,0 +1,44 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_STOP_DISCOVERY_H_ +#define TIZENAPIS_API_BLUETOOTH_STOP_DISCOVERY_H_ + +#include +#include + + +namespace DeviceAPI { +namespace Bluetooth { + +class EventBTStopDiscovery : public WrtDeviceApis::Commons::IEvent +{ +private: +public: + EventBTStopDiscovery() + { + } + + ~EventBTStopDiscovery() { } +}; + +typedef DPL::SharedPtr EventBTStopDiscoveryPtr; + +} +} +#endif + diff --git a/src/Bluetooth/EventBTUnregisterRFCOMM.h b/src/Bluetooth/EventBTUnregisterRFCOMM.h new file mode 100644 index 0000000..7529a51 --- /dev/null +++ b/src/Bluetooth/EventBTUnregisterRFCOMM.h @@ -0,0 +1,41 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_UNREGISTER_RFCOMM_SERVICE_H_ +#define TIZENAPIS_API_BLUETOOTH_UNREGISTER_RFCOMM_SERVICE_H_ + +#include +#include + + +namespace DeviceAPI { +namespace Bluetooth { + +class EventBTUnregisterRFCOMMService : public WrtDeviceApis::Commons::IEvent +{ +public: + EventBTUnregisterRFCOMMService() { } + ~EventBTUnregisterRFCOMMService() { } +}; + +typedef DPL::SharedPtr EventBTUnregisterRFCOMMServicePtr; + +} +} +#endif + diff --git a/src/Bluetooth/IBluetoothAdapterManager.cpp b/src/Bluetooth/IBluetoothAdapterManager.cpp new file mode 100644 index 0000000..c8d73e6 --- /dev/null +++ b/src/Bluetooth/IBluetoothAdapterManager.cpp @@ -0,0 +1,50 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "IBluetoothAdapterManager.h" + +namespace DeviceAPI { +namespace Bluetooth { + +using namespace WrtDeviceApis::Commons; +IBluetoothAdapterManager::IBluetoothAdapterManager() : +/* EventRequestReceiver(ThreadEnum::BLUETOOTH_THREAD), + EventRequestReceiver(ThreadEnum::BLUETOOTH_THREAD), + EventRequestReceiver(ThreadEnum::BLUETOOTH_THREAD), + EventRequestReceiver(ThreadEnum::BLUETOOTH_THREAD), + EventRequestReceiver(ThreadEnum::BLUETOOTH_THREAD), + EventRequestReceiver(ThreadEnum::BLUETOOTH_THREAD), + EventRequestReceiver(ThreadEnum::BLUETOOTH_THREAD), + EventRequestReceiver(ThreadEnum::BLUETOOTH_THREAD)*/ + EventRequestReceiver(ThreadEnum::NULL_THREAD), + EventRequestReceiver(ThreadEnum::NULL_THREAD), + EventRequestReceiver(ThreadEnum::NULL_THREAD), + EventRequestReceiver(ThreadEnum::NULL_THREAD), + EventRequestReceiver(ThreadEnum::NULL_THREAD), + EventRequestReceiver(ThreadEnum::NULL_THREAD), + EventRequestReceiver(ThreadEnum::NULL_THREAD), + EventRequestReceiver(ThreadEnum::NULL_THREAD) + +{ +} + +IBluetoothAdapterManager::~IBluetoothAdapterManager() { +} + +} +} diff --git a/src/Bluetooth/IBluetoothAdapterManager.h b/src/Bluetooth/IBluetoothAdapterManager.h new file mode 100644 index 0000000..87bc017 --- /dev/null +++ b/src/Bluetooth/IBluetoothAdapterManager.h @@ -0,0 +1,84 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_ADAPTER_MANAGER_H_ +#define TIZENAPIS_API_IBLUETOOTH_ADAPTER_MANAGER_H_ + +#include +#include +#include "EventBTCreateDestroyBonding.h" +#include "EventBTGetKnownDevices.h" +#include "EventBTGetDevice.h" +#include "EventBTSetPowered.h" +#include "EventBTRegisterRFCOMM.h" +#include "EventBTSetVisible.h" +#include "EventBTOnDiscoveryDevices.h" +#include "EventBTSetName.h" +#include "EventBTStopDiscovery.h" + +namespace DeviceAPI { +namespace Bluetooth { + +class IBluetoothAdapterManager : + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver + +{ +public: + virtual ~IBluetoothAdapterManager(); + virtual void setPowered(const EventBTSetPoweredPtr& event) = 0; + virtual void setVisible(const EventBTSetVisiblePtr& event) = 0; + virtual void discoveryDevicesEmitter(const EventBTOnDiscoveryDevicesEmitterPtr& emitter) = 0; + virtual void getKownDevices(const EventBTGetKnownDevicesPtr& event) = 0; + virtual void getDevice(const EventBTGetDevicePtr& event) = 0; + virtual void createBonding(const EventBTCreateDestroyBondingPtr& event) = 0; + virtual bool createBondingCancel() = 0; + virtual void destroyBonding(const EventBTCreateDestroyBondingPtr& event) = 0; + virtual void registerRFCOMMServiceByUUID(const EventBTRegisterRFCOMMPtr& event) = 0; + virtual void stopDiscovery(const EventBTStopDiscoveryPtr& event) = 0; + virtual void setAdapterName(const EventBTSetNamePtr& event) = 0; + virtual std::string getName() = 0; + virtual std::string getAddress() = 0; + virtual bool getPowered() = 0; + virtual bool getVisibility() = 0; + +protected: + IBluetoothAdapterManager(); + + 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 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 IBluetoothAdapterManagerPtr; + +} +} + +#endif diff --git a/src/Bluetooth/IBluetoothDeviceManager.cpp b/src/Bluetooth/IBluetoothDeviceManager.cpp new file mode 100644 index 0000000..faca0a6 --- /dev/null +++ b/src/Bluetooth/IBluetoothDeviceManager.cpp @@ -0,0 +1,38 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "IBluetoothDeviceManager.h" + +namespace DeviceAPI { +namespace Bluetooth { + +using namespace WrtDeviceApis::Commons; + +IBluetoothDeviceManager::IBluetoothDeviceManager() : +// EventRequestReceiver(ThreadEnum::BLUETOOTH_THREAD) + EventRequestReceiver(ThreadEnum::NULL_THREAD) + +{ +} + +IBluetoothDeviceManager::~IBluetoothDeviceManager() { +} + +} +} + diff --git a/src/Bluetooth/IBluetoothDeviceManager.h b/src/Bluetooth/IBluetoothDeviceManager.h new file mode 100644 index 0000000..b21d98c --- /dev/null +++ b/src/Bluetooth/IBluetoothDeviceManager.h @@ -0,0 +1,64 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_DEVICE_MANAGER_H_ +#define TIZENAPIS_API_IBLUETOOTH_DEVICE_MANAGER_H_ + +#include +#include +#include"EventBTConnectToServiceByUUID.h" +#include "BTDevice.h" + +namespace DeviceAPI { +namespace Bluetooth { + + +class IBluetoothDeviceManager : + public WrtDeviceApis::Commons::EventRequestReceiver +{ +public: + virtual ~IBluetoothDeviceManager(); + virtual void connectToServiceByUUID(const EventBTConnectToServiceByUUIDPtr& event) = 0; + + virtual void setNameProperty(const std::string name) = 0; + virtual void setAddressProperty(const std::string address) = 0; + virtual void setBondProperty(const bool bonded) = 0; + virtual void setTrustProperty(const bool trused) = 0; + virtual void setConnectProperty(const bool connected) = 0; + virtual void setUuidsProperty(const std::vector uuids) = 0; + virtual void cancelConnectToServiceByUUID() = 0; + + virtual std::string getNameProperty(void) = 0; + virtual std::string getAddressProperty(void) = 0; + virtual bool getBondProperty(void) = 0; + virtual bool getTrustProperty(void) = 0; + virtual bool getConnectProperty(void) = 0; + virtual std::vector getUuidsProperty(void) = 0; + virtual void setDevice(const BluetoothDeviceData device) = 0; + virtual BluetoothDeviceDataClass getClass() = 0; +protected: + IBluetoothDeviceManager(); + virtual void OnRequestReceived(const EventBTConnectToServiceByUUIDPtr& event) = 0; +}; + +typedef DPL::SharedPtr IBluetoothDeviceManagerPtr; + +} +} + +#endif diff --git a/src/Bluetooth/IBluetoothServiceHandlerManager.cpp b/src/Bluetooth/IBluetoothServiceHandlerManager.cpp new file mode 100644 index 0000000..334892b --- /dev/null +++ b/src/Bluetooth/IBluetoothServiceHandlerManager.cpp @@ -0,0 +1,38 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "IBluetoothServiceHandlerManager.h" + +using namespace WrtDeviceApis::Commons; + +namespace DeviceAPI { +namespace Bluetooth { + + +IBluetoothServiceHandlerManager::IBluetoothServiceHandlerManager() : +// EventRequestReceiver(ThreadEnum::BLUETOOTH_THREAD) + EventRequestReceiver(ThreadEnum::NULL_THREAD) +{ +} + +IBluetoothServiceHandlerManager::~IBluetoothServiceHandlerManager() { +} + +} +} + diff --git a/src/Bluetooth/IBluetoothServiceHandlerManager.h b/src/Bluetooth/IBluetoothServiceHandlerManager.h new file mode 100644 index 0000000..45accef --- /dev/null +++ b/src/Bluetooth/IBluetoothServiceHandlerManager.h @@ -0,0 +1,53 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include "EventBTUnregisterRFCOMM.h" +#include "EventBTServiceOnConnect.h" + +namespace DeviceAPI { +namespace Bluetooth { + +class IBluetoothServiceHandlerManager : + public WrtDeviceApis::Commons::EventRequestReceiver +{ +public: + virtual ~IBluetoothServiceHandlerManager(); + virtual void unRegister(const EventBTUnregisterRFCOMMServicePtr &event) = 0; + virtual void 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 IBluetoothServiceHandlerManagerPtr; + +} +} +#endif diff --git a/src/Bluetooth/IBluetoothSocketManager.cpp b/src/Bluetooth/IBluetoothSocketManager.cpp new file mode 100644 index 0000000..203d179 --- /dev/null +++ b/src/Bluetooth/IBluetoothSocketManager.cpp @@ -0,0 +1,34 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "IBluetoothSocketManager.h" + +namespace DeviceAPI { +namespace Bluetooth { + + +IBluetoothSocketManager::IBluetoothSocketManager() +{ +} + +IBluetoothSocketManager::~IBluetoothSocketManager() { +} + +} +} + diff --git a/src/Bluetooth/IBluetoothSocketManager.h b/src/Bluetooth/IBluetoothSocketManager.h new file mode 100644 index 0000000..35a17fd --- /dev/null +++ b/src/Bluetooth/IBluetoothSocketManager.h @@ -0,0 +1,54 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_SOCKET_MANAGER_H_ +#define TIZENAPIS_API_IBLUETOOTH_SOCKET_MANAGER_H_ + +#include +#include +#include "BTDevice.h" +#include "EventBTSocketNotification.h" + + +namespace DeviceAPI { +namespace Bluetooth { + +class IBluetoothSocketManager +{ +public: + virtual ~IBluetoothSocketManager(); + virtual std::string getUUID() = 0; + virtual unsigned int getProtocol() = 0; + 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; + virtual void setSocketData(BluetoothSocketData socketData) = 0; + virtual void setReadData(EventBTReadDataType readData) = 0; +protected: + IBluetoothSocketManager(); +}; + +typedef DPL::SharedPtr IBluetoothSocketManagerPtr; + +} +} +#endif diff --git a/src/Bluetooth/JSBluetoothAdapter.cpp b/src/Bluetooth/JSBluetoothAdapter.cpp new file mode 100644 index 0000000..01fffb2 --- /dev/null +++ b/src/Bluetooth/JSBluetoothAdapter.cpp @@ -0,0 +1,1390 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include "JSBluetoothAdapter.h" +#include "IBluetoothAdapterManager.h" +#include "BluetoothFactory.h" +#include "BluetoothProperty.h" +#include "BluetoothAdapterListener.h" +#include "BluetoothMultiCallback.h" +#include "BluetoothConverter.h" +#include "plugin_config.h" + +using namespace std; +using namespace DPL; +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + + +namespace DeviceAPI { +namespace Bluetooth { + +JSClassRef JSBluetoothAdapter::m_jsClassRef = NULL; + +JSClassDefinition JSBluetoothAdapter::m_classInfo = +{ + 0, + kJSClassAttributeNone, + "BluetoothAdapter", + NULL, + m_properties, + m_function, + initialize, + finalize, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + hasInstance, + NULL +}; + +JSStaticFunction JSBluetoothAdapter::m_function[] = +{ + { "setPowered", JSBluetoothAdapter::setPowered, kJSPropertyAttributeNone }, + { "setVisible", JSBluetoothAdapter::setVisible, kJSPropertyAttributeNone }, + { "setName", JSBluetoothAdapter::setName, kJSPropertyAttributeNone }, + { "discoverDevices", JSBluetoothAdapter::discoveryDevices, kJSPropertyAttributeNone }, + { "stopDiscovery", JSBluetoothAdapter::stopDiscovery, kJSPropertyAttributeNone }, + { "getKnownDevices", JSBluetoothAdapter::getKnownDevices, kJSPropertyAttributeNone }, + { "getDevice", JSBluetoothAdapter::getDevice, kJSPropertyAttributeNone }, + { "createBonding", JSBluetoothAdapter::createBonding, kJSPropertyAttributeNone }, + { "destroyBonding", JSBluetoothAdapter::destroyBonding, kJSPropertyAttributeNone }, + { "registerRFCOMMServiceByUUID", JSBluetoothAdapter::registerRFCOMMServiceByUUID, kJSPropertyAttributeNone }, + { 0, 0, 0 } +}; + +JSStaticValue JSBluetoothAdapter::m_properties[] = { + {"address", getAddress, NULL, kJSPropertyAttributeReadOnly}, + {"name", getName, NULL, kJSPropertyAttributeReadOnly}, + {"powered", getPowered, NULL, kJSPropertyAttributeReadOnly}, + {"visible", getVisible, NULL, kJSPropertyAttributeReadOnly}, + + {0, 0, 0, 0} +}; + +JSValueRef JSBluetoothAdapter::getName(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("Enter"); + + Converter converter(context); + JSBluetoothAdapterPriv *priv = static_cast(JSObjectGetPrivate(object)); + + Try + { + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + + IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject()); + std::string name = BluetoothAdapterManager->getName(); + return converter.toJSValueRef(name); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception"<<_rethrown_exception.GetMessage()); + } + + return NULL; +} + +JSValueRef JSBluetoothAdapter::setName(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("Enter"); + JSBluetoothAdapterPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + JSValueRef successCallback = NULL; + JSValueRef errorCallBack = NULL; + + if (priv == NULL) + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + } + + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL); + JSValueRef reserveArguments[3]; + size_t index = 0; + + Try + { + for (index = 0; index < 3; index++) + { + if (index < argumentCount) + reserveArguments[index] = arguments[index]; + else + reserveArguments[index] = JSValueMakeUndefined(context); + + } + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_SET_NAME]); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + BluetoothConverter converter(priv->getContext()); + + successCallback = converter.toFunctionOrNull(reserveArguments[1]); + errorCallBack = converter.toFunctionOrNull(reserveArguments[2]); + + if (cbm == NULL) + { + Throw(UnknownException); + } + + cbm->setOnSuccess(successCallback); + cbm->setOnError(errorCallBack); + + + + + + IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject()); + std::string name = converter.toString(reserveArguments[0]); + + + if (name != BluetoothAdapterManager->getName()) + { + EventBTSetNamePtr event(new EventBTSetName); + + event->setPrivateData(DPL::StaticPointerCast (cbm)); + BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance(); + event->setForAsynchronousCall(&listener); + event->setName(name); + BluetoothAdapterManager->setAdapterName(event); + } + else + { + LogDebug("same name is already set"); + cbm->callOnSuccess(); + } + } + Catch (WrtDeviceApis::Commons::ConversionException) + { + LogError("ConversionException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + + } + Catch (WrtDeviceApis::Commons::InvalidArgumentException) + { + LogError("InvalidArgumentException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::INVALID_VALUES_ERROR, "invalid values error")); + + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnsupportException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + + Catch (WrtDeviceApis::Commons::AlreadyInUseException) + { + LogError("AlreadyInUseException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::SERVICE_NOT_AVAILABLE, "blueetooth device busy")); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("UnkownException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "Unkown error"); + } + return JSValueMakeUndefined(context); +} + + +JSValueRef JSBluetoothAdapter::getAddress(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("Enter"); + + Converter converter(context); + JSBluetoothAdapterPriv *priv = static_cast(JSObjectGetPrivate(object)); + + Try + { + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject()); + std::string address = BluetoothAdapterManager->getAddress(); + return converter.toJSValueRef(address); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception"<<_rethrown_exception.GetMessage()); + } + + return NULL; + +} + + +JSValueRef JSBluetoothAdapter::getVisible(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("Enter"); + + Converter converter(context); + JSBluetoothAdapterPriv *priv = static_cast(JSObjectGetPrivate(object)); + Try + { + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject()); + bool visibility = BluetoothAdapterManager->getVisibility(); + return converter.toJSValueRef(visibility); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception"<<_rethrown_exception.GetMessage()); + } + + return NULL; + +} + + + +const JSClassRef JSBluetoothAdapter::getClassRef() +{ + if (!m_jsClassRef) + { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSBluetoothAdapter::getClassInfo() +{ + return &m_classInfo; +} + + +void JSBluetoothAdapter::initialize(JSContextRef context, JSObjectRef object) +{ + JSBluetoothAdapterPriv* priv = static_cast(JSObjectGetPrivate(object)); + + if (priv != NULL) + { + LogDebug("Already Exist"); + } + else + { + + IBluetoothAdapterManagerPtr BluetoothAdapterManager(BluetoothFactory::getInstance().getBluetoothAdapterManager()); + priv = new JSBluetoothAdapterPriv( context, BluetoothAdapterManager); + if(!JSObjectSetPrivate(object, static_cast(priv))) + { + LogError("Object can't store private data."); + delete priv; + } + LogDebug("JSBluetoothAdapter::initialize "); + } +} + +void JSBluetoothAdapter::finalize(JSObjectRef object) +{ + LogDebug("JSBluetoothAdapter::Finalrize"); + + JSBluetoothAdapterPriv* priv = static_cast(JSObjectGetPrivate(object)); + + if (priv != NULL) + { + JSObjectSetPrivate(object, NULL); + LogDebug("Deleting BluetoothAdapterManager"); + delete priv; + } + + +} + +bool JSBluetoothAdapter::hasInstance(JSContextRef context, JSObjectRef constructor, + JSValueRef possibleInstance, JSValueRef* exception) +{ + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + + +JSObjectRef JSBluetoothAdapter::createJSObject(JSContextRef context) +{ + IBluetoothAdapterManagerPtr BluetoothAdapterManager(BluetoothFactory::getInstance().getBluetoothAdapterManager()); + JSBluetoothAdapterPriv* priv = new JSBluetoothAdapterPriv( context, BluetoothAdapterManager); + + return JSObjectMake(context, getClassRef(), priv); + +} + +JSValueRef JSBluetoothAdapter::getPowered(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) + +{ + LogDebug("Enter"); + + Converter converter(context); + JSBluetoothAdapterPriv *priv = static_cast(JSObjectGetPrivate(object)); + + Try + { + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject()); + bool powered = BluetoothAdapterManager->getPowered(); + return converter.toJSValueRef(powered); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception"<<_rethrown_exception.GetMessage()); + } + + return NULL; +} + + +JSValueRef JSBluetoothAdapter::setPowered(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) +{ + + LogDebug("setPowered"); + + JSBluetoothAdapterPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + JSValueRef successCallback = NULL; + JSValueRef errorCallBack = NULL; + size_t index = 0; + JSValueRef reserveArguments[3]; + + if (priv == NULL) + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + } + + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL); + + Try + { + for (index = 0; index < 3; index++) + { + if (index < argumentCount) + reserveArguments[index] = arguments[index]; + else + reserveArguments[index] = JSValueMakeUndefined(context); + } + + LogDebug(bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_SET_POWERED]); + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_SET_POWERED]); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + BluetoothConverter converter(priv->getContext()); + + successCallback = converter.toFunctionOrNull(reserveArguments[1]); + errorCallBack = converter.toFunctionOrNull(reserveArguments[2]); + + if (cbm == NULL) + { + Throw(UnknownException); + } + + cbm->setOnSuccess(successCallback); + cbm->setOnError(errorCallBack); + + + + IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject()); + EventBTSetPoweredPtr event(new EventBTSetPowered); + + if (BluetoothAdapterManager == NULL || event == NULL) + { + LogError("BluetoothAdapterManager or event or listener NULL"); + Throw(UnknownException); + } + + bool powered = BluetoothAdapterManager->getPowered(); + LogDebug(converter.toBool(reserveArguments[0]) << converter.toString(reserveArguments[0])); + + if (converter.toBool(reserveArguments[0]) == true) + { + if (powered) + { + LogDebug("Already powered"); + cbm->callOnSuccess(); + return JSValueMakeUndefined(context); + } + else + { + event->setEnable(); + } + } + else + { + if (powered == false) + { + LogDebug("Already power off"); + cbm->callOnSuccess(); + return JSValueMakeUndefined(context); + } + else + { + event->setDisable(); + } + } + + event->setPrivateData(DPL::StaticPointerCast (cbm)); + BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance(); + event->setForAsynchronousCall(&listener); + BluetoothAdapterManager->setPowered(event); + } + Catch (WrtDeviceApis::Commons::ConversionException) + { + LogError("ConversionException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + + } + Catch (WrtDeviceApis::Commons::InvalidArgumentException) + { + LogError("InvalidArgumentException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::INVALID_VALUES_ERROR, "invalid values error")); + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnsupportException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + Catch (WrtDeviceApis::Commons::AlreadyInUseException) + { + LogError("AlreadyInUseException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::SERVICE_NOT_AVAILABLE, "blueetooth device busy")); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Exception"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "unknown error"); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSBluetoothAdapter::setVisible(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("setVisible"); + + JSBluetoothAdapterPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + JSValueRef successCallback = NULL; + JSValueRef errorCallBack = NULL; + size_t index = 0; + JSValueRef reserveArguments[4]; + + if (priv == NULL) + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + } + + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL); + + Try + { + for (index = 0; index < 4; index++) + { + if (index < argumentCount) + reserveArguments[index] = arguments[index]; + else + reserveArguments[index] = JSValueMakeUndefined(context); + + } + + LogDebug("check ace"); + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_SET_VISIBLE]); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + + BluetoothConverter converter(priv->getContext()); + + successCallback = converter.toFunctionOrNull(reserveArguments[1]); + errorCallBack = converter.toFunctionOrNull(reserveArguments[2]); + + + if (cbm == NULL) + { + Throw(UnknownException); + } + + cbm->setOnSuccess(successCallback); + cbm->setOnError(errorCallBack); + + + IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject()); + EventBTSetVisiblePtr event(new EventBTSetVisible); + + if (BluetoothAdapterManager == NULL || event == NULL) + { + LogError("BluetoothAdapterManager or event or listener NULL"); + Throw(UnknownException); + } + + if (converter.toBool(reserveArguments[0]) == true) + { + event->setVisible(); + } + else + { + event->setInvisible(); + } + + if (argumentCount == 4) + { + if (JSValueIsUndefined(context, reserveArguments[3]) == true || JSValueIsNull(context, reserveArguments[3]) == true) + { + event->setTimeout(0); + } + else + { + if (JSValueIsNumber(context, reserveArguments[3]) == false) + { + LogError("Wrong parameter passed"); + Throw(ConversionException); + } + } + LogDebug("timeout " << (short)converter.toInt(reserveArguments[3])); + short timeout = (short)converter.toInt(reserveArguments[3]); + + if (timeout < 0) + { + LogError("Wrong parameter passed, timemut should be > 0"); + Throw(ConversionException); + } + event->setTimeout((unsigned short)converter.toInt(reserveArguments[3])); + } + else + { + event->setTimeout(0); + } + + event->setPrivateData(DPL::StaticPointerCast (cbm)); + BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance(); + event->setForAsynchronousCall(&listener); + BluetoothAdapterManager->setVisible(event); + } + Catch (WrtDeviceApis::Commons::ConversionException) + { + LogError("ConversionException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + + } + Catch (WrtDeviceApis::Commons::InvalidArgumentException) + { + LogError("InvalidArgumentException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::INVALID_VALUES_ERROR, "invalid values error")); + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnsupportException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + Catch (WrtDeviceApis::Commons::AlreadyInUseException) + { + LogError("AlreadyInUseException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::SERVICE_NOT_AVAILABLE, "blueetooth device busy")); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Exception"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "unknown error"); + + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSBluetoothAdapter::discoveryDevices(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("discoveryDevices"); + JSBluetoothAdapterPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + size_t index = 0; + JSValueRef reserveArguments[2]; + JSValueRef errorArgument = JSValueMakeNull(context); + + Try + { + for (index = 0; index < 2; index++) + { + if (index < argumentCount) + reserveArguments[index] = arguments[index]; + else + reserveArguments[index] = JSValueMakeUndefined(context); + + } + + if (priv == NULL) + { + LogError("priv null"); + Throw(ConversionException); + } + + LogDebug(bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_DISCOVER_DEVICES]); + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_DISCOVER_DEVICES]); + + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + + if (argumentCount >= 2 && JSValueIsUndefined(context, reserveArguments[1]) == false) + { + errorArgument = reserveArguments[1]; + } + + BluetoothConverter converter(priv->getContext()); + EventBTOnDiscoveryDevicesPrivateDataPtr privData( + converter.toEventBTOnDiscoveryDevicesPrivateData(thisObject, reserveArguments[0], errorArgument)); + + IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject()); + EventBTOnDiscoveryDevicesEmitterPtr emitter(new EventBTOnDiscoveryDevicesEmitter); + + if (BluetoothAdapterManager == NULL || emitter == NULL || privData == NULL) + { + LogError("BluetoothAdapterManager or event or listener NULL"); + Throw(UnknownException); + } + emitter->setListener(&BluetoothAdapterListener::getInstance()); + emitter->setEventPrivateData(DPL::StaticPointerCast(privData)); + BluetoothAdapterManager->discoveryDevicesEmitter(emitter); + } + 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 value error"); + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnsupportException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + Catch (WrtDeviceApis::Commons::AlreadyInUseException) + { + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL); + LogError("AlreadyInUseException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::SERVICE_NOT_AVAILABLE, "blueetooth device busy")); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Exception"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "unknown error"); + } + return JSValueMakeUndefined(context); + +} + +JSValueRef JSBluetoothAdapter::stopDiscovery(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("discoveryDevices"); + JSBluetoothAdapterPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + JSValueRef successCallback = NULL; + JSValueRef errorCallBack = NULL; + size_t index = 0; + JSValueRef reserveArguments[2]; + + if (priv == NULL) + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + } + + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL); + + Try + { + for (index = 0; index < 2; index++) + { + if (index < argumentCount) + reserveArguments[index] = arguments[index]; + else + reserveArguments[index] = JSValueMakeUndefined(context); + + } + + LogDebug(bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_STOP_DISCOVERY]); + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_STOP_DISCOVERY]); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + BluetoothConverter converter(priv->getContext()); + + if (argumentCount >= 1 && JSValueIsUndefined(context, reserveArguments[0]) == false) + { + successCallback = converter.toFunctionOrNull(reserveArguments[0]); + } + + if (argumentCount >= 2 && JSValueIsUndefined(context, reserveArguments[1]) == false) + { + errorCallBack = converter.toFunctionOrNull(reserveArguments[1]); + } + + + if (cbm == NULL) + { + Throw(UnknownException); + } + + cbm->setOnSuccess(successCallback); + cbm->setOnError(errorCallBack); + + IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject()); + EventBTStopDiscoveryPtr event(new EventBTStopDiscovery); + + event->setPrivateData(DPL::StaticPointerCast (cbm)); + BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance(); + event->setForAsynchronousCall(&listener); + BluetoothAdapterManager->stopDiscovery(event); + } + Catch (WrtDeviceApis::Commons::ConversionException) + { + LogError("ConversionException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + + } + Catch (WrtDeviceApis::Commons::InvalidArgumentException) + { + LogError("InvalidArgumentException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::INVALID_VALUES_ERROR, "invalid values error")); + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnsupportException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Exception"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "unknown error"); + + } + + return JSValueMakeUndefined(context); + +} + + +JSValueRef JSBluetoothAdapter::getKnownDevices(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("getKnownDevices"); + JSBluetoothAdapterPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + JSValueRef successCallback = NULL; + JSValueRef errorCallBack = NULL; + + if (priv == NULL) + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + } + + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL); + size_t index = 0; + JSValueRef reserveArguments[2]; + + Try + { + for (index = 0; index < 2; index++) + { + if (index < argumentCount) + reserveArguments[index] = arguments[index]; + else + reserveArguments[index] = JSValueMakeUndefined(context); + + } + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_GET_KNOWN_DEVICES]); + + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + BluetoothConverter converter(priv->getContext()); + successCallback = converter.toFunction(reserveArguments[0]); + + if (argumentCount >= 2 && JSValueIsUndefined(context, reserveArguments[1]) == false) + { + errorCallBack = converter.toFunctionOrNull(reserveArguments[1]); + } + + if (cbm == NULL) + { + Throw(UnknownException); + } + + cbm->setOnSuccess(successCallback); + cbm->setOnError(errorCallBack); + + IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject()); + EventBTGetKnownDevicesPtr event(new EventBTGetKnownDevices); + + + if (BluetoothAdapterManager == NULL || event == NULL) + { + LogError("BluetoothAdapterManager or event or listener NULL"); + Throw(UnknownException); + } + + event->setPrivateData(DPL::StaticPointerCast (cbm)); + BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance(); + event->setForAsynchronousCall(&listener); + BluetoothAdapterManager->getKownDevices(event); + } + Catch (WrtDeviceApis::Commons::ConversionException) + { + LogError("ConversionException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + + } + Catch (WrtDeviceApis::Commons::InvalidArgumentException) + { + LogError("InvalidArgumentException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::INVALID_VALUES_ERROR, "invalid values error")); + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnsupportException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Exception"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "unknown error"); + + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSBluetoothAdapter::getDevice(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("Enter"); + JSBluetoothAdapterPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + JSValueRef successCallback = NULL; + JSValueRef errorCallBack = NULL; + size_t index = 0; + JSValueRef reserveArguments[3]; + + if (priv == NULL) + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + } + + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL); + + Try + { + for (index = 0; index < 3; index++) + { + if (index < argumentCount) + reserveArguments[index] = arguments[index]; + else + reserveArguments[index] = JSValueMakeUndefined(context); + + } + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_GET_DEVICE]); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + + BluetoothConverter converter(priv->getContext()); + successCallback = converter.toFunction(reserveArguments[1]); + errorCallBack = converter.toFunctionOrNull(reserveArguments[2]); + + if (cbm == NULL) + { + Throw(UnknownException); + } + + cbm->setOnSuccess(successCallback); + cbm->setOnError(errorCallBack); + + std::string address = converter.toBluetoothDeviceAddress(reserveArguments[0]); + + + IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject()); + EventBTGetDevicePtr event(new EventBTGetDevice); + + if (BluetoothAdapterManager == NULL || event == NULL) + { + LogError("BluetoothAdapterManager or event or listener NULL"); + Throw(UnknownException); + } + + event->setPrivateData(DPL::StaticPointerCast (cbm)); + BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance(); + event->setForAsynchronousCall(&listener); + event->setAddress(address); + BluetoothAdapterManager->getDevice(event); + } + Catch (WrtDeviceApis::Commons::ConversionException) + { + LogError("ConversionException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + + } + Catch (WrtDeviceApis::Commons::InvalidArgumentException) + { + LogError("InvalidArgumentException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::INVALID_VALUES_ERROR, "invalid values error")); + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnsupportException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + Catch (WrtDeviceApis::Commons::AlreadyInUseException) + { + LogError("AlreadyInUseException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::SERVICE_NOT_AVAILABLE, "blueetooth device busy")); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Exception"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "unknown error"); + + } + + return JSValueMakeUndefined(context);} + + +JSValueRef JSBluetoothAdapter::createBonding(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("createBonding"); + + JSBluetoothAdapterPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + JSValueRef successCallback = NULL; + JSValueRef errorCallBack = NULL; + size_t index = 0; + JSValueRef reserveArguments[3]; + + if (priv == NULL) + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + } + + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL); + + Try + { + + for (index = 0; index < 3; index++) + { + + if (index < argumentCount) + reserveArguments[index] = arguments[index]; + else + reserveArguments[index] = JSValueMakeUndefined(context); + } + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADPATER_CREATE_BONDING]); + + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + BluetoothConverter converter(priv->getContext()); + successCallback = converter.toFunction(reserveArguments[1]); + errorCallBack = converter.toFunctionOrNull(reserveArguments[2]); + + if (cbm == NULL) + { + Throw(UnknownException); + } + + cbm->setOnSuccess(successCallback); + cbm->setOnError(errorCallBack); + + std::string address = converter.toBluetoothDeviceAddress(reserveArguments[0]); + + + IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject()); + EventBTCreateDestroyBondingPtr event(new EventBTCreateDestroyBonding); + + if (BluetoothAdapterManager == NULL || event == NULL) + { + LogError("BluetoothAdapterManager or event or listener NULL"); + Throw(UnknownException); + } + BluetoothCreateBondingPrivateDataPtr privData(new BluetoothCreateBondingPrivateData(cbm, thisObject)); + +// event->setPrivateData(DPL::StaticPointerCast (cbm)); + event->setPrivateData(DPL::StaticPointerCast (privData)); + BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance(); + event->setForAsynchronousCall(&listener); + event->setAddress(address); + event->setCreateBonding(); + BluetoothAdapterManager->createBonding(event); + // temporarily remove pending operation +// JSValueRef pendingOperation = makePendingOperation(context, event); + //JSBluetoothDummyPendingOperation::createJSObject(context); + // return pendingOperation; + } + Catch (WrtDeviceApis::Commons::ConversionException) + { + LogError("ConversionException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + + } + Catch (WrtDeviceApis::Commons::InvalidArgumentException) + { + LogError("InvalidArgumentException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::INVALID_VALUES_ERROR, "invalid values error")); + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnsupportException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + Catch (WrtDeviceApis::Commons::AlreadyInUseException) + { + LogError("AlreadyInUseException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::SERVICE_NOT_AVAILABLE, "blueetooth device busy")); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Exception"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "unknown error"); + + } + return JSValueMakeUndefined(context); + +} + +JSValueRef JSBluetoothAdapter::destroyBonding(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) +{ + + LogDebug("destroyBonding"); + + JSBluetoothAdapterPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + JSValueRef successCallback = NULL; + JSValueRef errorCallBack = NULL; + size_t index = 0; + JSValueRef reserveArguments[3]; + + if (priv == NULL) + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + } + + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL); + + Try + { + for (index = 0; index < 3; index++) + { + if (index < argumentCount) + reserveArguments[index] = arguments[index]; + else + reserveArguments[index] = JSValueMakeUndefined(context); + } + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADPATER_DESTROY_BONDING]); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + BluetoothConverter converter(priv->getContext()); + successCallback = converter.toFunctionOrNull(reserveArguments[1]); + errorCallBack = converter.toFunctionOrNull(reserveArguments[2]); + + if (cbm == NULL) + { + Throw(UnknownException); + } + + cbm->setOnSuccess(successCallback); + cbm->setOnError(errorCallBack); + + std::string address = converter.toBluetoothDeviceAddress(reserveArguments[0]); + + IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject()); + EventBTCreateDestroyBondingPtr event(new EventBTCreateDestroyBonding); + + if (BluetoothAdapterManager == NULL || event == NULL) + { + LogError("BluetoothAdapterManager or event or listener NULL"); + Throw(UnknownException); + } + + BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance(); + event->setPrivateData(DPL::StaticPointerCast (cbm)); + event->setForAsynchronousCall(&listener); + event->setDestroyBonding(); + event->setAddress(address); + BluetoothAdapterManager->destroyBonding(event); + } + Catch (WrtDeviceApis::Commons::ConversionException) + { + LogError("ConversionException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + + } + Catch (WrtDeviceApis::Commons::InvalidArgumentException) + { + LogError("InvalidArgumentException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::INVALID_VALUES_ERROR, "invalid values error")); + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnsupportException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + Catch (WrtDeviceApis::Commons::AlreadyInUseException) + { + LogError("AlreadyInUseException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::SERVICE_NOT_AVAILABLE, "blueetooth device busy")); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Exception"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "unknown error"); + + } + + return JSValueMakeUndefined(context); +} + + +JSValueRef JSBluetoothAdapter::registerRFCOMMServiceByUUID(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("registerRFCOMMServiceByUUID"); + + JSBluetoothAdapterPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + JSValueRef successCallback = NULL; + JSValueRef errorCallBack = NULL; + + if (priv == NULL) + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + } + + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL); + size_t index = 0; + JSValueRef reserveArguments[4]; + + Try + { + for (index = 0; index < 4; index++) + { + if (index < argumentCount) + reserveArguments[index] = arguments[index]; + else + reserveArguments[index] = JSValueMakeUndefined(context); + } + + std::string serviceName, uuid; + unsigned short securityLevel= SECURITY_LEVEL_HIGH_VALUE_INT; + Validator validator(context); + + LogDebug("context address" << context << "priv-context" << priv->getContext()); + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADPATER_REGISTER_RFCOMM]); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + BluetoothConverter converter(priv->getContext()); + successCallback = converter.toFunction(reserveArguments[2]); + errorCallBack = converter.toFunctionOrNull(reserveArguments[3]); + + if (cbm == NULL) + { + Throw(UnknownException); + } + + cbm->setOnSuccess(successCallback); + cbm->setOnError(errorCallBack); + + + uuid = converter.toBluetoothUUIDString(reserveArguments[0]); + serviceName = converter.toString(reserveArguments[1]); + + + /*if (argumentCount >= 5) + { + securityLevel = converter.toBluetoothSecurityLevelInt(reserveArguments[4]); + }*/ + + + + IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject()); + EventBTRegisterRFCOMMPtr event(new EventBTRegisterRFCOMM); + + if (BluetoothAdapterManager == NULL || event == NULL) + { + LogError("BluetoothAdapterManager or event or listener NULL"); + Throw(UnknownException); + } + LogDebug("UUid:" << uuid << " serviceName:" << serviceName); + + BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance(); + event->setForAsynchronousCall(&listener); + event->setPrivateData(DPL::StaticPointerCast (cbm)); + event->setUuid(uuid); + event->setSecurityLevel(securityLevel); + event->setName(serviceName); + BluetoothAdapterManager->registerRFCOMMServiceByUUID(event); + } + Catch (WrtDeviceApis::Commons::ConversionException) + { + LogError("ConversionException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + + } + Catch (WrtDeviceApis::Commons::InvalidArgumentException) + { + LogError("InvalidArgumentException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::INVALID_VALUES_ERROR, "invalid values error")); + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnsupportException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + Catch (WrtDeviceApis::Commons::AlreadyInUseException) + { + LogError("AlreadyInUseException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::SERVICE_NOT_AVAILABLE, "blueetooth device busy")); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("AlreadyInUseException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "unknown error"); + + } + return JSValueMakeUndefined(context); + +} + + +} +} diff --git a/src/Bluetooth/JSBluetoothAdapter.h b/src/Bluetooth/JSBluetoothAdapter.h new file mode 100644 index 0000000..1123524 --- /dev/null +++ b/src/Bluetooth/JSBluetoothAdapter.h @@ -0,0 +1,151 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_ADAPTER_H_ +#define TIZENAPIS_TIZEN_JS_BLUETOOTH_ADAPTER_H_ + +#include +#include +#include "IBluetoothAdapterManager.h" +#include +#include + +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace WrtDeviceApis::Commons; + +namespace DeviceAPI { +namespace Bluetooth { + +typedef PrivateObjectT::Type JSBluetoothAdapterPriv; + +class BluetoothCreateBondingPrivateData : public IEventPrivateData +{ +public : + BluetoothCreateBondingPrivateData(const JSCallbackManagerPtr &callbackManager, + JSObjectRef object) : + m_callbackManager(callbackManager), + m_object(object) {} + + virtual ~BluetoothCreateBondingPrivateData() {} + + JSCallbackManagerPtr getCallbackManager() const {return m_callbackManager;} + JSObjectRef getObject() const {return m_object;}; +private: + JSCallbackManagerPtr m_callbackManager; + JSObjectRef m_object; +}; + +typedef DPL::SharedPtr BluetoothCreateBondingPrivateDataPtr; + + +class JSBluetoothAdapter { +public: + static const JSClassDefinition* getClassInfo(); + static const JSClassRef getClassRef(); + static JSObjectRef createJSObject(JSContextRef context); +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 setPowered( + JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef getPowered( + JSContextRef context, JSObjectRef object, + JSStringRef propertyName, JSValueRef* exception); + + static JSValueRef setVisible( + JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef getVisible( + JSContextRef context, JSObjectRef object, + JSStringRef propertyName, JSValueRef* exception); + + static JSValueRef setName( + 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 discoveryDevices( + JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef stopDiscovery( + JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + + static JSValueRef getKnownDevices( + JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + + static JSValueRef getDevice( + JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + + static JSValueRef createBonding( + JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef destroyBonding( + JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef registerRFCOMMServiceByUUID( + 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); + + static JSClassDefinition m_classInfo; + + static JSStaticFunction m_function[]; + static JSStaticValue m_properties[]; + + static JSClassRef m_jsClassRef; + static bool m_AdapterEnabled; +}; + +} +} + +#endif + diff --git a/src/Bluetooth/JSBluetoothClass.cpp b/src/Bluetooth/JSBluetoothClass.cpp new file mode 100644 index 0000000..b04b573 --- /dev/null +++ b/src/Bluetooth/JSBluetoothClass.cpp @@ -0,0 +1,309 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include "JSBluetoothClass.h" +#include "plugin_config.h" + + +using namespace std; +using namespace DPL; +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + +namespace DeviceAPI { +namespace Bluetooth { + +JSClassDefinition JSBluetoothClass::m_classInfo = +{ + 0, + kJSClassAttributeNone, + "BluetoothClass", + NULL, + m_properties, + m_function, + initialize, + finalize, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + hasInstance, + NULL +}; + + +JSStaticFunction JSBluetoothClass::m_function[] = +{ + { "hasService", JSBluetoothClass::hasService, kJSPropertyAttributeNone }, + + { 0, 0, 0 } +}; + + +JSStaticValue JSBluetoothClass::m_properties[] = +{ + {"major", JSBluetoothClass::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"minor", JSBluetoothClass::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"services", JSBluetoothClass::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {0, 0, 0, 0} +}; + + +const JSClassRef JSBluetoothClass::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSBluetoothClass::getClassInfo() +{ + return &m_classInfo; +} + +JSClassRef JSBluetoothClass::m_jsClassRef = JSClassCreate(JSBluetoothClass::getClassInfo()); + +void JSBluetoothClass::initialize(JSContextRef context, JSObjectRef object) +{ + LogDebug("JSBluetoothClass::initialize "); + JSBluetoothClassPriv* priv = static_cast(JSObjectGetPrivate(object)); + + if (priv == NULL) + { + BluetoothClassPtr btClass(new BluetoothClass()); + priv = new JSBluetoothClassPriv( context, btClass); + if(!JSObjectSetPrivate(object, static_cast(priv))) + { + LogError("Object can't store private data."); + delete priv; + } + } + else + { + LogDebug("JSBluetoothClass::already exist "); + } +} + + +JSObjectRef JSBluetoothClass::createJSObject(JSContextRef context) +{ + BluetoothClassPtr btClass(new BluetoothClass()); + JSBluetoothClassPriv* priv = new JSBluetoothClassPriv( context, btClass); + btClass->setReadOnly(); + + return JSObjectMake(context, getClassRef(), priv); +} + +JSObjectRef JSBluetoothClass::createJSObject(JSContextRef context, int device) +{ + BluetoothClassPtr btClass(new BluetoothClass()); + JSBluetoothClassPriv* priv = new JSBluetoothClassPriv( context, btClass); + + btClass->fromInt(device); + btClass->setReadOnly(); + + return JSObjectMake(context, getClassRef(), priv); + +} + +JSObjectRef JSBluetoothClass::createJSObject(JSContextRef context, BluetoothDeviceDataClass devClass) +{ + BluetoothClassPtr btClass(new BluetoothClass()); + JSBluetoothClassPriv* priv = new JSBluetoothClassPriv( context, btClass); + + btClass->setMajor(devClass.major); + btClass->setMinor(devClass.minor); + btClass->setServices(devClass.majorServiceMask); + btClass->setReadOnly(); + + LogDebug("Major:" << std::hex << devClass.major << "Minor:" << std::hex << devClass.minor << "ServiceClass:" << devClass.majorServiceMask); + + return JSObjectMake(context, getClassRef(), priv); +} + + +void JSBluetoothClass::finalize(JSObjectRef object) +{ + JSBluetoothClassPriv* priv = static_cast(JSObjectGetPrivate(object)); + + LogDebug("JSBluetoothClass::Finalrize"); + + if (priv != NULL) + { + JSObjectSetPrivate(object, NULL); + delete priv; + } +} + +bool JSBluetoothClass::hasInstance(JSContextRef context, JSObjectRef constructor, + JSValueRef possibleInstance, JSValueRef* exception) +{ + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + +JSValueRef JSBluetoothClass::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("OK"); + + Converter converter(context); + JSBluetoothClassPriv* priv = static_cast(JSObjectGetPrivate(object)); + + try + { + if (priv == NULL) + { + Throw(WrtDeviceApis::Commons::ConversionException); + } + + BluetoothClassPtr btClass(priv->getObject()); + std::string key = converter.toString(propertyName); + int value = 0; + + if (key == "major") + { + value = btClass->getMajor(); + return converter.toJSValueRef(value); + } + else if (key == "minor") + { + value = btClass->getMinor(); + return converter.toJSValueRef(value); + } + else if (key == "services") + { + std::vector service = btClass->getServices(); + JSObjectRef result = JSCreateArrayObject(context, 0, NULL); + + if (!result) + { + ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Could not create array object."); + } + + for (std::size_t i = 0; i < service.size(); ++i) + { + JSValueRef value = JSValueMakeNumber(context, service[i]); + + if (!JSSetArrayElement(context, result, i, value)) + { + ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Could not fill array."); + } + } + + return result; + } + else + { + btClass->find(key, value); + return converter.toJSValueRef(value); + } + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Unkwon Exception"); + } + return JSValueMakeNull(context); +} + +JSValueRef JSBluetoothClass::hasService(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) + +{ + JSBluetoothClassPriv* priv = static_cast(JSObjectGetPrivate(thisObject)); + JSValueRef reserveArgument = JSValueMakeUndefined(context); + + try + { + if (priv == NULL) + { + LogError("Private object is NULL"); + Throw(WrtDeviceApis::Commons::ConversionException); + } + + if (argumentCount >= 1) + { + reserveArgument = arguments[0]; + } + + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_BLUETOOTHCLASS_HAS_SERVICE]); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + BluetoothClassPtr btClass(priv->getObject()); + std::vector service = btClass->getServices(); + Converter converter(context); + int queryService = converter.toInt(reserveArgument); + int index = 0; + + for (index = 0; index < (int)service.size(); index++) + { + if (service[index] == queryService) + { + return converter.toJSValueRef(true); + } + } + return converter.toJSValueRef(false); + + } + Catch (WrtDeviceApis::Commons::InvalidArgumentException) + { + LogError("InvalidArgumentException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error"); + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnkownException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + Catch (WrtDeviceApis::Commons::SecurityException) + { + LogError("permission denied error"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::PERMISSION_DENIED_ERROR, "permission denied error"); + + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("UnkownException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "Unkown error"); + } +} +} +} + diff --git a/src/Bluetooth/JSBluetoothClass.h b/src/Bluetooth/JSBluetoothClass.h new file mode 100644 index 0000000..745d224 --- /dev/null +++ b/src/Bluetooth/JSBluetoothClass.h @@ -0,0 +1,70 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_CLASS_H_ +#define TIZENAPIS_TIZEN_JS_BLUETOOTH_CLASS_H_ + +#include + #include "BluetoothClass.h" +#include "BTDevice.h" + #include + +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; + + +namespace DeviceAPI { +namespace Bluetooth { + +typedef PrivateObjectT::Type JSBluetoothClassPriv; + +class JSBluetoothClass { +public: + static const JSClassDefinition* getClassInfo(); + static const JSClassRef getClassRef(); + static JSObjectRef createJSObject(JSContextRef context, BluetoothDeviceDataClass devClass); + static JSObjectRef createJSObject(JSContextRef context); + static JSObjectRef createJSObject(JSContextRef context, int device); + +private: + static void initialize(JSContextRef context, JSObjectRef object); + static void initConstants(); + static void finalize(JSObjectRef object); + static bool hasInstance(JSContextRef context, JSObjectRef constructor, + JSValueRef possibleInstance, JSValueRef* exception); + + static JSValueRef hasService(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef getProperty(JSContextRef context, JSObjectRef object, + JSStringRef propertyName, JSValueRef* exception); + + static JSClassDefinition m_classInfo; + static JSStaticFunction m_function[]; + static JSStaticValue m_properties[]; + + static JSClassRef m_jsClassRef; +}; + +} +} + +#endif + diff --git a/src/Bluetooth/JSBluetoothClassDeviceMajor.cpp b/src/Bluetooth/JSBluetoothClassDeviceMajor.cpp new file mode 100644 index 0000000..f4aba33 --- /dev/null +++ b/src/Bluetooth/JSBluetoothClassDeviceMajor.cpp @@ -0,0 +1,181 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include "JSBluetoothClassDeviceMajor.h" +#include "plugin_config.h" + + +using namespace std; +using namespace DPL; +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + + +namespace DeviceAPI { +namespace Bluetooth { + +JSClassDefinition JSBluetoothClassDeviceMajor::m_classInfo = +{ + 0, + kJSClassAttributeNone, + "BluetoothClassDeviceMajor", + NULL, + m_properties, + NULL, + initialize, + finalize, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + hasInstance, + NULL +}; + + + +JSStaticValue JSBluetoothClassDeviceMajor::m_properties[] = +{ + {"MISC", JSBluetoothClassDeviceMajor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"COMPUTER", JSBluetoothClassDeviceMajor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PHONE", JSBluetoothClassDeviceMajor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"NETWORK", JSBluetoothClassDeviceMajor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AUDIO_VIDEO", JSBluetoothClassDeviceMajor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PERIPHERAL", JSBluetoothClassDeviceMajor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"IMAGING", JSBluetoothClassDeviceMajor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"WEARABLE", JSBluetoothClassDeviceMajor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"TOY", JSBluetoothClassDeviceMajor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"HEALTH", JSBluetoothClassDeviceMajor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"UNCATEGORIZED", JSBluetoothClassDeviceMajor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {0, 0, 0, 0} +}; + + +const JSClassRef JSBluetoothClassDeviceMajor::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSBluetoothClassDeviceMajor::getClassInfo() +{ + return &m_classInfo; +} + +JSClassRef JSBluetoothClassDeviceMajor::m_jsClassRef = JSClassCreate(JSBluetoothClassDeviceMajor::getClassInfo()); + +void JSBluetoothClassDeviceMajor::initialize(JSContextRef context, JSObjectRef object) +{ + LogDebug("JSBluetoothClassDeviceMajor::initialize "); + JSBluetoothClassDeviceMajorPriv* priv = static_cast(JSObjectGetPrivate(object)); + + if (priv == NULL) + { + BluetoothClassPtr btClass(new BluetoothClass()); + priv = new JSBluetoothClassDeviceMajorPriv( context, btClass); + if(!JSObjectSetPrivate(object, static_cast(priv))) + { + LogError("Object can't store private data."); + delete priv; + } + } + else + { + LogDebug("JSBluetoothClassDeviceMajor::already exist "); + } +} + + +JSObjectRef JSBluetoothClassDeviceMajor::createJSObject(JSContextRef context) +{ + BluetoothClassPtr btClass(new BluetoothClass()); + JSBluetoothClassDeviceMajorPriv* priv = new JSBluetoothClassDeviceMajorPriv( context, btClass); + btClass->setReadOnly(); + + return JSObjectMake(context, getClassRef(), priv); +} + + +void JSBluetoothClassDeviceMajor::finalize(JSObjectRef object) +{ + JSBluetoothClassDeviceMajorPriv* priv = static_cast(JSObjectGetPrivate(object)); + + LogDebug("JSBluetoothClassDeviceMajor::Finalrize"); + + if (priv != NULL) + { + JSObjectSetPrivate(object, NULL); + delete priv; + } +} + +bool JSBluetoothClassDeviceMajor::hasInstance(JSContextRef context, JSObjectRef constructor, + JSValueRef possibleInstance, JSValueRef* exception) { + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + +JSValueRef JSBluetoothClassDeviceMajor::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("OK"); + + JSBluetoothClassDeviceMajorPriv* priv = static_cast(JSObjectGetPrivate(object)); + + try + { + + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + Converter converter(context); + BluetoothClassPtr btClass(priv->getObject()); + std::string key = converter.toString(propertyName); + int value = 0; + + if (btClass->find(key, value) == false) + { + ThrowMsg(WrtDeviceApis::Commons::UnknownException, "can not find property" << key); + } + return converter.toJSValueRef(value); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception"<<_rethrown_exception.GetMessage()); + } + + return NULL; +} +} +} + diff --git a/src/Bluetooth/JSBluetoothClassDeviceMajor.h b/src/Bluetooth/JSBluetoothClassDeviceMajor.h new file mode 100644 index 0000000..40fc9ee --- /dev/null +++ b/src/Bluetooth/JSBluetoothClassDeviceMajor.h @@ -0,0 +1,59 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_CLASS_DEVICE_MAJOR_H_ +#define TIZENAPIS_TIZEN_JS_BLUETOOTH_CLASS_DEVICE_MAJOR_H_ + +#include +#include "BluetoothClass.h" +#include "BTDevice.h" +#include + + +namespace DeviceAPI { +namespace Bluetooth { + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSBluetoothClassDeviceMajorPriv; + +class JSBluetoothClassDeviceMajor { +public: + static const JSClassDefinition* getClassInfo(); + static const JSClassRef getClassRef(); + static JSObjectRef createJSObject(JSContextRef context); + +private: + static void initialize(JSContextRef context, JSObjectRef object); + static void initConstants(); + static void finalize(JSObjectRef object); + static bool hasInstance(JSContextRef context, JSObjectRef constructor, + JSValueRef possibleInstance, JSValueRef* exception); + static JSValueRef getProperty(JSContextRef context, JSObjectRef object, + JSStringRef propertyName, JSValueRef* exception); + + static JSClassDefinition m_classInfo; + static JSStaticValue m_properties[]; + + static JSClassRef m_jsClassRef; +}; + +} +} + +#endif + + diff --git a/src/Bluetooth/JSBluetoothClassDeviceMinor.cpp b/src/Bluetooth/JSBluetoothClassDeviceMinor.cpp new file mode 100644 index 0000000..e702073 --- /dev/null +++ b/src/Bluetooth/JSBluetoothClassDeviceMinor.cpp @@ -0,0 +1,244 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include "JSBluetoothClassDeviceMinor.h" +#include "plugin_config.h" + + +using namespace std; +using namespace DPL; +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + + +namespace DeviceAPI { +namespace Bluetooth { + +JSClassDefinition JSBluetoothClassDeviceMinor::m_classInfo = +{ + 0, + kJSClassAttributeNone, + "BluetoothClassDeviceMinor", + NULL, + m_properties, + NULL, + initialize, + finalize, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + hasInstance, + NULL +}; + + +JSStaticValue JSBluetoothClassDeviceMinor::m_properties[] = +{ + {"COMPUTER_UNCATEGORIZED", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"COMPUTER_DESKTOP", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"COMPUTER_SERVER", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"COMPUTER_LAPTOP", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"COMPUTER_HANDHELD_PC_OR_PDA", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"COMPUTER_PALM_PC_OR_PDA", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"COMPUTER_WEARABLE", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PHONE_UNCATEGORIZED", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PHONE_CELLULAR", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PHONE_CORDLESS", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PHONE_SMARTPHONE", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PHONE_MODEM_OR_GATEWAY", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PHONE_ISDN", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_UNRECOGNIZED", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_WEARABLE_HEADSET", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_HANDSFREE", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_MICROPHONE", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_LOUDSPEAKER", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_HEADPHONES", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_PORTABLE_AUDIO", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_CAR_AUDIO", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_SETTOP_BOX", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_HIFI", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_VCR", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_VIDEO_CAMERA", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_CAMCORDER", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_MONITOR", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_DISPLAY_AND_LOUDSPEAKER", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_VIDEO_CONFERENCING", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AV_GAMING_TOY", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PERIPHERAL_UNCATEGORIZED", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PERIPHERAL_KEYBOARD", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PERIPHERAL_POINTING_DEVICE", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PERIPHERAL_KEYBOARD_AND_POINTING_DEVICE", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PERIPHERAL_JOYSTICK", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PERIPHERAL_GAMEPAD", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PERIPHERAL_REMOTE_CONTROL", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PERIPHERAL_SENSING_DEVICE", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PERIPHERAL_DEGITIZER_TABLET", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PERIPHERAL_CARD_READER", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PERIPHERAL_DIGITAL_PEN", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PERIPHERAL_HANDHELD_SCANNER", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"PERIPHERAL_HANDHELD_INPUT_DEVICE", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"IMAGING_UNCATEGORIZED", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"IMAGING_DISPLAY", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"IMAGING_CAMERA", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"IMAGING_SCANNER", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"IMAGING_PRINTER", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"WEARABLE_WRITST_WATCH", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"WEARABLE_PAGER", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"WEARABLE_JACKET", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"WEARABLE_HELMET", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"WEARABLE_GLASSES", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"TOY_ROBOT", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"TOY_VEHICLE", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"TOY_DOLL", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"TOY_CONTROLLER", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"TOY_GAME", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"HEALTH_UNDEFINED", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"HEALTH_BLOOD_PRESSURE_MONITOR", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"HEALTH_THERMOMETER", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"HEALTH_WEIGHING_SCALE", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"HEALTH_GLUCOSE_METER", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"HEALTH_PULSE_OXIMETER", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"HEALTH_PULSE_RATE_MONITOR", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"HEALTH_DATA_DISPLAY", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"HEALTH_STEP_COUNTER", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"HEALTH_BODY_COMPOSITION_ANALYZER", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"HEALTH_PEAK_FLOW_MONITOR", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"HEALTH_MEDICATION_MONITOR", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"HEALTH_KNEE_PROSTHESIS", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"HEALTH_ANKLE_PROSTHESIS", JSBluetoothClassDeviceMinor::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {0, 0, 0, 0} +}; + + +const JSClassRef JSBluetoothClassDeviceMinor::getClassRef() +{ + if (!m_jsClassRef) + { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSBluetoothClassDeviceMinor::getClassInfo() +{ + return &m_classInfo; +} + +JSClassRef JSBluetoothClassDeviceMinor::m_jsClassRef = JSClassCreate(JSBluetoothClassDeviceMinor::getClassInfo()); + +void JSBluetoothClassDeviceMinor::initialize(JSContextRef context, JSObjectRef object) +{ + LogDebug("JSBluetoothClassDeviceMinor::initialize "); + JSBluetoothClassDeviceMinorPriv* priv = static_cast(JSObjectGetPrivate(object)); + + if (priv == NULL) + { + BluetoothClassPtr btClass(new BluetoothClass()); + priv = new JSBluetoothClassDeviceMinorPriv( context, btClass); + if(!JSObjectSetPrivate(object, static_cast(priv))) + { + LogError("Object can't store private data."); + delete priv; + } + } + else + { + LogDebug("JSBluetoothClassDeviceMinor::already exist "); + } +} + + +JSObjectRef JSBluetoothClassDeviceMinor::createJSObject(JSContextRef context) +{ + BluetoothClassPtr btClass(new BluetoothClass()); + JSBluetoothClassDeviceMinorPriv* priv = new JSBluetoothClassDeviceMinorPriv( context, btClass); + btClass->setReadOnly(); + + return JSObjectMake(context, getClassRef(), priv); +} + + +void JSBluetoothClassDeviceMinor::finalize(JSObjectRef object) +{ + JSBluetoothClassDeviceMinorPriv* priv = static_cast(JSObjectGetPrivate(object)); + + LogDebug("JSBluetoothClassDeviceMinor::Finalrize"); + + if (priv != NULL) + { + JSObjectSetPrivate(object, NULL); + delete priv; + } +} + +bool JSBluetoothClassDeviceMinor::hasInstance(JSContextRef context, JSObjectRef constructor, + JSValueRef possibleInstance, JSValueRef* exception) +{ + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + +JSValueRef JSBluetoothClassDeviceMinor::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("OK"); + + Converter converter(context); + JSBluetoothClassDeviceMinorPriv* priv = static_cast(JSObjectGetPrivate(object)); + + try + { + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + Converter converter(context); + BluetoothClassPtr btClass(priv->getObject()); + std::string key = converter.toString(propertyName); + int value = 0; + + if (btClass->find(key, value) == false) + { + ThrowMsg(WrtDeviceApis::Commons::UnknownException, "can not find property" << key); + } + return converter.toJSValueRef(value); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception"<<_rethrown_exception.GetMessage()); + } + + return NULL; +} +} +} + diff --git a/src/Bluetooth/JSBluetoothClassDeviceMinor.h b/src/Bluetooth/JSBluetoothClassDeviceMinor.h new file mode 100644 index 0000000..cfee85e --- /dev/null +++ b/src/Bluetooth/JSBluetoothClassDeviceMinor.h @@ -0,0 +1,58 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_CLASS_H_ +#define TIZENAPIS_TIZEN_JS_BLUETOOTH_CLASS_H_ + +#include + #include "BluetoothClass.h" +#include "BTDevice.h" + #include + + namespace DeviceAPI { + namespace Bluetooth { + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSBluetoothClassDeviceMinorPriv; + +class JSBluetoothClassDeviceMinor +{ +public: + static const JSClassDefinition* getClassInfo(); + static const JSClassRef getClassRef(); + static JSObjectRef createJSObject(JSContextRef context); + +private: + static void initialize(JSContextRef context, JSObjectRef object); + static void initConstants(); + static void finalize(JSObjectRef object); + static bool hasInstance(JSContextRef context, JSObjectRef constructor, + JSValueRef possibleInstance, JSValueRef* exception); + static JSValueRef getProperty(JSContextRef context, JSObjectRef object, + JSStringRef propertyName, JSValueRef* exception); + + static JSClassDefinition m_classInfo; + static JSStaticValue m_properties[]; + + static JSClassRef m_jsClassRef; +}; + +} +} + +#endif + diff --git a/src/Bluetooth/JSBluetoothClassDeviceService.cpp b/src/Bluetooth/JSBluetoothClassDeviceService.cpp new file mode 100644 index 0000000..817e811 --- /dev/null +++ b/src/Bluetooth/JSBluetoothClassDeviceService.cpp @@ -0,0 +1,181 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include "JSBluetoothClassDeviceService.h" +#include "plugin_config.h" + + +using namespace std; +using namespace DPL; +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + + +namespace DeviceAPI { +namespace Bluetooth { + +JSClassDefinition JSBluetoothClassDeviceService::m_classInfo = +{ + 0, + kJSClassAttributeNone, + "BluetoothClassDeviceService", + NULL, + m_properties, + NULL, + initialize, + finalize, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + hasInstance, + NULL +}; + + + +JSStaticValue JSBluetoothClassDeviceService::m_properties[] = +{ + {"LIMITED_DISCOVERABILITY", JSBluetoothClassDeviceService::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"POSITIONING", JSBluetoothClassDeviceService::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"NETWORKING", JSBluetoothClassDeviceService::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"RENDERING", JSBluetoothClassDeviceService::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"CAPTURING", JSBluetoothClassDeviceService::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"OBJECT_TRANSFER", JSBluetoothClassDeviceService::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"AUDIO", JSBluetoothClassDeviceService::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"TELEPHONY", JSBluetoothClassDeviceService::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {"INFORMATION", JSBluetoothClassDeviceService::getProperty, NULL, kJSPropertyAttributeReadOnly }, + {0, 0, 0, 0} +}; + + +const JSClassRef JSBluetoothClassDeviceService::getClassRef() +{ + if (!m_jsClassRef) + { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSBluetoothClassDeviceService::getClassInfo() +{ + return &m_classInfo; +} + +JSClassRef JSBluetoothClassDeviceService::m_jsClassRef = JSClassCreate(JSBluetoothClassDeviceService::getClassInfo()); + +void JSBluetoothClassDeviceService::initialize(JSContextRef context, JSObjectRef object) +{ + LogDebug("JSBluetoothClassDeviceService::initialize "); + JSBluetoothClassDeviceServicePriv* priv = static_cast(JSObjectGetPrivate(object)); + + if (priv == NULL) + { + BluetoothClassPtr btClass(new BluetoothClass()); + priv = new JSBluetoothClassDeviceServicePriv( context, btClass); + if(!JSObjectSetPrivate(object, static_cast(priv))) + { + LogError("Object can't store private data."); + delete priv; + } + } + else + { + LogDebug("JSBluetoothClassDeviceService::already exist "); + } +} + + +JSObjectRef JSBluetoothClassDeviceService::createJSObject(JSContextRef context) +{ + BluetoothClassPtr btClass(new BluetoothClass()); + JSBluetoothClassDeviceServicePriv* priv = new JSBluetoothClassDeviceServicePriv( context, btClass); + btClass->setReadOnly(); + + return JSObjectMake(context, getClassRef(), priv); +} + +void JSBluetoothClassDeviceService::finalize(JSObjectRef object) +{ + JSBluetoothClassDeviceServicePriv* priv = static_cast(JSObjectGetPrivate(object)); + + LogDebug("JSBluetoothClassDeviceService::Finalrize"); + + if (priv != NULL) + { + JSObjectSetPrivate(object, NULL); + delete priv; + } +} + +bool JSBluetoothClassDeviceService::hasInstance(JSContextRef context, JSObjectRef constructor, + JSValueRef possibleInstance, JSValueRef* exception) +{ + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + +JSValueRef JSBluetoothClassDeviceService::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("OK"); + + Converter converter(context); + JSBluetoothClassDeviceServicePriv* priv = static_cast(JSObjectGetPrivate(object)); + + try + { + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + BluetoothClassPtr btClass(priv->getObject()); + std::string key = converter.toString(propertyName); + int value = 0; + + if (btClass->find(key, value) == false) + { + ThrowMsg(WrtDeviceApis::Commons::UnknownException, "can not find property" << key); + } + return converter.toJSValueRef(value); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception"<<_rethrown_exception.GetMessage()); + } + + return NULL; +} +} +} + + diff --git a/src/Bluetooth/JSBluetoothClassDeviceService.h b/src/Bluetooth/JSBluetoothClassDeviceService.h new file mode 100644 index 0000000..035bf8c --- /dev/null +++ b/src/Bluetooth/JSBluetoothClassDeviceService.h @@ -0,0 +1,57 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_CLASS_DEVICE_SERVICE_H_ +#define TIZENAPIS_TIZEN_JS_BLUETOOTH_CLASS_DEVICE_SERVICE_H_ + +#include +#include "BluetoothClass.h" +#include "BTDevice.h" +#include + +namespace DeviceAPI { +namespace Bluetooth { + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSBluetoothClassDeviceServicePriv; + +class JSBluetoothClassDeviceService +{ +public: + static const JSClassDefinition* getClassInfo(); + static const JSClassRef getClassRef(); + static JSObjectRef createJSObject(JSContextRef context); + + +private: + static void initialize(JSContextRef context, JSObjectRef object); + static void initConstants(); + static void finalize(JSObjectRef object); + static bool hasInstance(JSContextRef context, JSObjectRef constructor, + JSValueRef possibleInstance, JSValueRef* exception); + + static JSValueRef getProperty(JSContextRef context, JSObjectRef object, + JSStringRef propertyName, JSValueRef* exception); + static JSClassDefinition m_classInfo; + static JSStaticValue m_properties[]; + static JSClassRef m_jsClassRef; +}; +} +} + +#endif + + diff --git a/src/Bluetooth/JSBluetoothDevice.cpp b/src/Bluetooth/JSBluetoothDevice.cpp new file mode 100644 index 0000000..7d60493 --- /dev/null +++ b/src/Bluetooth/JSBluetoothDevice.cpp @@ -0,0 +1,504 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include "JSBluetoothDevice.h" +#include "IBluetoothDeviceManager.h" +#include "BluetoothFactory.h" +#include "BluetoothDeviceManagerListener.h" +#include "BluetoothProperty.h" +#include "JSBluetoothClass.h" +#include "BluetoothConverter.h" +#include "plugin_config.h" + +using namespace std; +using namespace DPL; +using namespace WrtDeviceApis; +using namespace DeviceAPI::Common; + +namespace DeviceAPI { +namespace Bluetooth { + +JSClassDefinition JSBluetoothDevice::m_classInfo = +{ + 0, + kJSClassAttributeNone, + "BluetoothDevice", + NULL, + m_properties, + m_function, + initialize, + finalize, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + hasInstance, + NULL +}; + +JSStaticFunction JSBluetoothDevice::m_function[] = +{ + { "connectToServiceByUUID", JSBluetoothDevice::connectToServiceByUUID, kJSPropertyAttributeNone }, + { 0, 0, 0 } +}; + +JSStaticValue JSBluetoothDevice::m_properties[] = { + {"name", getName, NULL, kJSPropertyAttributeReadOnly}, + {"address", getAddress, NULL, kJSPropertyAttributeReadOnly}, + {"deviceClass", getDeviceClass, NULL, kJSPropertyAttributeReadOnly}, + {"isBonded", getBondProperty, NULL, kJSPropertyAttributeReadOnly}, + {"isTrusted", getTrustProperty, NULL, kJSPropertyAttributeReadOnly}, + {"isConnected", getConnectProperty, NULL, kJSPropertyAttributeReadOnly}, + {"uuids", getUuids, NULL, kJSPropertyAttributeReadOnly}, + {0, 0, 0, 0} +}; + +const JSClassRef JSBluetoothDevice::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSBluetoothDevice::getClassInfo() +{ + return &m_classInfo; +} + +JSClassRef JSBluetoothDevice::m_jsClassRef = JSClassCreate(JSBluetoothDevice::getClassInfo()); + +JSObjectRef JSBluetoothDevice::m_deviceClass = NULL; + +void JSBluetoothDevice::initialize(JSContextRef context, JSObjectRef object) +{ + LogDebug("initialize "); + + JSBluetoothDevicePriv *priv = static_cast(JSObjectGetPrivate(object)); + + if (priv == NULL) + { + IBluetoothDeviceManagerPtr BluetoothManager(BluetoothFactory::getInstance().getBluetoothDeviceManager()); + priv = new JSBluetoothDevicePriv( context, BluetoothManager); + + if(!JSObjectSetPrivate(object, static_cast(priv))) + { + LogError("Object can't store private data."); + delete priv; + } + } + else + { + LogDebug("already exist"); + } + + +} + +void JSBluetoothDevice::finalize(JSObjectRef object) +{ + LogDebug("Finalrize"); + + JSBluetoothDevicePriv* priv = static_cast(JSObjectGetPrivate(object)); + + if (priv != NULL) + { + JSObjectSetPrivate(object, NULL); + LogDebug("Deleting BluetoothManager"); + delete priv; + } +} + + +bool JSBluetoothDevice::hasInstance(JSContextRef context, JSObjectRef constructor, + JSValueRef possibleInstance, JSValueRef* exception) +{ + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + + +JSObjectRef JSBluetoothDevice::createJSObject(JSContextRef context, BluetoothDeviceData device) +{ + IBluetoothDeviceManagerPtr BluetoothManager(BluetoothFactory::getInstance().getBluetoothDeviceManager()); + BluetoothManager->setDevice(device); + + JSBluetoothDevicePriv* priv = new JSBluetoothDevicePriv( context, BluetoothManager); + return JSObjectMake(context, getClassRef(), priv); +} + + + +JSValueRef JSBluetoothDevice::getName(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("Enter"); + + Converter converter(context); + JSBluetoothDevicePriv *priv = static_cast(JSObjectGetPrivate(object)); + + Try + { + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject()); + std::string name = BluetoothDeviceManager->getNameProperty(); + LogDebug("name" << name); + return converter.toJSValueRef(name); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception"<<_rethrown_exception.GetMessage()); + } + + return NULL; +} + +JSValueRef JSBluetoothDevice::getAddress(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("Enter"); + + Converter converter(context); + JSBluetoothDevicePriv *priv = static_cast(JSObjectGetPrivate(object)); + + Try + { + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject()); + std::string address = BluetoothDeviceManager->getAddressProperty(); + + LogDebug("address" << address); + return converter.toJSValueRef(address); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception"<<_rethrown_exception.GetMessage()); + } + + return NULL; +} +JSValueRef JSBluetoothDevice::getDeviceClass(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("Enter"); + + if(m_deviceClass == NULL) + { + JSBluetoothDevicePriv *priv = static_cast(JSObjectGetPrivate(object)); + + Try + { + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject()); + BluetoothDeviceDataClass devClass = BluetoothDeviceManager->getClass(); + + LogDebug("Major:" << std::hex << devClass.major << "Minor:" << std::hex << devClass.minor << "Service Mask:" << std::hex << devClass.majorServiceMask); + + m_deviceClass = JSBluetoothClass::createJSObject(priv->getContext(), devClass); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception"<<_rethrown_exception.GetMessage()); + return JSValueMakeUndefined(context); + } + } + + return m_deviceClass; + +} +JSValueRef JSBluetoothDevice::getBondProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("Enter"); + + Converter converter(context); + JSBluetoothDevicePriv *priv = static_cast(JSObjectGetPrivate(object)); + + Try + { + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject()); + bool isBonded = BluetoothDeviceManager->getBondProperty(); + + LogDebug("isBonded " << isBonded); + + return converter.toJSValueRef(isBonded); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception"<<_rethrown_exception.GetMessage()); + } + + return JSValueMakeUndefined(context); +} +JSValueRef JSBluetoothDevice::getTrustProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("Enter"); + + Converter converter(context); + JSBluetoothDevicePriv *priv = static_cast(JSObjectGetPrivate(object)); + + Try + { + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject()); + bool isTrusted = BluetoothDeviceManager->getTrustProperty(); + + LogDebug("isTrusted " << isTrusted); + return converter.toJSValueRef(isTrusted); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception"<<_rethrown_exception.GetMessage()); + } + + return JSValueMakeUndefined(context); +} +JSValueRef JSBluetoothDevice::getConnectProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("Enter"); + + Converter converter(context); + JSBluetoothDevicePriv *priv = static_cast(JSObjectGetPrivate(object)); + + Try + { + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject()); + bool isConnected = BluetoothDeviceManager->getConnectProperty(); + + LogDebug("isConnected " << isConnected); + return converter.toJSValueRef(isConnected); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception"<<_rethrown_exception.GetMessage()); + } + + return JSValueMakeUndefined(context); +} + +JSValueRef JSBluetoothDevice::getUuids(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("Enter"); + + Converter converter(context); + JSBluetoothDevicePriv *priv = static_cast(JSObjectGetPrivate(object)); + + Try + { + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject()); + std::vector uuids = BluetoothDeviceManager->getUuidsProperty(); + JSObjectRef result = JSCreateArrayObject(context, 0, NULL); + int length = uuids.size(); + + if (!result) + { + return converter.toJSValueRef(""); + } + + for (int i = 0; i < length; ++i) + { + JSValueRef value = converter.toJSValueRef(uuids[i]); + + if (!JSSetArrayElement(context, result, i, value)) + { + return converter.toJSValueRef(""); + } + } + + return result; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception"<<_rethrown_exception.GetMessage()); + } + + return JSValueMakeUndefined(context); +} + + + + +JSValueRef JSBluetoothDevice::connectToServiceByUUID(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) { + + LogDebug("connectToServiceByUUID"); + + JSBluetoothDevicePriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + JSValueRef successCallback = NULL; + JSValueRef errorCallBack = NULL; + size_t index = 0; + JSValueRef reserveArguments[3]; + + if (priv == NULL) + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + } + + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL); + + Try { + + for (index = 0; index < 3; index++) + { + if (index < argumentCount) + reserveArguments[index] = arguments[index]; + else + reserveArguments[index] = JSValueMakeNull(context); + + } + + LogDebug(bluetoothExportedNames[BLUETOOTH_FUNCTION_API_DEVICE_CONNECT_TO_SERVICE]); + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_DEVICE_CONNECT_TO_SERVICE]); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + + BluetoothConverter converter(context); + successCallback = converter.toFunction(reserveArguments[1]); + errorCallBack = converter.toFunctionOrNull(reserveArguments[2]); + + + if (cbm == NULL) + { + return JSValueMakeUndefined(context); + } + cbm->setOnSuccess(successCallback); + cbm->setOnError(errorCallBack); + + IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject()); + EventBTConnectToServiceByUUIDPtr event(new EventBTConnectToServiceByUUID); + BluetoothSocketData socketData; + socketData.uuid = converter.toBluetoothUUIDString(reserveArguments[0]); + socketData.protocol = PROTOCOL_TYPE_RFCOMM_VALUE_INT; + +/* if (argumentCount >= 4) + { + socketData.protocol = converter.toBluetoothProtocolInt(reserveArguments[3]); + }*/ + + + if (BluetoothDeviceManager == NULL || event == NULL) + { + LogError("BluetoothDeviceManager or event or listener NULL"); + Throw(WrtDeviceApis::Commons::UnknownException); + } + + event->setPrivateData(DPL::StaticPointerCast (cbm)); + + event->setForAsynchronousCall(&BluetoothDeviceManagerListener::getInstance()); + event->setSocketData(socketData); + BluetoothDeviceManager->connectToServiceByUUID(event); + } + 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::TYPE_MISMATCH_ERROR, "invalid value error"); + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnsupportException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + + Catch (WrtDeviceApis::Commons::AlreadyInUseException) + { + LogError("AlreadyInUseException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::SERVICE_NOT_AVAILABLE, "already connected")); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Exception"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "unknown error"); + } + + return JSValueMakeUndefined(context); +} +} +} + diff --git a/src/Bluetooth/JSBluetoothDevice.h b/src/Bluetooth/JSBluetoothDevice.h new file mode 100644 index 0000000..848d1fa --- /dev/null +++ b/src/Bluetooth/JSBluetoothDevice.h @@ -0,0 +1,67 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_DEVICE_H_ +#define TIZENAPIS_TIZEN_JS_BLUETOOTH_DEVICE_H_ + +#include +#include "IBluetoothDeviceManager.h" +#include + +using namespace WrtDeviceApis::CommonsJavaScript; + +namespace DeviceAPI { +namespace Bluetooth { + +typedef PrivateObjectT::Type JSBluetoothDevicePriv; + +class JSBluetoothDevice +{ +public: + static const JSClassDefinition* getClassInfo(); + static const JSClassRef getClassRef(); + static JSObjectRef createJSObject(JSContextRef context, BluetoothDeviceData device); + + +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 getName(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef getAddress(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef getDeviceClass(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef getBondProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef getTrustProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef getConnectProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef getUuids(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef connectToServiceByUUID(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + static JSClassDefinition m_classInfo; + static JSStaticFunction m_function[]; + static JSStaticValue m_properties[]; + static JSClassRef m_jsClassRef; + static JSObjectRef m_deviceClass; +}; + +} +} + +#endif + diff --git a/src/Bluetooth/JSBluetoothManager.cpp b/src/Bluetooth/JSBluetoothManager.cpp new file mode 100644 index 0000000..28546b1 --- /dev/null +++ b/src/Bluetooth/JSBluetoothManager.cpp @@ -0,0 +1,234 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include "BluetoothFactory.h" +#include "IBluetoothAdapterManager.h" +#include "BluetoothProperty.h" +#include "JSBluetoothManager.h" +#include "JSBluetoothAdapter.h" +#include "JSBluetoothClassDeviceMajor.h" +#include "JSBluetoothClassDeviceMinor.h" +#include "JSBluetoothClassDeviceService.h" +#include "plugin_config.h" + +using namespace WrtDeviceApis::Commons; +using namespace DeviceAPI::Common; + +namespace { + #define DEVICE_MAJOR "deviceMajor" + #define DEVICE_MINOR "deviceMinor" + #define DEVICE_SERVICE "deviceService" +} + +namespace DeviceAPI { +namespace Bluetooth { + +JSClassRef JSBluetoothManager::m_jsClassRef = NULL; +JSObjectRef JSBluetoothManager::m_deviceMajor = NULL; +JSObjectRef JSBluetoothManager::m_deviceMinor = NULL; +JSObjectRef JSBluetoothManager::m_deviceService = NULL; + + +JSClassDefinition JSBluetoothManager::m_classInfo = +{ + 0, + kJSClassAttributeNone, + "BluetoothManager", + NULL, + m_properties, + m_function, + initialize, + finalize, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL +}; + + +JSStaticFunction JSBluetoothManager::m_function[] = +{ + { "getDefaultAdapter", getDefaultAdapter, kJSPropertyAttributeNone }, + { 0, 0, 0 } +}; + + +JSStaticValue JSBluetoothManager::m_properties[] = +{ + {DEVICE_MAJOR, getProperty, NULL, kJSPropertyAttributeReadOnly}, + {DEVICE_MINOR, getProperty, NULL, kJSPropertyAttributeReadOnly}, + {DEVICE_SERVICE, getProperty, NULL, kJSPropertyAttributeReadOnly}, + {0, 0, 0, 0} +}; + + + +const JSClassRef JSBluetoothManager::getClassRef() +{ + if (!m_jsClassRef) + { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +JSValueRef JSBluetoothManager::getDefaultAdapter(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) +{ + JSBluetoothManagerPriv* priv = static_cast(JSObjectGetPrivate(thisObject)); + + LogDebug("OK"); + + Try + { + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_MANAGER_GET_DEFAULT_ADAPTER]); + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + JSContextRef globalContext = priv->getContext(); + + return JSBluetoothAdapter::createJSObject(globalContext); + } + Catch (WrtDeviceApis::Commons::SecurityException) + { + LogError("permission denied error"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::PERMISSION_DENIED_ERROR, "permission denied error"); + + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnkownException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("UnkownException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "Unkown error"); + } +} + + +JSValueRef JSBluetoothManager::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("OK"); + + Try + { + if(JSStringIsEqualToUTF8CString(propertyName, DEVICE_MAJOR)) + { + if(!m_deviceMajor) + m_deviceMajor = JSBluetoothClassDeviceMajor::createJSObject(context); + return m_deviceMajor; + } + else if(JSStringIsEqualToUTF8CString(propertyName, DEVICE_MINOR)) + { + if(!m_deviceMinor) + m_deviceMinor = JSBluetoothClassDeviceMinor::createJSObject(context); + return m_deviceMinor; + } + else if(JSStringIsEqualToUTF8CString(propertyName, DEVICE_SERVICE)) + { + if(!m_deviceService) + m_deviceService = JSBluetoothClassDeviceService::createJSObject(context); + return m_deviceService; + } + + } + Catch (Exception) + { + LogWarning("Exception "<<_rethrown_exception.GetMessage()); + } + + return NULL; +} + + + +const JSClassDefinition* JSBluetoothManager::getClassInfo() +{ + return &m_classInfo; +} + + +void JSBluetoothManager::initialize(JSContextRef context, JSObjectRef object) +{ + JSBluetoothManagerPriv *priv = static_cast(JSObjectGetPrivate(object)); + LogDebug("JSBluetoothManager::initialize"); + + if (priv != NULL) + { + LogError("already exist"); + } + else + { + priv = new JSBluetoothManagerPriv(context); + + if(!JSObjectSetPrivate(object, static_cast(priv))) + { + LogError("Object can't store private data."); + delete priv; + } + } +} + +void JSBluetoothManager::finalize(JSObjectRef object) +{ + JSBluetoothManagerPriv* priv = static_cast(JSObjectGetPrivate(object)); + LogDebug("JSBluetoothManager::Finalrize"); + + if (priv != NULL) + { + JSObjectSetPrivate(object, NULL); + LogDebug("Deleting BluetoothManager"); + delete priv; + } +} + +bool JSBluetoothManager::hasInstance(JSContextRef context, JSObjectRef constructor, + JSValueRef possibleInstance, JSValueRef* exception) +{ + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} +} +} + diff --git a/src/Bluetooth/JSBluetoothManager.h b/src/Bluetooth/JSBluetoothManager.h new file mode 100644 index 0000000..180bd50 --- /dev/null +++ b/src/Bluetooth/JSBluetoothManager.h @@ -0,0 +1,58 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_H_ +#define TIZENAPIS_TIZEN_JS_BLUETOOTH_H_ + +#include + #include + +using namespace WrtDeviceApis; + + namespace DeviceAPI { + namespace Bluetooth { + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSBluetoothManagerPriv; + +class JSBluetoothManager +{ +public: + static const JSClassDefinition* getClassInfo(); + static const JSClassRef getClassRef(); + +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 getDefaultAdapter(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) ; + static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static JSClassDefinition m_classInfo; + static JSStaticFunction m_function[]; + static JSStaticValue m_properties[]; + static JSClassRef m_jsClassRef; + static JSObjectRef m_deviceMajor; + static JSObjectRef m_deviceMinor; + static JSObjectRef m_deviceService; +}; +} +} + +#endif + diff --git a/src/Bluetooth/JSBluetoothServiceHandler.cpp b/src/Bluetooth/JSBluetoothServiceHandler.cpp new file mode 100644 index 0000000..a391c55 --- /dev/null +++ b/src/Bluetooth/JSBluetoothServiceHandler.cpp @@ -0,0 +1,409 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include "BluetoothProperty.h" +#include "BluetoothConverter.h" +#include "BluetoothAdapterListener.h" +#include "BluetoothFactory.h" +#include +#include "plugin_config.h" + +using namespace std; +using namespace DPL; +using namespace WrtDeviceApis; +using namespace DeviceAPI::Common; +using namespace WrtDeviceApis::CommonsJavaScript; + + +namespace DeviceAPI { +namespace Bluetooth { + +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(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(cbm)); + BluetoothServiceHandlerManager->setServiceHandlerListener(emitter); + + 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(JSObjectGetPrivate(object)); + BluetoothConverter converter(priv->getContext()); + + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + IBluetoothServiceHandlerManagerPtr BluetoothServiceHandlerManager(priv->getObject()); + std::string uuid = BluetoothServiceHandlerManager->getUUID(); + return converter.toJSValueRef(uuid); + + } + catch (const WrtDeviceApis::Commons::Exception& ex) + { + LogWarning("Exception: " << ex.GetMessage()); + } + + return NULL; +} + + +JSValueRef JSBluetoothServiceHandler::getName(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("OK"); + + try + { + JSBluetoothServiceHandlerPriv *priv = static_cast(JSObjectGetPrivate(object)); + BluetoothConverter converter(priv->getContext()); + + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + IBluetoothServiceHandlerManagerPtr BluetoothServiceHandlerManager(priv->getObject()); + std::string name = BluetoothServiceHandlerManager->getName(); + return converter.toJSValueRef(name); + + } + catch (const WrtDeviceApis::Commons::Exception& ex) + { + LogWarning("Exception"<(JSObjectGetPrivate(object)); + BluetoothConverter converter(priv->getContext()); + + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + IBluetoothServiceHandlerManagerPtr BluetoothServiceHandlerManager(priv->getObject()); + bool connected = BluetoothServiceHandlerManager->getIsConnected(); + return converter.toJSValueRef(connected); + + } + catch (const WrtDeviceApis::Commons::Exception& ex) + { + LogWarning("Exception"<(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; + JSBluetoothServiceHandlerPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + + if (priv == NULL) + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + } + + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL); + size_t index = 0; + JSValueRef reserveArguments[2]; + Try + { + for (index = 0; index < 2; index++) + { + if (index < argumentCount) + reserveArguments[index] = arguments[index]; + else + reserveArguments[index] = JSValueMakeUndefined(context); + } + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADPATER_UNREGISTER]); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + + BluetoothConverter converter(priv->getContext()); + + if (argumentCount >= 1 && JSValueIsUndefined(context, reserveArguments[0]) == false) + { + successCallback = converter.toFunctionOrNull(reserveArguments[0]); + } + + if (argumentCount >= 2 && JSValueIsUndefined(context, reserveArguments[1]) == false) + { + errorCallBack = converter.toFunctionOrNull(reserveArguments[1]); + } + + + if (cbm == NULL) + { + Throw(UnknownException); + } + + cbm->setOnSuccess(successCallback); + cbm->setOnError(errorCallBack); + + 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 (cbm)); + BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance(); + event->setForAsynchronousCall(&listener); + BluetoothServiceHandlerManager->unRegister(event); + + } + Catch (WrtDeviceApis::Commons::ConversionException) + { + LogError("ConversionException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"); + + } + Catch (WrtDeviceApis::Commons::InvalidArgumentException) + { + LogError("InvalidArgumentException"); + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), + JSTizenException::INVALID_VALUES_ERROR, "invalid values error")); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Exception"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "unknown error"); + } + return JSValueMakeUndefined(context); +} + + +} +} + diff --git a/src/Bluetooth/JSBluetoothServiceHandler.h b/src/Bluetooth/JSBluetoothServiceHandler.h new file mode 100644 index 0000000..e5e5afe --- /dev/null +++ b/src/Bluetooth/JSBluetoothServiceHandler.h @@ -0,0 +1,63 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include "IBluetoothServiceHandlerManager.h" + + +using namespace WrtDeviceApis::CommonsJavaScript; + +namespace DeviceAPI { +namespace Bluetooth { + +typedef PrivateObjectT::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 + diff --git a/src/Bluetooth/JSBluetoothSocket.cpp b/src/Bluetooth/JSBluetoothSocket.cpp new file mode 100644 index 0000000..44bda49 --- /dev/null +++ b/src/Bluetooth/JSBluetoothSocket.cpp @@ -0,0 +1,502 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include "BluetoothFactory.h" +#include "BluetoothProperty.h" +#include +#include +#include "BluetoothSocketListener.h" +#include "JSBluetoothSocket.h" +#include "JSBluetoothDevice.h" +#include "BluetoothMultiCallback.h" +#include "BluetoothConverter.h" +#include +#include "plugin_config.h" + +using namespace std; +using namespace DPL; +using namespace DeviceAPI::Common; + + +namespace DeviceAPI { +namespace Bluetooth { + + +JSClassDefinition JSBluetoothSocket::m_classInfo = +{ + 0, + kJSClassAttributeNone, + "BluetoothSocket", + NULL, + m_properties, + m_function, + initialize, + finalize, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + hasInstance, + NULL +}; + +JSStaticValue JSBluetoothSocket::m_properties[] = +{ + {"uuid", getProperty, NULL, kJSPropertyAttributeReadOnly}, +// {"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[] = +{ + { "writeData", JSBluetoothSocket::writeData, kJSPropertyAttributeNone }, + { "readData", JSBluetoothSocket::readData, kJSPropertyAttributeNone }, + { "close", JSBluetoothSocket::close, kJSPropertyAttributeNone }, + { 0, 0, 0 } +}; + +const JSClassRef JSBluetoothSocket::getClassRef() +{ + if (!m_jsClassRef) + { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSBluetoothSocket::getClassInfo() +{ + return &m_classInfo; +} + +JSClassRef JSBluetoothSocket::m_jsClassRef = JSClassCreate(JSBluetoothSocket::getClassInfo()); + +JSObjectRef JSBluetoothSocket::m_peer = NULL; + + +bool JSBluetoothSocket::setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + LogDebug("OK"); + + try + { + JSBluetoothSocketPriv *priv = static_cast(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(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(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 "); + +} + +void JSBluetoothSocket::finalize(JSObjectRef object) +{ + LogDebug("JSBluetoothSocket::Finalrize"); + + JSBluetoothSocketPriv *priv = static_cast(JSObjectGetPrivate(object)); + + if (priv != NULL) + { + delete priv; + JSObjectSetPrivate(object, NULL); + } +} + +bool JSBluetoothSocket::hasInstance(JSContextRef context, JSObjectRef constructor, + JSValueRef possibleInstance, JSValueRef* exception) +{ + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + +JSObjectRef JSBluetoothSocket::createJSObject(JSContextRef context, BluetoothSocketData socketData) +{ + IBluetoothSocketManagerPtr BluetoothSocketManager(BluetoothFactory::getInstance().getBluetoothSocketManager()); + JSBluetoothSocketPriv* priv = new JSBluetoothSocketPriv( context, BluetoothSocketManager); + BluetoothSocketManager->setSocketData(socketData); + + 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(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) +{ + IBluetoothSocketManagerPtr BluetoothSocketManager(BluetoothFactory::getInstance().getBluetoothSocketManager()); + JSBluetoothSocketPriv* priv = new JSBluetoothSocketPriv( context, BluetoothSocketManager); + BluetoothSocketManager->setSocketData(socketData); + BluetoothSocketManager->setReadData(readData); + return JSObjectMake(context, getClassRef(), priv); +} +JSValueRef JSBluetoothSocket::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + LogDebug("OK"); + + + Try + { + JSBluetoothSocketPriv *priv = static_cast(JSObjectGetPrivate(object)); + IBluetoothSocketManagerPtr BluetoothSocketManager(priv->getObject()); + BluetoothConverter converter(priv->getContext()); + + if (priv == NULL) + { + LogError("priv null"); + Throw(WrtDeviceApis::Commons::ConversionException); + } + + if(JSStringIsEqualToUTF8CString(propertyName, "uuid")) + { + std::string uuid = BluetoothSocketManager->getUUID(); + return converter.toJSValueRef(uuid); + } + else if(JSStringIsEqualToUTF8CString(propertyName, "protocol")) + { + unsigned short int protocol = BluetoothSocketManager->getProtocol(); + return converter.toBluetoothProtocolJSValue(protocol); + + } + else if(JSStringIsEqualToUTF8CString(propertyName, "state")) + { + unsigned short int state = BluetoothSocketManager->getState(); + return converter.toBluetoothStateJSValue(state); + } + else if(JSStringIsEqualToUTF8CString(propertyName, "peer")) + { + if(m_peer == NULL) + { + BluetoothDeviceData device = BluetoothSocketManager->getPeer(); + m_peer = JSBluetoothDevice::createJSObject(priv->getContext(), device); + } + + return m_peer; + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + + return JSValueMakeUndefined(context); +} + + +JSValueRef JSBluetoothSocket::writeData(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("JSBluetoothSocket"); + Converter converter(context); + Try + { + JSBluetoothSocketPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + + if (priv == NULL) + { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + } + + if (argumentCount < 1) + { + LogError("argument wrong"); + Throw(WrtDeviceApis::Commons::ConversionException); + } + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_SOCKET_WRITE_DATA]); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + IBluetoothSocketManagerPtr BluetoothSocketManager(priv->getObject()); + std::vector data = converter.toVectorOfChars(arguments[0]); + unsigned int index = 0; + + if (data.size() == 0) + { + LogError("size 0 array passed"); + Throw(WrtDeviceApis::Commons::ConversionException); + } + + DPL::ScopedArray buffer(new char[data.size()]); + + for (index = 0; index < data.size(); index++) + { + buffer[index] = data[index]; + } + + if (BluetoothSocketManager->writeData(buffer.Get(), data.size()) != BT_ERROR_NONE) + { + LogError("BluetoothSocket Write Error"); + Throw(WrtDeviceApis::Commons::UnknownException); + } + + return converter.toJSValueRef(data.size()); + } + 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::TYPE_MISMATCH_ERROR, "type mismatch error"); + + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnsupportException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Exception"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "unknown error"); + } +} + + +JSValueRef JSBluetoothSocket::readData(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) +{ + + + LogDebug("JSBluetoothSocket"); + + Try + { + JSBluetoothSocketPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + if(!priv) + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + + IBluetoothSocketManagerPtr BluetoothSocketManager(priv->getObject()); + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + 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) + { + LogError("BluetoothSocket Read Error"); + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + + + JSObjectRef result = converter.toBluetoothByteArray(data); + return result; + } + Catch (WrtDeviceApis::Commons::SecurityException) + { + LogError("permission denied error"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::PERMISSION_DENIED_ERROR, "permission denied error"); + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnsupportException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Exception"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "unknown error"); + } +} + + +JSValueRef JSBluetoothSocket::close(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception) +{ + LogDebug("JSBluetoothSocket"); + + Try + { + JSBluetoothSocketPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + if(!priv) + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is NULL."); + + IBluetoothSocketManagerPtr BluetoothSocketManager(priv->getObject()); + + LogDebug(bluetoothExportedNames[BLUETOOTH_FUNCTION_API_SOCKET_CLOSE]); + + AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_SOCKET_CLOSE]); + + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + if (BluetoothSocketManager->close() != BT_ERROR_NONE) + { + Throw(WrtDeviceApis::Commons::UnknownException); + } + + return JSValueMakeNull(context); + + } + Catch (WrtDeviceApis::Commons::SecurityException) + { + LogError("permission denied error"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::PERMISSION_DENIED_ERROR, "permission denied error"); + } + Catch(WrtDeviceApis::Commons::UnsupportedException) + { + LogError("UnsupportException"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, "Unsupport Exception"); + } + Catch (WrtDeviceApis::Commons::Exception) + { + LogError("Exception"); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, "unknown error"); + } +} +} +} + diff --git a/src/Bluetooth/JSBluetoothSocket.h b/src/Bluetooth/JSBluetoothSocket.h new file mode 100644 index 0000000..142eb33 --- /dev/null +++ b/src/Bluetooth/JSBluetoothSocket.h @@ -0,0 +1,95 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_SOCKET_H_ +#define TIZENAPIS_TIZEN_JS_BLUETOOTH_SOCKET_H_ + +#include +#include +#include "BTDevice.h" +#include "IBluetoothSocketManager.h" + +using namespace WrtDeviceApis::CommonsJavaScript; + +namespace DeviceAPI { +namespace Bluetooth { + +typedef PrivateObjectT::Type JSBluetoothSocketPriv; +class JSBluetoothSocket +{ +public: + static const JSClassDefinition* getClassInfo(); + static const JSClassRef getClassRef(); + static JSObjectRef createJSObject(JSContextRef context, BluetoothSocketData socketData); + static JSObjectRef createJSObject(JSContextRef context, BluetoothSocketData socketData, + EventBTReadDataType readData); + +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 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[], + JSValueRef* exception); + + static JSValueRef writeData(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + + static JSValueRef readData(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + + static JSValueRef close(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + + static JSValueRef getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static JSClassDefinition m_classInfo; + static JSStaticFunction m_function[]; + static JSStaticValue m_properties[]; + + static JSClassRef m_jsClassRef; + static JSObjectRef m_peer; + +}; + +} +} + +#endif + diff --git a/src/Bluetooth/config.xml b/src/Bluetooth/config.xml new file mode 100644 index 0000000..ef2c4b0 --- /dev/null +++ b/src/Bluetooth/config.xml @@ -0,0 +1,26 @@ + + + + libwrt-plugins-tizen-bluetooth.so + bluetooth.install.uri + SAMSUNG plugin group + SAMSUNG certificate authority + AAAABBBBCCCCDDDEEEE0000 + + http://tizen.org/privilege/bluetooth.admin + bluetooth.admin + + + http://tizen.org/privilege/bluetooth.gap + bluetooth.gap + + + http://tizen.org/privilege/bluetooth.spp + bluetooth.spp + + + http://tizen.org/privilege/bluetoothmanager + bluetoothmanager + + + diff --git a/src/Bluetooth/plugin_config.cpp b/src/Bluetooth/plugin_config.cpp new file mode 100644 index 0000000..2bc273c --- /dev/null +++ b/src/Bluetooth/plugin_config.cpp @@ -0,0 +1,166 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include "plugin_config.h" + +#define BLUETOOTH_FEATURE_API_ADMIN "http://tizen.org/privilege/bluetooth.admin" +#define BLUETOOTH_FEATURE_API_GAP "http://tizen.org/privilege/bluetooth.gap" +#define BLUETOOTH_FEATURE_API_SPP "http://tizen.org/privilege/bluetooth.spp" +#define BLUETOOTH_FEATURE_API_MANAGER "http://tizen.org/privilege/bluetoothmanager" + +#define BLUETOOTH_DEVICE_CAP_ADMIN "bluetooth.admin" +#define BLUETOOTH_DEVICE_CAP_GAP "bluetooth.gap" +#define BLUETOOTH_DEVICE_CAP_SPP "bluetooth.spp" +#define BLUETOOTH_DEVICE_CAP_MANAGER "bluetoothmanager" + +namespace DeviceAPI { +namespace Bluetooth { + +const char* bluetoothExportedNames[] = +{ + "getDefaultAdapter", + "setName", + "setPowered", + "setVisible", + "discoverDevices", + "stopDiscovery", + "getKnownDevices", + "getDevice", + "createBonding", + "destroyBonding", + "hasService", + "registerRFCOMMServiceByUUID", + "unregister", + "connectToServiceByUUID", + "writeData", + "readData", + "close" +}; + +static WrtDeviceApis::Commons::FunctionMapping createBluetoothFunctions(); + +static WrtDeviceApis::Commons::FunctionMapping BluetoothFunctions = + createBluetoothFunctions(); + +DEFINE_FUNCTION_GETTER(Bluetooth, BluetoothFunctions); + +static WrtDeviceApis::Commons::FunctionMapping createBluetoothFunctions() +{ + using namespace WrtDeviceApis::Commons; + + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BLUETOOTH_ADMIN, BLUETOOTH_DEVICE_CAP_ADMIN); + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BLUETOOTH_GAP, BLUETOOTH_DEVICE_CAP_GAP); + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BLUETOOTH_SPP, BLUETOOTH_DEVICE_CAP_SPP); + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BLUETOOTH_MANAGER, BLUETOOTH_DEVICE_CAP_MANAGER); + + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BLUETOOTH_ADMIN); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_BLUETOOTH_ADMIN, DEVICE_CAP_BLUETOOTH_ADMIN); + + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BLUETOOTH_GAP); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_BLUETOOTH_GAP, DEVICE_CAP_BLUETOOTH_GAP); + + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BLUETOOTH_SPP); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_BLUETOOTH_SPP, DEVICE_CAP_BLUETOOTH_SPP); + + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BLUETOOTH_MANAGER); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_BLUETOOTH_MANAGER, DEVICE_CAP_BLUETOOTH_MANAGER); + + ACE_CREATE_FEATURE(FEATURE_ADMIN, BLUETOOTH_FEATURE_API_ADMIN); + ACE_CREATE_FEATURE(FEATURE_GAP, BLUETOOTH_FEATURE_API_GAP); + ACE_CREATE_FEATURE(FEATURE_SPP, BLUETOOTH_FEATURE_API_SPP); + ACE_CREATE_FEATURE(FEATURE_MANAGER, BLUETOOTH_FEATURE_API_MANAGER); + + ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_ADMIN); + ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_ADMIN, FEATURE_ADMIN); + + ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_GAP); + ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_GAP, FEATURE_GAP); + + ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_SPP); + ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP, FEATURE_SPP); + + ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_MANAGER); + ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_MANAGER, FEATURE_MANAGER); + // FEATURE_ADMIN will be remove from BLUETOOTH_FEATURES_BLUETOOTH_MANAGER + ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_MANAGER, FEATURE_ADMIN); + + FunctionMapping BluetoothFunctions; + + for (int index = BLUETOOTH_FUNCTION_API_ADAPTER_SET_NAME; + index <= BLUETOOTH_FUNCTION_API_ADAPTER_SET_POWERED; index++) + { + AceFunction adminLoopFunc = + ACE_CREATE_FUNCTION(FUNCTION_ADMIN_DUMMY_FUNC_ID, bluetoothExportedNames[index], + BLUETOOTH_FEATURES_BLUETOOTH_ADMIN, DEVICE_LIST_BLUETOOTH_ADMIN); + BluetoothFunctions.insert(std::make_pair( + bluetoothExportedNames[index], adminLoopFunc)); + } + + AceFunction managerSetVisible = + ACE_CREATE_FUNCTION(FUNCTION_ADMIN_DUMMY_FUNC_ID, + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_SET_VISIBLE], + BLUETOOTH_FEATURES_BLUETOOTH_MANAGER, DEVICE_LIST_BLUETOOTH_MANAGER); + BluetoothFunctions.insert(std::make_pair( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_SET_VISIBLE], + managerSetVisible)); + + for (int index = BLUETOOTH_FUNCTION_API_ADAPTER_DISCOVER_DEVICES; + index <= BLUETOOTH_FUNCTION_API_BLUETOOTHCLASS_HAS_SERVICE; index++) + { + AceFunction gapLoopFunc = + ACE_CREATE_FUNCTION(FUNCTION_GAP_DUMMY_FUNC_ID, bluetoothExportedNames[index], + BLUETOOTH_FEATURES_BLUETOOTH_GAP, DEVICE_LIST_BLUETOOTH_GAP); + BluetoothFunctions.insert(std::make_pair( + bluetoothExportedNames[index], gapLoopFunc)); + } + + // allow getDefaultAdapter for bluetooth.gap feature + AceFunction gapDefaultAdapter = + ACE_CREATE_FUNCTION(FUNCTION_GAP_DUMMY_FUNC_ID, + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_MANAGER_GET_DEFAULT_ADAPTER], + BLUETOOTH_FEATURES_BLUETOOTH_GAP, DEVICE_LIST_BLUETOOTH_GAP); + BluetoothFunctions.insert(std::make_pair( + bluetoothExportedNames[BLUETOOTH_FUNCTION_API_MANAGER_GET_DEFAULT_ADAPTER], + gapDefaultAdapter)); + + + for (int index = BLUETOOTH_FUNCTION_API_ADPATER_REGISTER_RFCOMM; + index <= BLUETOOTH_FUNCTION_API_SOCKET_CLOSE; index++) + { + AceFunction sppLoopFunc = + ACE_CREATE_FUNCTION(FUNCTION_SPP_DUMMY_FUNC_ID, bluetoothExportedNames[index], + BLUETOOTH_FEATURES_BLUETOOTH_SPP, DEVICE_LIST_BLUETOOTH_SPP); + BluetoothFunctions.insert(std::make_pair( + bluetoothExportedNames[index], sppLoopFunc)); + } + + return BluetoothFunctions; +} +} +} + +#undef BLUETOOTH_FEATURE_API +#undef BLUETOOTH_FEATURE_API_GAP +#undef BLUETOOTH_FEATURE_API_SPP +#undef BLUETOOTH_DEVICE_CAP_GAP +#undef BLUETOOTH_DEVICE_CAP_SPP diff --git a/src/Bluetooth/plugin_config.h b/src/Bluetooth/plugin_config.h new file mode 100644 index 0000000..ba2cd79 --- /dev/null +++ b/src/Bluetooth/plugin_config.h @@ -0,0 +1,59 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_PLUGIN_CONFIG_H_ +#define TIZENAPIS_TIZEN_JS_BLUETOOTH_PLUGIN_CONFIG_H_ + +#include + +namespace DeviceAPI { +namespace Bluetooth { + +typedef enum +{ +BLUETOOTH_FUNCTION_API_MANAGER_GET_DEFAULT_ADAPTER = 0, +BLUETOOTH_FUNCTION_API_ADAPTER_SET_NAME, +BLUETOOTH_FUNCTION_API_ADAPTER_SET_POWERED, +BLUETOOTH_FUNCTION_API_ADAPTER_SET_VISIBLE, +BLUETOOTH_FUNCTION_API_ADAPTER_DISCOVER_DEVICES, +BLUETOOTH_FUNCTION_API_ADAPTER_STOP_DISCOVERY, +BLUETOOTH_FUNCTION_API_ADAPTER_GET_KNOWN_DEVICES, +BLUETOOTH_FUNCTION_API_ADAPTER_GET_DEVICE, +BLUETOOTH_FUNCTION_API_ADPATER_CREATE_BONDING, +BLUETOOTH_FUNCTION_API_ADPATER_DESTROY_BONDING, +BLUETOOTH_FUNCTION_API_BLUETOOTHCLASS_HAS_SERVICE, +BLUETOOTH_FUNCTION_API_ADPATER_REGISTER_RFCOMM, +BLUETOOTH_FUNCTION_API_ADPATER_UNREGISTER, +BLUETOOTH_FUNCTION_API_DEVICE_CONNECT_TO_SERVICE, +BLUETOOTH_FUNCTION_API_SOCKET_WRITE_DATA, +BLUETOOTH_FUNCTION_API_SOCKET_READ_DATA, +BLUETOOTH_FUNCTION_API_SOCKET_CLOSE, +} bluetoothFuncNames; + + +extern const char* bluetoothExportedNames[]; + +DECLARE_FUNCTION_GETTER(Bluetooth); + +#define BLUETOOTH_CHECK_ACCESS(functionName) \ + aceCheckAccess >( \ + getBluetoothFunctionData, \ + functionName) +} +} + +#endif diff --git a/src/Bluetooth/plugin_initializer.cpp b/src/Bluetooth/plugin_initializer.cpp new file mode 100644 index 0000000..ffe1325 --- /dev/null +++ b/src/Bluetooth/plugin_initializer.cpp @@ -0,0 +1,73 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include + + +#include "JSBluetoothManager.h" +#include "JSBluetoothAdapter.h" + +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; + +namespace DeviceAPI { +namespace Bluetooth { + +void on_widget_start_callback(int widgetId) +{ + LogDebug("[Tizen\\Bluetooth ] on_widget_start_callback ("< + +#ifndef _BOOKMARKDATA_H_ +#define _BOOKMARKDATA_H_ + +namespace DeviceAPI { +namespace Bookmark { + +#define UNDEFINED_ID 0 +#define ROOTFOLDER_ID 1 + +enum bookmarkType { + BOOKMARKITEM_TYPE = 0, + BOOKMARKFOLDER_TYPE = 1 +}; + +class BookmarkData { +public: + BookmarkData(bookmarkType type, const std::string& title, const std::string& url, const int id = UNDEFINED_ID, const int parentId = UNDEFINED_ID) + : m_type(type), m_title(title), m_url(url), m_id(id), m_parentId(parentId) {}; + bookmarkType m_type; + std::string m_title; + std::string m_url; + int m_id; + int m_parentId; +}; + +typedef boost::shared_ptr BookmarkDataPtr; +} +} +#endif //_BOOKMARKDATA_H_ \ No newline at end of file diff --git a/src/Bookmark/BookmarkManager.cpp b/src/Bookmark/BookmarkManager.cpp new file mode 100755 index 0000000..859f38b --- /dev/null +++ b/src/Bookmark/BookmarkManager.cpp @@ -0,0 +1,264 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "BookmarkManager.h" +#include "JSBookmarkFolder.h" +#include "JSBookmarkItem.h" +#include +#include +#include +#include +#include +#include +#include + +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + +namespace DeviceAPI { +namespace Bookmark{ +static bool favorites_bookmark_foreach_cb(favorites_bookmark_entry_s *entry, void *user_data) { + LogDebug("Entered"); + if (user_data) { + BookmarkSearchData *searchData = static_cast(user_data); + int parentId = 0; + if (searchData->m_bookmark) + parentId = (searchData->m_bookmark)->m_id; + else + parentId = BookmarkManager::getInstance()->getRootFolderId(); + + LogDebug("parentId : " << parentId); + LogDebug("m_reculsive : " << searchData->m_reculsive); + LogDebug("entry title : " << entry->title); + LogDebug("entry id : " << entry->id); + if (!(searchData->isAlive) && (entry->id == parentId)) + searchData->isAlive = true; + + LogDebug("isAlive : " << searchData->isAlive); + + if ((searchData->m_reculsive) || (entry->folder_id == parentId)) { + LogDebug("found subitem : " << entry->title); + BookmarkDataPtr bookmark; + if (entry->is_folder) + bookmark = BookmarkDataPtr(new BookmarkData(BOOKMARKFOLDER_TYPE, entry->title, "", entry->id, entry->folder_id)); + else + bookmark = BookmarkDataPtr(new BookmarkData(BOOKMARKITEM_TYPE, entry->title, entry->address, entry->id, entry->folder_id)); + + (searchData->m_results).insert(std::pair(entry->folder_id, bookmark)); + } + if (!(searchData->isAlive) || (searchData->m_reculsive) || (parentId == BookmarkManager::getInstance()->getRootFolderId()) || ((searchData->m_bookmark)->m_type == BOOKMARKFOLDER_TYPE)) + return true; + } else + LogDebug("user_data is null"); + + LogDebug("stop "); + return false; +} + +static bool favorites_bookmark_parent_search_cb(favorites_bookmark_entry_s *entry, void *user_data) { + if (user_data){ + BookmarkParentSearchData *parentSearchData = static_cast(user_data); + LogDebug("entry->id : " << entry->id); + + if (entry->id == parentSearchData->m_id) { + parentSearchData->isAlive = true; + } else if (entry->id == parentSearchData->m_parentId){ + LogDebug("Found parent"); + parentSearchData->isParentAlive = true; + parentSearchData->m_parent = BookmarkDataPtr(new BookmarkData(BOOKMARKFOLDER_TYPE, entry->title, "", entry->id, entry->folder_id)); + } else + return true; + + if (parentSearchData->isAlive && parentSearchData->isParentAlive) { + LogDebug("Found parent.Stop."); + return false; + } else + return true; + } + + LogDebug("user_data is null"); + return false; +} + + +std::vector BookmarkManager::get(BookmarkSearchDataPtr &searchData){ + LogDebug("Entered"); + int count; + std::vector bookmarkArray; + if (favorites_bookmark_get_count(&count) == FAVORITES_ERROR_NONE) { + if (!count) { + if (searchData->m_bookmark == NULL) { + return bookmarkArray; + } else { + throw NotFoundException("No Bookmark in DB"); + } + } else { + if (searchData->m_bookmark == NULL) + searchData->isAlive = true; + + int result = favorites_bookmark_foreach(favorites_bookmark_foreach_cb, searchData.get()); + if (result == FAVORITES_ERROR_NONE) + return _getCompleteCB(searchData); + else if (result == FAVORITES_ERROR_DB_FAILED) + throw IOException("DB Failed"); + else + throw UnknownException("Unknown Error"); + } + } else { + throw IOException("DB failed"); + } +} + +std::vector BookmarkManager::_getCompleteCB(BookmarkSearchDataPtr &searchData){ + LogDebug("Enter"); + std::vector bookmarkArray; + //check if searchData->m_bookmark is in db or not + if (searchData->isAlive) { + //find sub items. If it is empty, it will return empty array + if ((searchData->m_results).size() > 0) { + std::multimap::iterator it; + //If searchData->m_bookmark is null, it is to get bookmarks under root folder. + //If it is root folder or reculsive is false, it is no need to filter because bookmarks excluding from list doesn't exist. + if (searchData->m_reculsive && searchData->m_bookmark) { + std::queue folders; // It is the queue of finding item + + BookmarkData *parent = searchData->m_bookmark; + for (it=(searchData->m_results).begin(); it!=(searchData->m_results).end(); ++it) + LogDebug("it->first:"<first << " it->second:" <<(it->second)->m_id); + + int lastItemId = (((searchData->m_results).rbegin())->second)->m_id; + LogDebug("end's first:"<<((searchData->m_results).rbegin())->first << "end's second:"<m_results).find(parent->m_id); + LogDebug("it->first:"<first << " parent->m_id:" <m_id); + while (it->first == parent->m_id) { + LogDebug("it->second:"<<(it->second)->m_id); + bookmarkArray.push_back(it->second); + LogDebug("m_type:"<<(it->second)->m_type); + //if it is folder, it will be pushed in folders vector + if ((it->second)->m_type == BOOKMARKFOLDER_TYPE) + folders.push((it->second).get()); + + if ((it->second)->m_id != lastItemId) { + LogDebug("not last"); + it++; + LogDebug("it->first:"<first << " it->second:" <<(it->second)->m_id); + } else + break; + + } + + if (folders.size()) { + parent = folders.front(); + LogDebug("parent->m_id:" <m_id); + folders.pop(); + } else + break; + + } + } else { + for (it=(searchData->m_results).begin(); it!=(searchData->m_results).end(); ++it) { + bookmarkArray.push_back(it->second); + } + } + } + } else { // Not found Error because it is not in db + throw NotFoundException("Can't find the parent folder"); + } + LogDebug("Success!"); + return bookmarkArray; +} + +int BookmarkManager::add(bookmarkType type, const int parent_id, const std::string& title, const std::string& url) { + LogDebug("Entered"); + int id = UNDEFINED_ID; + int result = favorites_bookmark_add(title.c_str(), url.c_str(), parent_id, static_cast(type), &id); + if (result == FAVORITES_ERROR_NONE) + return id; + else if (result == FAVORITES_ERROR_ITEM_ALREADY_EXIST) + throw InvalidValuesException("Already Exist"); + else if (result == FAVORITES_ERROR_INVALID_PARAMETER) + throw InvalidValuesException("Wrong parameter"); + else if (result == FAVORITES_ERROR_DB_FAILED) + throw IOException("DB Failed"); + else if (result == FAVORITES_ERROR_NO_SUCH_FILE) + throw NotFoundException("Can't find the parent folder"); + else + throw UnknownException("Unknown Error"); +} + +void BookmarkManager::remove(BookmarkSearchDataPtr &searchData) { + LogDebug("Entered"); + int result = FAVORITES_ERROR_NONE; + if (searchData->m_bookmark == NULL) + result = favorites_bookmark_delete_all_bookmarks(); + else if ((searchData->m_bookmark)->m_type == BOOKMARKITEM_TYPE) + result = favorites_bookmark_delete_bookmark((searchData->m_bookmark)->m_id); + else { + result = favorites_bookmark_foreach(favorites_bookmark_foreach_cb, searchData.get()); + if (result == FAVORITES_ERROR_NONE) { + std::vector deletebookmarks = _getCompleteCB(searchData); + result = favorites_bookmark_delete_bookmark((searchData->m_bookmark)->m_id); + if (result == FAVORITES_ERROR_NONE) { + for (int i = 0; i < deletebookmarks.size(); ++i) { + result = favorites_bookmark_delete_bookmark(deletebookmarks[i]->m_id); + if (result != FAVORITES_ERROR_NONE) + break; + } + } + } + } + + if (result == FAVORITES_ERROR_NONE) + return; + else if (result == FAVORITES_ERROR_DB_FAILED) + throw IOException("DB Failed"); + else + throw UnknownException("Unknown Error"); +} + +bool BookmarkManager::findParent(BookmarkParentSearchDataPtr &parentSearchData) { + if (parentSearchData->m_parentId == getRootFolderId()) + parentSearchData->isParentAlive = true; + + int result = favorites_bookmark_foreach(favorites_bookmark_parent_search_cb, parentSearchData.get()); + if ((result == FAVORITES_ERROR_NONE) && parentSearchData->isAlive && parentSearchData->isParentAlive) + return true; + else + return false; +} + +int BookmarkManager::getRootFolderId() { + return rootFolderId; + +} + +BookmarkManager* BookmarkManager::getInstance(){ + static BookmarkManager instance; + return &instance; +} + +BookmarkManager::BookmarkManager(){ + rootFolderId = 1; + favorites_bookmark_get_root_folder_id(&rootFolderId); +} +BookmarkManager::~BookmarkManager(){ +} + +} +} + diff --git a/src/Bookmark/BookmarkManager.h b/src/Bookmark/BookmarkManager.h new file mode 100755 index 0000000..9e3202d --- /dev/null +++ b/src/Bookmark/BookmarkManager.h @@ -0,0 +1,79 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 _BOOKMARKMANAGER_ +#define _BOOKMARKMANAGER_ + +#include +#include +#include +#include +#include +#include +#include "BookmarkData.h" + +namespace DeviceAPI { +namespace Bookmark{ + + +class BookmarkSearchData { + public: + BookmarkSearchData(BookmarkData *bookmarkData, bool reculsive = true) + : m_bookmark(bookmarkData), m_reculsive(reculsive), isAlive(false) {} + BookmarkData *m_bookmark; + bool m_reculsive; + bool isAlive; + std::multimap m_results; +}; +typedef boost::shared_ptr BookmarkSearchDataPtr; + +class BookmarkParentSearchData { + public: + BookmarkParentSearchData(int id, int parentId) : m_id(id), m_parentId(parentId), isAlive(false), isParentAlive(false) {} + int m_id; + int m_parentId; + bool isAlive; + bool isParentAlive; + BookmarkDataPtr m_parent; +}; +typedef boost::shared_ptr BookmarkParentSearchDataPtr; + +class BookmarkManager{ + public: + std::vector get(BookmarkSearchDataPtr &searchData); + int add(bookmarkType type, const int parent_id, const std::string& title, const std::string& url = ""); + void remove(BookmarkSearchDataPtr &searchData); + bool findParent(BookmarkParentSearchDataPtr &parentSearchData); + int getRootFolderId(); + static BookmarkManager* getInstance(); + + private: + int rootFolderId; + BookmarkManager(); + ~BookmarkManager(); + std::vector _getCompleteCB(BookmarkSearchDataPtr &searchData); + +}; + + + +} +} + +#endif //_BOOKMARKMANAGER_ + diff --git a/src/Bookmark/CMakeLists.txt b/src/Bookmark/CMakeLists.txt new file mode 100755 index 0000000..0520b61 --- /dev/null +++ b/src/Bookmark/CMakeLists.txt @@ -0,0 +1,47 @@ +SET(TARGET_NAME ${bookmark_target}) +SET(DESTINATION_NAME ${bookmark_dest}) +SET(TARGET_IMPL_NAME ${bookmark_impl}) + +PKG_SEARCH_MODULE(favorites REQUIRED capi-web-favorites) + +SET(CMAKE_INSTALL_RPATH + ${CMAKE_INSTALL_RPATH} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME} +) + +SET(SRCS_IMPL + JSBookmarkManager.cpp + BookmarkManager.cpp + JSBookmarkFolder.cpp + JSBookmarkItem.cpp +) + +INCLUDE_DIRECTORIES( + ${TOP}/Common + ${favorites_INCLUDE_DIRS} +) + +ADD_LIBRARY(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL}) + +TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME} + ${LIBS_COMMON} + ${favorites_LIBRARIES} +) + +SET(SRCS + plugin_config.cpp + plugin_initializer.cpp +) + +ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS}) + +TARGET_LINK_LIBRARIES(${TARGET_NAME} + ${TARGET_IMPL_NAME} +) + +INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) +INSTALL( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/bookmark + FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE +) diff --git a/src/Bookmark/JSBookmarkFolder.cpp b/src/Bookmark/JSBookmarkFolder.cpp new file mode 100755 index 0000000..50aad17 --- /dev/null +++ b/src/Bookmark/JSBookmarkFolder.cpp @@ -0,0 +1,180 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include "JSBookmarkFolder.h" +#include "BookmarkManager.h" +#include "BookmarkData.h" + +using namespace DeviceAPI::Common; +using namespace WrtDeviceApis::CommonsJavaScript; + +#define TIZEN_BOOKMARKFOLDER_PARENT "parent" +#define TIZEN_BOOKMARKFOLDER_TITLE "title" + +namespace DeviceAPI { +namespace Bookmark { + +JSClassRef JSBookmarkFolder::m_jsClassRef = NULL; + +JSClassDefinition JSBookmarkFolder::m_jsClassInfo = { + 0, // current (and only) version is 0 + kJSClassAttributeNone, //attributes + "BookmarkFolder", //class name + NULL, // parent class + JSBookmarkFolder::m_property, //static values + NULL, // static functions + JSBookmarkFolder::initialize, // initialize + JSBookmarkFolder::finalize, //finalize + NULL, //hasProperty + NULL, //getProperty + NULL, //setProperty + NULL, //deleteProperty + NULL, //getPropertyNames + NULL, // callAsFunction + NULL, // constructor + JSBookmarkFolder::hasInstance, + NULL // convertToType +}; + + +JSStaticValue JSBookmarkFolder::m_property[] = +{ + {TIZEN_BOOKMARKFOLDER_PARENT, getProperty, NULL, kJSPropertyAttributeReadOnly}, + {TIZEN_BOOKMARKFOLDER_TITLE, getProperty, NULL, kJSPropertyAttributeReadOnly}, + { 0, 0, 0, 0 } +}; + +const JSClassRef JSBookmarkFolder::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_jsClassInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSBookmarkFolder::getClassInfo() +{ + return &m_jsClassInfo; +} + +void JSBookmarkFolder::initialize(JSContextRef ctx, JSObjectRef object) +{ + LogDebug("JSBookmarkFolder::initialize()\n"); +} + +void JSBookmarkFolder::finalize(JSObjectRef object) +{ + LogDebug("JSBookmarkFolder::finalize()\n"); + BookmarkData * priv = static_cast(JSObjectGetPrivate(object)); + if( priv ){ + JSObjectSetPrivate(object, NULL); + delete priv; + } +} + +bool JSBookmarkFolder::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) { + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + +JSObjectRef JSBookmarkFolder::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){ + LogDebug("Enter"); + try{ + ArgumentValidator validator(ctx, argumentCount, arguments); + + std::string title = validator.toString(0); + return createJSObject(ctx, title); + } catch(const BasePlatformException& err){ + JSObjectRef error = JSWebAPIError::makeJSWebAPIError(ctx, err); + *exception = error; + return error; + } +} + +JSObjectRef JSBookmarkFolder::createJSObject(JSContextRef context, const std::string &title) { + return createJSObject(context, title, UNDEFINED_ID, UNDEFINED_ID); +} + +JSObjectRef JSBookmarkFolder::createJSObject(JSContextRef context, const std::string &title, const int id, const int parentId) { + LogDebug("Enter"); + if (title == "") + throw InvalidValuesException("Title is empty"); + BookmarkData *priv = new BookmarkData(BOOKMARKFOLDER_TYPE, title, "", id, parentId); + JSObjectRef obj = JSObjectMake(context, getClassRef(), priv); + return obj; +} + +#if 0 +JSObjectRef JSBookmarkFolder::createJSObject(JSContextRef context, void *priv) { + JSObjectRef obj = JSObjectMake(context, getClassRef(), priv); + return obj; +} +#endif +JSValueRef JSBookmarkFolder::getParent(JSContextRef context, JSObjectRef object) { + LogDebug("Enter");; + BookmarkData * priv = static_cast(JSObjectGetPrivate(object)); + + if (!priv) + throw TypeMismatchException("Private data is null"); + + LogDebug("bookmark id:" << priv->m_id); + LogDebug("bookmark parent id:" << priv->m_parentId); + if (priv->m_id != UNDEFINED_ID) { + BookmarkParentSearchDataPtr parentSearchData(new BookmarkParentSearchData(priv->m_id, priv->m_parentId)); + bool isAlive = BookmarkManager::getInstance()->findParent(parentSearchData); + if (isAlive) { + if (priv->m_parentId == ROOTFOLDER_ID) + return JSValueMakeNull(context); + else + return createJSObject(context, (parentSearchData->m_parent)->m_title, (parentSearchData->m_parent)->m_id, (parentSearchData->m_parent)->m_parentId); + } + priv->m_parentId = UNDEFINED_ID; + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSBookmarkFolder::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) +{ + LogDebug("Enter"); + + try { + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_BOOKMARKFOLDER_PARENT)) { + return getParent(context, object); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_BOOKMARKFOLDER_TITLE)) { + Converter convert(context); + BookmarkData *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) + throw TypeMismatchException("Private data is null"); + return convert.toJSValueRef(priv->m_title); + } + }catch(const BasePlatformException& err){ + return JSWebAPIError::throwException(context, exception, err); + }catch(const WrtDeviceApis::Commons::ConversionException& err){ + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "converting fail"); + } + return JSValueMakeUndefined(context); +} + +} // Bookmark +} // TizenApis + diff --git a/src/Bookmark/JSBookmarkFolder.h b/src/Bookmark/JSBookmarkFolder.h new file mode 100755 index 0000000..cd28971 --- /dev/null +++ b/src/Bookmark/JSBookmarkFolder.h @@ -0,0 +1,58 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_BOOKMARKFOLDER_H_ +#define _JS_BOOKMARKFOLDER_H_ + +#include +#include + +namespace DeviceAPI { +namespace Bookmark { + +class JSBookmarkFolder +{ + public: + + static const JSClassDefinition* getClassInfo(); + static const JSClassRef getClassRef(); + static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + static JSObjectRef createJSObject(JSContextRef context, const std::string &title); + static JSObjectRef createJSObject(JSContextRef context, const std::string &title, const int id, const int parentId); +#if 0 + static JSObjectRef createJSObject(JSContextRef context, void * priv); +#endif + static JSValueRef getParent(JSContextRef context, JSObjectRef object); + static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); + static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + private: + + static JSClassDefinition m_jsClassInfo; + static JSClassRef m_jsClassRef; + static JSStaticValue m_property[]; + + static void initialize(JSContextRef context, JSObjectRef object); + static void finalize(JSObjectRef object); +}; + +} +} + +#endif /* _JS_BOOKMARKFOLDER_H_ */ + + + diff --git a/src/Bookmark/JSBookmarkItem.cpp b/src/Bookmark/JSBookmarkItem.cpp new file mode 100755 index 0000000..2625fc7 --- /dev/null +++ b/src/Bookmark/JSBookmarkItem.cpp @@ -0,0 +1,166 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "JSBookmarkItem.h" +#include "JSBookmarkFolder.h" +#include "BookmarkData.h" +#include +#include +#include +#include +#include +#include +#include + +using namespace DeviceAPI::Common; +using namespace WrtDeviceApis::CommonsJavaScript; + +namespace DeviceAPI { +namespace Bookmark { + +#define TIZEN_BOOKMARKITEM_PARENT "parent" +#define TIZEN_BOOKMARKITEM_TITLE "title" +#define TIZEN_BOOKMARKITEM_URL "url" + +JSClassRef JSBookmarkItem::m_jsClassRef = NULL; + +JSClassDefinition JSBookmarkItem::m_jsClassInfo = { + 0, // current (and only) version is 0 + kJSClassAttributeNone, //attributes + "BookmarkItem", //class name + NULL, // parent class + JSBookmarkItem::m_property, //static values + NULL, // static functions + JSBookmarkItem::initialize, // initialize + JSBookmarkItem::finalize, //finalize + NULL, //hasProperty + NULL, //getProperty + NULL, //setProperty + NULL, //deleteProperty + NULL, //getPropertyNames + NULL, // callAsFunction + NULL, // constructor + JSBookmarkItem::hasInstance, + NULL // convertToType +}; + + +JSStaticValue JSBookmarkItem::m_property[] = +{ + {TIZEN_BOOKMARKITEM_PARENT, getProperty, NULL, kJSPropertyAttributeReadOnly}, + {TIZEN_BOOKMARKITEM_TITLE, getProperty, NULL, kJSPropertyAttributeReadOnly}, + {TIZEN_BOOKMARKITEM_URL, getProperty, NULL, kJSPropertyAttributeReadOnly}, + { 0, 0, 0, 0 } +}; + + +const JSClassRef JSBookmarkItem::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_jsClassInfo); + } + return m_jsClassRef; +} +const JSClassDefinition* JSBookmarkItem::getClassInfo() +{ + return &m_jsClassInfo; +} + + +void JSBookmarkItem::initialize(JSContextRef ctx, JSObjectRef object) +{ + LogDebug("JSBookmarkItem::initialize()"); +} + +void JSBookmarkItem::finalize(JSObjectRef object) +{ + LogDebug("JSBookmarkItem::finalize()"); + BookmarkData *priv = static_cast(JSObjectGetPrivate(object)); + if( priv ){ + JSObjectSetPrivate(object, NULL); + delete priv; + } +} + +bool JSBookmarkItem::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) { + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + +JSObjectRef JSBookmarkItem::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){ + LogDebug("JSBookmarkItem::constructor()"); + ArgumentValidator validator(ctx, argumentCount, arguments); + try{ + std::string title = validator.toString(0); + std::string url = validator.toString(1); + return createJSObject(ctx, title, url); + }catch(const BasePlatformException& err){ + JSObjectRef error = JSWebAPIError::makeJSWebAPIError(ctx, err); + *exception = error; + return error; + } +} + +JSObjectRef JSBookmarkItem::createJSObject(JSContextRef context, const std::string &title, const std::string &url) { + LogDebug("Enter"); + return createJSObject(context, title, url, UNDEFINED_ID, UNDEFINED_ID); +} +JSObjectRef JSBookmarkItem::createJSObject(JSContextRef context, const std::string &title, const std::string &url, const int id, const int parentId) { + LogDebug("Enter"); + if (title == "") + throw InvalidValuesException("Title is empty"); + if (url == "") + throw InvalidValuesException("URL is empty"); + + BookmarkData *priv = new BookmarkData(BOOKMARKITEM_TYPE, title, url, id, parentId); + JSObjectRef obj = JSObjectMake(context, getClassRef(), priv); + return obj; +} +#if 0 +JSObjectRef JSBookmarkItem::createJSObject(JSContextRef context, void *priv) { + JSObjectRef obj = JSObjectMake(context, getClassRef(), priv); + return obj; +} +#endif +JSValueRef JSBookmarkItem::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) +{ + LogDebug("Enter"); + try { + Converter convert(context); + BookmarkData *priv = static_cast(JSObjectGetPrivate(object)); + + if (!priv) + throw TypeMismatchException("Private data is null"); + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_BOOKMARKITEM_PARENT)) { + return JSBookmarkFolder::getParent(context, object); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_BOOKMARKITEM_TITLE)) { + return convert.toJSValueRef(priv->m_title); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_BOOKMARKITEM_URL)) { + return convert.toJSValueRef(priv->m_url); + } + }catch(const BasePlatformException& err){ + return JSWebAPIError::throwException(context, exception, err); + }catch(const WrtDeviceApis::Commons::ConversionException& err){ + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "converting fail"); + } + return JSValueMakeUndefined(context); +} + + +} // Bookmark +} // TizenApis + diff --git a/src/Bookmark/JSBookmarkItem.h b/src/Bookmark/JSBookmarkItem.h new file mode 100755 index 0000000..75ae5fb --- /dev/null +++ b/src/Bookmark/JSBookmarkItem.h @@ -0,0 +1,57 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_BOOKMARKITEM_H_ +#define _JS_BOOKMARKITEM_H_ + +#include +#include + +namespace DeviceAPI { +namespace Bookmark { + +class JSBookmarkItem +{ + public: + + static const JSClassDefinition* getClassInfo(); + static const JSClassRef getClassRef(); + static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + static JSObjectRef createJSObject(JSContextRef context, const std::string &title, const std::string &url); + static JSObjectRef createJSObject(JSContextRef context, const std::string &title, const std::string &url, const int id, const int parentId); +#if 0 + static JSObjectRef createJSObject(JSContextRef context, void * priv); +#endif + static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); + static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + private: + + static JSClassDefinition m_jsClassInfo; + static JSClassRef m_jsClassRef; + static JSStaticValue m_property[]; + + static void initialize(JSContextRef context, JSObjectRef object); + static void finalize(JSObjectRef object); +}; + +} +} + +#endif /* _JS_BOOKMARKITEM_H_ */ + + + diff --git a/src/Bookmark/JSBookmarkManager.cpp b/src/Bookmark/JSBookmarkManager.cpp new file mode 100755 index 0000000..979d67d --- /dev/null +++ b/src/Bookmark/JSBookmarkManager.cpp @@ -0,0 +1,244 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include "JSBookmarkManager.h" +#include "JSBookmarkFolder.h" +#include "JSBookmarkItem.h" +#include "BookmarkManager.h" +#include "plugin_config.h" +#include +#include +#include +#include + +#include +#include +#include + +#undef LOG_TAG +#define LOG_TAG "TIZEN_DEVICEAPI" + +using namespace std; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace WrtDeviceApis::Commons; +using namespace DeviceAPI::Common; + + +namespace DeviceAPI { +namespace Bookmark { + +JSClassRef JSBookmarkManager::m_jsClassRef = NULL; + +JSClassDefinition JSBookmarkManager::m_jsClassInfo = { + 0, // current (and only) version is 0 + kJSClassAttributeNone, //attributes + "BookmarkManager", //class name + NULL, // parent class + NULL, //static values + JSBookmarkManager::m_function, // static functions + JSBookmarkManager::initialize, // initialize + JSBookmarkManager::finalize, //finalize + NULL, //hasProperty + NULL, //getProperty + NULL, //setProperty + NULL, //deleteProperty + NULL, //getPropertyNames + NULL, // callAsConstructor + NULL, // constructor + JSBookmarkManager::hasInstance, + NULL // convertToType +}; + + +JSStaticFunction JSBookmarkManager::m_function[] = { + { "get", JSBookmarkManager::get, kJSPropertyAttributeNone }, + { "add", JSBookmarkManager::add, kJSPropertyAttributeNone }, + { "remove", JSBookmarkManager::remove, kJSPropertyAttributeNone }, + { 0, 0, 0 } +}; + +const JSClassRef JSBookmarkManager::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_jsClassInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSBookmarkManager::getClassInfo() +{ + return &m_jsClassInfo; +} + +void JSBookmarkManager::initialize(JSContextRef ctx, JSObjectRef object) +{ +} + +void JSBookmarkManager::finalize(JSObjectRef object) +{ +} + +bool JSBookmarkManager::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) { + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + +JSValueRef JSBookmarkManager::get(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){ + LogDebug("Entered"); + AceSecurityStatus status = BOOKMARK_CHECK_ACCESS(BOOKMARK_FUNCTION_API_READ_FUNCS); + TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception); + + try{ + ArgumentValidator validator(ctx, argumentCount, arguments); + + bool reculsive = validator.toBool(1, true); + + JSObjectRef parentobj = NULL; + + parentobj = validator.toObject(0, JSBookmarkFolder::getClassRef(), true); + + BookmarkData * parentFolder = NULL; + if (parentobj) { + parentFolder = static_cast(JSObjectGetPrivate(parentobj)); + + if (!parentFolder) + throw TypeMismatchException("Private data is null"); + } + + BookmarkSearchDataPtr searchData(new BookmarkSearchData(parentFolder,reculsive)); + std::vector bookmarkList = BookmarkManager::getInstance()->get(searchData); + unsigned short bookmarksCount = bookmarkList.size(); + LogDebug("count : " << bookmarksCount); + std::vector bookmarksArray; + Converter converter(ctx); + for (int i = 0; i < bookmarksCount; i++) { + JSValueRef bookmark; + LogDebug("bookmarkList["<m_title)); + if (bookmarkList[i]->m_type == BOOKMARKITEM_TYPE) + bookmark = static_cast(JSBookmarkItem::createJSObject(ctx, bookmarkList[i]->m_title, bookmarkList[i]->m_url, bookmarkList[i]->m_id, bookmarkList[i]->m_parentId)); + else + bookmark = static_cast(JSBookmarkFolder::createJSObject(ctx, bookmarkList[i]->m_title, bookmarkList[i]->m_id, bookmarkList[i]->m_parentId)); + bookmarksArray.push_back(bookmark); + } + + return converter.toJSValueRef(bookmarksArray); + + }catch( const BasePlatformException& err){ + return JSWebAPIError::throwException(ctx, exception, err); + } + + return JSValueMakeUndefined(ctx); + +} + +JSValueRef JSBookmarkManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){ + LogDebug("Entered"); + AceSecurityStatus status = BOOKMARK_CHECK_ACCESS(BOOKMARK_FUNCTION_API_WRITE_FUNCS); + TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception); + + try{ + ArgumentValidator validator(ctx, argumentCount, arguments); + //convert bookmark + JSObjectRef bookmarkobj = NULL; + try { + bookmarkobj = validator.toObject(0, JSBookmarkItem::getClassRef()); + } catch (const TypeMismatchException& err){ + LogDebug("Bookmark's type is not BookmarkItem"); + bookmarkobj = validator.toObject(0, JSBookmarkFolder::getClassRef()); + } + BookmarkData * bookmark = static_cast(JSObjectGetPrivate(bookmarkobj)); + + if (!bookmark) + throw TypeMismatchException("Bookmark private data is null"); + + //convert parentFolder + JSObjectRef parentobj = NULL; + + parentobj = validator.toObject(1, JSBookmarkFolder::getClassRef(), true); + + BookmarkData * parentFolder = NULL; + if (parentobj) { + parentFolder = static_cast(JSObjectGetPrivate(parentobj)); + if (!parentFolder) + throw TypeMismatchException("Parent Folder private data is null"); + } + + int parentId = 0; + if (parentFolder) + parentId = parentFolder->m_id; + else + parentId = BookmarkManager::getInstance()->getRootFolderId(); + + if (parentId == UNDEFINED_ID) + throw Common::NotFoundException("Parent doesn't exist in db"); + + bookmark->m_id = BookmarkManager::getInstance()->add(bookmark->m_type, parentId, bookmark->m_title, bookmark->m_url); + bookmark->m_parentId = parentId; + LogDebug("bookmark id:" << bookmark->m_id); + LogDebug("bookmark parent id:" << bookmark->m_parentId); + + }catch( const BasePlatformException& err){ + return JSWebAPIError::throwException(ctx, exception, err); + } + + return JSValueMakeUndefined(ctx); + +} + +JSValueRef JSBookmarkManager::remove(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){ + LogDebug("Entered"); + AceSecurityStatus status = BOOKMARK_CHECK_ACCESS(BOOKMARK_FUNCTION_API_WRITE_FUNCS); + TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception); + + try{ + ArgumentValidator validator(ctx, argumentCount, arguments); + + JSObjectRef bookmarkobj = NULL; + try { + bookmarkobj = validator.toObject(0, JSBookmarkItem::getClassRef(), true); + } catch (const TypeMismatchException& err){ + LogDebug("Bookmark's type is not BookmarkItem"); + bookmarkobj = validator.toObject(0, JSBookmarkFolder::getClassRef(), true); + } + + BookmarkData *bookmark = NULL; + if (bookmarkobj) { + bookmark = static_cast(JSObjectGetPrivate(bookmarkobj)); + if (!bookmark) + throw TypeMismatchException("Bookmark private data is null"); + } + + BookmarkSearchDataPtr searchData(new BookmarkSearchData(bookmark)); + + BookmarkManager::getInstance()->remove(searchData); + + }catch( const BasePlatformException& err){ + return JSWebAPIError::throwException(ctx, exception, err); + } + + return JSValueMakeUndefined(ctx); + +} +} // Bookmark +} // TizenApis + + diff --git a/src/Bookmark/JSBookmarkManager.h b/src/Bookmark/JSBookmarkManager.h new file mode 100755 index 0000000..92ea1f6 --- /dev/null +++ b/src/Bookmark/JSBookmarkManager.h @@ -0,0 +1,60 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_BOOKMARK_MANAGER_H_ +#define _JS_BOOKMARK_MANAGER_H_ + +#include +#include + +namespace DeviceAPI { +namespace Bookmark { + +class JSBookmarkManager +{ + public: + + static const JSClassDefinition* getClassInfo(); + static const JSClassRef getClassRef(); + + private: + + static JSClassDefinition m_jsClassInfo; + static JSClassRef m_jsClassRef; + + static JSStaticFunction m_function[]; + + 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 get(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + static JSValueRef add(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + static JSValueRef remove(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + + + +}; + +} +} + +#endif /* _JS_BOOKMARK_MANAGER_H_ */ + + diff --git a/src/Bookmark/config.xml b/src/Bookmark/config.xml new file mode 100755 index 0000000..a513eea --- /dev/null +++ b/src/Bookmark/config.xml @@ -0,0 +1,19 @@ + + + + libwrt-plugins-tizen-bookmark.so + bookmark.install.uri + SAMSUNG plugin group + SAMSUNG certificate authority + AAAABBBBCCCCDDDEEEE0000 + + + http://tizen.org/privilege/bookmark.read + bookmark.read + + + + http://tizen.org/privilege/bookmark.write + bookmark.write + + diff --git a/src/Bookmark/plugin_config.cpp b/src/Bookmark/plugin_config.cpp new file mode 100755 index 0000000..a9f3c00 --- /dev/null +++ b/src/Bookmark/plugin_config.cpp @@ -0,0 +1,109 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include "plugin_config.h" + +#define BOOKMARK_FEATURE_API_READ "http://tizen.org/privilege/bookmark.read" +#define BOOKMARK_FEATURE_API_WRITE "http://tizen.org/privilege/bookmark.write" + +#define BOOKMARK_DEVICE_CAP_READ "bookmark.read" +#define BOOKMARK_DEVICE_CAP_WRITE "bookmark.write" + +namespace DeviceAPI { +namespace Bookmark { + +static WrtDeviceApis::Commons::FunctionMapping createBookmarkFunctions(); + +static WrtDeviceApis::Commons::FunctionMapping bookmarkFunctions = + createBookmarkFunctions(); + +DEFINE_FUNCTION_GETTER(Bookmark, bookmarkFunctions); + +static WrtDeviceApis::Commons::FunctionMapping createBookmarkFunctions() +{ + using namespace WrtDeviceApis::Commons; + + /** + * Device capabilities + */ + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BOOKMARK_READ, BOOKMARK_DEVICE_CAP_READ); + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BOOKMARK_WRITE, BOOKMARK_DEVICE_CAP_WRITE); + + ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST); + + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BOOKMARK_READ); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_BOOKMARK_READ, DEVICE_CAP_BOOKMARK_READ); + + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BOOKMARK_WRITE); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_BOOKMARK_WRITE, DEVICE_CAP_BOOKMARK_WRITE); + + /** + * API features + */ + ACE_CREATE_FEATURE(FEATURE_READ, BOOKMARK_FEATURE_API_READ); + ACE_CREATE_FEATURE(FEATURE_WRITE, BOOKMARK_FEATURE_API_WRITE); + + ACE_CREATE_FEATURE_LIST(BOOKMARK_FEATURES_READ); + ACE_ADD_API_FEATURE(BOOKMARK_FEATURES_READ, FEATURE_READ); + + ACE_CREATE_FEATURE_LIST(BOOKMARK_FEATURES_WRITE); + ACE_ADD_API_FEATURE(BOOKMARK_FEATURES_WRITE, FEATURE_WRITE); + + /** + * Functions + */ + FunctionMapping bookmarkFunctions; + + AceFunction bookmarkReadFuncs = ACE_CREATE_FUNCTION( + FUNCTION_BOOKMARK_READ_FUNCTIONS, + BOOKMARK_FUNCTION_API_READ_FUNCS, + BOOKMARK_FEATURES_READ, + DEVICE_LIST_BOOKMARK_READ); + + bookmarkFunctions.insert(std::make_pair( + BOOKMARK_FUNCTION_API_READ_FUNCS, + bookmarkReadFuncs)); + + AceFunction bookmarkWriteFuncs = ACE_CREATE_FUNCTION( + FUNCTION_BOOKMARK_WRITE_FUNCTIONS, + BOOKMARK_FUNCTION_API_WRITE_FUNCS, + BOOKMARK_FEATURES_WRITE, + DEVICE_LIST_BOOKMARK_WRITE); + + bookmarkFunctions.insert(std::make_pair( + BOOKMARK_FUNCTION_API_WRITE_FUNCS, + bookmarkWriteFuncs)); + + + return bookmarkFunctions; +} + +} // namespace Bookmark +} // namespace DeviceAPI + +#undef BOOKMARK_DEVICE_CAP_WRITE +#undef BOOKMARK_DEVICE_CAP_READ +#undef BOOKMARK_FEATURE_API_WRITE +#undef BOOKMARK_FEATURE_API_READ + diff --git a/src/Bookmark/plugin_config.h b/src/Bookmark/plugin_config.h new file mode 100755 index 0000000..5b14bc0 --- /dev/null +++ b/src/Bookmark/plugin_config.h @@ -0,0 +1,39 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 _BOOKMARK_PLUGIN_CONFIG_H_ +#define _BOOKMARK_PLUGIN_CONFIG_H_ + +#include + +namespace DeviceAPI { +namespace Bookmark { + +#define BOOKMARK_FUNCTION_API_READ_FUNCS "BookmarkReadFunction" +#define BOOKMARK_FUNCTION_API_WRITE_FUNCS "BookmarkWriteFunction" + +DECLARE_FUNCTION_GETTER(Bookmark); + +#define BOOKMARK_CHECK_ACCESS(functionName) \ + aceCheckAccess >( \ + getBookmarkFunctionData, \ + functionName) +} +} + +#endif // _BOOKMARK_PLUGIN_CONFIG_H_ diff --git a/src/Bookmark/plugin_initializer.cpp b/src/Bookmark/plugin_initializer.cpp new file mode 100755 index 0000000..ef9f908 --- /dev/null +++ b/src/Bookmark/plugin_initializer.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include + +#include +#include +#include +#include +#include "JSBookmarkManager.h" +#include "JSBookmarkFolder.h" +#include "JSBookmarkItem.h" + +namespace DeviceAPI { +namespace Bookmark { + +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; +using namespace DeviceAPI::Common; + +void on_widget_start_callback(int widgetId) +{ + LogDebug("[Tizen\\Bookmark] on_widget_start_callback (" << widgetId << ")"); + + Try { + WrtAccessSingleton::Instance().initialize(widgetId); + } Catch (Exception) { + LogError("WrtAccess initialization failed"); + } +} + +void on_widget_stop_callback(int widgetId) +{ + LogDebug("[Tizen\\Bookmark] on_widget_stop_callback (" << widgetId << ")"); + + Try { + WrtAccessSingleton::Instance().deinitialize(widgetId); + } Catch (Exception) { + LogError("WrtAccess deinitialization failed"); + } +} + +void on_frame_load_callback(const void * context) +{ + LogDebug("[Tizen\\Bookmark] on_frame_load_callback (" << context << ")"); + GlobalContextManager::getInstance()->addGlobalContext(static_cast(context)); +} + +void on_frame_unload_callback(const void * context) +{ + LogDebug("[Tizen\\Bookmark] on_frame_unload_callback (" << context << ")"); + GlobalContextManager::getInstance()->removeGlobalContext(static_cast(context)); +} + +class_definition_options_t BookmarkOptions = +{ + JS_INTERFACE, + CREATE_INSTANCE, + NONE_NOTICE, + USE_OVERLAYED, //ignored + NULL, + NULL, + NULL +}; + +PLUGIN_ON_WIDGET_START(on_widget_start_callback) +PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback) + +PLUGIN_ON_FRAME_LOAD(on_frame_load_callback) +PLUGIN_ON_FRAME_UNLOAD(on_frame_unload_callback) + +PLUGIN_CLASS_MAP_BEGIN +PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, + "bookmark", + (js_class_template_getter)JSBookmarkManager::getClassRef, + NULL) +PLUGIN_CLASS_MAP_ADD_INTERFACE(WRT_JS_EXTENSION_OBJECT_TIZEN, + "BookmarkItem", + (js_class_template_getter)JSBookmarkItem::getClassRef, + reinterpret_cast(JSBookmarkItem::constructor), + &BookmarkOptions) +PLUGIN_CLASS_MAP_ADD_INTERFACE(WRT_JS_EXTENSION_OBJECT_TIZEN, + "BookmarkFolder", + (js_class_template_getter)JSBookmarkFolder::getClassRef, + reinterpret_cast(JSBookmarkFolder::constructor), + &BookmarkOptions) +PLUGIN_CLASS_MAP_END + +} +} + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt old mode 100644 new mode 100755 index 2b23445..38887fa --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,26 +1,58 @@ -# Includes CMake configuration file (*.cmake), preserving appropriate paths. -macro(include_config_file INCLUDED_CONFIG_FILE_PATH) - get_filename_component(CURRENT_CONFIG_FILE_PATH ${CMAKE_CURRENT_LIST_FILE} PATH) - include(${CURRENT_CONFIG_FILE_PATH}/${INCLUDED_CONFIG_FILE_PATH}/${CONFIG_FILE_NAME} OPTIONAL) -endmacro() +# ----------------------------------------------------------------------------- +# Common Module +# ----------------------------------------------------------------------------- +SET(COMMON_TARGET_NAME "wrt-plugins-tizen-common") +SET(COMMON_DESTINATION_NAME "tizen-tizen") -# Gets actual path for CMake configuration file (*.cmake). -# By default, if no argument is passed, current path will be set to variable -# named CURRENT_PATH. -# @param [Optional] Name of the variable to set with current path. -macro(get_current_path) - set(VARIABLE "CURRENT_PATH") - if (${ARGC} GREATER 0) - set(VARIABLE ${ARGV0}) - endif () - get_filename_component(${VARIABLE} ${CMAKE_CURRENT_LIST_FILE} PATH) -endmacro() +SET(CMAKE_INSTALL_RPATH + ${CMAKE_INSTALL_RPATH} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${COMMON_DESTINATION_NAME} +) -set(HOST_ARCH $ENV{DEB_HOST_ARCH}) -if("${HOST_ARCH}" MATCHES "armel") - set(HOST_ARCH "armel") -endif() +configure_and_install_pkg(wrt-plugins-tizen-common.pc) +add_subdir(Common) -add_subdirectory(platform) -add_subdirectory(standards) +set(LIBS_COMMON + ${LIBS_COMMON} + ${COMMON_TARGET_NAME} +) +add_subdir(Common/StandaloneConsole) + +set(LIBS_TEST + ${LIBS_COMMON} + "standaloneconsole" +) + +# ----------------------------------------------------------------------------- +# Plugin Modules +# ----------------------------------------------------------------------------- + +add_plugin( + Tizen + Content + Calendar + Contact + DataControl + Bluetooth + Application + Messaging + Callhistory + TimeUtil + Systeminfo + NFC + Log + Filesystem + Alarm + Power + Notification + Download + NetworkBearerSelection + Push + SystemSetting + MessagePort + Package + Bookmark + SecureElement + DataSync +) diff --git a/src/Calendar/CMakeLists.txt b/src/Calendar/CMakeLists.txt new file mode 100755 index 0000000..a3476a2 --- /dev/null +++ b/src/Calendar/CMakeLists.txt @@ -0,0 +1,87 @@ +SET(TARGET_NAME ${calendar_target}) +SET(DESTINATION_NAME ${calendar_dest}) +SET(TARGET_IMPL_NAME ${calendar_impl}) + +PKG_SEARCH_MODULE(calendar REQUIRED calendar-service2) +PKG_SEARCH_MODULE(icu REQUIRED icu-i18n) + +SET(CMAKE_INSTALL_RPATH + ${CMAKE_INSTALL_RPATH} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${contact_dest} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME} +) + +SET(SRCS_IMPL + CalendarResponseDispatcher.cpp + CalendarConverter.cpp + JSCalendarEvent.cpp + JSCalendarTask.cpp + JSCalendarItemProperties.cpp + JSCalendarEventId.cpp + JSCalendar.cpp + JSCalendarManager.cpp + JSCalendarAttendee.cpp + JSCalendarRecurrenceRule.cpp + JSCalendarAlarm.cpp + JSStringArray.cpp + JSNumberArray.cpp + JSTZDateArray.cpp + CalendarAsyncCallbackManager.cpp + CalendarListenerManager.cpp + Calendar.cpp + CalendarManager.cpp + EventWrapper.cpp + CalendarFilter.cpp + CalendarFilterValidator.cpp + CalendarEvent.cpp + CalendarFactory.cpp + ICalendar.cpp + ICalendarManager.cpp + EventAttendee.cpp + EventRecurrenceRule.cpp + EventId.cpp + EventAlarm.cpp + CalendarUtility.cpp +) + +INCLUDE_DIRECTORIES( + ${TOP}/Tizen + ${TOP}/TimeUtil + ${TOP}/Contact + ${TOP}/Common + ${calendar_INCLUDE_DIRS} + ${icu_INCLUDE_DIRS} +) + +ADD_LIBRARY(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL}) + +TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME} + ${LIBS_COMMON} + ${calendar_LIBRARIES} + ${icu_LIBRARIES} +) + +SET(SRCS + plugin_config.cpp + plugin_initializer.cpp +) + +ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS}) + +TARGET_LINK_LIBRARIES(${TARGET_NAME} + ${TARGET_IMPL_NAME} + ${contact_impl} + ${contact_config} + ${tizen_impl} + ${timeutil_impl} + ${LIBS_COMMON} +) + +INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) +INSTALL( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/calendar + FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE +) \ No newline at end of file diff --git a/src/Calendar/Calendar.cpp b/src/Calendar/Calendar.cpp new file mode 100755 index 0000000..85663b1 --- /dev/null +++ b/src/Calendar/Calendar.cpp @@ -0,0 +1,1324 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include "Calendar.h" +#include "CalendarManager.h" +#include "CalendarFilter.h" +#include "CalendarFilterValidator.h" +#include "CalendarUtility.h" +#include "OnEventsChanged.h" +#include "IEventWatchChanges.h" +#include "IEventClearWatch.h" +#include "EventId.h" +#include +#include +#include +#include + +using namespace WrtDeviceApis::Commons; + +namespace DeviceAPI { +namespace Calendar { + +Calendar::Calendar() +{ +} + +Calendar::~Calendar() +{ +} + +void Calendar::OnRequestReceived(const IEventAddEventPtr &event) +{ + Try + { + if (!event->getEvent()) { + ThrowMsg(NullPointerException, "Item parameter is NULL."); + } + if (event->getEvent()->getIdIsSet()) { + LogWarning("Non-null item id."); + event->getEvent()->resetId(); + } + + DPL::ScopedPtr eventWrapper(new EventWrapper(event->getEvent(), getType())); + + if(getIsUnified()) { + LogDebug("Set the default calendar id for a unified calendar item."); + event->getEvent()->setCalendarId(DEFAULT_EVENT_CALENDAR_BOOK_ID); + } else { + std::stringstream ss(getId()); + int calendarId; + ss>>calendarId; + event->getEvent()->setCalendarId(calendarId); + } + + eventWrapper->convertAbstractEventToPlatformEvent(); + + eventWrapper->saveEvent(); + + event->setResult(true); + } + Catch (Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } +} + +void Calendar::OnRequestReceived(const IEventAddEventsPtr &event) +{ + calendar_list_h listForAdd = NULL; + + Try + { + if (event->getEvents()->empty()) { + ThrowMsg(NullPointerException, "Item array is empty."); + } + + int ret, count = 0; + calendar_record_h record = NULL; + int* ids = NULL; + + ret = calendar_list_create(&listForAdd); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Can't create a list: "<getEvents()->size(); i++) { + CalendarEventPtr theItem = event->getEvents()->at(i); + if (theItem->getIdIsSet()) { + LogWarning("Item has index: " << i << ". Resetting it."); + theItem->resetId(); + } + DPL::ScopedPtr eventWrapper(new EventWrapper(theItem, getType())); + + if(getIsUnified()) { + LogDebug("Set the default calendar id for a unified calendar item."); + theItem->setCalendarId(DEFAULT_EVENT_CALENDAR_BOOK_ID); + } else { + std::stringstream ss(getId()); + int calendarId; + ss>>calendarId; + theItem->setCalendarId(calendarId); + } + + eventWrapper->convertAbstractEventToPlatformEvent(); + + // Clone the record because the platform event will be freed by destructor. + record = NULL; + ret = calendar_record_clone(eventWrapper->getPlatformEvent(), &record); + if(CALENDAR_ERROR_NONE!=ret) { + ThrowMsg(PlatformException, "Clonning failed: "<getEvents()->at(i)->setId(ids[i]); + } + + if(ids) { + free(ids); + } + + event->setResult(true); + } + Catch (Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } + + if(listForAdd) { + calendar_list_destroy(listForAdd, true); + } +} + +void Calendar::OnRequestReceived(const IEventUpdateEventPtr &event) +{ + calendar_query_h query = NULL; + calendar_filter_h filter = NULL; + + Try + { + if (!event->getEvent()) { + ThrowMsg(NullPointerException, "Item object is NULL."); + } + + CalendarEventPtr theItem = event->getEvent(); + if (!theItem->getIdIsSet()) { + ThrowMsg(InvalidArgumentException, "Item id is not set."); + } + + int ret; + + const char *dataType; + if(getType() == CalendarEvent::TASK_TYPE) { + dataType = _calendar_todo._uri; + } else { + dataType = _calendar_event._uri; + } + + DPL::ScopedPtr eventWrapper(new EventWrapper(theItem, getType())); + eventWrapper->convertAbstractEventToPlatformEvent(true); + + if ( event->getUpdateAllInstances() || 0>=theItem->getRecurrenceRule()->getFrequency()) { + // Platform detects the detached events and uptates all instances. + eventWrapper->saveEvent(); + } else { + LogDebug("Update the exdate for a recurring parent event and add a new child event."); + + // First update the parent event. + EventRecurrenceRulePtr rrule = theItem->getRecurrenceRule(); + (*rrule->getExceptions()).push_back(theItem->getRecurrenceId()); + + std::string exdate = ""; + for( unsigned int i=0; igetExceptions()->size(); i++ ) { + std::stringstream ss; + ss<getExceptions()->at(i); + exdate.append(ss.str()); + if(i!=rrule->getExceptions()->size()-1) { + exdate.append(","); + } + } + ret = calendar_record_set_str(eventWrapper->getPlatformEvent(), _calendar_event.exdate, exdate.c_str()); + if(ret!=CALENDAR_ERROR_NONE) { + ThrowMsg(PlatformException, "Can't update the exdate: "<getPlatformEvent(), _calendar_event.recurrence_id, NULL); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Can't set recurrence id."); + } + + eventWrapper->saveEvent(); + + // Now add the detached child event. + EventRecurrenceRulePtr emptyRRule( new EventRecurrenceRule() ); + // Detached event should not have rrule set. + theItem->setRecurrenceRule(emptyRRule); + + theItem->setParentId(theItem->getId()); + + // Convert the modified child event. + eventWrapper->convertAbstractEventToPlatformEvent(); + + // Reset id for record insertion. + theItem->resetId(); + eventWrapper->saveEvent(); + + theItem->setIsDetached(true); + } + + event->setResult(true); + } + Catch (Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } + + if(query) { + calendar_query_destroy(query); + } + if(filter) { + calendar_filter_destroy(filter); + } +} + +void Calendar::OnRequestReceived(const IEventUpdateEventsPtr &event) +{ + calendar_list_h listForUpdate = NULL; + calendar_list_h listForAdd = NULL; + calendar_query_h query = NULL; + calendar_filter_h filter = NULL; + + Try + { + if (event->getEvents()->empty()) { + ThrowMsg(NullPointerException, "Item array is empty."); + } + + int ret, count = -1; + calendar_record_h record = NULL; + + const char *dataType; + if(getType() == CalendarEvent::TASK_TYPE) { + dataType = _calendar_todo._uri; + } else { + dataType = _calendar_event._uri; + } + + ret = calendar_list_create(&listForUpdate); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Can't create a list for update: "<getEvents()->size(); i++) { + CalendarEventPtr thisEvent = event->getEvents()->at(i); + if (!thisEvent->getIdIsSet()) { + ThrowMsg(InvalidArgumentException, "Item id is not set."); + } + + DPL::ScopedPtr eventWrapper(new EventWrapper(thisEvent, getType())); + eventWrapper->convertAbstractEventToPlatformEvent(true); + + if( true==thisEvent->getIsDetached() ) { + // Treat the detached event same as the parent event. + record = NULL; + ret = calendar_record_clone(eventWrapper->getPlatformEvent(), &record); + if(CALENDAR_ERROR_NONE!=ret) { + ThrowMsg(PlatformException, "Clonning failed: "<getId()); + } + } else if (event->getUpdateAllInstances() || 0>=thisEvent->getRecurrenceRule()->getFrequency()) { + // Platform detects the detached events and uptates all instances. + record = NULL; + ret = calendar_record_clone(eventWrapper->getPlatformEvent(), &record); + if(CALENDAR_ERROR_NONE!=ret) { + ThrowMsg(PlatformException, "Clonning failed: "< eventWrapperChild(new EventWrapper(thisEvent, getType())); + eventWrapperChild->convertAbstractEventToPlatformEvent(true); + + std::stringstream ss; + ss<getRecurrenceId(); + ret = calendar_record_set_str(eventWrapperChild->getPlatformEvent(), _calendar_event.recurrence_id, ss.str().c_str()); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Cannot set event recurrence id: "<getRecurrenceId()); + } + + ret = calendar_record_set_int(eventWrapperChild->getPlatformEvent(), _calendar_event.original_event_id, thisEvent->getId()); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Cannot set the parent id: "<getPlatformEvent(), _calendar_event.freq, CALENDAR_RECURRENCE_NONE); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Cannot set the frequency: "<getPlatformEvent(), &record); + if(CALENDAR_ERROR_NONE!=ret) { + ThrowMsg(PlatformException, "Clonning the child event failed: "<setIsDetached(true); + + // Now update the parent event. + EventRecurrenceRulePtr rrule = thisEvent->getRecurrenceRule(); + (*rrule->getExceptions()).push_back(thisEvent->getRecurrenceId()); + + std::string exdate = ""; + for( unsigned int j=0; jgetExceptions()->size(); j++ ) { + std::stringstream ss; + ss<getExceptions()->at(j); + exdate.append(ss.str()); + if(j!=rrule->getExceptions()->size()-1) { + exdate.append(","); + } + } + ret = calendar_record_set_str(eventWrapper->getPlatformEvent(), _calendar_event.exdate, exdate.c_str()); + if(ret!=CALENDAR_ERROR_NONE) { + ThrowMsg(PlatformException, "Can't update the exdate: "<getPlatformEvent(), &record); + if(CALENDAR_ERROR_NONE!=ret) { + ThrowMsg(PlatformException, "Clonning the child event failed: "<0) { + ret = calendar_db_insert_records(listForAdd, NULL, NULL); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Can't insert the item list: "<0) { + ret = calendar_db_update_records(listForUpdate); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Can't update the item list: "<setResult(true); + } + Catch (Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } + + if(listForAdd) { + calendar_list_destroy(listForAdd, true); + } + if(listForUpdate) { + calendar_list_destroy(listForUpdate, true); + } + if(query) { + calendar_query_destroy(query); + } + if(filter) { + calendar_filter_destroy(filter); + } +} + +void Calendar::OnRequestReceived(const IEventDeleteEventPtr &event) +{ + Try + { + if (!event->getEventId()) { + ThrowMsg(NullPointerException, "Item id is not set."); + } + + DPL::ScopedPtr eventWrapper(new EventWrapper(getType())); + event->getEventId()->setCalendarType(getType()); + std::istringstream stream(event->getEventId()->getUId()); + int id = -1; + stream>>id; + eventWrapper->getAbstractEvent()->setId(id); + + std::stringstream ss(event->getEventId()->getRecurrenceId()); + long long int rid; + ss>>rid; + + LogDebug("id: " << id << ", rid: " << rid); + + eventWrapper->loadEvent(id); + + // recurrence id is reset while loading the platform event. + eventWrapper->getAbstractEvent()->setRecurrenceId(rid); + + eventWrapper->deleteEvent(); + event->setResult(true); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::NotFoundException); + } + Catch (Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } +} + +void Calendar::OnRequestReceived(const IEventGetPtr &event) +{ + Try + { + if (!event->getItemId()) { + ThrowMsg(NullPointerException, "Id parameter is NULL"); + } + + DPL::ScopedPtr eventWrapper(new EventWrapper(getType())); + std::stringstream ss(event->getItemId()->getUId()); + int id = -1; + ss>>id; + + eventWrapper->loadEvent(id); + + event->setItem(eventWrapper->getAbstractEvent()); + event->setResult(true); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::NotFoundException); + } + Catch (Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } +} + +void Calendar::OnRequestReceived(const IEventDeleteEventsPtr &event) +{ + calendar_list_h listForUpdate = NULL; + calendar_query_h query = NULL; + calendar_filter_h filter = NULL; + + Try + { + if (event->getEventIds()->empty()) { + ThrowMsg(NullPointerException, "Item id array is empty."); + } + + std::vector listForDelete; + std::vector listForDetached; + std::vector listForDetachedParent; + + int ret, id, count; + long long int rid; + calendar_record_h item, record; + const char *dataType = NULL; + + ret = calendar_list_create(&listForUpdate); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Can't create a list for update: "<getEventIds()->size(); i++) { + DPL::ScopedPtr eventWrapper(new EventWrapper(getType())); + event->getEventIds()->at(i)->setCalendarType(getType()); + + std::istringstream stream(event->getEventIds()->at(i)->getUId()); + stream>>id; + eventWrapper->getAbstractEvent()->setId(id); + + eventWrapper->loadEvent(id); + item = eventWrapper->getPlatformEvent(); + + std::stringstream ss(event->getEventIds()->at(i)->getRecurrenceId()); + ss>>rid; + eventWrapper->getAbstractEvent()->setRecurrenceId(rid); + + // If the recurrenceId is set, delete the instance of recurring event only. + LogDebug("id to delete: " << id << ", rid: " << rid << ", type: " << getType()); + + dataType = NULL; + if(getType() == CalendarEvent::TASK_TYPE) { + dataType = _calendar_todo._uri; + } else { + dataType = _calendar_event._uri; + } + + /* Platform detects the detached events and deletes them automatically. + But if both parent and detached ids are added to the list, platform error is returned. */ + if ( 0>=rid ) { + listForDelete.push_back(id); + } else if (true==eventWrapper->getAbstractEvent()->getIsDetached() ) { + listForDetached.push_back(id); + + int parentId; + ret = calendar_record_get_int(eventWrapper->getPlatformEvent(), _calendar_event.original_event_id, &parentId); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Can't get the parent id: "<getAbstractEvent()->getRecurrenceRule(); + (*rrule->getExceptions()).push_back(rid); + + std::string exdate = ""; + for( unsigned int i=0; igetExceptions()->size(); i++ ) { + std::stringstream ss; + ss<getExceptions()->at(i); + exdate.append(ss.str()); + if(i!=rrule->getExceptions()->size()-1) { + exdate.append(","); + } + } + ret = calendar_record_set_str(item, _calendar_event.exdate, exdate.c_str()); + if(ret!=CALENDAR_ERROR_NONE) { + ThrowMsg(PlatformException, "Can't delete the instance: "<0) { + ret = calendar_db_update_records(listForUpdate); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Can't update the item list: "<::iterator it; + it = std::find(listForDelete.begin(), listForDelete.end(), listForDetachedParent.at(count)); + if(listForDelete.end()==it) { + listForDelete.push_back(listForDetached.at(count)); + LogDebug("Add the detached event id to the delete list: "<0) { + ret = calendar_db_delete_records(dataType, &listForDelete[0], count); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Can't delete the records: "<setResult(true); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::NotFoundException); + } + Catch (Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } + + if(query) { + calendar_query_destroy(query); + } + if(filter) { + calendar_filter_destroy(filter); + } + if(listForUpdate) { + calendar_list_destroy(listForUpdate, true); + } +} + +void Calendar::OnRequestReceived(const IEventFindEventsPtr &event) +{ + Try + { + CalendarFilterPtr calendarFilter( new CalendarFilter() ); + + calendarFilter->setType(getType()); + LogDebug("Default filter created with type "<(calendarFilter); + + int calendarId; + std::stringstream ss(getId()); + ss>>calendarId; + if (event->getGenericFilterIsSet()) { + DeviceAPI::Tizen::FilterPtr genericFilter = event->getGenericFilter(); + + DeviceAPI::Tizen::FilterValidatorPtr validator = CalendarFilterValidatorFactory::getCalendarFilterValidator(); + bool success = genericFilter->validate(validator); + if(!success) { + ThrowMsg(InvalidArgumentException, "Invalid filter arguments."); + } else { + LogDebug("Filter validation has passed."); + } + + genericFilter->travel(filterTraversal, 0); + + if(getIsUnified()) { + LogDebug("Set all calendars flag for a unified calendar."); + calendarFilter->setCalendarId(CALENDAR_BOOK_FILTER_ALL, true); + } else { + LogDebug("Set additional calendar id: "<setCalendarId(calendarId, true); + } + } else { + if(getIsUnified()) { + LogDebug("Set all calendars flag for a unified calendar."); + calendarFilter->setCalendarId(CALENDAR_BOOK_FILTER_ALL, false); + } else { + LogDebug("Set calendar id: "<setCalendarId(calendarId, false); + } + } + + if (event->getSortModesIsSet()) { + calendarFilter->setSortMode(event->getSortModes()); + } + + calendarFilter->executeQuery(); + + LogDebug("Return the query result after conversion."); + + calendar_list_h resultList = calendarFilter->getResultRecordList(); + int ret; + int count = calendarFilter->getResultRecordCount(); + calendar_record_h currentRecord = NULL; + + calendar_list_first(resultList); + + while(count--) { + currentRecord = NULL; + ret = calendar_list_get_current_record_p(resultList, ¤tRecord); + if ( CALENDAR_ERROR_NONE != ret ) { + ThrowMsg(PlatformException, "Can't get current record: "< eventWrapper(new EventWrapper(currentRecord, getType())); + event->addEvent(eventWrapper->convertPlatformEventToAbstractEvent()); + + calendar_list_next(resultList); + } + LogDebug("Length of found events: "<getEvents()->size()); + + event->setResult(true); + } + Catch (InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::InvalidArgumentException); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::NotFoundException); + } + Catch (Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } +} + +void Calendar::OnRequestReceived(const IEventCreateEventFromStringPtr &event) +{ + Try + { + DPL::ScopedPtr eventWrapper(new EventWrapper(getType())); + eventWrapper->createEventFromString(event->getEventString()); + event->setEvent(eventWrapper->convertPlatformEventToAbstractEvent()); + event->getEvent()->setCalendarType(getType()); + event->setResult(true); + } + Catch(PlatformException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + LogDebug("eventString: " + event->getEventString()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::InvalidArgumentException); + } + Catch (Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + LogDebug("eventString: " + event->getEventString()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } +} + +void Calendar::OnRequestReceived(const IEventExportEventToStringPtr &event) +{ + Try + { + if (!event->getEvent()) { + ThrowMsg(NullPointerException, "event parameter is NULL"); + } + + DPL::ScopedPtr eventWrapper(new EventWrapper(event->getEvent(), getType())); + event->getEvent()->setCalendarType(getType()); + eventWrapper->convertAbstractEventToPlatformEvent(); + event->setEventString(eventWrapper->exportEventToString()); + event->setResult(true); + } + Catch (Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } +} + +static void eventChangedCb(const char *view_uri, void *user_data) +{ + LogDebug("Items change cb with view_uri: "<getIsUnified()) { + LogDebug("Set the all calendar id for a unified calendar."); + calendarId = CALENDAR_BOOK_FILTER_ALL; + } else { + std::stringstream ss(thisCalendar->getId()); + ss>>calendarId; + } + + LogDebug("Getting items with calendar id: "<getLastChangedVersion()<<", type: "<getType()); + if (CalendarEvent::TASK_TYPE==thisCalendar->getType()) { + ret = calendar_db_get_changes_by_version(_calendar_todo._uri, calendarId, thisCalendar->getLastChangedVersion(), &list, &updatedVersion); + } else { + ret = calendar_db_get_changes_by_version(_calendar_event._uri, calendarId, thisCalendar->getLastChangedVersion(), &list, &updatedVersion); + } + if( CALENDAR_ERROR_NONE!=ret ) { + ThrowMsg(PlatformException, "Can't get the updated item list: "<setStatus(OnEventsChanged::ON_ADD); + } else if ( CALENDAR_EVENT_MODIFIED_STATUS_UPDATED==type ) { + eventPtr->setStatus(OnEventsChanged::ON_UPDATE); + } else if ( CALENDAR_EVENT_MODIFIED_STATUS_DELETED==type ) { + eventPtr->setStatus(OnEventsChanged::ON_DELETE); + } else { + LogWarning("Wrong change type."); + calendar_list_next(list); + continue; + } + + DPL::ScopedPtr eventWrapper(new EventWrapper(thisCalendar->getType())); + Try { + eventWrapper->loadEvent(id); + } Catch (NotFoundException){ + LogDebug("Handling deleted event with index: "<addEvent(eventWrapper->getAbstractEvent()); + + calendar_list_next(list); + } + + ret = calendar_db_get_current_version(&updatedVersion); + if( CALENDAR_ERROR_NONE!=ret ) { + ThrowMsg(PlatformException, "Can't get new version: "<setLastChangedVersion(updatedVersion); + LogDebug("Last change fetch version: "<getLastChangedVersion()); + + eventPtr->setResult(true); + eventPtr->setCalendarType(thisCalendar->getType()); + + if( eventPtr->getEventList()->size() > 0 ) { + thisCalendar->m_changeEmitters.emit(eventPtr); + } else { + LogDebug("No actual changes. Skip signal emission."); + } + } + Catch (Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + + if( list ) { + calendar_list_destroy(list, true); + } +} + +void Calendar::OnRequestReceived(const IEventWatchChangesPtr &event) +{ + Try + { + // Subscribe the watch to the platform just once. + int ret; + if( m_changeEmitters.size()==0 ) + { + const char *dataType; + if(getType() == CalendarEvent::TASK_TYPE) { + dataType = _calendar_todo._uri; + } else { + dataType = _calendar_event._uri; + } + + ret = calendar_db_add_changed_cb(dataType, eventChangedCb, this); + if( CALENDAR_ERROR_NONE!=ret ) { + ThrowMsg(PlatformException, "Can't add db changed cb: "<getEmitter()); + event->setWatchId(event->getEmitter()->getId()); + event->setResult(true); + } + Catch (Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } +} + +void Calendar::OnRequestReceived(const IEventClearWatchPtr &event) +{ + Try + { + if( m_changeEmitters.detach(event->getWatchId()) ) { + if( m_changeEmitters.size()==0 ) { + const char *dataType; + if(getType() == CalendarEvent::TASK_TYPE) { + dataType = _calendar_todo._uri; + } else { + dataType = _calendar_event._uri; + } + + if( CALENDAR_ERROR_NONE!=calendar_db_remove_changed_cb(dataType, eventChangedCb, this) ) { + ThrowMsg(PlatformException, "Can't remove change cb."); + } else { + LogDebug("Platform watch cleared successfully."); + } + } + event->setResult(true); + } else { + LogDebug("Wrong watch Id."); + event->setResult(false); + } + } + Catch (Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } +} + +void Calendar::OnRequestReceived(const IEventExpandEventRecurrencePtr &event) +{ + const CalendarEventPtr calEvent = event->getEvent(); + const long long int startDate = event->getStartDate(); + const long long int endDate = event->getEndDate(); + bool isAllDay = calEvent->getIsAllDay(); + + calendar_query_h query = NULL; + calendar_filter_h filter = NULL; + calendar_list_h list = NULL; + + Try { + if ( 0 >= calEvent->getRecurrenceRule()->getFrequency()) { + ThrowMsg(InvalidArgumentException, "This is not a recurring event."); + } + + calendar_record_h currentRecord = NULL; + int ret, currentRecordIndex, count=0; + + calendar_time_s st, et; + if( true==isAllDay ) { + st.type = CALENDAR_TIME_LOCALTIME; + st.time.date = CalendarUtility::LLIToCalTime(calEvent->getTimeZone().c_str(), startDate).time.date; + + et.type = CALENDAR_TIME_LOCALTIME; + et.time.date = CalendarUtility::LLIToCalTime(calEvent->getTimeZone().c_str(), endDate).time.date; + } else { + st.type = CALENDAR_TIME_UTIME; + st.time.utime = startDate; + + et.type = CALENDAR_TIME_UTIME; + et.time.utime = endDate; + } + + if( true==isAllDay ) { + ret = calendar_query_create(_calendar_instance_allday_calendar_book._uri, &query); + } else { + ret = calendar_query_create(_calendar_instance_normal_calendar_book._uri, &query); + } + if( CALENDAR_ERROR_NONE!=ret ) { + ThrowMsg(PlatformException, "Creating a query failed: "<getId()) { + DPL::ScopedPtr recurringEventWrapper(new EventWrapper(getType())); + recurringEventWrapper->loadEvent(calEvent->getId()); + + // Set distintive attributes of each instance. + if( true==isAllDay ) { + ret = calendar_record_get_caltime(currentRecord, _calendar_instance_allday_calendar_book.start_time, &st); + + recurringEventWrapper->getAbstractEvent()->setRecurrenceId(CalendarUtility::calTimeToLLI(calEvent->getTimeZone().c_str(), st)); + recurringEventWrapper->getAbstractEvent()->setStartTime(CalendarUtility::calTimeToLLI(calEvent->getTimeZone().c_str(), st)); + } else { + ret = calendar_record_get_caltime(currentRecord, _calendar_instance_normal_calendar_book.start_time, &st); + + recurringEventWrapper->getAbstractEvent()->setRecurrenceId(st.time.utime); + recurringEventWrapper->getAbstractEvent()->setStartTime(st.time.utime); + } + if ( CALENDAR_ERROR_NONE != ret ) { + ThrowMsg(PlatformException, "Can't get current record start time: "<getAbstractEvent()->setEndTime(CalendarUtility::calTimeToLLI(calEvent->getTimeZone().c_str(), et)); + } else { + ret = calendar_record_get_caltime(currentRecord, _calendar_instance_normal_calendar_book.end_time, &et); + + recurringEventWrapper->getAbstractEvent()->setEndTime(et.time.utime); + } + if ( CALENDAR_ERROR_NONE != ret ) { + ThrowMsg(PlatformException, "Can't get current record end time: "<getAbstractEvent()->getRecurrenceId()); + + event->addExpandedEvent(recurringEventWrapper->getAbstractEvent()); + } + + calendar_list_next(list); + } + LogDebug("Length of expanded events from parent: "<getExpandedEventList()->size()); + + if(query) { + calendar_query_destroy(query); + query = NULL; + } + if(filter) { + calendar_filter_destroy(filter); + filter = NULL; + } + if( list ) { + calendar_list_destroy(list, true); + list = NULL; + } + + // Consider the detached events also. + currentRecord = NULL; + int parentId = event->getEvent()->getId(); + + ret = calendar_query_create(_calendar_event._uri, &query); + if( CALENDAR_ERROR_NONE!=ret ) { + ThrowMsg(PlatformException, "Creating a query failed: "<=startDate && et.time.utime<=endDate) { + LogDebug("Found a valid detached event: "< detachedEventWrapper(new EventWrapper(getType())); + detachedEventWrapper->loadEvent(currentRecordIndex); + + // Set the same parent uid to each instances + detachedEventWrapper->getAbstractEvent()->setId(parentId); + // Set distintive attributes of each instance. + detachedEventWrapper->getAbstractEvent()->setRecurrenceId(st.time.utime); + detachedEventWrapper->getAbstractEvent()->setStartTime(st.time.utime); + detachedEventWrapper->getAbstractEvent()->setEndTime(et.time.utime); + + event->addExpandedEvent(detachedEventWrapper->getAbstractEvent()); + } + + calendar_list_next(list); + } + + LogDebug("Length of total expanded events: "<getExpandedEventList()->size()); + + event->setResult(true); + + if(query) { + calendar_query_destroy(query); + query = NULL; + } + if(filter) { + calendar_filter_destroy(filter); + filter = NULL; + } + if( list ) { + calendar_list_destroy(list, true); + list = NULL; + } + } + Catch (InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::InvalidArgumentException); + } + Catch (Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } + + if(query) { + calendar_query_destroy(query); + } + if(filter) { + calendar_filter_destroy(filter); + } + if( list ) { + calendar_list_destroy(list, true); + } +} + +} +} diff --git a/src/Calendar/Calendar.h b/src/Calendar/Calendar.h new file mode 100755 index 0000000..ef41704 --- /dev/null +++ b/src/Calendar/Calendar.h @@ -0,0 +1,53 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_H_ +#define _CALENDAR_H_ + +#include "ICalendar.h" +#include "EventWrapper.h" + +namespace DeviceAPI { +namespace Calendar { + +class Calendar : public ICalendar +{ + public: + Calendar(); + virtual ~Calendar(); + + protected: + virtual void OnRequestReceived(const IEventAddEventPtr &event); + virtual void OnRequestReceived(const IEventAddEventsPtr &events); + virtual void OnRequestReceived(const IEventDeleteEventPtr &event); + virtual void OnRequestReceived(const IEventDeleteEventsPtr &events); + virtual void OnRequestReceived(const IEventUpdateEventPtr &event); + virtual void OnRequestReceived(const IEventUpdateEventsPtr &events); + virtual void OnRequestReceived(const IEventFindEventsPtr &event); + virtual void OnRequestReceived(const IEventCreateEventFromStringPtr &event); + virtual void OnRequestReceived(const IEventExportEventToStringPtr &event); + virtual void OnRequestReceived(const IEventWatchChangesPtr &event); + virtual void OnRequestReceived(const IEventClearWatchPtr &event); + virtual void OnRequestReceived(const IEventExpandEventRecurrencePtr &event); + virtual void OnRequestReceived(const IEventGetPtr &event); +}; + +} +} + +#endif /* _CALENDAR_H_ */ diff --git a/src/Calendar/CalendarAsyncCallbackManager.cpp b/src/Calendar/CalendarAsyncCallbackManager.cpp new file mode 100755 index 0000000..d215fa4 --- /dev/null +++ b/src/Calendar/CalendarAsyncCallbackManager.cpp @@ -0,0 +1,23 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "CalendarAsyncCallbackManager.h" +#include + +IMPLEMENT_SINGLETON(DeviceAPI::Calendar::CalendarAsyncCallbackManager) + diff --git a/src/Calendar/CalendarAsyncCallbackManager.h b/src/Calendar/CalendarAsyncCallbackManager.h new file mode 100755 index 0000000..de060eb --- /dev/null +++ b/src/Calendar/CalendarAsyncCallbackManager.h @@ -0,0 +1,47 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _TIZEN_CALENDAR_ASYNC_CALLBACK_MANAGER_H_ +#define _TIZEN_CALENDAR_ASYNC_CALLBACK_MANAGER_H_ + +#include +#include + +namespace DeviceAPI { +namespace Calendar { + +class CalendarAsyncCallbackManager : public DeviceAPI::Common::AsyncCallbackManager +{ +public: + CalendarAsyncCallbackManager() + { + } + + virtual ~CalendarAsyncCallbackManager() + { + } + + friend class DPL::Singleton; +}; + +typedef DPL::Singleton CalendarAsyncCallbackManagerSingleton; + +} // Calendar +} // DeviceAPI + +#endif // _TIZEN_CALENDAR_ASYNC_CALLBACK_MANAGER_H_ \ No newline at end of file diff --git a/src/Calendar/CalendarConverter.cpp b/src/Calendar/CalendarConverter.cpp new file mode 100755 index 0000000..db94119 --- /dev/null +++ b/src/Calendar/CalendarConverter.cpp @@ -0,0 +1,1017 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include "JSCalendarEvent.h" +#include "JSCalendarTask.h" +#include "JSCalendarItemProperties.h" +#include "JSCalendarEventId.h" +#include "CalendarConverter.h" +#include "JSCalendar.h" +#include "JSCalendarManager.h" +#include "JSCalendarAttendee.h" +#include "JSCalendarRecurrenceRule.h" +#include "JSCalendarAlarm.h" +#include "JSStringArray.h" +#include "JSNumberArray.h" +#include "JSTZDateArray.h" + +#include +#include +#include +#include + + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Time; + +namespace { +const int DEFAULT_EVENT_INTERVAL = 1; +} + +namespace DeviceAPI { +namespace Calendar { + +CalendarConverter::CalendarConverter(JSContextRef context, CalendarEvent::CalendarType calendarType) : Converter(context) +{ + m_calendarType = calendarType; +} + +CalendarConverter::~CalendarConverter() +{ +} + +JSValueRef CalendarConverter::toJSValueRefEvent(const CalendarEventPtr& arg) +{ + return JSUtils::makeObject(m_context, JSCalendarEvent::getClassRef(), arg); +} + +JSValueRef CalendarConverter::toJSValueRefTask(const CalendarEventPtr& arg) +{ + return JSUtils::makeObject(m_context, JSCalendarTask::getClassRef(), arg); +} + +JSValueRef CalendarConverter::toJSValueRefEventArray(const CalendarEventListPtr &arg) +{ + return toJSValueRef_(*arg, &CalendarConverter::toJSValueRefEvent, this); +} + +JSValueRef CalendarConverter::toJSValueRefTaskArray(const CalendarEventListPtr &arg) +{ + return toJSValueRef_(*arg, &CalendarConverter::toJSValueRefTask, this); +} + +JSValueRef CalendarConverter::toJSValueRefCalendar(const ICalendarPtr& arg) +{ + CalendarPrivObject *priv = new CalendarPrivObject(m_context, arg); + return JSObjectMake(m_context, JSCalendar::getClassRef(), priv); +} + +JSValueRef CalendarConverter::toJSValueRef(const std::vector &arg) +{ + return toJSValueRef_(arg, &CalendarConverter::toJSValueRefCalendar, this); +} + +JSValueRef CalendarConverter::toJSValueRef(const StringArrayPtr &arg) +{ + return JSStringArray::createArray(m_context, arg); +} + +JSValueRef CalendarConverter::toJSValueRefNumberArray(const NumberArrayPtr &arg) +{ + return JSNumberArray::createArray(m_context, arg); +} + +JSValueRef CalendarConverter::toJSValueRefTZDateArray(const NumberArrayPtr &arg) +{ + return JSTZDateArray::createArray(m_context, arg); +} + +StringArrayPtr CalendarConverter::toStringArray(const JSValueRef &jsValue) +{ + if(JSStringArray::isObjectOfClass(m_context, jsValue)) + return JSStringArray::getStringArray(m_context, jsValue); + + if(!JSIsArrayValue(m_context, jsValue)) + ThrowMsg(WrtDeviceApis::Commons::ConversionException, "StringArray is not array."); + + StringArrayPtr result = StringArrayPtr(new StringArray()); + JSObjectRef jsObject = toJSObjectRef(jsValue); + for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) { + JSValueRef element = JSGetArrayElement(m_context, jsObject, i); + result->push_back(toString(element)); + } + return result; +} + +NumberArrayPtr CalendarConverter::toNumberArray(const JSValueRef &jsValue) +{ + if(JSNumberArray::isObjectOfClass(m_context, jsValue)) + return JSNumberArray::getNumberArray(m_context, jsValue); + + if(!JSIsArrayValue(m_context, jsValue)) + ThrowMsg(WrtDeviceApis::Commons::ConversionException, "NumberArray is not array."); + + NumberArrayPtr result = NumberArrayPtr(new NumberArray()); + JSObjectRef jsObject = toJSObjectRef(jsValue); + for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) { + JSValueRef element = JSGetArrayElement(m_context, jsObject, i); + result->push_back((long long int) (toLongLong(element))); + } + LogDebug("First number: "<at(0)); + return result; +} + +NumberArrayPtr CalendarConverter::toTZDateArray(const JSValueRef &jsValue) +{ + if(JSNumberArray::isObjectOfClass(m_context, jsValue)) + return JSNumberArray::getNumberArray(m_context, jsValue); + + if(!JSIsArrayValue(m_context, jsValue)) + ThrowMsg(WrtDeviceApis::Commons::ConversionException, "NumberArray is not array."); + + TimeUtilConverter timeConverter(m_context); + + NumberArrayPtr result = NumberArrayPtr(new NumberArray()); + JSObjectRef jsObject = toJSObjectRef(jsValue); + for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) { + JSValueRef element = JSGetArrayElement(m_context, jsObject, i); + result->push_back((long long int) (timeConverter.getTimeInMilliseconds(element)/1000)); + } + LogDebug("First value: "<at(0)); + return result; +} + +EventAlarm::EventAlarmType CalendarConverter::toEventAlarmType(std::string alarmMethod) +const +{ + if (!alarmMethod.compare(TIZEN_CALENDAR_PROPERTY_DISPLAY_ALARM)) + return EventAlarm::SILENT_ALARM; + else if (!alarmMethod.compare(TIZEN_CALENDAR_PROPERTY_SOUND_ALARM)) + return EventAlarm::SOUND_ALARM; + else + ThrowMsg(ConversionException, "Invalid alarm type."); + + return EventAlarm::UNDEFINED_ALARM_TYPE; +} + +std::string CalendarConverter::toTizenValue(EventAlarm::EventAlarmType abstractValue) const +{ + switch (abstractValue) { + case EventAlarm::SILENT_ALARM: + return TIZEN_CALENDAR_PROPERTY_DISPLAY_ALARM; + case EventAlarm::SOUND_ALARM: + return TIZEN_CALENDAR_PROPERTY_SOUND_ALARM; + default: + break; + } + ThrowMsg(ConversionException, "Invalid alarm type"); +} + +CalendarEvent::EventStatus CalendarConverter::toEventStatus(std::string tizenValue) const +{ + if(!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_TENTATIVE_STATUS)) + return CalendarEvent::TENTATIVE_STATUS; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_CONFIRMED_STATUS)) + return CalendarEvent::CONFIRMED_STATUS; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_CANCELLED_STATUS)) + return CalendarEvent::CANCELLED_STATUS; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_NEEDS_ACTION_STATUS)) + return CalendarEvent::NEEDS_ACTION_STATUS; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_IN_PROCESS_STATUS)) + return CalendarEvent::IN_PROCESS_STATUS; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_COMPLETED_STATUS)) + return CalendarEvent::COMPLETED_STATUS; + else + ThrowMsg(ConversionException, "Invalid status type."); + + return CalendarEvent::UNDEFINED_STATUS; +} + +std::string CalendarConverter::toTizenValue(CalendarEvent::EventStatus abstractValue) +const +{ + switch (abstractValue) { + case CalendarEvent::TENTATIVE_STATUS: + return TIZEN_CALENDAR_PROPERTY_TENTATIVE_STATUS; + case CalendarEvent::CONFIRMED_STATUS: + return TIZEN_CALENDAR_PROPERTY_CONFIRMED_STATUS; + case CalendarEvent::CANCELLED_STATUS: + return TIZEN_CALENDAR_PROPERTY_CANCELLED_STATUS; + case CalendarEvent::NEEDS_ACTION_STATUS: + return TIZEN_CALENDAR_PROPERTY_NEEDS_ACTION_STATUS; + case CalendarEvent::IN_PROCESS_STATUS: + return TIZEN_CALENDAR_PROPERTY_IN_PROCESS_STATUS; + case CalendarEvent::COMPLETED_STATUS: + return TIZEN_CALENDAR_PROPERTY_COMPLETED_STATUS; + default: + { + if (CalendarEvent::TASK_TYPE==m_calendarType) { + return TIZEN_CALENDAR_PROPERTY_NEEDS_ACTION_STATUS; + } else { + return TIZEN_CALENDAR_PROPERTY_CONFIRMED_STATUS; + } + break; + } + } +} + +EventRecurrenceRule::EventRecurrence CalendarConverter::toRecurrenceFrequency( + std::string tizenValue) const +{ + 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; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_MONTHLY_RECURRENCE)) + return EventRecurrenceRule::MONTHLY_RECURRENCE; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_YEARLY_RECURRENCE)) + return EventRecurrenceRule::YEARLY_RECURRENCE; + else + ThrowMsg(ConversionException, "Invalid recurrence frequency type."); + + return EventRecurrenceRule::UNDEFINED_RECURRENCE; +} + +std::string CalendarConverter::toTizenValue( + EventRecurrenceRule::EventRecurrence abstractValue) const +{ + switch (abstractValue) { + case EventRecurrenceRule::DAILY_RECURRENCE: + return TIZEN_CALENDAR_PROPERTY_DAILY_RECURRENCE; + case EventRecurrenceRule::WEEKLY_RECURRENCE: + return TIZEN_CALENDAR_PROPERTY_WEEKLY_RECURRENCE; + case EventRecurrenceRule::MONTHLY_RECURRENCE: + return TIZEN_CALENDAR_PROPERTY_MONTHLY_RECURRENCE; + case EventRecurrenceRule::YEARLY_RECURRENCE: + return TIZEN_CALENDAR_PROPERTY_YEARLY_RECURRENCE; + case EventRecurrenceRule::NO_RECURRENCE: + default: + return ""; + break; + } +} + +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 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)); + //const ScopedJSStringRef daysOfTheYearStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR)); + //const ScopedJSStringRef weeksOfTheYearStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_WEEKS_OF_THE_YEAR)); + const ScopedJSStringRef setPositionsStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_SET_POSITIONS)); + const ScopedJSStringRef exceptionsStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_EXCEPTIONS)); + + JSObjectRef arg = toJSObjectRef(rrule); + + JSValueRef frequencyData = JSObjectGetProperty(m_context, arg, frequencyStr.get(), NULL); + JSValueRef intervalData = JSObjectGetProperty(m_context, arg, intervalStr.get(), NULL); + JSValueRef untilDateData = JSObjectGetProperty(m_context, arg, untilDateStr.get(), NULL); + JSValueRef occurrenceCountData = JSObjectGetProperty(m_context, arg, occurrenceCountStr.get(), NULL); + //JSValueRef daysOfTheMonthData = JSObjectGetProperty(m_context, arg, daysOfTheMonthStr.get(), NULL); + JSValueRef daysOfTheWeekData = JSObjectGetProperty(m_context, arg, daysOfTheWeekStr.get(), NULL); + //JSValueRef daysOfTheYearData = JSObjectGetProperty(m_context, arg, daysOfTheYearStr.get(), NULL); + //JSValueRef weeksOfTheYearData = JSObjectGetProperty(m_context, arg, weeksOfTheYearStr.get(), NULL); + JSValueRef setPositionsData = JSObjectGetProperty(m_context, arg, setPositionsStr.get(), NULL); + JSValueRef exceptionsData = JSObjectGetProperty(m_context, arg, exceptionsStr.get(), NULL); + + if (!JSValueIsUndefined(m_context, frequencyData)) { + result->setFrequency(toRecurrenceFrequency(toString(frequencyData))); + } + if (!JSValueIsUndefined(m_context, intervalData)) { + result->setInterval(toInt(intervalData)); + } + if (!JSValueIsUndefined(m_context, untilDateData)) { + if (!JSValueIsNull(m_context, untilDateData)) { + TimeUtilConverter timeUtilConverter(m_context); + result->setEndDate((long long int) (timeUtilConverter.getTimeInMilliseconds(untilDateData)/1000)); + result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(untilDateData).timezone); + } else { + result->setEndDate(0); + } + } + if (!JSValueIsUndefined(m_context, occurrenceCountData)) { + result->setOccurrenceCount(toLong(occurrenceCountData)); + } + /*if (!JSValueIsUndefined(m_context, daysOfTheMonthData)) { + result->setDaysOfTheMonth(toVectorOfInts(daysOfTheMonthData)); + }*/ + if (!JSValueIsUndefined(m_context, daysOfTheWeekData)) { + result->setDaysOfTheWeek(toStringArray(daysOfTheWeekData)); + } + /*if (!JSValueIsUndefined(m_context, daysOfTheYearData)) { + result->setDaysOfTheYear(toVectorOfInts(daysOfTheYearData)); + } + if (!JSValueIsUndefined(m_context, weeksOfTheYearData)) { + result->setWeeksOfTheYear(toVectorOfInts(weeksOfTheYearData)); + }*/ + if (!JSValueIsUndefined(m_context, setPositionsData)) { + result->setSetPositions(toNumberArray(setPositionsData)); + } + if (!JSValueIsUndefined(m_context, exceptionsData)) { + result->setExceptions(toTZDateArray(exceptionsData)); + } + + return result; +} + +CalendarEvent::EventVisibility CalendarConverter::toEventVisibility(std::string tizenValue) +const +{ + if(!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_PUBLIC_VISIBILITY)) + return CalendarEvent::PUBLIC_VISIBILITY; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_PRIVATE_VISIBILITY)) + return CalendarEvent::PRIVATE_VISIBILITY; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_CONFIDENTIAL_VISIBILITY)) + return CalendarEvent::CONFIDENTIAL_VISIBILITY; + else + ThrowMsg(ConversionException, "Invalid visibility type."); + + return CalendarEvent::UNDEFINED_VISIBILITY; +} + +std::string CalendarConverter::toTizenValue( + CalendarEvent::EventVisibility abstractValue) const +{ + switch (abstractValue) { + case CalendarEvent::PUBLIC_VISIBILITY: + return TIZEN_CALENDAR_PROPERTY_PUBLIC_VISIBILITY; + case CalendarEvent::PRIVATE_VISIBILITY: + return TIZEN_CALENDAR_PROPERTY_PRIVATE_VISIBILITY; + case CalendarEvent::CONFIDENTIAL_VISIBILITY: + return TIZEN_CALENDAR_PROPERTY_CONFIDENTIAL_VISIBILITY; + default: + break; + } + + return TIZEN_CALENDAR_PROPERTY_PUBLIC_VISIBILITY; +} + +CalendarEvent::EventAvailability CalendarConverter::toEventAvailability(std::string tizenValue) +const +{ + if(!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_BUSY)) + return CalendarEvent::BUSY_FB; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_BUSY_UNAVAILABLE_FB)) + return CalendarEvent::BUSY_UNAVAILABLE_FB; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_FREE)) + return CalendarEvent::FREE_FB; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_BUSY_TENTATIVE)) + return CalendarEvent::BUSY_TENTATIVE_FB; + else + ThrowMsg(ConversionException, "Invalid availability type."); + + return CalendarEvent::UNDEFINED_AVAILABILITY; +} + +std::string CalendarConverter::toTizenValue( + CalendarEvent::EventAvailability abstractValue) const +{ + switch (abstractValue) { + case CalendarEvent::BUSY_FB: + return TIZEN_CALENDAR_PROPERTY_BUSY; + case CalendarEvent::BUSY_UNAVAILABLE_FB: + return TIZEN_CALENDAR_PROPERTY_BUSY_UNAVAILABLE_FB; + case CalendarEvent::FREE_FB: + return TIZEN_CALENDAR_PROPERTY_FREE; + case CalendarEvent::BUSY_TENTATIVE_FB: + return TIZEN_CALENDAR_PROPERTY_BUSY_TENTATIVE; + default: + break; + } + + return TIZEN_CALENDAR_PROPERTY_BUSY; +} + +EventAttendee::EventAttendeeRole CalendarConverter::toEventAttendeeRole(std::string tizenValue) +const +{ + if(!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_REQ_PARTICIPANT_ROLE)) + return EventAttendee::REQ_PARTICIPANT_ROLE; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_OPT_PARTICIPANT_ROLE)) + return EventAttendee::OPT_PARTICIPANT_ROLE; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_NON_PARTICIPANT_ROLE)) + return EventAttendee::NON_PARTICIPANT_ROLE; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_CHAIR_ROLE)) + return EventAttendee::CHAIR_ROLE; + else + ThrowMsg(ConversionException, "Invalid attendee role type."); + + return EventAttendee::UNDEFINED_ATTENDEE_ROLE; +} + +std::string CalendarConverter::toTizenValue( + EventAttendee::EventAttendeeRole abstractValue) const +{ + switch (abstractValue) { + case EventAttendee::REQ_PARTICIPANT_ROLE: + return TIZEN_CALENDAR_PROPERTY_REQ_PARTICIPANT_ROLE; + case EventAttendee::OPT_PARTICIPANT_ROLE: + return TIZEN_CALENDAR_PROPERTY_OPT_PARTICIPANT_ROLE; + case EventAttendee::NON_PARTICIPANT_ROLE: + return TIZEN_CALENDAR_PROPERTY_NON_PARTICIPANT_ROLE; + case EventAttendee::CHAIR_ROLE: + return TIZEN_CALENDAR_PROPERTY_CHAIR_ROLE; + default: + break; + } + return TIZEN_CALENDAR_PROPERTY_REQ_PARTICIPANT_ROLE; +} + +EventAttendee::EventAttendeeStatus CalendarConverter::toEventAttendeeStatus(std::string tizenValue) +const +{ + if(!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_PENDING_STATUS)) + return EventAttendee::PENDING_AT_STATUS; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_ACCEPTED_STATUS)) + return EventAttendee::ACCEPTED_AT_STATUS; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_DECLINED_STATUS)) + return EventAttendee::DECLINED_AT_STATUS; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_TENTATIVE_STATUS)) + return EventAttendee::TENTATIVE_AT_STATUS; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_DELEGATED_STATUS)) + return EventAttendee::DELEGATED_AT_STATUS; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_COMPLETED_STATUS)) + return EventAttendee::COMPLETED_AT_STATUS; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_IN_PROCESS_STATUS)) + return EventAttendee::IN_PROCESS_AT_STATUS; + else + ThrowMsg(ConversionException, "Invalid attendee status type."); + + return EventAttendee::UNDEFINED_ATTENDEE_STATUS; +} + +std::string CalendarConverter::toTizenValue( + EventAttendee::EventAttendeeStatus abstractValue) const +{ + switch (abstractValue) { + case EventAttendee::PENDING_AT_STATUS: + return TIZEN_CALENDAR_PROPERTY_PENDING_STATUS; + case EventAttendee::ACCEPTED_AT_STATUS: + return TIZEN_CALENDAR_PROPERTY_ACCEPTED_STATUS; + case EventAttendee::DECLINED_AT_STATUS: + return TIZEN_CALENDAR_PROPERTY_DECLINED_STATUS; + case EventAttendee::TENTATIVE_AT_STATUS: + return TIZEN_CALENDAR_PROPERTY_TENTATIVE_STATUS; + case EventAttendee::DELEGATED_AT_STATUS: + return TIZEN_CALENDAR_PROPERTY_DELEGATED_STATUS; + case EventAttendee::COMPLETED_AT_STATUS: + return TIZEN_CALENDAR_PROPERTY_COMPLETED_STATUS; + case EventAttendee::IN_PROCESS_AT_STATUS: + return TIZEN_CALENDAR_PROPERTY_IN_PROCESS_STATUS; + default: + break; + } + return TIZEN_CALENDAR_PROPERTY_PENDING_STATUS; +} + +EventAttendee::EventAttendeeType CalendarConverter::toEventAttendeeType(std::string tizenValue) +const +{ + if(!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_INDIVIDUAL_TYPE)) + return EventAttendee::INDIVIDUAL_TYPE; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_GROUP_TYPE)) + return EventAttendee::GROUP_TYPE; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_RESOURCE_TYPE)) + return EventAttendee::RESOURCE_TYPE; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_ROOM_TYPE)) + return EventAttendee::ROOM_TYPE; + else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_UNKNOWN_TYPE)) + return EventAttendee::UNKNOWN_TYPE; + else + ThrowMsg(ConversionException, "Invalid attendee type."); + + return EventAttendee::INDIVIDUAL_TYPE; +} + +std::string CalendarConverter::toTizenValue( + EventAttendee::EventAttendeeType abstractValue) const +{ + switch (abstractValue) { + case EventAttendee::INDIVIDUAL_TYPE: + return TIZEN_CALENDAR_PROPERTY_INDIVIDUAL_TYPE; + case EventAttendee::GROUP_TYPE: + return TIZEN_CALENDAR_PROPERTY_GROUP_TYPE; + case EventAttendee::RESOURCE_TYPE: + return TIZEN_CALENDAR_PROPERTY_RESOURCE_TYPE; + case EventAttendee::ROOM_TYPE: + return TIZEN_CALENDAR_PROPERTY_ROOM_TYPE; + case EventAttendee::UNKNOWN_TYPE: + return TIZEN_CALENDAR_PROPERTY_UNKNOWN_TYPE; + default: + break; + } + + return TIZEN_CALENDAR_PROPERTY_INDIVIDUAL_TYPE; +} + +JSValueRef CalendarConverter::toFunctionOrNull(const JSValueRef& arg) +{ + if (Validator(m_context).isCallback(arg)) { + return arg; + } else if (!JSValueIsNull(m_context, + arg) && !JSValueIsUndefined(m_context, arg)) { + ThrowMsg(ConversionException, "Not a function nor JS null."); + } + return NULL; +} + +JSValueRef CalendarConverter::toFunction(const JSValueRef& arg) +{ + if (Validator(m_context).isCallback(arg)) { + return arg; + } + ThrowMsg(ConversionException, "Not a function."); +} + +StringArrayPtr CalendarConverter::toCategories(JSValueRef categories) +{ + StringArrayPtr result(new StringArray()); + *result = toVectorOfStrings(categories); + return result; +} + +EventAttendeePtr CalendarConverter::toAttendee(JSValueRef attendee) +{ + EventAttendeePtr result(new EventAttendee()); + 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 contactRefStr(JSStringCreateWithUTF8CString(TIZEN_ATTENDEE_CONTACT_REF)); + + JSObjectRef arg = toJSObjectRef(attendee); + + JSValueRef nameData = JSObjectGetProperty(m_context, arg, nameStr.get(), NULL); + JSValueRef uriData = JSObjectGetProperty(m_context, arg, uriStr.get(), NULL); + JSValueRef roleData = JSObjectGetProperty(m_context, arg, roleStr.get(), NULL); + JSValueRef statusData = JSObjectGetProperty(m_context, arg, statusStr.get(), NULL); + JSValueRef RSVPData = JSObjectGetProperty(m_context, arg, RSVPStr.get(), NULL); + JSValueRef typeData = JSObjectGetProperty(m_context, arg, typeStr.get(), NULL); + JSValueRef groupData = JSObjectGetProperty(m_context, arg, groupStr.get(), NULL); + JSValueRef delegatorURIData = JSObjectGetProperty(m_context, arg, delegatorURIStr.get(), NULL); + JSValueRef delegateURIData = JSObjectGetProperty(m_context, arg, delegateURIStr.get(), NULL); + JSValueRef contactRefData = JSObjectGetProperty(m_context, arg, contactRefStr.get(), NULL); + + if (!JSValueIsUndefined(m_context, nameData)) { + result->setName(toString(nameData)); + } + if (!JSValueIsUndefined(m_context, uriData)) { + result->setURI(toString(uriData)); + } + if (!JSValueIsUndefined(m_context, roleData)) { + result->setRole(toEventAttendeeRole(toString(roleData))); + } + if (!JSValueIsUndefined(m_context, statusData)) { + result->setStatus(toEventAttendeeStatus(toString(statusData))); + } + if (!JSValueIsUndefined(m_context, RSVPData)) { + result->setRSVP(toBool(RSVPData)); + } + if (!JSValueIsUndefined(m_context, typeData)) { + result->setType(toEventAttendeeType(toString(typeData))); + } + if (!JSValueIsUndefined(m_context, groupData)) { + result->setGroup(toString(groupData)); + } + if (!JSValueIsUndefined(m_context, delegatorURIData)) { + result->setDelegatorURI(toString(delegatorURIData)); + } + if (!JSValueIsUndefined(m_context, delegateURIData)) { + result->setDelegateURI(toString(delegateURIData)); + } + if (!JSValueIsUndefined(m_context, contactRefData)) { + DeviceAPI::Contact::ContactConverter contactConverter(m_context); + result->setContactId(contactConverter.toContactRef(contactRefData)->getContactId()); + result->setAddressBookId(contactConverter.toContactRef(contactRefData)->getAddressBookId()); + } + + return result; +} + +EventAttendeeListPtr CalendarConverter::toVectorOfAttendeesFromDictionary(JSValueRef attendees) +{ + EventAttendeeListPtr result(new EventAttendeeList()); + + std::vector resultVector; + JSObjectRef objArg = toJSObjectRef(attendees); + LogDebug("array length "< resultVector; + JSObjectRef objArg = toJSObjectRef(attendees); + LogDebug("array length "<setAbsoluteDate((long long int) (timeConverter.getTimeInMilliseconds(absoluteDateData)/1000)); + } + if (!JSValueIsUndefined(m_context, beforeData)) { + TimeUtilConverter timeConverter(m_context); + result->setDuration(timeConverter.getDurationPropertis(beforeData)); + } + if (!JSValueIsUndefined(m_context, methodData)) { + result->setMethod(toEventAlarmType(toString(methodData))); + } + if (!JSValueIsUndefined(m_context, descriptionData)) { + result->setDescription(toString(descriptionData)); + } + + return result; +} + +EventAlarmListPtr CalendarConverter::toVectorOfEventAlarmsFromDictionary(JSValueRef alarms) +{ + EventAlarmListPtr result(new EventAlarmList()); + + std::vector resultVector; + JSObjectRef objArg = toJSObjectRef(alarms); + LogDebug("array length "< resultVector; + JSObjectRef objArg = toJSObjectRef(alarms); + LogDebug("array length "<setDescription(toString(descriptionData)); + } + + if (!JSValueIsUndefined(m_context, summaryData)) { + result->setSubject(toString(summaryData)); + } + + //It's important to set startTime before duration to set end date + if (!JSValueIsUndefined(m_context, startTimeData)) { + result->setStartTime((long long int) (timeUtilConverter.getTimeInMilliseconds(startTimeData)/1000)); + result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(startTimeData).timezone); + LogInfo("start time converted from TZDate: "<getStartTime()<<", time zone: "<getTimeZone()); + } else { + + //set default value, current local time. + if(m_calendarType == CalendarEvent::EVENT_TYPE) { + //result->setStartTime(std::time(NULL)); + } + } + + if (!JSValueIsUndefined(m_context, durationData)) { + long length = timeUtilConverter.getDurationLength(durationData); + int unit = timeUtilConverter.getDurationUnit(durationData); + LogInfo("duration length: "<setEndTime(result->getStartTime() + length); + } else if ( MINUTES_UNIT==unit ) { + result->setEndTime(result->getStartTime() + length*60); + } else if ( HOURS_UNIT==unit ) { + result->setEndTime(result->getStartTime() + length*60*60); + } else if ( DAYS_UNIT==unit ) { + result->setEndTime(result->getStartTime() + length*24*60*60); + } else { + ThrowMsg(ConversionException, "Wrong duration unit."); + } + } + if (!JSValueIsUndefined(m_context, locationData)) { + result->setLocation(toString(locationData)); + } + if (!JSValueIsUndefined(m_context, categoriesData)) { + StringArrayPtr categories(new StringArray()); + *categories = toVectorOfStrings(categoriesData); + result->setCategories(categories); + } + + if (!JSValueIsUndefined(m_context, statusData)) { + result->setStatus(toEventStatus(toString(statusData))); + } else { + result->setStatus(CalendarEvent::CONFIRMED_STATUS); + } + if (!JSValueIsUndefined(m_context, alarmsData)) { + EventAlarmListPtr alarms = toVectorOfEventAlarmsFromReference(alarmsData); + result->setAlarms(alarms); + } + if (!JSValueIsUndefined(m_context, isAllDayData)) { + result->setIsAllDay(toBool(isAllDayData)); + } + if (!JSValueIsUndefined(m_context, organizerData)) { + result->setOrganizer(toString(organizerData)); + } + if (!JSValueIsUndefined(m_context, attendeesData)) { + EventAttendeeListPtr attendees = toVectorOfAttendeesFromReference(attendeesData); + result->setAttendees(attendees); + } + if (!JSValueIsUndefined(m_context, geolocationData)) { + DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation = + DeviceAPI::Tizen::JSSimpleCoordinates::getSimpleCoordinates(m_context, geolocationData); + result->setLatitude(geoLocation->getLatitude()); + result->setLongitude(geoLocation->getLongitude()); + } + if (!JSValueIsUndefined(m_context, visibilityData)) { + result->setVisibility(toEventVisibility(toString(visibilityData))); + } + if (!JSValueIsUndefined(m_context, availabilityData)) { + result->setAvailability(toEventAvailability(toString(availabilityData))); + } + if (!JSValueIsUndefined(m_context, recurrenceRuleData)) { + result->setRecurrenceRule(JSCalendarRecurrenceRule::getPrivateObject(JSValueToObject(m_context, recurrenceRuleData, NULL))); + } + if (!JSValueIsUndefined(m_context, priorityData)) { + result->setPriority(toTaskPriority(toString(priorityData))); + } + if (!JSValueIsUndefined(m_context, endDateData)) { + if( result->getTimeZone().empty() ) { + result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(endDateData).timezone); + } + result->setEndTime((long long int) (timeUtilConverter.getTimeInMilliseconds(endDateData)/1000)); + } + if (!JSValueIsUndefined(m_context, dueDateData)) { + if( result->getTimeZone().empty() ) { + result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(dueDateData).timezone); + } + result->setEndTime((long long int) (timeUtilConverter.getTimeInMilliseconds(dueDateData)/1000)); + } + if (!JSValueIsUndefined(m_context, completedDateData)) { + if( result->getTimeZone().empty() ) { + result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(completedDateData).timezone); + } + result->setCompletedDate((long long int) (timeUtilConverter.getTimeInMilliseconds(completedDateData)/1000)); + } + if (!JSValueIsUndefined(m_context, progressData)) { + result->setProgress(toInt(progressData)); + } + LogDebug("timezone: "<getTimeZone()); + + return result; +} + +CalendarEventListPtr CalendarConverter::toVectorOfEvents(JSValueRef events) +{ + CalendarEventListPtr result(new CalendarEventList()); + + std::vector resultVector; + JSObjectRef objArg = toJSObjectRef(events); + LogDebug("array length "< resultVector; + JSObjectRef objArg = toJSObjectRef(events); + LogDebug("array length "<setUId(toString(uidData)); + } + if (!JSValueIsUndefined(m_context, recurrenceIdData)) { + result->setRecurrenceId(toString(recurrenceIdData)); + } + + return result; +} + +EventIdListPtr CalendarConverter::toVectorOfEventIds(JSValueRef eventIds) +{ + EventIdListPtr result(new EventIdList()); + + std::vector resultVector; + JSObjectRef objArg = toJSObjectRef(eventIds); + LogDebug("array length "<setCalendarType(CalendarEvent::EVENT_TYPE); + resultVector.push_back(idPtr); + } + + *result = resultVector; + return result; +} + +std::vector CalendarConverter::toVectorOfTimeFromTZDate(JSValueRef dates) +{ + std::vector result; + TimeUtilConverter converter(m_context); + + JSObjectRef objArg = toJSObjectRef(dates); + LogDebug("array length "< +#include +#include "ICalendar.h" +#include "EventAttendee.h" +#include "EventAlarm.h" +#include +#include + +namespace DeviceAPI { +namespace Calendar { + +class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter +{ + public: + using Converter::toJSValueRef; + public: + explicit CalendarConverter(JSContextRef context, CalendarEvent::CalendarType calendarType=CalendarEvent::EVENT_TYPE); + virtual ~CalendarConverter(); + + CalendarEventPtr toEvent(const JSValueRef event); + CalendarEventListPtr toVectorOfEvents(JSValueRef events); + CalendarEventListPtr toVectorOfEventsFromProperty(JSValueRef events); + StringArrayPtr toCategories(JSValueRef categories); + EventAttendeePtr toAttendee(JSValueRef attendee); + EventAttendeeListPtr toVectorOfAttendeesFromDictionary(JSValueRef attendees); + EventAttendeeListPtr toVectorOfAttendeesFromReference(JSValueRef attendees); + + EventAlarm::EventAlarmType toEventAlarmType(std::string tizenValue) const; + CalendarEvent::EventStatus toEventStatus(std::string tizenValue) const; + EventRecurrenceRule::EventRecurrence toRecurrenceFrequency(std::string tizenValue) const; + EventRecurrenceRulePtr toEventRecurrenceRule(JSValueRef rrule); + + CalendarEvent::EventVisibility toEventVisibility(std::string tizenValue) const; + CalendarEvent::EventAvailability toEventAvailability(std::string tizenValue) const; + EventAttendee::EventAttendeeRole toEventAttendeeRole(std::string tizenValue) const; + EventAttendee::EventAttendeeStatus toEventAttendeeStatus(std::string tizenValue) const; + EventAttendee::EventAttendeeType toEventAttendeeType(std::string tizenValue) const; + + std::string toTizenValue(EventAlarm::EventAlarmType abstractValue) const; + std::string toTizenValue(CalendarEvent::EventStatus abstractValue) const; + std::string toTizenValue(EventRecurrenceRule::EventRecurrence abstractValue) const; + std::string toTizenValue(CalendarEvent::EventVisibility abstractValue) const; + std::string toTizenValue(CalendarEvent::EventAvailability abstractValue) const; + std::string toTizenValue(EventAttendee::EventAttendeeRole abstractValue) const; + std::string toTizenValue(EventAttendee::EventAttendeeStatus abstractValue) const; + std::string toTizenValue(EventAttendee::EventAttendeeType abstractValue) const; + std::string toTizenValue(CalendarEvent::TaskPriority abstractValue) const; + + JSValueRef toJSValueRefEvent(const CalendarEventPtr& arg); + JSValueRef toJSValueRefTask(const CalendarEventPtr& arg); + JSValueRef toJSValueRefEventArray(const CalendarEventListPtr &arg); + JSValueRef toJSValueRefTaskArray(const CalendarEventListPtr &arg); + JSValueRef toJSValueRefCalendar(const ICalendarPtr& arg); + JSValueRef toJSValueRef(const std::vector &arg); + JSValueRef toJSValueRef(const StringArrayPtr &arg); + JSValueRef toJSValueRefNumberArray(const NumberArrayPtr &arg); + JSValueRef toJSValueRefTZDateArray(const NumberArrayPtr &arg); + StringArrayPtr toStringArray(const JSValueRef &jsValue); + NumberArrayPtr toNumberArray(const JSValueRef &jsValue); + NumberArrayPtr toTZDateArray(const JSValueRef &jsValue); + + EventAlarmPtr toEventAlarm(JSValueRef alarm); + EventAlarmListPtr toVectorOfEventAlarmsFromDictionary(JSValueRef alarms); + EventAlarmListPtr toVectorOfEventAlarmsFromReference(JSValueRef alarms); + EventIdPtr toEventId(JSValueRef eventId); + EventIdListPtr toVectorOfEventIds(JSValueRef eventIds); + std::vector toVectorOfTimeFromTZDate(JSValueRef dates); + CalendarEvent::TaskPriority toTaskPriority(std::string priority) const; + CalendarEvent::CalendarType toCalendarType(std::string type) const; + CalendarEvent::VObjectFormat toVObjectFormat(std::string type) const; + + /** + * @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: + CalendarEvent::CalendarType m_calendarType; +}; + +} +} + +#endif /* _JS_TIZEN_CALENDAR_CONVERTER_H_ */ diff --git a/src/Calendar/CalendarEvent.cpp b/src/Calendar/CalendarEvent.cpp new file mode 100755 index 0000000..5ff2037 --- /dev/null +++ b/src/Calendar/CalendarEvent.cpp @@ -0,0 +1,503 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include "CalendarEvent.h" + +namespace DeviceAPI { +namespace Calendar { + +CalendarEvent::CalendarEvent(): + m_id(UNDEFINED_ITEM_ID), + m_parentId(UNDEFINED_ITEM_ID), + m_calendarId(UNDEFINED_CALENDAR_ID), + m_startTime(UNDEFINED_TIME), + m_endTime(UNDEFINED_TIME), + m_recurrence(new EventRecurrenceRule()), + m_status(UNDEFINED_STATUS), + m_alarms(new EventAlarmList()), + m_categories(new StringArray()), + m_isAllDay(false), + m_lastModifiedDate(UNDEFINED_TIME), + m_visibility(PUBLIC_VISIBILITY), + m_availability(BUSY_FB), + m_uid(UNDEFINED_ID), + m_recurrenceId(UNDEFINED_TIME), + m_attendees(new EventAttendeeList()), + m_isDetached(false), + m_attributesOfInterest(new AttributeList()), + m_latitude(UNDEFINED_GEO), + m_longitude(UNDEFINED_GEO), + m_timeZone(DEFAULT_TIMEZONE), + m_priority(LOW_PRIORITY), + m_createdDate(UNDEFINED_TIME), + m_completedDate(UNDEFINED_TIME), + m_progress(0), + m_calendarType(EVENT_TYPE) +{ +} + +CalendarEvent::CalendarEvent(const CalendarEvent &original) +{ + LogDebug("Copy constructor called."); + + m_id = original.getId(); + m_parentId = original.getParentId(); + m_calendarId = original.getCalendarId(); + m_description = original.getDescription(); + m_subject = original.getSubject(); + m_startTime = original.getStartTime(); + m_endTime = original.getEndTime(); + m_location = original.getLocation(); + + EventRecurrenceRulePtr recurrenceRulePtr( new EventRecurrenceRule() ); + m_recurrence = recurrenceRulePtr; + m_recurrence->setFrequency(original.getRecurrenceRule()->getFrequency()); + m_recurrence->setInterval(original.getRecurrenceRule()->getInterval()); + m_recurrence->setEndDate(original.getRecurrenceRule()->getEndDate()); + m_recurrence->setOccurrenceCount(original.getRecurrenceRule()->getOccurrenceCount()); + m_recurrence->setDaysOfTheMonth(original.getRecurrenceRule()->getDaysOfTheMonth()); + m_recurrence->setDaysOfTheWeek(original.getRecurrenceRule()->getDaysOfTheWeek()); + m_recurrence->setDaysOfTheYear(original.getRecurrenceRule()->getDaysOfTheYear()); + m_recurrence->setWeeksOfTheYear(original.getRecurrenceRule()->getWeeksOfTheYear()); + m_recurrence->setSetPositions(original.getRecurrenceRule()->getSetPositions()); + m_recurrence->setExceptions(original.getRecurrenceRule()->getExceptions()); + m_recurrence->setTimeZone(original.getRecurrenceRule()->getTimeZone()); + + m_status = original.getStatus(); + + LogDebug("Copying alarms..."); + EventAlarmListPtr alarmsPtr( new EventAlarmList() ); + m_alarms = alarmsPtr; + for( unsigned int i=0; isize(); i++) { + EventAlarmPtr alarmPtr( new EventAlarm() ); + alarmPtr->setAbsoluteDate(original.getAlarms()->at(i)->getAbsoluteDate()); + alarmPtr->setDuration(original.getAlarms()->at(i)->getDuration()); + alarmPtr->setMethod(original.getAlarms()->at(i)->getMethod()); + alarmPtr->setTimeZone(original.getAlarms()->at(i)->getTimeZone()); + alarmPtr->setDescription(original.getAlarms()->at(i)->getDescription()); + m_alarms->push_back(alarmPtr); + } + + StringArrayPtr categoriesPtr( new StringArray() ); + m_categories = categoriesPtr; + *m_categories = *(original.getCategories()); + + m_isAllDay = original.getIsAllDay(); + m_organizer = original.getOrganizer(); + m_lastModifiedDate = original.getLastModifiedDate(); + m_visibility = original.getVisibility(); + m_availability = original.getAvailability(); + m_uid = original.getUId(); + m_recurrenceId = original.getRecurrenceId(); + + LogDebug("Copying attendees..."); + EventAttendeeListPtr attendeesPtr( new EventAttendeeList() ); + m_attendees = attendeesPtr; + for( unsigned int i=0; isize(); i++) { + EventAttendeePtr attendeePtr( new EventAttendee() ); + attendeePtr->setName(original.getAttendees()->at(i)->getName()); + attendeePtr->setURI(original.getAttendees()->at(i)->getURI()); + attendeePtr->setRole(original.getAttendees()->at(i)->getRole()); + attendeePtr->setStatus(original.getAttendees()->at(i)->getStatus()); + attendeePtr->setRSVP(original.getAttendees()->at(i)->getRSVP()); + attendeePtr->setType(original.getAttendees()->at(i)->getType()); + attendeePtr->setGroup(original.getAttendees()->at(i)->getGroup()); + attendeePtr->setDelegatorURI(original.getAttendees()->at(i)->getDelegatorURI()); + attendeePtr->setDelegateURI(original.getAttendees()->at(i)->getDelegateURI()); + attendeePtr->setAddressBookId(original.getAttendees()->at(i)->getAddressBookId()); + attendeePtr->setContactId(original.getAttendees()->at(i)->getContactId()); + m_attendees->push_back(attendeePtr); + } + + m_isDetached = original.getIsDetached(); + + AttributeListPtr attributesPtr( new AttributeList() ); + m_attributesOfInterest = attributesPtr; + *m_attributesOfInterest = *(original.getAttributesOfInterest()); + + m_latitude = original.getLatitude(); + m_longitude = original.getLongitude(); + + m_timeZone = original.getTimeZone(); + m_priority = original.getPriority(); + m_createdDate = original.getCreatedDate(); + m_completedDate = original.getCompletedDate(); + m_progress = original.getProgress(); + m_calendarType = original.getCalendarType(); + + LogDebug("Copying done."); +} + +CalendarEvent::~CalendarEvent() +{ +} + +int CalendarEvent::getId() const +{ + return m_id; +} + +void CalendarEvent::setId(int value) +{ + m_id = value; + + // Set the uid also. + std::stringstream ss; + ss<getFrequency()!=EventRecurrenceRule::NO_RECURRENCE) { + LogDebug("recurrence frequency " << m_recurrence->getFrequency()); + LogDebug("recurrence interval " << m_recurrence->getInterval()); + LogDebug("recurrence recurrenceCount " << m_recurrence->getOccurrenceCount()); + LogDebug("recurrence endDate " << m_recurrence->getEndDate()); + } +} + +bool CalendarEvent::validate() const +{ + LogInfo("Nothing to validate."); + return true; +} + +bool CalendarEvent::getIsAllDay() const +{ + return m_isAllDay; +} + +void CalendarEvent::setIsAllDay(bool value) +{ + m_isAllDay = value; +} + +std::string CalendarEvent::getOrganizer() const +{ + return m_organizer; +} + +void CalendarEvent::setOrganizer(const std::string &value) +{ + m_organizer = value; +} + +long long int CalendarEvent::getLastModifiedDate() const +{ + return m_lastModifiedDate; +} + +void CalendarEvent::setLastModifiedDate(long long int value) +{ + m_lastModifiedDate = value; +} + +CalendarEvent::EventVisibility CalendarEvent::getVisibility() const +{ + return m_visibility == UNDEFINED_VISIBILITY ? PUBLIC_VISIBILITY : m_visibility; +} + +void CalendarEvent::setVisibility(EventVisibility value) +{ + m_visibility = value; +} + +CalendarEvent::EventAvailability CalendarEvent::getAvailability() const +{ + return m_availability == UNDEFINED_AVAILABILITY ? BUSY_FB : m_availability; +} + +void CalendarEvent::setAvailability(EventAvailability value) +{ + m_availability = value; +} + +std::string CalendarEvent::getUId() const +{ + return m_uid; +} + +void CalendarEvent::setUId(const std::string &value) +{ + m_uid = value; +} + +long long int CalendarEvent::getRecurrenceId() const +{ + return m_recurrenceId; +} + +void CalendarEvent::setRecurrenceId(long long int value) +{ + m_recurrenceId = value; +} + +EventAttendeeListPtr CalendarEvent::getAttendees() const +{ + return m_attendees; +} + +void CalendarEvent::setAttendees(const EventAttendeeListPtr value) +{ + m_attendees = value; +} + +bool CalendarEvent::getIsDetached() const +{ + return m_isDetached; +} + +void CalendarEvent::setIsDetached(bool value) +{ + m_isDetached = value; +} + +AttributeListPtr CalendarEvent::getAttributesOfInterest() const +{ + return m_attributesOfInterest; +} + +void CalendarEvent::setAttributesOfInterest(AttributeListPtr value) +{ + m_attributesOfInterest = value; +} + +double CalendarEvent::getLatitude() const +{ + return m_latitude; +} + +void CalendarEvent::setLatitude(double value) +{ + m_latitude = value; +} + +double CalendarEvent::getLongitude() const +{ + return m_longitude; +} + +void CalendarEvent::setLongitude(double value) +{ + m_longitude = value; +} + +std::string CalendarEvent::getTimeZone() const +{ + return m_timeZone; +} + +void CalendarEvent::setTimeZone(std::string value) +{ + m_timeZone = value; +} + +CalendarEvent::TaskPriority CalendarEvent::getPriority() const +{ + return m_priority; +} + +void CalendarEvent::setPriority(TaskPriority value) +{ + m_priority = value; +} + +long long int CalendarEvent::getCreatedDate() const +{ + return m_createdDate; +} + +void CalendarEvent::setCreatedDate(long long int value) +{ + m_createdDate = value; +} + +long long int CalendarEvent::getCompletedDate() const +{ + return m_completedDate; +} + +void CalendarEvent::setCompletedDate(long long int value) +{ + m_completedDate = value; +} + +int CalendarEvent::getProgress() const +{ + return m_progress; +} + +void CalendarEvent::setProgress(int value) +{ + m_progress = value; +} + +CalendarEvent::CalendarType CalendarEvent::getCalendarType() const +{ + return m_calendarType; +} + +void CalendarEvent::setCalendarType(CalendarType type) +{ + m_calendarType = type; +} + +} +} diff --git a/src/Calendar/CalendarEvent.h b/src/Calendar/CalendarEvent.h new file mode 100755 index 0000000..b593444 --- /dev/null +++ b/src/Calendar/CalendarEvent.h @@ -0,0 +1,237 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_CALENDAR_EVENT_H_ +#define _ABSTRACT_LAYER_CALENDAR_EVENT_H_ + +#include +#include +#include +#include + +#include "EventAlarm.h" +#include "EventAttendee.h" +#include "EventRecurrenceRule.h" + +namespace DeviceAPI { +namespace Calendar { + +#define UNDEFINED_CALENDAR_ID -1 +#define UNDEFINED_ITEM_ID -1 +#define UNDEFINED_GEO -1 +#define UNDEFINED_ID "-1" + +typedef std::vector AttributeList; +typedef DPL::SharedPtr AttributeListPtr; + +/* This object represents a single calendar event */ +class CalendarEvent +{ + public: + typedef enum + { + TENTATIVE_STATUS, + CONFIRMED_STATUS, + CANCELLED_STATUS, + NEEDS_ACTION_STATUS, + IN_PROCESS_STATUS, + COMPLETED_STATUS, + UNDEFINED_STATUS + } EventStatus; + + typedef enum + { + PUBLIC_VISIBILITY, + PRIVATE_VISIBILITY, + CONFIDENTIAL_VISIBILITY, + UNDEFINED_VISIBILITY + } EventVisibility; + + typedef enum + { + BUSY_FB, + BUSY_UNAVAILABLE_FB, + FREE_FB, + BUSY_TENTATIVE_FB, + UNDEFINED_AVAILABILITY + } EventAvailability; + + typedef enum + { + LOW_PRIORITY, + MEDIUM_PRIORITY, + HIGH_PRIORITY, + UNDEFINED_PRIORITY + } TaskPriority; + + typedef enum + { + ICALENDAR_20, + VCALENDAR_10, + UNDEFINED_FORMAT + } VObjectFormat; + + typedef enum + { + EVENT_TYPE = 0, + TASK_TYPE, + UNDEFINED_TYPE + } CalendarType; + + + CalendarEvent(); + CalendarEvent(const CalendarEvent &original); // copy constructor for clone operation + virtual ~CalendarEvent(); + + int getId() const; + void setId(int value); + void resetId(); + bool getIdIsSet() const; + + int getParentId() const; + void setParentId(int value); + + int getCalendarId() const; + void setCalendarId(int value); + + std::string getDescription() const; + void setDescription(const std::string &value); + + std::string getSubject() const; + void setSubject(const std::string &value); + + long long int getStartTime() const; + void setStartTime(long long int value); + + long long int getEndTime() const; + void setEndTime(long long int value); + + std::string getLocation() const; + void setLocation(const std::string &value); + + EventRecurrenceRulePtr getRecurrenceRule() const; + void setRecurrenceRule(EventRecurrenceRulePtr value); + + EventStatus getStatus() const; + void setStatus(EventStatus value); + + EventAlarmListPtr getAlarms() const; + void setAlarms(const EventAlarmListPtr value); + + StringArrayPtr getCategories() const; + void setCategories(const StringArrayPtr value); + + void display() const; + bool validate() const; + + bool getIsAllDay() const; + void setIsAllDay(bool value); + + long long int getLastModifiedDate() const; + void setLastModifiedDate(long long int value); + + std::string getOrganizer() const; + void setOrganizer(const std::string &value); + + EventVisibility getVisibility() const; + void setVisibility(EventVisibility value); + + EventAvailability getAvailability() const; + void setAvailability(EventAvailability value); + + std::string getUId() const; + void setUId(const std::string &value); + + long long int getRecurrenceId() const; + void setRecurrenceId(long long int value); + + EventAttendeeListPtr getAttendees() const; + void setAttendees(const EventAttendeeListPtr value); + + bool getIsDetached() const; + void setIsDetached(bool value); + + void setAttributesOfInterest(AttributeListPtr value); + AttributeListPtr getAttributesOfInterest() const; + + double getLatitude() const; + void setLatitude(double value); + + double getLongitude() const; + void setLongitude(double value); + + void setTimeZone(std::string value); + std::string getTimeZone() const; + + TaskPriority getPriority() const; + void setPriority(TaskPriority value); + + long long int getCreatedDate() const; + void setCreatedDate(long long int value); + + long long int getCompletedDate() const; + void setCompletedDate(long long int value); + + int getProgress() const; + void setProgress(int value); + + CalendarType getCalendarType() const; + void setCalendarType(CalendarType type); + + protected: + int m_id; + int m_parentId; // the parent id if it's detached. + int m_calendarId; + std::string m_description; + std::string m_subject; + long long int m_startTime; + long long int m_endTime; + std::string m_location; + EventRecurrenceRulePtr m_recurrence; + EventStatus m_status; + EventAlarmListPtr m_alarms; + StringArrayPtr m_categories; + bool m_isAllDay; + std::string m_organizer; + long long int m_lastModifiedDate; + EventVisibility m_visibility; + EventAvailability m_availability; + std::string m_uid; // uid is same with id. + long long int m_recurrenceId; + EventAttendeeListPtr m_attendees; + bool m_isDetached; + AttributeListPtr m_attributesOfInterest; + double m_latitude; + double m_longitude; + std::string m_timeZone; + TaskPriority m_priority; + long long int m_createdDate; + long long int m_completedDate; + int m_progress; + CalendarType m_calendarType; +}; + +typedef DPL::SharedPtr CalendarEventPtr; +typedef std::vector CalendarEventList; +typedef DPL::SharedPtr CalendarEventListPtr; + +} +} + +#endif /* _ABSTRACT_LAYER_CALENDAR_EVENT_H_ */ + diff --git a/src/Calendar/CalendarFactory.cpp b/src/Calendar/CalendarFactory.cpp new file mode 100755 index 0000000..ec4ea82 --- /dev/null +++ b/src/Calendar/CalendarFactory.cpp @@ -0,0 +1,47 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "CalendarFactory.h" +#include "ICalendarManager.h" +#include "ICalendar.h" +#include "CalendarManager.h" + + +namespace DeviceAPI { +namespace Calendar { + +ICalendarManagerPtr CalendarFactory::createCalendarManagerObject() +{ + ICalendarManagerPtr result(new CalendarManager()); + return result; +} + +ICalendarPtr CalendarFactory::createCalendarObject() +{ + ICalendarPtr result(new Calendar()); + return result; +} + +CalendarFactory& CalendarFactory::getInstance() +{ + static CalendarFactory theInstance; + return theInstance; +} + +} +} \ No newline at end of file diff --git a/src/Calendar/CalendarFactory.h b/src/Calendar/CalendarFactory.h new file mode 100755 index 0000000..ea31a0f --- /dev/null +++ b/src/Calendar/CalendarFactory.h @@ -0,0 +1,45 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_CALENDAR_FACTORY_H_ +#define _ABSTRACT_LAYER_CALENDAR_FACTORY_H_ + +#include "ICalendarManager.h" +#include "ICalendar.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +class CalendarFactory : private DPL::Noncopyable +{ + private: + CalendarFactory() + { + } + public: + static CalendarFactory& getInstance(); + ICalendarManagerPtr createCalendarManagerObject(); + ICalendarPtr createCalendarObject(); +}; + +} +} + + +#endif /* _ABSTRACT_LAYER_CALENDAR_FACTORY_H_ */ diff --git a/src/Calendar/CalendarFilter.cpp b/src/Calendar/CalendarFilter.cpp new file mode 100755 index 0000000..3fab69b --- /dev/null +++ b/src/Calendar/CalendarFilter.cpp @@ -0,0 +1,607 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include "CalendarFilter.h" +#include +#include +#include +#include + +#include "CalendarUtility.h" + +using namespace WrtDeviceApis::Commons; + +namespace DeviceAPI { +namespace Calendar { + +std::map CalendarFilter::m_eventAttributeMap = { + {CALENDAR_FILTER_ATTRIBUTE_ID_UID, _calendar_event.id}, + {CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE, _calendar_event.last_modified_time}, + {CALENDAR_FILTER_ATTRIBUTE_DESCRIPTION, _calendar_event.description}, + {CALENDAR_FILTER_ATTRIBUTE_SUMMARY, _calendar_event.summary}, + {CALENDAR_FILTER_ATTRIBUTE_START_DATE, _calendar_event.start_time}, + {CALENDAR_FILTER_ATTRIBUTE_LOCATION, _calendar_event.location}, + {CALENDAR_FILTER_ATTRIBUTE_LATITUDE, _calendar_event.latitude}, + {CALENDAR_FILTER_ATTRIBUTE_LONGITUDE, _calendar_event.longitude}, + {CALENDAR_FILTER_ATTRIBUTE_ORGANIZER, _calendar_event.organizer_name}, + {CALENDAR_FILTER_ATTRIBUTE_VISIBILITY, _calendar_event.sensitivity}, + {CALENDAR_FILTER_ATTRIBUTE_STATUS, _calendar_event.event_status}, + {CALENDAR_FILTER_ATTRIBUTE_ALARMS, _calendar_event.has_alarm}, + {CALENDAR_FILTER_ATTRIBUTE_CATEGORIES, _calendar_event.categories}, + {CALENDAR_FILTER_ATTRIBUTE_PRIORITY, _calendar_event.priority}, + {CALENDAR_FILTER_ATTRIBUTE_IS_DETACHED, _calendar_event.original_event_id}, + {CALENDAR_FILTER_ATTRIBUTE_IS_ALL_DAY, _calendar_event.is_allday}, + {CALENDAR_FILTER_ATTRIBUTE_ATTENDEES, _calendar_event.has_attendee}, + {CALENDAR_FILTER_ATTRIBUTE_END_DATE, _calendar_event.end_time}, + {CALENDAR_FILTER_ATTRIBUTE_AVAILABILITY, _calendar_event.busy_status}, + {CALENDAR_FILTER_ATTRIBUTE_RECURRENCE_RULE, _calendar_event.freq} +}; + +std::map CalendarFilter::m_taskAttributeMap = { + {CALENDAR_FILTER_ATTRIBUTE_ID, _calendar_todo.id}, + {CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE, _calendar_todo.last_modified_time}, + {CALENDAR_FILTER_ATTRIBUTE_DESCRIPTION, _calendar_todo.description}, + {CALENDAR_FILTER_ATTRIBUTE_SUMMARY, _calendar_todo.summary}, + {CALENDAR_FILTER_ATTRIBUTE_START_DATE, _calendar_todo.start_time}, + {CALENDAR_FILTER_ATTRIBUTE_LOCATION, _calendar_todo.location}, + {CALENDAR_FILTER_ATTRIBUTE_LATITUDE, _calendar_todo.latitude}, + {CALENDAR_FILTER_ATTRIBUTE_LONGITUDE, _calendar_todo.longitude}, + {CALENDAR_FILTER_ATTRIBUTE_ORGANIZER, _calendar_todo.organizer_name}, + {CALENDAR_FILTER_ATTRIBUTE_VISIBILITY, _calendar_todo.sensitivity}, + {CALENDAR_FILTER_ATTRIBUTE_STATUS, _calendar_todo.todo_status}, + {CALENDAR_FILTER_ATTRIBUTE_ALARMS, _calendar_todo.has_alarm}, + {CALENDAR_FILTER_ATTRIBUTE_CATEGORIES, _calendar_todo.categories}, + {CALENDAR_FILTER_ATTRIBUTE_PRIORITY, _calendar_todo.priority}, + {CALENDAR_FILTER_ATTRIBUTE_DUE_DATE, _calendar_todo.due_time}, + {CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE, _calendar_todo.completed_time}, + {CALENDAR_FILTER_ATTRIBUTE_PROGRESS, _calendar_todo.progress}, + {CALENDAR_FILTER_ATTRIBUTE_IS_ALL_DAY, _calendar_todo.is_allday}, + {CALENDAR_FILTER_ATTRIBUTE_ATTENDEES, _calendar_todo.has_attendee} +}; + +CalendarFilter::CalendarFilter() +{ + m_type = CalendarEvent::UNDEFINED_TYPE; + m_query = NULL; + m_filter = NULL; + m_recordList = NULL; + m_recordCount = 0; +} + +CalendarFilter::~CalendarFilter() +{ + LogDebug("Clear internal structs for filter."); + if(m_query) { + calendar_query_destroy(m_query); + } + if(m_filter) { + calendar_filter_destroy(m_filter); + } + + // Child record will be freed in the caller function. + if(m_recordList) { + calendar_list_destroy(m_recordList, false); + } +} + +void CalendarFilter::visitPreComposite(DeviceAPI::Tizen::FilterType& type, int depth) +{ +} + +void CalendarFilter::visitInComposite(DeviceAPI::Tizen::FilterType& type, int depth) +{ + LogDebug("Composite type: "<toString()<<", matchFlag: "<getString()); + } else { + value = matchValue->getInt(); + } + + if(CalendarEvent::TASK_TYPE==m_type) { + calendar_filter_add_int(m_filter, m_taskAttributeMap[attrName], intMatchFlag, value); + } else { + calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], intMatchFlag, value); + } + LogDebug("Added int filter with value: "<getString()); + ss>>id; + + if(CalendarEvent::TASK_TYPE==m_type) { + calendar_filter_add_int(m_filter, m_taskAttributeMap[attrName], intMatchFlag, id); + } else { + calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], intMatchFlag, id); + + // Include the detached events. + calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_OR); + calendar_filter_add_int(m_filter, _calendar_event.original_event_id, CALENDAR_MATCH_EQUAL, id); + } + LogDebug("Added int filter with id: "<getTimeT(); + if(CalendarEvent::TASK_TYPE==m_type) { + calendar_filter_add_lli(m_filter, m_taskAttributeMap[attrName], intMatchFlag, (long long int) time); + } else { + calendar_filter_add_lli(m_filter, m_eventAttributeMap[attrName], intMatchFlag, (long long int) time); + } + LogDebug("Added lli filter with value: "<getString().c_str()); + } else { + calendar_filter_add_str(m_filter, m_eventAttributeMap[attrName], strMatchFlag, matchValue->getString().c_str()); + } + LogDebug("Added str filter with value: "<getString()); + } else if(CALENDAR_FILTER_ATTRIBUTE_IS_ALL_DAY==attrName) { + if(CalendarEvent::TASK_TYPE==m_type) { + calendar_filter_add_int(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_EQUAL, matchValue->getBool() ? 1 : 0); + } else { + calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_EQUAL, matchValue->getBool() ? 1 : 0); + } + LogDebug("Added int filter with value: "<getBool()); + } else if(CALENDAR_FILTER_ATTRIBUTE_START_DATE==attrName || + CALENDAR_FILTER_ATTRIBUTE_DUE_DATE==attrName || + CALENDAR_FILTER_ATTRIBUTE_END_DATE==attrName) { + calendar_time_s calTime = {CALENDAR_TIME_UTIME, {0}}; + std::time_t time = matchValue->getTimeT(); + calTime.time.utime = (long long int) time; + if(CalendarEvent::TASK_TYPE==m_type) { + calendar_filter_add_caltime(m_filter, m_taskAttributeMap[attrName], intMatchFlag, calTime); + } else { + calendar_filter_add_caltime(m_filter, m_eventAttributeMap[attrName], intMatchFlag, calTime); + } + LogDebug("Added caltime filter with value: "<getDouble()); + } else { + calendar_filter_add_double(m_filter, m_eventAttributeMap[attrName], intMatchFlag, matchValue->getDouble()); + } + LogDebug("Added double filter with value: "<getDouble()); + } else if(CALENDAR_FILTER_ATTRIBUTE_ALARMS==attrName || + CALENDAR_FILTER_ATTRIBUTE_ATTENDEES==attrName) { + if(CalendarEvent::TASK_TYPE==m_type) { + if( DeviceAPI::Tizen::MATCH_EXACTLY==matchFlag ) { + if( matchValue->isNullOrUndefined() ) { + calendar_filter_add_int(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_EQUAL, 0); + } else { + calendar_filter_add_int(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_EQUAL, 1); + } + } else { + calendar_filter_add_int(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_EQUAL, 1); + } + } else { + if( DeviceAPI::Tizen::MATCH_EXACTLY==matchFlag ) { + if( matchValue->isNullOrUndefined() ) { + calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_EQUAL, 0); + } else { + calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_EQUAL, 1); + } + } else { + calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_EQUAL, 1); + } + } + LogDebug("Added int filter."); + } else if(CALENDAR_FILTER_ATTRIBUTE_CATEGORIES==attrName) { + if(CalendarEvent::TASK_TYPE==m_type) { + calendar_filter_add_str(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_CONTAINS, matchValue->getString().c_str()); + } else { + calendar_filter_add_str(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_CONTAINS, matchValue->getString().c_str()); + } + LogDebug("Added str filter for categories with value: "<getString()); + } else if(CALENDAR_FILTER_ATTRIBUTE_IS_DETACHED==attrName) { + if(CalendarEvent::TASK_TYPE==m_type) { + LogWarning("isDetached not supported for a task."); + } else { + calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN, 0); + } + LogDebug("Added int filter for isDetached with value 0."); + } else if(CALENDAR_FILTER_ATTRIBUTE_RECURRENCE_RULE==attrName) { + if(CalendarEvent::TASK_TYPE==m_type) { + LogWarning("rrule not supported for a task."); + } else { + if( DeviceAPI::Tizen::MATCH_EXACTLY==matchFlag ) { + if( matchValue->isNullOrUndefined() ) { + calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_EQUAL, 0); + } else { + calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN, 0); + } + LogDebug("Added int filter for rrule EXACTLY flag."); + } else { + calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN, 0); + LogDebug("Added int filter for rrule."); + } + } + } else { + LogWarning("Not supported filter attribute: "<toString()<<", endValue: " <toString()<<", depth: "<isNullOrUndefined()) { + startTime.time.utime = (long long int) (initialValue->getTimeT()); + startTimeAllday.time.date = CalendarUtility::LLIToCalTime(NULL, (long long int) (initialValue->getTimeT())).time.date; + } + if (!endValue->isNullOrUndefined()) { + endTime.time.utime = (long long int) (endValue->getTimeT()); + endTimeAllday.time.date = CalendarUtility::LLIToCalTime(NULL, (long long int) (endValue->getTimeT())).time.date; + } + if(CalendarEvent::TASK_TYPE==m_type) { + calendar_filter_h subFilter = NULL; + calendar_filter_create(_calendar_todo._uri, &subFilter); + if (!initialValue->isNullOrUndefined()) { + calendar_filter_add_caltime(subFilter, m_taskAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, startTime); + } + if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) { + calendar_filter_add_operator(subFilter, CALENDAR_FILTER_OPERATOR_AND); + } + if (!endValue->isNullOrUndefined()) { + calendar_filter_add_caltime(subFilter, m_taskAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, endTime); + } + calendar_filter_add_filter(m_filter, subFilter); + + calendar_filter_h subFilter2 = NULL; + calendar_filter_create(_calendar_todo._uri, &subFilter2); + if (!initialValue->isNullOrUndefined()) { + calendar_filter_add_caltime(subFilter2, m_taskAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, startTimeAllday); + } + if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) { + calendar_filter_add_operator(subFilter2, CALENDAR_FILTER_OPERATOR_AND); + } + if (!endValue->isNullOrUndefined()) { + calendar_filter_add_caltime(subFilter2, m_taskAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, endTimeAllday); + } + calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_OR); + calendar_filter_add_filter(m_filter, subFilter2); + } else { + calendar_filter_h subFilter = NULL; + calendar_filter_create(_calendar_event._uri, &subFilter); + if (!initialValue->isNullOrUndefined()) { + calendar_filter_add_caltime(subFilter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, startTime); + } + if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) { + calendar_filter_add_operator(subFilter, CALENDAR_FILTER_OPERATOR_AND); + } + if (!endValue->isNullOrUndefined()) { + calendar_filter_add_caltime(subFilter, m_eventAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, endTime); + } + calendar_filter_add_filter(m_filter, subFilter); + + calendar_filter_h subFilter2 = NULL; + calendar_filter_create(_calendar_event._uri, &subFilter2); + if (!initialValue->isNullOrUndefined()) { + calendar_filter_add_caltime(subFilter2, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, startTimeAllday); + } + if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) { + calendar_filter_add_operator(subFilter2, CALENDAR_FILTER_OPERATOR_AND); + } + if (!endValue->isNullOrUndefined()) { + calendar_filter_add_caltime(subFilter2, m_eventAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, endTimeAllday); + } + calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_OR); + calendar_filter_add_filter(m_filter, subFilter2); + } + LogDebug("Added caltime range filter with initial value: "<isNullOrUndefined()) { + calendar_filter_add_double(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, initialValue->getDouble()); + } + if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) { + calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_AND); + } + if (!endValue->isNullOrUndefined()) { + calendar_filter_add_double(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, endValue->getDouble()); + } + } else { + if (!initialValue->isNullOrUndefined()) { + calendar_filter_add_double(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, initialValue->getDouble()); + } + if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) { + calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_AND); + } + if (!endValue->isNullOrUndefined()) { + calendar_filter_add_double(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, endValue->getDouble()); + } + } + LogDebug("Added double range filter with initial value: "<getDouble()<<", end value: "<getDouble()); + } else if(CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE==attrName || + CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE==attrName) { + if(CalendarEvent::TASK_TYPE==m_type) { + if (!initialValue->isNullOrUndefined()) { + calendar_filter_add_lli(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, (long long int)(initialValue->getTimeT())); + } + if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) { + calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_AND); + } + if (!endValue->isNullOrUndefined()) { + calendar_filter_add_lli(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, (long long int)(endValue->getTimeT())); + } + } else { + if (!initialValue->isNullOrUndefined()) { + calendar_filter_add_lli(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, (long long int)(initialValue->getTimeT())); + } + if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) { + calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_AND); + } + if (!endValue->isNullOrUndefined()) { + calendar_filter_add_lli(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, (long long int)(endValue->getTimeT())); + } + } + LogDebug("Added lli range filter with initial value: "<getTimeT()<<", end value: "<getTimeT()); + } else if(CALENDAR_FILTER_ATTRIBUTE_PROGRESS==attrName) { + if(CalendarEvent::TASK_TYPE==m_type) { + if (!initialValue->isNullOrUndefined()) { + calendar_filter_add_int(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, initialValue->getInt()); + } + if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) { + calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_AND); + } + if (!endValue->isNullOrUndefined()) { + calendar_filter_add_int(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, endValue->getInt()); + } + } else { + if (!initialValue->isNullOrUndefined()) { + calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, initialValue->getInt()); + } + if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) { + calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_AND); + } + if (!endValue->isNullOrUndefined()) { + calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, endValue->getInt()); + } + } + LogDebug("Added double range filter with initial value: "<getInt()<<", end value: "<getInt()); + } else { + LogWarning("Not supported filter attribute: "<begin(); + + // The first sort mode only. + attrName = (*it)->getAttributeName(); + if (attrName.compare("") != 0) { + LogDebug("Setting the sort mode with attrName: "<getOrder()==DeviceAPI::Tizen::ASCENDING_SORT_ORDER) { + if(CalendarEvent::TASK_TYPE==m_type) { + calendar_query_set_sort(m_query, m_taskAttributeMap[attrName], true); + } else { + calendar_query_set_sort(m_query, m_eventAttributeMap[attrName], true); + } + } else { + if(CalendarEvent::TASK_TYPE==m_type) { + calendar_query_set_sort(m_query, m_taskAttributeMap[attrName], false); + } else { + calendar_query_set_sort(m_query, m_eventAttributeMap[attrName], false); + } + } + } else { + LogWarning("Empty attribute name."); + } +} + +void CalendarFilter::executeQuery() +{ + int ret; + ret = calendar_query_set_filter(m_query, m_filter); + if( CALENDAR_ERROR_NONE!=ret ) { + ThrowMsg(PlatformException, "Setting filter failed: "< +#include +#include +#include +#include "CalendarEvent.h" +#include + + + +namespace DeviceAPI { +namespace Calendar { + +// List of attributes that can be used as the filter argument. +#define CALENDAR_FILTER_ATTRIBUTE_ID_UID "id.uid" // for event +#define CALENDAR_FILTER_ATTRIBUTE_ID "id" // for task +#define CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE "lastModificationDate" +#define CALENDAR_FILTER_ATTRIBUTE_DESCRIPTION "description" +#define CALENDAR_FILTER_ATTRIBUTE_SUMMARY "summary" +#define CALENDAR_FILTER_ATTRIBUTE_IS_ALL_DAY "isAllDay" +#define CALENDAR_FILTER_ATTRIBUTE_START_DATE "startDate" +#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 DeviceAPI::Tizen::IFilterVisitor +{ +private: + CalendarEvent::CalendarType m_type; + calendar_query_h m_query; + calendar_filter_h m_filter; + calendar_list_h m_recordList; + int m_recordCount; + static std::map m_eventAttributeMap; + static std::map m_taskAttributeMap; + +public: + CalendarFilter(); + virtual ~CalendarFilter(); + + virtual void visitPreComposite(DeviceAPI::Tizen::FilterType& type, int depth); + + virtual void visitInComposite(DeviceAPI::Tizen::FilterType& type, int depth); + + virtual void visitPostComposite(DeviceAPI::Tizen::FilterType& type, int depth); + + virtual void visitAttribute(std::string& attrName, + DeviceAPI::Tizen::MatchFlag& matchFlag, + DeviceAPI::Tizen::AnyPtr& matchValue, + int depth); + + virtual void visitAttributeRange(std::string& attrName, + DeviceAPI::Tizen::AnyPtr& initialValue, + DeviceAPI::Tizen::AnyPtr& endValue, + int depth); + + void setType(CalendarEvent::CalendarType type); + + void setCalendarId(int calendarId, bool isFilterSet); + + void setSortMode(DeviceAPI::Tizen::SortModeArrayPtr attr); + + void executeQuery(); + + int getResultRecordCount() const; + + calendar_list_h getResultRecordList() const; + +private: + int convertStringToIntValue(const std::string attrName, const std::string valueString); +}; + +typedef DPL::SharedPtr CalendarFilterPtr; + +} +} + +#endif /* _CALENDAR_FILTER_H_ */ diff --git a/src/Calendar/CalendarFilterValidator.cpp b/src/Calendar/CalendarFilterValidator.cpp new file mode 100755 index 0000000..d732265 --- /dev/null +++ b/src/Calendar/CalendarFilterValidator.cpp @@ -0,0 +1,64 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 DeviceAPI { +namespace Calendar { + +using namespace DeviceAPI::Tizen; + +static PropertyStructArray properties = +{ + {CALENDAR_FILTER_ATTRIBUTE_ID_UID, PrimitiveType_String}, + {CALENDAR_FILTER_ATTRIBUTE_ID, PrimitiveType_String}, + {CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE, PrimitiveType_Time}, + {CALENDAR_FILTER_ATTRIBUTE_DESCRIPTION, PrimitiveType_String}, + {CALENDAR_FILTER_ATTRIBUTE_SUMMARY, PrimitiveType_String}, + {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_DETACHED, PrimitiveType_Boolean}, + {CALENDAR_FILTER_ATTRIBUTE_IS_ALL_DAY, PrimitiveType_Boolean}, + {CALENDAR_FILTER_ATTRIBUTE_END_DATE, PrimitiveType_Time}, + {CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE, PrimitiveType_Time}, + {CALENDAR_FILTER_ATTRIBUTE_PROGRESS, PrimitiveType_Integer}, + {CALENDAR_FILTER_ATTRIBUTE_AVAILABILITY, PrimitiveType_String}, + {CALENDAR_FILTER_ATTRIBUTE_RECURRENCE_RULE, PrimitiveType_Null}, + {CALENDAR_FILTER_ATTRIBUTE_ALARMS, PrimitiveType_Null}, + {CALENDAR_FILTER_ATTRIBUTE_ATTENDEES, PrimitiveType_Null}, + {0, PrimitiveType_NoType} +}; + +FilterValidatorPtr CalendarFilterValidatorFactory::getCalendarFilterValidator() +{ + static FilterValidatorPtr theInstance = + FilterValidatorPtr(new FilterValidator(properties)); + return theInstance; +} + +} // Calendar +} // DeviceAPI diff --git a/src/Calendar/CalendarFilterValidator.h b/src/Calendar/CalendarFilterValidator.h new file mode 100755 index 0000000..a20df6c --- /dev/null +++ b/src/Calendar/CalendarFilterValidator.h @@ -0,0 +1,41 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 + +namespace DeviceAPI { +namespace Calendar { + +class CalendarFilterValidatorFactory : private DPL::Noncopyable +{ +private: + CalendarFilterValidatorFactory() + { + } + +public: + static DeviceAPI::Tizen::FilterValidatorPtr getCalendarFilterValidator(); +}; + +} // Calendar +} // DeviceAPI + +#endif // _PLATFORM_CALENDAR_FILTER_VALIDATOR_H_ \ No newline at end of file diff --git a/src/Calendar/CalendarListenerManager.cpp b/src/Calendar/CalendarListenerManager.cpp new file mode 100755 index 0000000..9c32655 --- /dev/null +++ b/src/Calendar/CalendarListenerManager.cpp @@ -0,0 +1,23 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "CalendarListenerManager.h" +#include + +IMPLEMENT_SINGLETON(DeviceAPI::Calendar::CalendarListenerManager) + diff --git a/src/Calendar/CalendarListenerManager.h b/src/Calendar/CalendarListenerManager.h new file mode 100755 index 0000000..d50db48 --- /dev/null +++ b/src/Calendar/CalendarListenerManager.h @@ -0,0 +1,89 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _TIZEN_CALENDAR_LISTENER_MANAGER_H_ +#define _TIZEN_CALENDAR_LISTENER_MANAGER_H_ + +#include +#include +#include +#include +#include +#include +#include "CalendarResponseDispatcher.h" +#include "JSCalendar.h" +#include "ICalendar.h" + +namespace DeviceAPI { +namespace Calendar { + + + +class CalendarListenerManager : public DeviceAPI::Common::IListenerController +{ +public: + CalendarListenerManager() + { + } + + virtual ~CalendarListenerManager() + { + } +}; +typedef DPL::Singleton CalendarListenerManagerSingleton; + +class CalendarListenerCanceller : public DeviceAPI::Common::IListenerItem +{ +public: + CalendarListenerCanceller(JSContextRef context, JSObjectRef object, long watchId) : + DeviceAPI::Common::IListenerItem(context, object, watchId) + { + } + + virtual ~CalendarListenerCanceller() + { + } + + virtual void cancelListener() + { + CalendarPrivObject *privateObject = static_cast(JSObjectGetPrivate(m_object)); + if (!privateObject) { + LogWarning("Object is null."); + return; + } + + ICalendarPtr calendar = privateObject->getObject(); + + Try { + LogDebug("Remove change listeners for calendar."); + + IEventClearWatchPtr dplEvent(new IEventClearWatch()); + dplEvent->setWatchId(m_watchId); + dplEvent->setForSynchronousCall(); + calendar->clearWatch(dplEvent); + } Catch(WrtDeviceApis::Commons::Exception) { + LogError("Error on platform : " << _rethrown_exception.GetMessage()); + } + } +}; +typedef DPL::SharedPtr CalendarListenerCancellerPtr; + +} // Calendar +} // DeviceAPI + +#endif // _TIZEN_CALENDAR_LISTENER_MANAGER_H_ diff --git a/src/Calendar/CalendarManager.cpp b/src/Calendar/CalendarManager.cpp new file mode 100755 index 0000000..cd1b943 --- /dev/null +++ b/src/Calendar/CalendarManager.cpp @@ -0,0 +1,344 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "CalendarManager.h" +#include +#include +#include +#include + +using namespace WrtDeviceApis::Commons; + +namespace DeviceAPI { +namespace Calendar { + +int CalendarManager::m_instanceCount = 0; + +CalendarManager::CalendarManager() +{ + DPL::Mutex::ScopedLock mx(&m_constructorMutex); + if (m_instanceCount == 0) { + LogDebug("Connect to the calendar DB."); + if (CALENDAR_ERROR_NONE != calendar_connect()) { + LogError("Calendar DB connection failed."); + } + } + m_instanceCount++; +} + +CalendarManager::~CalendarManager() +{ + DPL::Mutex::ScopedLock mx(&m_constructorMutex); + m_instanceCount--; + if (m_instanceCount == 0) { + LogDebug("Disconnect calendar DB."); + if (CALENDAR_ERROR_NONE != calendar_disconnect()) { + LogError("Calendar DB disconnect failed."); + } + } +} + +void CalendarManager::OnRequestReceived(const IEventGetCalendarsPtr &event) +{ + Try + { + int ret, count; + calendar_list_h list = NULL; + ret = calendar_db_get_all_records(_calendar_book._uri, 0, 0, &list); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Getting calendar list failed: "<getType()) || + (CALENDAR_BOOK_TYPE_TODO==storeType && CalendarEvent::TASK_TYPE==event->getType()) ) { + ICalendarPtr newCalendar(new Calendar()); + newCalendar->setName(name); + newCalendar->setId(id); + newCalendar->setAccountId(accountId); + newCalendar->setType(event->getType()); + event->addCalendar(newCalendar); + } else { + LogDebug("Different calendar type."); + } + free(name); + } else { + LogError("Calendar contains invalid parameters"); + } + calendar = NULL; + + calendar_list_next(list); + } + + if(list) { + calendar_list_destroy(list, true); + } + + event->setResult(true); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } +} +void CalendarManager::OnRequestReceived(const IEventGetDefaultCalendarPtr &event) +{ + ICalendarPtr newCalendar(new Calendar()); + Try + { + int ret, count; + calendar_list_h list = NULL; + ret = calendar_db_get_all_records(_calendar_book._uri, 0, 0, &list); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Getting calendar list failed: "<getType()) || + (CALENDAR_BOOK_TYPE_TODO==storeType && CalendarEvent::TASK_TYPE==event->getType()) ) { + newCalendar->setName(name); + newCalendar->setId(id); + newCalendar->setAccountId(accountId); + newCalendar->setType(event->getType()); + event->setCalendar(newCalendar); + break; + } else { + LogDebug("Different calendar type."); + } + free(name); + } else { + LogError("Calendar contains invalid parameters"); + } + + calendar = NULL; + + calendar_list_next(list); + } + + if(list) { + calendar_list_destroy(list, true); + } + + event->setResult(true); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } +} + +void CalendarManager::OnRequestReceived(const IEventGetUnifiedCalendarPtr &event) +{ + Try + { + ICalendarPtr newCalendar(new Calendar()); + newCalendar->setType(event->getType()); + newCalendar->setIsUnified(true); + + LogDebug("Setting empty values, id: "<getId()<<", name: "<getName()<<", account id: "<getAccountId()<<", type: "<getType()); + + event->setCalendar(newCalendar); + + event->setResult(true); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } +} + +void CalendarManager::OnRequestReceived(const IEventGetCalendarPtr &event) +{ + Try + { + std::stringstream ss(event->getId()); + int calendarId = -1; + ss>>calendarId; + + LogInfo("Given id: "<getId()<<", converted id: "<getType()) || + (CALENDAR_BOOK_TYPE_TODO==storeType && CalendarEvent::TASK_TYPE==event->getType()) ) { + if(id==calendarId) { + newCalendar->setName(name); + newCalendar->setId(id); + newCalendar->setAccountId(accountId); + newCalendar->setType(event->getType()); + event->setCalendar(newCalendar); + break; + } + } else { + LogDebug("Different calendar type."); + } + free(name); + } else { + LogError("Calendar contains invalid parameters"); + } + + calendar = NULL; + + calendar_list_next(list); + } + + if(list) { + calendar_list_destroy(list, true); + } + + event->setResult(true); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + event->setResult(false); + event->setExceptionCode(ExceptionCodes::UnknownException); + } +} + +} +} diff --git a/src/Calendar/CalendarManager.h b/src/Calendar/CalendarManager.h new file mode 100755 index 0000000..e18bdf2 --- /dev/null +++ b/src/Calendar/CalendarManager.h @@ -0,0 +1,49 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 _CALENDARMANAGER_H_ +#define _CALENDARMANAGER_H_ + +#include "ICalendarManager.h" +#include "Calendar.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +class CalendarManager : public ICalendarManager +{ + public: + CalendarManager(); + virtual ~CalendarManager(); + + protected: + virtual void OnRequestReceived(const IEventGetCalendarsPtr &event); + virtual void OnRequestReceived(const IEventGetDefaultCalendarPtr &event); + virtual void OnRequestReceived(const IEventGetUnifiedCalendarPtr &event); + virtual void OnRequestReceived(const IEventGetCalendarPtr &event); + + private: + static int m_instanceCount; + DPL::Mutex m_constructorMutex; +}; + +} +} + +#endif /* _CALENDARMANAGER_H_ */ diff --git a/src/Calendar/CalendarMultiCallback.h b/src/Calendar/CalendarMultiCallback.h new file mode 100755 index 0000000..6a0710f --- /dev/null +++ b/src/Calendar/CalendarMultiCallback.h @@ -0,0 +1,128 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_MULTI_CALLBACK_H_ +#define _CALENDAR_MULTI_CALLBACK_H_ + +#include +#include +#include +#include +#include "CalendarEvent.h" + + +using namespace WrtDeviceApis::CommonsJavaScript; + +namespace DeviceAPI { +namespace Calendar { + +struct CalendarEventsSuccessCallback { + JSValueRef onSuccess; + JSValueRef onEventSuccess; + JSValueRef onEventError; + + CalendarEventsSuccessCallback() + : onSuccess(NULL), + onEventSuccess(NULL), + onEventError(NULL) + { } +}; + +class CalendarEventsCallbackPrivateData : public WrtDeviceApis::Commons::IEventPrivateData +{ +public: + CalendarEventsCallbackPrivateData(const JSCallbackManagerPtr& onSuccess, + const JSCallbackManagerPtr& onEvent): m_onSuccess(onSuccess), + m_onEvent(onEvent) + { + } + + JSCallbackManagerPtr getOnSuccess() const + { + return m_onSuccess; + } + JSCallbackManagerPtr getOnEvent() const + { + return m_onEvent; + } + +private: + JSCallbackManagerPtr m_onSuccess; + JSCallbackManagerPtr m_onEvent; +}; +typedef DPL::SharedPtr CalendarEventsCallbackPrivateDataPtr; + +struct CalendarChangeCallback { + JSValueRef onAdded; + JSValueRef onUpdated; + JSValueRef onDeleted; + //JSValueRef onCalendarReset; + + CalendarChangeCallback() + : onAdded(NULL), + onUpdated(NULL), + onDeleted(NULL) + //onCalendarReset(NULL) + { } +}; + +class CalendarChangeCallbackPrivateData : public WrtDeviceApis::Commons::IEventPrivateData +{ +public: + CalendarChangeCallbackPrivateData(const JSCallbackManagerPtr& onAdded, + const JSCallbackManagerPtr& onUpdated, const JSCallbackManagerPtr& onDeleted): + //const JSCallbackManagerPtr& onCalendarReset): + m_onAdded(onAdded), + m_onUpdated(onUpdated), + m_onDeleted(onDeleted) + //m_onCalendarReset(onCalendarReset) + { + } + + JSCallbackManagerPtr getOnAdded() const + { + return m_onAdded; + } + JSCallbackManagerPtr getOnUpdated() const + { + return m_onUpdated; + } + JSCallbackManagerPtr getOnDeleted() const + { + return m_onDeleted; + } + + /* + JSCallbackManagerPtr getOnCalendarReset() const + { + return m_onCalendarReset; + } + */ + + private: + JSCallbackManagerPtr m_onAdded; + JSCallbackManagerPtr m_onUpdated; + JSCallbackManagerPtr m_onDeleted; + //JSCallbackManagerPtr m_onCalendarReset; +}; +typedef DPL::SharedPtr CalendarChangeCallbackPrivateDataPtr; + +} +} + +#endif /* _CALENDAR_MULTI_CALLBACK_H_ */ diff --git a/src/Calendar/CalendarResponseDispatcher.cpp b/src/Calendar/CalendarResponseDispatcher.cpp new file mode 100755 index 0000000..c991530 --- /dev/null +++ b/src/Calendar/CalendarResponseDispatcher.cpp @@ -0,0 +1,337 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "CalendarResponseDispatcher.h" +#include +#include +#include +#include +#include "CalendarConverter.h" +#include "JSCalendarEventId.h" +#include "CalendarMultiCallback.h" +#include "EventId.h" + +#include "CalendarAsyncCallbackManager.h" + + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; + +namespace DeviceAPI { +namespace Calendar { + +CalendarResponseDispatcher& CalendarResponseDispatcher::getInstance() +{ + static CalendarResponseDispatcher instance; + return instance; +} + +CalendarResponseDispatcher::CalendarResponseDispatcher() : + GetCalendarsEventAnswerReceiver(ThreadEnum::NULL_THREAD), + CalendarEventsEventAnswerReceiverAdds(ThreadEnum::NULL_THREAD), + CalendarEventsEventAnswerReceiverDeletes(ThreadEnum::NULL_THREAD), + CalendarEventsEventAnswerReceiverUpdates(ThreadEnum::NULL_THREAD), + CalendarEventsEventAnswerReceiverFind(ThreadEnum::NULL_THREAD), + CalendarEventsEventAnswerReceiverExpand(ThreadEnum::NULL_THREAD), + OnEventsChangedListener(ThreadEnum::NULL_THREAD) +{ +} + +CalendarResponseDispatcher::~CalendarResponseDispatcher() +{ +} + +void CalendarResponseDispatcher::OnAnswerReceived(const IEventGetCalendarsPtr &event) +{ + JSCallbackManagerPtr cbm = DPL::StaticPointerCast(event->getPrivateData()); + if (!cbm) { + LogError("no callback manager"); + return; + } + + Try + { + CalendarAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(cbm); + + if (event->getResult()) { + CalendarConverter converter(cbm->getContext()); + const std::vector &results = event->getCalendars(); + LogDebug("found calendars: " << results.size()); + JSValueRef result = converter.toJSValueRef(results); + cbm->callOnSuccess(result); + return; + } + } + Catch(Exception) + { + LogError("error during processing answer"); + } + JSValueRef errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject( + cbm->getContext(), DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR); + cbm->callOnError(errorObject); +} + +void CalendarResponseDispatcher::OnAnswerReceived(const IEventAddEventsPtr &event) +{ + JSCallbackManagerPtr cbm = DPL::StaticPointerCast(event->getPrivateData()); + Try + { + if (!cbm) { + LogDebug("no callback manager"); + return; + } + + CalendarAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(cbm); + + if (event->getResult()) { + LogDebug("result success"); + CalendarConverter converter(cbm->getContext()); + + JSValueRef result; + if (CalendarEvent::TASK_TYPE==event->getCalendarType()) { + result = converter.toJSValueRefTaskArray(event->getEvents()); + } else { + result = converter.toJSValueRefEventArray(event->getEvents()); + } + + cbm->callOnSuccess(result); + return; + } + LogDebug("result fail"); + } + Catch(ConversionException) + { + LogError("cannot convert event"); + } + JSValueRef errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject( + cbm->getContext(), DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR); + cbm->callOnError(errorObject); +} + +void CalendarResponseDispatcher::OnAnswerReceived(const IEventUpdateEventsPtr &event) +{ + JSCallbackManagerPtr cbm = DPL::StaticPointerCast(event->getPrivateData()); + if (!cbm) { + LogDebug("no callback manager"); + return; + } + + CalendarAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(cbm); + + if (event->getResult()) { + cbm->callOnSuccess(); + } else { + JSValueRef errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject( + cbm->getContext(), DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR); + cbm->callOnError(errorObject); + } +} + +void CalendarResponseDispatcher::OnAnswerReceived(const IEventDeleteEventsPtr &event) +{ + JSCallbackManagerPtr cbm = DPL::StaticPointerCast(event->getPrivateData()); + if (!cbm) { + LogDebug("no callback manager"); + return; + } + + CalendarAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(cbm); + + if (event->getResult()) { + cbm->callOnSuccess(); + } else { + JSValueRef errorObject; + if (event->getExceptionCode() == + ExceptionCodes::NotFoundException) { + errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject( + cbm->getContext(), DeviceAPI::Common::JSTizenException::NOT_FOUND_ERROR); + } else { + errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject( + cbm->getContext(), DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR); + } + cbm->callOnError(errorObject); + } +} + +void CalendarResponseDispatcher::OnAnswerReceived(const IEventFindEventsPtr &event) +{ + JSCallbackManagerPtr cbm = DPL::StaticPointerCast(event->getPrivateData()); + if (!cbm) { + LogError("no callback manager"); + return; + } + Try + { + CalendarAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(cbm); + + if (event->getResult()) { + CalendarConverter converter(cbm->getContext()); + + JSValueRef result; + if (CalendarEvent::TASK_TYPE==event->getCalendarType()) { + result = converter.toJSValueRefTaskArray(event->getEvents()); + } else { + result = converter.toJSValueRefEventArray(event->getEvents()); + } + cbm->callOnSuccess(result); + return; + } else { + JSValueRef errorObject; + if (event->getExceptionCode() == ExceptionCodes::InvalidArgumentException) { + errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject( + cbm->getContext(), DeviceAPI::Common::JSTizenException::INVALID_VALUES_ERROR); + } else if (event->getExceptionCode() == ExceptionCodes::NotFoundException) { + errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject( + cbm->getContext(), DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR); + } else { + errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject( + cbm->getContext(), DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR); + } + cbm->callOnError(errorObject); + return; + } + } + Catch(Exception) + { + LogError("error during processing answer"); + JSValueRef errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject( + cbm->getContext(), DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR); + cbm->callOnError(errorObject); + } +} + +void CalendarResponseDispatcher::OnAnswerReceived(const IEventExpandEventRecurrencePtr &event) +{ + JSCallbackManagerPtr cbm = DPL::StaticPointerCast(event->getPrivateData()); + Try + { + if (!cbm) { + LogDebug("no callback manager"); + return; + } + + CalendarAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(cbm); + + if (event->getResult()) { + CalendarConverter converter(cbm->getContext()); + cbm->callOnSuccess(converter.toJSValueRefEventArray(event->getExpandedEventList())); + return; + } else { + JSValueRef errorObject; + if (event->getExceptionCode()==ExceptionCodes::InvalidArgumentException) { + errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject( + cbm->getContext(), DeviceAPI::Common::JSTizenException::INVALID_VALUES_ERROR); + } else if (event->getExceptionCode()==ExceptionCodes::NotFoundException) { + errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject( + cbm->getContext(), DeviceAPI::Common::JSTizenException::NOT_FOUND_ERROR); + } else { + errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject( + cbm->getContext(), DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR); + } + cbm->callOnError(errorObject); + return; + } + } + Catch(Exception) + { + LogError("error during processing answer"); + JSValueRef errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject( + cbm->getContext(), DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR); + cbm->callOnError(errorObject); + } +} + +void CalendarResponseDispatcher::onAnswerReceived(const OnEventsChangedPtr& event) +{ + CalendarChangeCallbackPrivateDataPtr multiCallbacks = + DPL::StaticPointerCast(event->getPrivateData()); + JSContextRef context = multiCallbacks->getOnAdded()->getContext(); + + CalendarConverter converter(context); + JSValueRef result; + + Try + { + switch (event->getStatus()) + { + case OnEventsChanged::ON_ADD: + { + if (CalendarEvent::TASK_TYPE==event->getCalendarType()) { + result = converter.toJSValueRefTaskArray(event->getEventList()); + } else { + result = converter.toJSValueRefEventArray(event->getEventList()); + } + + multiCallbacks->getOnAdded()->callOnSuccess(result); + break; + } + case OnEventsChanged::ON_UPDATE: + { + if (CalendarEvent::TASK_TYPE==event->getCalendarType()) { + result = converter.toJSValueRefTaskArray(event->getEventList()); + } else { + result = converter.toJSValueRefEventArray(event->getEventList()); + } + multiCallbacks->getOnUpdated()->callOnSuccess(result); + break; + } + case OnEventsChanged::ON_DELETE: + { + CalendarEventListPtr eventList = event->getEventList(); + + JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL); + if (NULL == jsResult) { + ThrowMsg(ConversionException, "Could not create js array object"); + } + + for (std::size_t i = 0; i < eventList->size(); i++) { + EventIdPtr eventId( new EventId() ); + eventId->setUId(eventList->at(i)->getUId()); + std::stringstream ss; + std::time_t rid = eventList->at(i)->getRecurrenceId(); + ss<setRecurrenceId(ss.str()); + JSValueRef tmpVal =JSCalendarEventId::createJSCalendarEventId(context, eventId); + if (!JSSetArrayElement(context, jsResult, i, tmpVal)) { + ThrowMsg(ConversionException, "Could not create js array element"); + } + } + + multiCallbacks->getOnDeleted()->callOnSuccess(jsResult); + break; + } + //case OnEventsChanged::ON_CALENDAR_RESET: + default: + { + LogDebug("Invalid status!"); + break; + } + } + } + Catch(ConversionException) + { + LogError("cannot convert change event"); + } + Catch(Exception) + { + LogError("exception occurred while handling change noti callback!"); + } +} + +} +} diff --git a/src/Calendar/CalendarResponseDispatcher.h b/src/Calendar/CalendarResponseDispatcher.h new file mode 100755 index 0000000..dd7122e --- /dev/null +++ b/src/Calendar/CalendarResponseDispatcher.h @@ -0,0 +1,77 @@ + // + // Tizen Web Device API + // Copyright (c) 2012 Samsung Electronics Co., Ltd. + // + // Licensed under the Apache License, Version 2.0 (the License); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT 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_RESPONSEDISPATCHER_H_ +#define _CALENDAR_RESPONSEDISPATCHER_H_ + +#include +#include +#include "IEventGetCalendars.h" +#include "IEventAddEvents.h" +#include "IEventDeleteEvents.h" +#include "IEventFindEvents.h" +#include "IEventUpdateEvents.h" +#include "IEventExpandEventRecurrence.h" +#include "OnEventsChanged.h" + +namespace DeviceAPI { +namespace Calendar { + +typedef WrtDeviceApis::Commons::EventAnswerReceiver +GetCalendarsEventAnswerReceiver; +typedef WrtDeviceApis::Commons::EventAnswerReceiver +CalendarEventsEventAnswerReceiverAdds; +typedef WrtDeviceApis::Commons::EventAnswerReceiver +CalendarEventsEventAnswerReceiverDeletes; +typedef WrtDeviceApis::Commons::EventAnswerReceiver +CalendarEventsEventAnswerReceiverUpdates; +typedef WrtDeviceApis::Commons::EventAnswerReceiver +CalendarEventsEventAnswerReceiverFind; +typedef WrtDeviceApis::Commons::EventAnswerReceiver +CalendarEventsEventAnswerReceiverExpand; +typedef WrtDeviceApis::Commons::EventListener +OnEventsChangedListener; + +class CalendarResponseDispatcher : + public GetCalendarsEventAnswerReceiver, + public CalendarEventsEventAnswerReceiverAdds, + public CalendarEventsEventAnswerReceiverDeletes, + public CalendarEventsEventAnswerReceiverUpdates, + public CalendarEventsEventAnswerReceiverFind, + public CalendarEventsEventAnswerReceiverExpand, + public OnEventsChangedListener +{ + public: + static CalendarResponseDispatcher& getInstance(); + void onAnswerReceived(const OnEventsChangedPtr& event); + private: + CalendarResponseDispatcher(); + virtual ~CalendarResponseDispatcher(); + protected: + void OnAnswerReceived(const IEventGetCalendarsPtr &event); + void OnAnswerReceived(const IEventAddEventsPtr &event); + void OnAnswerReceived(const IEventDeleteEventsPtr &event); + void OnAnswerReceived(const IEventUpdateEventsPtr &event); + void OnAnswerReceived(const IEventFindEventsPtr &event); + void OnAnswerReceived(const IEventExpandEventRecurrencePtr &event); +}; + +} +} + +#endif /* _CALENDAR_RESPONSEDISPATCHER_H_ */ diff --git a/src/Calendar/CalendarUtility.cpp b/src/Calendar/CalendarUtility.cpp new file mode 100755 index 0000000..5dd59a2 --- /dev/null +++ b/src/Calendar/CalendarUtility.cpp @@ -0,0 +1,133 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "CalendarUtility.h" + +#include + +#include +#include +#include +#include + +namespace DeviceAPI { +namespace Calendar { + +#define ms2sec(ms) (long long int)(ms / 1000.0) +#define sec2ms(s) (s * 1000.0) + +CalendarUtility::CalendarUtility() +{ +} + +CalendarUtility::~CalendarUtility() +{ +} + +calendar_time_s CalendarUtility::LLIToCalTime(const char* tzid, const long long int lli) +{ + int y, mon, d; + UCalendar *ucal; + UErrorCode status = U_ZERO_ERROR; + + calendar_time_s ct = {CALENDAR_TIME_LOCALTIME, {0}}; + + UChar *_tzid = NULL; + + if (tzid == NULL) + { + tzid = "Etc/Unknown"; + } + _tzid = (UChar*)calloc(strlen(tzid) + 1, sizeof(UChar)); + if (_tzid == NULL) + { + LogError("Failed to calloc"); + return ct; + } + u_uastrcpy(_tzid, tzid); + + LogDebug("tzid: "< + +namespace DeviceAPI { +namespace Calendar { + +class CalendarUtility +{ +public: + CalendarUtility(); + virtual ~CalendarUtility(); + + static calendar_time_s LLIToCalTime(const char* tzid, const long long int lli); + static long long int calTimeToLLI(const char* tzid, const calendar_time_s ct); +}; + +} // Calendar +} // DeviceAPI + +#endif // _CALENDAR_UTILITY_H_ diff --git a/src/Calendar/EventAlarm.cpp b/src/Calendar/EventAlarm.cpp new file mode 100755 index 0000000..5a0bb13 --- /dev/null +++ b/src/Calendar/EventAlarm.cpp @@ -0,0 +1,82 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "EventAlarm.h" +#include "EventRecurrenceRule.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +EventAlarm::EventAlarm() +{ + m_absoluteDate = UNDEFINED_TIME; + m_timeZone = DEFAULT_TIMEZONE; + m_method = SOUND_ALARM; +} +EventAlarm::~EventAlarm() +{ +} + +long long int EventAlarm::getAbsoluteDate() const +{ + return m_absoluteDate; +} +void EventAlarm::setAbsoluteDate(const long long int &value) +{ + m_absoluteDate = value; +} + +Time::DurationProperties EventAlarm::getDuration() const +{ + return m_duration; +} +void EventAlarm::setDuration(Time::DurationProperties value) +{ + m_duration = value; +} + +EventAlarm::EventAlarmType EventAlarm::getMethod() const +{ + return m_method; +} +void EventAlarm::setMethod(const EventAlarm::EventAlarmType value) +{ + m_method = value; +} + +std::string EventAlarm::getTimeZone() const +{ + return m_timeZone; +} +void EventAlarm::setTimeZone(const std::string &value) +{ + m_timeZone = value; +} + +std::string EventAlarm::getDescription() const +{ + return m_description; +} +void EventAlarm::setDescription(const std::string &value) +{ + m_description = value; +} + +} +} diff --git a/src/Calendar/EventAlarm.h b/src/Calendar/EventAlarm.h new file mode 100755 index 0000000..3c36a60 --- /dev/null +++ b/src/Calendar/EventAlarm.h @@ -0,0 +1,75 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 _EVENT_ALARM_H_ +#define _EVENT_ALARM_H_ + +#include +#include +#include +#include +#include + +namespace DeviceAPI { +namespace Calendar { + +class EventAlarm +{ + public: + typedef enum + { + NO_ALARM, + SILENT_ALARM, + SOUND_ALARM, + UNDEFINED_ALARM_TYPE + } EventAlarmType; + + EventAlarm(); + virtual ~EventAlarm(); + + long long int getAbsoluteDate() const; + void setAbsoluteDate(const long long int &value); + + Time::DurationProperties getDuration() const; + void setDuration(Time::DurationProperties value); + + EventAlarmType getMethod() const; + void setMethod(const EventAlarmType value); + + std::string getTimeZone() const; + void setTimeZone(const std::string &value); + + std::string getDescription() const; + void setDescription(const std::string &value); + + protected: + long long int m_absoluteDate; + Time::DurationProperties m_duration; + EventAlarmType m_method; + std::string m_description; + std::string m_timeZone; +}; + +typedef DPL::SharedPtr EventAlarmPtr; +typedef std::vector EventAlarmList; +typedef DPL::SharedPtr EventAlarmListPtr; + +} +} + +#endif /* _EVENT_ALARM_H_ */ diff --git a/src/Calendar/EventAttendee.cpp b/src/Calendar/EventAttendee.cpp new file mode 100755 index 0000000..f907525 --- /dev/null +++ b/src/Calendar/EventAttendee.cpp @@ -0,0 +1,148 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "EventAttendee.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +EventAttendee::EventAttendee() +{ + m_role = REQ_PARTICIPANT_ROLE; + m_status = PENDING_AT_STATUS; + m_RSVP = false; + m_type = INDIVIDUAL_TYPE; +} + +EventAttendee::~EventAttendee() +{ +} + +std::string EventAttendee::getName() const +{ + return m_name; +} + +void EventAttendee::setName(const std::string &value) +{ + m_name = value; +} + +std::string EventAttendee::getURI() const +{ + return m_uri; +} + +void EventAttendee::setURI(const std::string &value) +{ + m_uri = value; +} + +EventAttendee::EventAttendeeRole EventAttendee::getRole() const +{ + return m_role; +} + +void EventAttendee::setRole(EventAttendeeRole value) +{ + m_role = value; +} + +EventAttendee::EventAttendeeStatus EventAttendee::getStatus() const +{ + return m_status; +} + +void EventAttendee::setStatus(EventAttendeeStatus value) +{ + m_status = value; +} + +bool EventAttendee::getRSVP() const +{ + return m_RSVP; +} + +void EventAttendee::setRSVP(bool value) +{ + m_RSVP = value; +} + +EventAttendee::EventAttendeeType EventAttendee::getType() const +{ + return m_type; +} + +void EventAttendee::setType(EventAttendeeType value) +{ + m_type = value; +} + +std::string EventAttendee::getGroup() const +{ + return m_group; +} + +void EventAttendee::setGroup(const std::string &value) +{ + m_group = value; +} + +std::string EventAttendee::getDelegatorURI() const +{ + return m_delegatorURI; +} + +void EventAttendee::setDelegatorURI(const std::string &value) +{ + m_delegatorURI = value; +} + +std::string EventAttendee::getDelegateURI() const +{ + return m_delegateURI; +} + +void EventAttendee::setDelegateURI(const std::string &value) +{ + m_delegateURI = value; +} + +std::string EventAttendee::getAddressBookId() const +{ + return m_addressBookId; +} + +void EventAttendee::setAddressBookId(const std::string &value) +{ + m_addressBookId = value; +} + +std::string EventAttendee::getContactId() const +{ + return m_contactId; +} + +void EventAttendee::setContactId(const std::string &value) +{ + m_contactId = value; +} + +} +} diff --git a/src/Calendar/EventAttendee.h b/src/Calendar/EventAttendee.h new file mode 100755 index 0000000..4d28d38 --- /dev/null +++ b/src/Calendar/EventAttendee.h @@ -0,0 +1,121 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_EVENT_ATTENDEE_H_ +#define _ABSTRACT_LAYER_EVENT_ATTENDEE_H_ + +#include +#include +#include + +namespace DeviceAPI { +namespace Calendar { + +class EventAttendee +{ + public: + + typedef enum + { + REQ_PARTICIPANT_ROLE, + OPT_PARTICIPANT_ROLE, + NON_PARTICIPANT_ROLE, + CHAIR_ROLE, + UNDEFINED_ATTENDEE_ROLE + } EventAttendeeRole; + + typedef enum + { + PENDING_AT_STATUS, + ACCEPTED_AT_STATUS, + DECLINED_AT_STATUS, + TENTATIVE_AT_STATUS, + DELEGATED_AT_STATUS, + COMPLETED_AT_STATUS, + IN_PROCESS_AT_STATUS, + UNDEFINED_ATTENDEE_STATUS + } EventAttendeeStatus; + + typedef enum + { + INDIVIDUAL_TYPE, + GROUP_TYPE, + RESOURCE_TYPE, + ROOM_TYPE, + UNKNOWN_TYPE, + UNDEFINED_ATTENDEE_TYPE + } EventAttendeeType; + + EventAttendee(); + virtual ~EventAttendee(); + + std::string getName() const; + void setName(const std::string &value); + + std::string getURI() const; + void setURI(const std::string &value); + + EventAttendeeRole getRole() const; + void setRole(EventAttendeeRole value); + + EventAttendeeStatus getStatus() const; + void setStatus(EventAttendeeStatus value); + + bool getRSVP() const; + void setRSVP(bool value); + + EventAttendeeType getType() const; + void setType(EventAttendeeType value); + + std::string getGroup() const; + void setGroup(const std::string &value); + + std::string getDelegatorURI() const; + void setDelegatorURI(const std::string &value); + + std::string getDelegateURI() const; + void setDelegateURI(const std::string &value); + + std::string getAddressBookId() const; + void setAddressBookId(const std::string &value); + + std::string getContactId() const; + void setContactId(const std::string &value); + + protected: + std::string m_name; + std::string m_uri; + EventAttendeeRole m_role; + EventAttendeeStatus m_status; + bool m_RSVP; + EventAttendeeType m_type; + std::string m_group; + std::string m_delegatorURI; + std::string m_delegateURI; + std::string m_addressBookId; + std::string m_contactId; +}; + +typedef DPL::SharedPtr EventAttendeePtr; +typedef std::vector EventAttendeeList; +typedef DPL::SharedPtr EventAttendeeListPtr; + +} +} + +#endif /* _ABSTRACT_LAYER_EVENT_ATTENDEE_H_ */ diff --git a/src/Calendar/EventId.cpp b/src/Calendar/EventId.cpp new file mode 100755 index 0000000..d91979f --- /dev/null +++ b/src/Calendar/EventId.cpp @@ -0,0 +1,66 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "EventId.h" + +namespace DeviceAPI { +namespace Calendar { + +EventId::EventId() +{ + m_uid = ""; + m_recurrenceId = "0"; + m_calendarType = CalendarEvent::UNDEFINED_TYPE; +} + +EventId::~EventId() +{ +} + +std::string EventId::getUId() const +{ + return m_uid; +} + +void EventId::setUId(const std::string &value) +{ + m_uid = value; +} + +std::string EventId::getRecurrenceId() const +{ + return m_recurrenceId; +} + +void EventId::setRecurrenceId(const std::string &value) +{ + m_recurrenceId = value; +} + +CalendarEvent::CalendarType EventId::getCalendarType() const +{ + return m_calendarType; +} + +void EventId::setCalendarType(CalendarEvent::CalendarType type) +{ + m_calendarType = type; +} + +} +} diff --git a/src/Calendar/EventId.h b/src/Calendar/EventId.h new file mode 100755 index 0000000..343c091 --- /dev/null +++ b/src/Calendar/EventId.h @@ -0,0 +1,60 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_EVENT_ID_H_ +#define _ABSTRACT_LAYER_EVENT_ID_H_ + +#include +#include +#include +#include + +#include "CalendarEvent.h" + +namespace DeviceAPI { +namespace Calendar { + +class EventId +{ + public: + EventId(); + virtual ~EventId(); + + std::string getUId() const; + void setUId(const std::string &value); + + std::string getRecurrenceId() const; + void setRecurrenceId(const std::string &value); + + CalendarEvent::CalendarType getCalendarType() const; + void setCalendarType(CalendarEvent::CalendarType type); + + protected: + std::string m_uid; + std::string m_recurrenceId; + CalendarEvent::CalendarType m_calendarType; +}; + +typedef DPL::SharedPtr EventIdPtr; +typedef std::vector EventIdList; +typedef DPL::SharedPtr EventIdListPtr; + +} +} + +#endif /* _ABSTRACT_LAYER_EVENT_ID_H_ */ diff --git a/src/Calendar/EventRecurrenceRule.cpp b/src/Calendar/EventRecurrenceRule.cpp new file mode 100755 index 0000000..31a78e9 --- /dev/null +++ b/src/Calendar/EventRecurrenceRule.cpp @@ -0,0 +1,155 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "EventRecurrenceRule.h" +#include +#include + +namespace DeviceAPI { +namespace Calendar { + +EventRecurrenceRule::EventRecurrenceRule() +{ + m_frequency = NO_RECURRENCE; + m_interval = DEFAULT_INTERVAL; + m_endDate = UNDEFINED_TIME; + m_occurrenceCount = -1; + StringArrayPtr stringArrayPtr(new StringArray()); + m_daysOfTheWeek = stringArrayPtr; + NumberArrayPtr numberArraySetPositionsPtr(new NumberArray()); + m_setPositions = numberArraySetPositionsPtr; + NumberArrayPtr numberArrayExceptionsPtr(new NumberArray()); + m_exceptions = numberArrayExceptionsPtr; + m_timeZone = DEFAULT_TIMEZONE; +} + +EventRecurrenceRule::~EventRecurrenceRule() +{ +} + +EventRecurrenceRule::EventRecurrence EventRecurrenceRule::getFrequency() const +{ + return m_frequency; +} + +void EventRecurrenceRule::setFrequency(const EventRecurrenceRule::EventRecurrence &value) +{ + m_frequency = value; +} + +int EventRecurrenceRule::getInterval() const +{ + return m_interval; +} + +void EventRecurrenceRule::setInterval(const int &value) +{ + m_interval = value; +} + +long long int EventRecurrenceRule::getEndDate() const +{ + return m_endDate; +} + +void EventRecurrenceRule::setEndDate(long long int value) +{ + m_endDate = value; +} + +long EventRecurrenceRule::getOccurrenceCount() const +{ + return m_occurrenceCount; +} +void EventRecurrenceRule::setOccurrenceCount(long value) +{ + m_occurrenceCount = value; +} + +std::vector EventRecurrenceRule::getDaysOfTheMonth() const +{ + return m_daysOfTheMonth; +} + +void EventRecurrenceRule::setDaysOfTheMonth(std::vector value) +{ + m_daysOfTheMonth = value; +} + +StringArrayPtr EventRecurrenceRule::getDaysOfTheWeek() const +{ + return m_daysOfTheWeek; +} + +void EventRecurrenceRule::setDaysOfTheWeek(StringArrayPtr value) +{ + m_daysOfTheWeek = value; +} + +std::vector EventRecurrenceRule::getDaysOfTheYear() const +{ + return m_daysOfTheYear; +} + +void EventRecurrenceRule::setDaysOfTheYear(std::vector value) +{ + m_daysOfTheYear = value; +} + +std::vector EventRecurrenceRule::getWeeksOfTheYear() const +{ + return m_weeksOfTheYear; +} + +void EventRecurrenceRule::setWeeksOfTheYear(std::vector value) +{ + m_weeksOfTheYear = value; +} + +NumberArrayPtr EventRecurrenceRule::getSetPositions() const +{ + return m_setPositions; +} + +void EventRecurrenceRule::setSetPositions(NumberArrayPtr value) +{ + m_setPositions = value; +} + +NumberArrayPtr EventRecurrenceRule::getExceptions() const +{ + return m_exceptions; +} + +void EventRecurrenceRule::setExceptions(NumberArrayPtr value) +{ + m_exceptions = value; +} + +std::string EventRecurrenceRule::getTimeZone() const +{ + return m_timeZone; +} + +void EventRecurrenceRule::setTimeZone(std::string value) +{ + m_timeZone = value; +} + +} +} diff --git a/src/Calendar/EventRecurrenceRule.h b/src/Calendar/EventRecurrenceRule.h new file mode 100755 index 0000000..b8693c0 --- /dev/null +++ b/src/Calendar/EventRecurrenceRule.h @@ -0,0 +1,109 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 _EVENT_RECURRENCE_RULE_H_ +#define _EVENT_RECURRENCE_RULE_H_ + +#include +#include +#include +#include + +namespace DeviceAPI { +namespace Calendar { + +typedef std::vector StringArray; +typedef DPL::SharedPtr StringArrayPtr; + +typedef std::vector NumberArray; +typedef DPL::SharedPtr NumberArrayPtr; + +#define UNDEFINED_TIME -1 +#define DEFAULT_TIMEZONE "" +#define DEFAULT_INTERVAL 1 + +class EventRecurrenceRule +{ + public: + + typedef enum + { + NO_RECURRENCE, + DAILY_RECURRENCE, + WEEKLY_RECURRENCE, + MONTHLY_RECURRENCE, + YEARLY_RECURRENCE, + UNDEFINED_RECURRENCE + } EventRecurrence; + + EventRecurrenceRule(); + virtual ~EventRecurrenceRule(); + + EventRecurrence getFrequency() const; + void setFrequency(const EventRecurrence &value); + + int getInterval() const; + void setInterval(const int &value); + + long long int getEndDate() const; + void setEndDate(long long int value); + + long getOccurrenceCount() const; + void setOccurrenceCount(long value); + + std::vector getDaysOfTheMonth() const; + void setDaysOfTheMonth(std::vector value); + + StringArrayPtr getDaysOfTheWeek() const; + void setDaysOfTheWeek(StringArrayPtr value); + + std::vector getDaysOfTheYear() const; + void setDaysOfTheYear(std::vector value); + + std::vector getWeeksOfTheYear() const; + void setWeeksOfTheYear(std::vector value); + + NumberArrayPtr getSetPositions() const; + void setSetPositions(NumberArrayPtr value); + + NumberArrayPtr getExceptions() const; + void setExceptions(NumberArrayPtr value); + + std::string getTimeZone() const; + void setTimeZone(std::string value); + + protected: + EventRecurrence m_frequency; + int m_interval; + long long int m_endDate; + long m_occurrenceCount; + std::vector m_daysOfTheMonth; + StringArrayPtr m_daysOfTheWeek; + std::vector m_daysOfTheYear; + std::vector m_weeksOfTheYear; + NumberArrayPtr m_setPositions; + NumberArrayPtr m_exceptions; + std::string m_timeZone; +}; + +typedef DPL::SharedPtr EventRecurrenceRulePtr; + +} +} + +#endif /* _EVENT_RECURRENCE_RULE_H_ */ diff --git a/src/Calendar/EventWrapper.cpp b/src/Calendar/EventWrapper.cpp new file mode 100755 index 0000000..b64ab3c --- /dev/null +++ b/src/Calendar/EventWrapper.cpp @@ -0,0 +1,2349 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include "EventWrapper.h" +#include "Calendar.h" +#include "CalendarUtility.h" + +using namespace WrtDeviceApis::Commons; + +namespace DeviceAPI { +namespace Calendar { + +EventWrapper::EventWrapper(CalendarEvent::CalendarType type) : + m_platformEvent(NULL), + m_abstractEvent(NULL), + m_calendarType(type) +{ + m_abstractEvent = CalendarEventPtr(new CalendarEvent()); + if (!m_abstractEvent) { + ThrowMsg(UnknownException, "Abstract object is not created."); + } +} + +EventWrapper::EventWrapper(const CalendarEventPtr &event, CalendarEvent::CalendarType type) : + m_platformEvent(NULL), + m_abstractEvent(event), + m_calendarType(type) +{ +} + +EventWrapper::EventWrapper(calendar_record_h event, CalendarEvent::CalendarType type) : + m_platformEvent(event), + m_abstractEvent(NULL), + m_calendarType(type) +{ + m_abstractEvent = CalendarEventPtr(new CalendarEvent()); + if (!m_abstractEvent) { + ThrowMsg(UnknownException, "Abstract object is not created."); + } +} + +EventWrapper::~EventWrapper() +{ + freePlatformEvent(); +} + +void EventWrapper::saveEvent() +{ + if (m_platformEvent == NULL) { + ThrowMsg(NullPointerException, "m_platformEvent is not set"); + } + + int itemId = m_abstractEvent->getId(); + LogDebug("Before saving/update eventId: " << itemId); + + //displayPlatformEvent(); + + int ret; + if (itemId <= UNDEFINED_ITEM_ID) { + ret = calendar_db_insert_record(m_platformEvent, &itemId); + if (CALENDAR_ERROR_NONE!=ret) { + ThrowMsg(PlatformException, "Can't insert new item: "<setId(itemId); + LogDebug("New calendar item inserted with id: "<setCalendarType(getType()); + + //displayAbstractEvent(); +} + +void EventWrapper::deleteEvent() +{ + if (m_platformEvent == NULL) { + ThrowMsg(NullPointerException, "Platform event is null."); + } + + // If the recurrenceId is set, delete the instance of recurring event only. + int itemId = m_abstractEvent->getId(); + long long int recurrenceId = m_abstractEvent->getRecurrenceId(); + LogDebug("itemId to delete: " << itemId << ", recurrenceId: " << recurrenceId << ", type: " << getType()); + + calendar_record_h item = NULL; + const char *dataType; + if(getType() == CalendarEvent::TASK_TYPE) { + dataType = _calendar_todo._uri; + } else { + dataType = _calendar_event._uri; + } + + int ret = calendar_db_get_record(dataType, itemId, &item); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(NotFoundException, "Can't get calendar item: "<=recurrenceId || true==getAbstractEvent()->getIsDetached()) { + // Platform detects the detached events and uptates all instances. + ret = calendar_db_delete_record(dataType, itemId); + if (CALENDAR_ERROR_NONE != ret) { + if(CALENDAR_ERROR_DB_RECORD_NOT_FOUND==ret) { + ThrowMsg(NotFoundException, "Item not found."); + } else { + ThrowMsg(PlatformException, "Can't delete calendar item: "<resetId(); + } else { + EventRecurrenceRulePtr rrule = m_abstractEvent->getRecurrenceRule(); + (*rrule->getExceptions()).push_back(recurrenceId); + + std::string exdate = ""; + for( unsigned int i=0; igetExceptions()->size(); i++ ) { + std::stringstream ss; + ss<getExceptions()->at(i); + exdate.append(ss.str()); + if(i!=rrule->getExceptions()->size()-1) { + exdate.append(","); + } + } + ret = calendar_record_set_str(m_platformEvent, _calendar_event.exdate, exdate.c_str()); + if(ret!=CALENDAR_ERROR_NONE) { + ThrowMsg(PlatformException, "Can't delete the instance: "<getId(), &m_platformEvent); + if (CALENDAR_ERROR_NONE!=ret) { + ThrowMsg(NotFoundException, "Can't load the item with id: "<getId()<<", error code: "<getId()); + } + } else { + ret = calendar_record_create(dataType, &m_platformEvent); + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Can't create platform record: "<getCalendarId()); + } else { + ret = calendar_record_set_int(m_platformEvent, _calendar_event.calendar_book_id, m_abstractEvent->getCalendarId()); + } + if (CALENDAR_ERROR_NONE!=ret) { + LogWarning("Can't set calendarId."); + } +} + +void EventWrapper::setDescriptionToPlatformEvent() +{ + int ret; + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_set_str(m_platformEvent, _calendar_todo.description, m_abstractEvent->getDescription().c_str()); + } else { + ret = calendar_record_set_str(m_platformEvent, _calendar_event.description, m_abstractEvent->getDescription().c_str()); + } + if (CALENDAR_ERROR_NONE!=ret) { + LogWarning("Can't set item description."); + } +} + +void EventWrapper::setSummaryToPlatformEvent() +{ + int ret; + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_set_str(m_platformEvent, _calendar_todo.summary, m_abstractEvent->getSubject().c_str()); + } else { + ret = calendar_record_set_str(m_platformEvent, _calendar_event.summary, m_abstractEvent->getSubject().c_str()); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set item subject."); + } +} + +void EventWrapper::setStartTimeToPlatformEvent() +{ + int ret; + long long int time = m_abstractEvent->getStartTime(); + if (time == UNDEFINED_TIME) { + time = m_abstractEvent->getEndTime(); + } + + std::string timeZone = m_abstractEvent->getTimeZone(); + + calendar_time_s cal; + if(m_abstractEvent->getIsAllDay()) { + cal.type = CALENDAR_TIME_LOCALTIME; + cal.time.date = CalendarUtility::LLIToCalTime(timeZone.c_str(), time).time.date; + } else { + cal.type = CALENDAR_TIME_UTIME; + cal.time.utime = time; + } + + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_set_caltime(m_platformEvent, _calendar_todo.start_time, cal); + } else { + ret = calendar_record_set_caltime(m_platformEvent, _calendar_event.start_time, cal); + } + if (CALENDAR_ERROR_NONE != ret) { + ThrowMsg(PlatformException, "Can't set start time: "<getEndTime(); + if (time == UNDEFINED_TIME) { + time = m_abstractEvent->getStartTime(); + } + + calendar_time_s cal; + if(m_abstractEvent->getIsAllDay()) { + cal.type = CALENDAR_TIME_LOCALTIME; + cal.time.date = CalendarUtility::LLIToCalTime(m_abstractEvent->getTimeZone().c_str(), time).time.date; + } else { + cal.type = CALENDAR_TIME_UTIME; + cal.time.utime = time; + } + + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_set_caltime(m_platformEvent, _calendar_todo.due_time, cal); + } else { + ret = calendar_record_set_caltime(m_platformEvent, _calendar_event.end_time, cal); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set end/due time: "<getLocation().c_str()); + } else { + ret = calendar_record_set_str(m_platformEvent, _calendar_event.location, m_abstractEvent->getLocation().c_str()); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set location."); + } +} + +void EventWrapper::setRecurrenceRuleToPlatformEvent() +{ + if (CalendarEvent::TASK_TYPE==getType()) { + LogDebug("No need to set rrule for a task."); + return; + } + + EventRecurrenceRulePtr rrule = m_abstractEvent->getRecurrenceRule(); + if (NULL==rrule) { + LogDebug("rrule is not set."); + return; + } else if(EventRecurrenceRule::NO_RECURRENCE==rrule->getFrequency()) { + LogDebug("No recurrence frequency."); + return; + } else if(EventRecurrenceRule::UNDEFINED_RECURRENCE==rrule->getFrequency()) { + LogDebug("Undefined recurrence frequency."); + return; + } else { + LogDebug("frequency "<getFrequency()); + } + + // set frequency + switch (rrule->getFrequency()) { + case EventRecurrenceRule::NO_RECURRENCE: + if(CALENDAR_ERROR_NONE!=calendar_record_set_int(m_platformEvent, _calendar_event.freq, CALENDAR_RECURRENCE_NONE)) { + LogWarning("Failed setting frequency."); + } + break; + case EventRecurrenceRule::DAILY_RECURRENCE: + if(CALENDAR_ERROR_NONE!=calendar_record_set_int(m_platformEvent, _calendar_event.freq, CALENDAR_RECURRENCE_DAILY)) { + LogWarning("Failed setting frequency."); + } + break; + case EventRecurrenceRule::WEEKLY_RECURRENCE: + { + if(CALENDAR_ERROR_NONE!=calendar_record_set_int(m_platformEvent, _calendar_event.freq, CALENDAR_RECURRENCE_WEEKLY)) { + LogWarning("Failed setting frequency."); + } + break; + } + case EventRecurrenceRule::MONTHLY_RECURRENCE: + { + if(CALENDAR_ERROR_NONE!=calendar_record_set_int(m_platformEvent, _calendar_event.freq, CALENDAR_RECURRENCE_MONTHLY)) { + LogWarning("Failed setting frequency."); + } + break; + } + case EventRecurrenceRule::YEARLY_RECURRENCE: + { + if(CALENDAR_ERROR_NONE!=calendar_record_set_int(m_platformEvent, _calendar_event.freq, CALENDAR_RECURRENCE_YEARLY)) { + LogWarning("Failed setting frequency."); + } + break; + } + case EventRecurrenceRule::UNDEFINED_RECURRENCE: + default: + LogWarning("Invalid reccurence rule frequency "<getFrequency()); + break; + } + + // set byday + StringArrayPtr daysOfTheWeek = rrule->getDaysOfTheWeek(); + if( 0 != daysOfTheWeek->size() ) { + std::string byday = ""; + for(unsigned int i=0; isize(); i++) { + byday.append(daysOfTheWeek->at(i)); + if(i!=daysOfTheWeek->size()-1) { + byday.append(","); + } + } + + LogDebug("byday: "<getOccurrenceCount()) { + LogDebug("Set the occurrence count: "<getOccurrenceCount()); + + if (CALENDAR_ERROR_NONE != calendar_record_set_int(m_platformEvent, _calendar_event.range_type, CALENDAR_RANGE_COUNT)) { + LogWarning("Can't set rrule range type."); + } + + if (CALENDAR_ERROR_NONE != calendar_record_set_int(m_platformEvent, _calendar_event.count, rrule->getOccurrenceCount())) { + LogWarning("Can't set occurrence count."); + } + } + + // set the exceptions + if ( !rrule->getExceptions()->empty() ) + { + LogDebug("Set the exceptions of length: "<getExceptions()->size()); + + std::string exdate = ""; + for( unsigned int i=0; igetExceptions()->size(); i++ ) + { + std::stringstream ss; + ss<getExceptions()->at(i); + exdate.append(ss.str()); + if(i!=rrule->getExceptions()->size()-1) { + exdate.append(","); + } + } + LogDebug("exdate: "<getSetPositions()->empty() ) + { + LogDebug("Set the setPositions of length: "<getSetPositions()->size()); + + std::string bysetpos = ""; + for( unsigned int i=0; igetSetPositions()->size(); i++ ) + { + std::stringstream ss; + ss<getSetPositions()->at(i); + bysetpos.append(ss.str()); + if(i!=rrule->getSetPositions()->size()-1) { + bysetpos.append(","); + } + } + LogDebug("bysetpos: "<getInterval())) + { + LogWarning("Can't set interval."); + } + + // set the recurrence end date. This is automatically calculated by platform if empty. + if (UNDEFINED_TIME!=rrule->getEndDate()) { + LogDebug("Setting the end date: "<getEndDate()); + + if (CALENDAR_ERROR_NONE != calendar_record_set_int(m_platformEvent, _calendar_event.range_type, CALENDAR_RANGE_UNTIL)) { + LogWarning("Can't set rrule range type."); + } + + int ret; + calendar_time_s cal = {CALENDAR_TIME_UTIME, {0}}; + cal.type = CALENDAR_TIME_UTIME; + cal.time.utime = m_abstractEvent->getRecurrenceRule()->getEndDate(); + ret = calendar_record_set_caltime(m_platformEvent, _calendar_event.until_time, cal); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set rrule until time: "<getAlarms()->size() ) { + int ret; + calendar_record_h alarm = NULL; + + for( unsigned int i=0; igetAlarms()->size(); i++ ) + { + LogDebug("Set the alarms #"<getAlarms()->at(i); + + calendar_alarm_time_unit_type_e tickUnit = CALENDAR_ALARM_NONE; + int tick = 0; + if( UNDEFINED_TIME!=theAlarm->getAbsoluteDate() ) { + tickUnit = CALENDAR_ALARM_TIME_UNIT_SPECIFIC; + } else { + if( Time::MSECS_UNIT==theAlarm->getDuration().unit ) { + tickUnit = CALENDAR_ALARM_TIME_UNIT_MINUTE; // minimum calendar time unit. + tick = theAlarm->getDuration().length / 60000; + } else if( Time::SECONDS_UNIT==theAlarm->getDuration().unit ) { + tickUnit = CALENDAR_ALARM_TIME_UNIT_MINUTE; + tick = theAlarm->getDuration().length / 1000; + } else if( Time::MINUTES_UNIT==theAlarm->getDuration().unit ) { + tickUnit = CALENDAR_ALARM_TIME_UNIT_MINUTE; + tick = theAlarm->getDuration().length; + } else if( Time::HOURS_UNIT==theAlarm->getDuration().unit ) { + tickUnit = CALENDAR_ALARM_TIME_UNIT_HOUR; + tick = theAlarm->getDuration().length; + } else if( Time::DAYS_UNIT==theAlarm->getDuration().unit ) { + tickUnit = CALENDAR_ALARM_TIME_UNIT_DAY; + tick = theAlarm->getDuration().length; + } else { + LogWarning("Wrong alarm time unit: "<getDuration().unit); + } + } + + if( CALENDAR_ALARM_TIME_UNIT_SPECIFIC==tickUnit ) { + long long int time = theAlarm->getAbsoluteDate(); + LogDebug("Save absolute date: "<getMethod()); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set alarm type: "<getDescription().c_str()); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set alarm description: "<getStatus()) { + case CalendarEvent::NEEDS_ACTION_STATUS: + taskStatus = CALENDAR_TODO_STATUS_NEEDS_ACTION; + break; + case CalendarEvent::COMPLETED_STATUS: + taskStatus = CALENDAR_TODO_STATUS_COMPLETED; + break; + case CalendarEvent::IN_PROCESS_STATUS: + taskStatus = CALENDAR_TODO_STATUS_IN_PROCESS; + break; + case CalendarEvent::CANCELLED_STATUS: + taskStatus = CALENDAR_TODO_STATUS_CANCELED; + break; + default: + break; + } + + ret = calendar_record_set_int(m_platformEvent, _calendar_todo.todo_status, taskStatus); + } else { + calendar_event_status_e eventStatus = CALENDAR_EVENT_STATUS_NONE; + + switch (m_abstractEvent->getStatus()) { + case CalendarEvent::TENTATIVE_STATUS: + eventStatus = CALENDAR_EVENT_STATUS_TENTATIVE; + break; + case CalendarEvent::CONFIRMED_STATUS: + eventStatus = CALENDAR_EVENT_STATUS_CONFIRMED; + break; + case CalendarEvent::CANCELLED_STATUS: + eventStatus = CALENDAR_EVENT_STATUS_CANCELLED; + break; + default: + break; + } + + ret = calendar_record_set_int(m_platformEvent, _calendar_event.event_status, eventStatus); + } + + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set item status."); + } +} + +void EventWrapper::setCategoriesToPlatformEvent() +{ + int ret; + std::string categories = ""; + + // Need to concatenate all categories into one string separated by a comma. + for (size_t i = 0; i < m_abstractEvent->getCategories()->size(); ++i) { + if(0==i) { + categories.append(m_abstractEvent->getCategories()->at(i)); + } else { + categories.append("," + m_abstractEvent->getCategories()->at(i)); + } + } + + LogDebug("Saving categories: "<getRecurrenceId()) { + std::stringstream ss; + ss<getRecurrenceId(); + ret = calendar_record_set_str(m_platformEvent, _calendar_event.recurrence_id, ss.str().c_str()); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set recurrence id."); + } else { + LogDebug("Set the recurrence id: "<getParentId()) { + ret = calendar_record_set_int(m_platformEvent, _calendar_event.original_event_id, m_abstractEvent->getParentId()); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set parent Id."); + } else { + LogDebug("Set the parent id: "<getParentId()); + } + } else { + LogDebug("Parent id not defined."); + } +} + +void EventWrapper::setIsAllDayToPlatformEvent() +{ + LogDebug("All day flag is set in the start time struct: "<getIsAllDay()); +} + +void EventWrapper::setOrganizerToPlatformEvent() +{ + int ret; + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_set_str(m_platformEvent, _calendar_todo.organizer_name, m_abstractEvent->getOrganizer().c_str()); + } else { + ret = calendar_record_set_str(m_platformEvent, _calendar_event.organizer_name, m_abstractEvent->getOrganizer().c_str()); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set item organizer."); + } +} + +void EventWrapper::setVisibilityToPlatformEvent() +{ + int ret; + calendar_sensitivity_e visibility = CALENDAR_SENSITIVITY_PUBLIC; + + switch (m_abstractEvent->getVisibility()) { + case CalendarEvent::PUBLIC_VISIBILITY: + visibility = CALENDAR_SENSITIVITY_PUBLIC; + break; + case CalendarEvent::PRIVATE_VISIBILITY: + visibility = CALENDAR_SENSITIVITY_PRIVATE; + break; + case CalendarEvent::CONFIDENTIAL_VISIBILITY: + visibility = CALENDAR_SENSITIVITY_CONFIDENTIAL; + break; + default: + LogDebug("Use the default visibility"); + break; + } + + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_set_int(m_platformEvent, _calendar_todo.sensitivity, visibility); + } else { + ret = calendar_record_set_int(m_platformEvent, _calendar_event.sensitivity, visibility); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set visibility."); + } +} + +void EventWrapper::setAvailabilityToPlatformEvent() +{ + if(CalendarEvent::TASK_TYPE==getType()) { + LogDebug("No need to set availability for a task."); + return; + } + + calendar_event_busy_status_e availability = CALENDAR_EVENT_BUSY_STATUS_FREE; + switch (m_abstractEvent->getAvailability()) { + case CalendarEvent::BUSY_FB: + availability = CALENDAR_EVENT_BUSY_STATUS_BUSY; + break; + case CalendarEvent::BUSY_UNAVAILABLE_FB: + availability = CALENDAR_EVENT_BUSY_STATUS_UNAVAILABLE; + break; + case CalendarEvent::FREE_FB: + availability = CALENDAR_EVENT_BUSY_STATUS_FREE; + break; + case CalendarEvent::BUSY_TENTATIVE_FB: + availability = CALENDAR_EVENT_BUSY_STATUS_TENTATIVE; + break; + default: + LogDebug("Use the default availability"); + break; + } + + int ret = calendar_record_set_int(m_platformEvent, _calendar_event.busy_status, availability); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set availability."); + } +} + +void EventWrapper::setUIdToPlatformEvent() +{ + int ret; + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_set_str(m_platformEvent, _calendar_todo.uid, m_abstractEvent->getUId().c_str()); + } else { + ret = calendar_record_set_str(m_platformEvent, _calendar_event.uid, m_abstractEvent->getUId().c_str()); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set item uid."); + } +} + +void EventWrapper::setAttendeesToPlatformEvent() +{ + EventAttendeeListPtr attendeeList = m_abstractEvent->getAttendees(); + + if( 0!=attendeeList->size() ) { + int ret; + calendar_record_h attendee = NULL; + + for (size_t i = 0; i < attendeeList->size(); ++i) { + LogDebug("Adding attendee "<size()); + + attendee = NULL; + ret = calendar_record_create(_calendar_attendee._uri, &attendee); + if(CALENDAR_ERROR_NONE!=ret) { + LogWarning("Attendee creation failed: "<at(i); + + // save name + ret = calendar_record_set_str(attendee, _calendar_attendee.name, theAttendee->getName().c_str()); + if (CALENDAR_ERROR_NONE!=ret) { + LogWarning("Cannot set attendee name: "<getURI().c_str()); + if (CALENDAR_ERROR_NONE!=ret) { + LogWarning("Cannot set attendee URI: "<getRole()) { + case EventAttendee::REQ_PARTICIPANT_ROLE: + role = CALENDAR_ATTENDEE_ROLE_REQ_PARTICIPANT; + break; + case EventAttendee::OPT_PARTICIPANT_ROLE: + role = CALENDAR_ATTENDEE_ROLE_OPT_PARTICIPANT; + break; + case EventAttendee::NON_PARTICIPANT_ROLE: + role = CALENDAR_ATTENDEE_ROLE_NON_PARTICIPANT; + break; + case EventAttendee::CHAIR_ROLE: + role = CALENDAR_ATTENDEE_ROLE_CHAIR; + break; + default: + LogDebug("Use the default role"); + break; + } + ret = calendar_record_set_int(attendee, _calendar_attendee.role, role); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot set attendee role: "<getStatus()) { + case EventAttendee::PENDING_AT_STATUS: + status = CALENDAR_ATTENDEE_STATUS_PENDING; + break; + case EventAttendee::ACCEPTED_AT_STATUS: + status = CALENDAR_ATTENDEE_STATUS_ACCEPTED; + break; + case EventAttendee::DECLINED_AT_STATUS: + status = CALENDAR_ATTENDEE_STATUS_DECLINED; + break; + case EventAttendee::TENTATIVE_AT_STATUS: + status = CALENDAR_ATTENDEE_STATUS_TENTATIVE; + break; + case EventAttendee::DELEGATED_AT_STATUS: + status = CALENDAR_ATTENDEE_STATUS_DELEGATED; + break; + case EventAttendee::COMPLETED_AT_STATUS: + status = CALENDAR_ATTENDEE_STATUS_COMPLETED; + break; + case EventAttendee::IN_PROCESS_AT_STATUS: + status = CALENDAR_ATTENDEE_STATUS_IN_PROCESS; + break; + default: + LogDebug("Use the default status"); + break; + } + ret = calendar_record_set_int(attendee, _calendar_attendee.status, status); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot set attendee status: "<getRSVP()); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot set attendee RSVP: "<getType()); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot set attendee type: "<getGroup().c_str()); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot set attendee group: "<getDelegatorURI().c_str()); + if (CALENDAR_ERROR_NONE != ret ) { + LogWarning("Cannot set attendee delegator uri "<getDelegateURI().c_str()); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot set attendee delegate uri: "<getContactId().c_str()); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot set attendee uid: "<at(i)->getAddressBookId()); + int addressBookId; + ss>>addressBookId; + LogDebug("addressBookId: "<getLatitude()); + } else { + ret = calendar_record_set_double(m_platformEvent, _calendar_event.latitude, m_abstractEvent->getLatitude()); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set latitude: "<getLongitude()); + } else { + ret = calendar_record_set_double(m_platformEvent, _calendar_event.longitude, m_abstractEvent->getLongitude()); + } + + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set longitude: "<getPriority()) { + case CalendarEvent::HIGH_PRIORITY: + todoPriority = CALENDAR_TODO_PRIORITY_HIGH; + break; + case CalendarEvent::MEDIUM_PRIORITY: + todoPriority = CALENDAR_TODO_PRIORITY_NORMAL; + break; + case CalendarEvent::LOW_PRIORITY: + todoPriority = CALENDAR_TODO_PRIORITY_LOW; + break; + default: + break; + } + + ret = calendar_record_set_int(m_platformEvent, _calendar_todo.priority, todoPriority); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set task priority: "<getPriority()) { + case CalendarEvent::HIGH_PRIORITY: + eventPriority = CALENDAR_EVENT_PRIORITY_HIGH; + break; + case CalendarEvent::MEDIUM_PRIORITY: + eventPriority = CALENDAR_EVENT_PRIORITY_NORMAL; + break; + case CalendarEvent::LOW_PRIORITY: + eventPriority = CALENDAR_EVENT_PRIORITY_LOW; + break; + default: + break; + } + + ret = calendar_record_set_int(m_platformEvent, _calendar_event.priority, eventPriority); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set event priority: "<getCreatedDate()); + } else { + ret = calendar_record_set_lli(m_platformEvent, _calendar_event.created_time, m_abstractEvent->getCreatedDate()); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set createde time: "<getCompletedDate()); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning( "Can't set createde time: "<getProgress()); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't set progress: "<setCalendarId(calendarId); +} + +void EventWrapper::setDescriptionFromPlatformEvent() +{ + int ret; + char *description = NULL; + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_str(m_platformEvent, _calendar_todo.description, &description); + } else { + ret = calendar_record_get_str(m_platformEvent, _calendar_event.description, &description); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get description: "<setDescription(description); + free(description); + } +} + +void EventWrapper::setSummaryFromPlatformEvent() +{ + int ret; + char *summary = NULL; + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_str(m_platformEvent, _calendar_todo.summary, &summary); + } else { + ret = calendar_record_get_str(m_platformEvent, _calendar_event.summary, &summary); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get summary: "<setSubject(summary); + free(summary); + } +} + +void EventWrapper::setStartTimeFromPlatformEvent() +{ + int ret; + calendar_time_s cal; + + // Retrive the time zone info only when the start time is loaded. + char *timeZone = NULL; + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_str(m_platformEvent, _calendar_todo.start_tzid, &timeZone); + } else { + ret = calendar_record_get_str(m_platformEvent, _calendar_event.start_tzid, &timeZone); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get time zone: "<setTimeZone(std::string(timeZone)); + } + + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_caltime(m_platformEvent, _calendar_todo.start_time, &cal); + } else { + ret = calendar_record_get_caltime(m_platformEvent, _calendar_event.start_time, &cal); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get start time: "<setStartTime(CalendarUtility::calTimeToLLI(timeZone, cal)); + m_abstractEvent->setIsAllDay(true); + } else { + m_abstractEvent->setStartTime(cal.time.utime); + m_abstractEvent->setIsAllDay(false); + } + + if( timeZone ) { + free(timeZone); + } +} + +void EventWrapper::setEndTimeFromPlatformEvent() +{ + int ret; + calendar_time_s cal; + + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_caltime(m_platformEvent, _calendar_todo.due_time, &cal); + } else { + ret = calendar_record_get_caltime(m_platformEvent, _calendar_event.end_time, &cal); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get due/end time: "<setEndTime(CalendarUtility::calTimeToLLI(m_abstractEvent->getTimeZone().c_str(), cal)); + } else { + m_abstractEvent->setEndTime(cal.time.utime); +} +} + +void EventWrapper::setLocationFromPlatformEvent() +{ + int ret; + char *location = NULL; + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_str(m_platformEvent, _calendar_todo.location, &location); + } else { + ret = calendar_record_get_str(m_platformEvent, _calendar_event.location, &location); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get location: "<setLocation(location); + free(location); + } +} + +void EventWrapper::setRecurrenceRuleFromPlatformEvent() +{ + if (CalendarEvent::TASK_TYPE==getType()) { + LogDebug("No need to set rrule for a task."); + return; + } + + int ret; + EventRecurrenceRulePtr rrule(new EventRecurrenceRule()); + + // load the recurrence frequency + int frequency; + ret = calendar_record_get_int(m_platformEvent, _calendar_event.freq, &frequency); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get frequency: "<setFrequency(EventRecurrenceRule::NO_RECURRENCE); + return; + break; + case CALENDAR_RECURRENCE_DAILY: + rrule->setFrequency(EventRecurrenceRule::DAILY_RECURRENCE); + break; + case CALENDAR_RECURRENCE_WEEKLY: + rrule->setFrequency(EventRecurrenceRule::WEEKLY_RECURRENCE); + break; + case CALENDAR_RECURRENCE_MONTHLY: + rrule->setFrequency(EventRecurrenceRule::MONTHLY_RECURRENCE); + break; + case CALENDAR_RECURRENCE_YEARLY: + rrule->setFrequency(EventRecurrenceRule::YEARLY_RECURRENCE); + break; + default: + LogWarning("Unknown recurrence frequency."); + rrule->setFrequency(EventRecurrenceRule::NO_RECURRENCE); + return; + break; + } + + // load the byday + StringArrayPtr daysOfTheWeek(new StringArray()); + char* byday = NULL; + ret = calendar_record_get_str(m_platformEvent, _calendar_event.byday, &byday); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get byday: "<setDaysOfTheWeek(daysOfTheWeek); + LogDebug("Number of daysOfTheWeek: "<getDaysOfTheWeek()->size()); + + // load the recurrence interval + int interval; + ret = calendar_record_get_int(m_platformEvent, _calendar_event.interval, &interval); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get interval: "<setInterval(interval); + + // load the ocurrence count + int occurrrenceCount; + ret = calendar_record_get_int(m_platformEvent, _calendar_event.count, &occurrrenceCount); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get occurrrence count: "<setOccurrenceCount(occurrrenceCount); + + // load the recurrence end date + calendar_time_s cal = {CALENDAR_TIME_UTIME, {0}}; + ret = calendar_record_get_caltime(m_platformEvent, _calendar_event.until_time, &cal); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get recurrence end date: "<0) { + rrule->setEndDate(cal.time.utime); + } else { + rrule->setEndDate(UNDEFINED_TIME); + } + LogDebug("endDate from platform = "<getEndDate()); + + // load the exceptions + NumberArrayPtr exceptions(new NumberArray()); + char* exdate = NULL; + ret = calendar_record_get_str(m_platformEvent, _calendar_event.exdate, &exdate); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get exdate: "<>oneException; + (*exceptions).push_back(oneException); + pch = strtok_r(NULL, ",", &saveptr); + } + free(exdate); + } + rrule->setExceptions(exceptions); + LogDebug("Number of exceptions: "<getExceptions()->size()); + + // load the setPositions + NumberArrayPtr setPositions(new NumberArray()); + char* bysetpos = NULL; + ret = calendar_record_get_str(m_platformEvent, _calendar_event.bysetpos, &bysetpos); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get bysetpos: "<>setPos; + (*setPositions).push_back(setPos); + pch = strtok_r(NULL, ",", &saveptr); + } + free(bysetpos); + } + rrule->setSetPositions(setPositions); + LogDebug("Number of setPositions: "<getSetPositions()->size()); + + // set the loaded recurrence rule + m_abstractEvent->setRecurrenceRule(rrule); +} + +void EventWrapper::setAlarmsFromPlatformEvent() +{ + int ret; + unsigned int count = 0, i; + calendar_list_h list = NULL; + + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_child_record_count(m_platformEvent, _calendar_todo.calendar_alarm, &count); + } else { + ret = calendar_record_get_child_record_count(m_platformEvent, _calendar_event.calendar_alarm, &count); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get alarms count: "<setAbsoluteDate(time); + LogDebug("Loaded absolute date: "<getAbsoluteDate()); + } else { + ret = calendar_record_get_int(alarm, _calendar_alarm.tick, &tick); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot read alarm tick. Stop processing alarms."); + continue; + } + + Time::DurationProperties duration; + if( CALENDAR_ALARM_TIME_UNIT_MINUTE==tickUnit ) { + duration.unit = Time::MINUTES_UNIT; + duration.length = tick; + } else if( CALENDAR_ALARM_TIME_UNIT_HOUR==tickUnit ) { + duration.unit = Time::HOURS_UNIT; + duration.length = tick; + } else if( CALENDAR_ALARM_TIME_UNIT_DAY==tickUnit ) { + duration.unit = Time::DAYS_UNIT; + duration.length = tick; + } else if( CALENDAR_ALARM_TIME_UNIT_WEEK==tickUnit) { + duration.unit = Time::DAYS_UNIT; + duration.length = tick*7; + } else if( CALENDAR_ALARM_TIME_UNIT_MONTH==tickUnit) { + // Not supportd correctly. + duration.unit = Time::DAYS_UNIT; + duration.length = tick*30; + } else { + LogWarning("Wrong tick unit: "<setDuration(duration); + } + + int type; + ret = calendar_record_get_int(alarm, _calendar_alarm.type, &type); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot read alarm type: "<setMethod((EventAlarm::EventAlarmType)type); + + char* description = NULL; + ret = calendar_record_get_str(alarm, _calendar_alarm.description, &description); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot read alarm description: "<setDescription(""); + free(description); + } else { + LogDebug("Alarm description: "<setDescription(description); + } + } + + // Save the alarm. + m_abstractEvent->getAlarms()->push_back(theAlarm); + } + + if(list) { + calendar_list_destroy(list, true); + } + LogDebug("Number of alarms: "<getAlarms()->size()); +} + +void EventWrapper::setStatusFromPlatformEvent() +{ + int ret; + int status; + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_int(m_platformEvent, _calendar_todo.todo_status, &status); + } else { + ret = calendar_record_get_int(m_platformEvent, _calendar_event.event_status, &status); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get status: "<setStatus(CalendarEvent::TENTATIVE_STATUS); + break; + case CALENDAR_EVENT_STATUS_CONFIRMED: + m_abstractEvent->setStatus(CalendarEvent::CONFIRMED_STATUS); + break; + case CALENDAR_EVENT_STATUS_CANCELLED: + case CALENDAR_TODO_STATUS_CANCELED: + m_abstractEvent->setStatus(CalendarEvent::CANCELLED_STATUS); + break; + case CALENDAR_TODO_STATUS_NEEDS_ACTION: + m_abstractEvent->setStatus(CalendarEvent::NEEDS_ACTION_STATUS); + break; + case CALENDAR_TODO_STATUS_COMPLETED: + m_abstractEvent->setStatus(CalendarEvent::COMPLETED_STATUS); + break; + case CALENDAR_TODO_STATUS_IN_PROCESS: + m_abstractEvent->setStatus(CalendarEvent::IN_PROCESS_STATUS); + break; + default: + m_abstractEvent->setStatus(CalendarEvent::UNDEFINED_STATUS); + break; + } +} + +void EventWrapper::setCategoriesFromPlatformEvent() +{ + m_abstractEvent->getCategories()->clear(); + + int ret; + char *categories = NULL; + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_str(m_platformEvent, _calendar_todo.categories, &categories); + } else { + ret = calendar_record_get_str(m_platformEvent, _calendar_event.categories, &categories); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get categories: "<getCategories()->push_back(pch); + pch = strtok_r(NULL, ",", &saveptr); + } + free(categories); + } + + LogDebug("Number of categories: "<getCategories()->size()); +} + +void EventWrapper::setIdFromPlatformEvent() +{ + if (m_platformEvent == NULL) { + ThrowMsg(NullPointerException, "m_platformEvent is not set"); + } + + int ret, id; + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_int(m_platformEvent, _calendar_todo.id, &id); + } else { + ret = calendar_record_get_int(m_platformEvent, _calendar_event.id, &id); + } + if (CALENDAR_ERROR_NONE!=ret) { + ThrowMsg(PlatformException, "Can't get id: "<setId(id); + + // Set the uid also. + std::stringstream ss; + ss<setUId(ss.str()); +} + +void EventWrapper::setRecurrenceIdFromPlatformEvent() +{ + if(CalendarEvent::TASK_TYPE==getType()) { + LogDebug("No need to set the recurrence id for a task."); + return; + } + + int ret; + char* recurrenceId = NULL; + ret = calendar_record_get_str(m_platformEvent, _calendar_event.recurrence_id, &recurrenceId); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get recurrence id: "<>rid; + m_abstractEvent->setRecurrenceId(rid); + LogDebug("Set the recurrence id: "<setRecurrenceId(UNDEFINED_TIME); + } +} + +void EventWrapper::setParentIdFromPlatformEvent() +{ + if(CalendarEvent::TASK_TYPE==getType()) { + LogDebug("No need to set the parent id for a task."); + return; + } + + int ret, parentId; + ret = calendar_record_get_int(m_platformEvent, _calendar_event.original_event_id, &parentId); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get parent id: "<0 ) { + m_abstractEvent->setParentId(parentId); + } else { + m_abstractEvent->setParentId(UNDEFINED_ITEM_ID); + } +} + +void EventWrapper::setIsAllDayFromPlatformEvent() +{ + LogDebug("All day flag is set when getting the start time: "<getIsAllDay()); +} + +void EventWrapper::setOrganizerFromPlatformEvent() +{ + int ret; + char* organizer = NULL; + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_str(m_platformEvent, _calendar_todo.organizer_name, &organizer); + } else { + ret = calendar_record_get_str(m_platformEvent, _calendar_event.organizer_name, &organizer); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get organizer: "<setOrganizer(organizer); + free(organizer); + } +} + +void EventWrapper::setLastModifiedDateFromPlatformEvent() +{ + int ret; + long long int lastModifiedDate; + + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_lli(m_platformEvent, _calendar_todo.last_modified_time, &lastModifiedDate); + } else { + ret = calendar_record_get_lli(m_platformEvent, _calendar_event.last_modified_time, &lastModifiedDate); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get last modification time: "<setLastModifiedDate(lastModifiedDate); +} + +void EventWrapper::setVisibilityFromPlatformEvent() +{ + int ret, visibility; + + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_int(m_platformEvent, _calendar_todo.sensitivity, &visibility); + } else { + ret = calendar_record_get_int(m_platformEvent, _calendar_event.sensitivity, &visibility); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get visibility: "<setVisibility(CalendarEvent::PUBLIC_VISIBILITY); + break; + case CALENDAR_SENSITIVITY_PRIVATE: + m_abstractEvent->setVisibility(CalendarEvent::PRIVATE_VISIBILITY); + break; + case CALENDAR_SENSITIVITY_CONFIDENTIAL: + m_abstractEvent->setVisibility(CalendarEvent::CONFIDENTIAL_VISIBILITY); + break; + default: + m_abstractEvent->setVisibility(CalendarEvent::PUBLIC_VISIBILITY); + break; + } +} + +void EventWrapper::setAvailabilityFromPlatformEvent() +{ + if(CalendarEvent::TASK_TYPE==getType()) { + LogDebug("No need to set availability for a task."); + return; + } + + int ret, availability; + ret = calendar_record_get_int(m_platformEvent, _calendar_event.busy_status, &availability); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get visibility: "<setAvailability(CalendarEvent::BUSY_FB); + break; + case CALENDAR_EVENT_BUSY_STATUS_UNAVAILABLE: + m_abstractEvent->setAvailability(CalendarEvent::BUSY_UNAVAILABLE_FB); + break; + case CALENDAR_EVENT_BUSY_STATUS_FREE: + m_abstractEvent->setAvailability(CalendarEvent::FREE_FB); + break; + case CALENDAR_EVENT_BUSY_STATUS_TENTATIVE: + m_abstractEvent->setAvailability(CalendarEvent::BUSY_TENTATIVE_FB); + break; + default: + m_abstractEvent->setAvailability(CalendarEvent::FREE_FB); + break; + } +} + +void EventWrapper::setUIdFromPlatformEvent() +{ + int ret; + char* uid = NULL; + + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_str(m_platformEvent, _calendar_todo.uid, &uid); + } else { + ret = calendar_record_get_str(m_platformEvent, _calendar_event.uid, &uid); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get uid: "<setUId(uid); + free(uid); + } +} + +void EventWrapper::setAttendeesFromPlatformEvent() +{ + if ( NULL != m_abstractEvent->getAttendees() ) { + m_abstractEvent->getAttendees()->clear(); + } + + int ret; + unsigned int count = 0, i; + calendar_record_h attendee = NULL; + calendar_list_h list = NULL; + + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_child_record_count(m_platformEvent, _calendar_todo.calendar_attendee, &count); + } else { + ret = calendar_record_get_child_record_count(m_platformEvent, _calendar_event.calendar_attendee, &count); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get attendee count: "<setName(""); + } else { + if(attendeeName) { + attendeePtr->setName(attendeeName); + free(attendeeName); + } + } + + // load URI + char* attendeeURI = NULL; + ret = calendar_record_get_str(attendee, _calendar_attendee.email, &attendeeURI); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot read attendee URI. Setting an empty string."); + attendeePtr->setURI(""); + } else { + if(attendeeURI) { + attendeePtr->setURI(attendeeURI); + free(attendeeURI); + } + } + + // load role + int attendeeRole; + ret = calendar_record_get_int(attendee, _calendar_attendee.role, &attendeeRole); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot read attendee role. Setting the default value."); + } + switch (attendeeRole) { + case CALENDAR_ATTENDEE_ROLE_REQ_PARTICIPANT: + attendeePtr->setRole(EventAttendee::REQ_PARTICIPANT_ROLE); + break; + case CALENDAR_ATTENDEE_ROLE_OPT_PARTICIPANT: + attendeePtr->setRole(EventAttendee::OPT_PARTICIPANT_ROLE); + break; + case CALENDAR_ATTENDEE_ROLE_NON_PARTICIPANT: + attendeePtr->setRole(EventAttendee::NON_PARTICIPANT_ROLE); + break; + case CALENDAR_ATTENDEE_ROLE_CHAIR: + attendeePtr->setRole(EventAttendee::CHAIR_ROLE); + break; + default: + attendeePtr->setRole(EventAttendee::REQ_PARTICIPANT_ROLE); + break; + } + + // load status + int attendeeStatus; + ret = calendar_record_get_int(attendee, _calendar_attendee.status, &attendeeStatus); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot read attendee status. Setting the default value."); + } + switch (attendeeStatus) { + case CALENDAR_ATTENDEE_STATUS_PENDING: + attendeePtr->setStatus(EventAttendee::PENDING_AT_STATUS); + break; + case CALENDAR_ATTENDEE_STATUS_ACCEPTED: + attendeePtr->setStatus(EventAttendee::ACCEPTED_AT_STATUS); + break; + case CALENDAR_ATTENDEE_STATUS_DECLINED: + attendeePtr->setStatus(EventAttendee::DECLINED_AT_STATUS); + break; + case CALENDAR_ATTENDEE_STATUS_TENTATIVE: + attendeePtr->setStatus(EventAttendee::TENTATIVE_AT_STATUS); + break; + case CALENDAR_ATTENDEE_STATUS_DELEGATED: + attendeePtr->setStatus(EventAttendee::DELEGATED_AT_STATUS); + break; + case CALENDAR_ATTENDEE_STATUS_COMPLETED: + attendeePtr->setStatus(EventAttendee::COMPLETED_AT_STATUS); + break; + case CALENDAR_ATTENDEE_STATUS_IN_PROCESS: + attendeePtr->setStatus(EventAttendee::IN_PROCESS_AT_STATUS); + break; + default: + attendeePtr->setStatus(EventAttendee::PENDING_AT_STATUS); + break; + } + + // load RSVP + int attendeeRSVP; + ret = calendar_record_get_int(attendee, _calendar_attendee.rsvp, &attendeeRSVP); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot read attendee RSVP. Setting the default value."); + } + attendeePtr->setRSVP(attendeeRSVP>0 ? true : false); + + // load type + int attendeeType; + ret = calendar_record_get_int(attendee, _calendar_attendee.type, &attendeeType); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot read attendee type. Setting the default value."); + } + attendeePtr->setType((EventAttendee::EventAttendeeType)attendeeType); + + // load group + char* attendeeGroup = NULL; + ret = calendar_record_get_str(attendee, _calendar_attendee.group, &attendeeGroup); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot read attendee group. Setting an empty string."); + attendeePtr->setGroup(""); + } else { + if(attendeeGroup) { + attendeePtr->setGroup(attendeeGroup); + free(attendeeGroup); + } + } + + // load delegatorURI + char* attendeeDelegatorURI = NULL; + ret = calendar_record_get_str(attendee, _calendar_attendee.delegator_uri, &attendeeDelegatorURI); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot read attendee delegatorURI. Setting an empty string."); + attendeePtr->setDelegatorURI(""); + } else { + if(attendeeDelegatorURI) { + attendeePtr->setDelegatorURI(attendeeDelegatorURI); + free(attendeeDelegatorURI); + } + } + + // load delegateURI + char* attendeeDelegateURI = NULL; + ret = calendar_record_get_str(attendee, _calendar_attendee.delegate_uri, &attendeeDelegateURI); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot read attendee delegateURI. Setting an empty string."); + attendeePtr->setDelegateURI(""); + } else { + if(attendeeDelegateURI) { + attendeePtr->setDelegateURI(attendeeDelegateURI); + free(attendeeDelegateURI); + } + } + + // load contactId + char* attendeeContactId = NULL; + ret = calendar_record_get_str(attendee, _calendar_attendee.uid, &attendeeContactId); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Cannot read attendee UId. Setting an empty string."); + attendeePtr->setContactId(""); + } else { + if(attendeeContactId) { + attendeePtr->setContactId(attendeeContactId); + free(attendeeContactId); + } + } + + // load addressBookId + int attendeeAddressBookId; + ret = calendar_record_get_int(attendee, _calendar_attendee.person_id, &attendeeAddressBookId); + LogDebug("attendeeAddressBookId: "<=0) { + ss<setAddressBookId(ss.str()); + + m_abstractEvent->getAttendees()->push_back(attendeePtr); + } + + if(list) { + calendar_list_destroy(list, true); + } +} + +void EventWrapper::setPositionFromPlatformEvent() +{ + int ret; + double value; + + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_double(m_platformEvent, _calendar_todo.latitude, &value); + } else { + ret = calendar_record_get_double(m_platformEvent, _calendar_event.latitude, &value); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get item latitude."); + return; + } + m_abstractEvent->setLatitude(value); + + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_double(m_platformEvent, _calendar_todo.longitude, &value); + } else { + ret = calendar_record_get_double(m_platformEvent, _calendar_event.longitude, &value); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get item longitude."); + return; + } + m_abstractEvent->setLongitude(value); +} + +void EventWrapper::setPriorityFromPlatformEvent() +{ + int ret; + int priority; + + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_int(m_platformEvent, _calendar_todo.priority, &priority); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get task priority: "<setPriority(CalendarEvent::LOW_PRIORITY); + break; + case CALENDAR_TODO_PRIORITY_NORMAL: + m_abstractEvent->setPriority(CalendarEvent::MEDIUM_PRIORITY); + break; + case CALENDAR_TODO_PRIORITY_HIGH: + m_abstractEvent->setPriority(CalendarEvent::HIGH_PRIORITY); + break; + default: + m_abstractEvent->setPriority(CalendarEvent::MEDIUM_PRIORITY); + break; + } + } else { + ret = calendar_record_get_int(m_platformEvent, _calendar_event.priority, &priority); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get event priority: "<setPriority(CalendarEvent::LOW_PRIORITY); + break; + case CALENDAR_EVENT_PRIORITY_NORMAL: + m_abstractEvent->setPriority(CalendarEvent::MEDIUM_PRIORITY); + break; + case CALENDAR_EVENT_PRIORITY_HIGH: + m_abstractEvent->setPriority(CalendarEvent::HIGH_PRIORITY); + break; + default: + m_abstractEvent->setPriority(CalendarEvent::MEDIUM_PRIORITY); + break; + } + } +} + +void EventWrapper::setCreatedDateFromPlatformEvent() +{ + int ret; + long long int createdDate; + + if(CalendarEvent::TASK_TYPE==getType()) { + ret = calendar_record_get_lli(m_platformEvent, _calendar_todo.created_time, &createdDate); + } else { + ret = calendar_record_get_lli(m_platformEvent, _calendar_event.created_time, &createdDate); + } + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get created date: "<setCreatedDate(createdDate); +} + +void EventWrapper::setCompletedDateFromPlatformEvent() +{ + if(CalendarEvent::EVENT_TYPE==getType()) { + LogDebug("No need to set completedDate for an event."); + return; + } + + int ret; + long long int completedDate; + + ret = calendar_record_get_lli(m_platformEvent, _calendar_todo.completed_time, &completedDate); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get completed date: "<setCompletedDate(completedDate); +} + +void EventWrapper::setProgressFromPlatformEvent() +{ + if(CalendarEvent::EVENT_TYPE==getType()) { + LogDebug("No need to set progress for an event."); + return; + } + + int ret; + int progress = 0; + ret = calendar_record_get_int(m_platformEvent, _calendar_todo.progress, &progress); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get progress: "<setProgress(progress); +} + +void EventWrapper::setIsDetachedFromPlatformEvent() +{ + if(CalendarEvent::TASK_TYPE==getType()) { + LogDebug("No need to set isDetached flag for a task."); + return; + } + + int ret; + int isDetached; + ret = calendar_record_get_int(m_platformEvent, _calendar_event.original_event_id, &isDetached); + if (CALENDAR_ERROR_NONE != ret) { + LogWarning("Can't get isDetached: "<0) { + m_abstractEvent->setIsDetached(true); + LogDebug("This is a detached event."); + } else { + m_abstractEvent->setIsDetached(false); + } +} + +void EventWrapper::displayAbstractEvent() +{ + m_abstractEvent->display(); +} + +void EventWrapper::displayPlatformEvent() +{ + LogDebug("Displaying platform itemt disabled."); +} + +CalendarEvent::CalendarType EventWrapper::getType() +{ + return m_calendarType; +} + +} +} diff --git a/src/Calendar/EventWrapper.h b/src/Calendar/EventWrapper.h new file mode 100755 index 0000000..07a575e --- /dev/null +++ b/src/Calendar/EventWrapper.h @@ -0,0 +1,119 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_EVENT_WRAPPER_H_ +#define _CALENDAR_EVENT_WRAPPER_H_ + +#include +#include +#include +#include "CalendarEvent.h" +#include "EventAlarm.h" +#include "EventAttendee.h" +#include "EventRecurrenceRule.h" + +namespace DeviceAPI { +namespace Calendar { + +class EventWrapper +{ + public: + EventWrapper(CalendarEvent::CalendarType type = CalendarEvent::EVENT_TYPE); + explicit EventWrapper(const CalendarEventPtr &event, CalendarEvent::CalendarType type = CalendarEvent::EVENT_TYPE); + explicit EventWrapper(calendar_record_h event, CalendarEvent::CalendarType type = CalendarEvent::EVENT_TYPE); + virtual ~EventWrapper(); + calendar_record_h convertAbstractEventToPlatformEvent(bool loadBeforeConvert = false); + CalendarEventPtr convertPlatformEventToAbstractEvent(); + calendar_record_h getPlatformEvent() const; + CalendarEventPtr getAbstractEvent() const; + void freePlatformEvent(); + + void saveEvent(); + void loadEvent(int id); + void deleteEvent(); + void createEventFromString(std::string value); + std::string exportEventToString(); + + void displayAbstractEvent(); + void displayPlatformEvent(); + + protected: + void setCalendarIdToPlatformEvent(); + void setDescriptionToPlatformEvent(); + void setSummaryToPlatformEvent(); + void setStartTimeToPlatformEvent(); + void setEndTimeToPlatformEvent(); + void setLocationToPlatformEvent(); + void setRecurrenceRuleToPlatformEvent(); + void setAlarmsToPlatformEvent(); + void setStatusToPlatformEvent(); + void setCategoriesToPlatformEvent(); + void setRecurrenceIdToPlatformEvent(); + void setParentIdToPlatformEvent(); + void setIsAllDayToPlatformEvent(); + void setOrganizerToPlatformEvent(); + void setVisibilityToPlatformEvent(); + void setAvailabilityToPlatformEvent(); + void setUIdToPlatformEvent(); + void setAttendeesToPlatformEvent(); + void setPositionToPlatformEvent(); + void setPriorityToPlatformEvent(); + void setCreatedDateToPlatformEvent(); + void setCompletedDateToPlatformEvent(); + void setProgressToPlatformEvent(); + + void setCalendarIdFromPlatformEvent(); + void setDescriptionFromPlatformEvent(); + void setSummaryFromPlatformEvent(); + void setStartTimeFromPlatformEvent(); + void setEndTimeFromPlatformEvent(); + void setLocationFromPlatformEvent(); + void setRecurrenceRuleFromPlatformEvent(); + void setAlarmsFromPlatformEvent(); + void setStatusFromPlatformEvent(); + void setCategoriesFromPlatformEvent(); + void setIdFromPlatformEvent(); + void setRecurrenceIdFromPlatformEvent(); + void setParentIdFromPlatformEvent(); + void setIsAllDayFromPlatformEvent(); + void setOrganizerFromPlatformEvent(); + void setLastModifiedDateFromPlatformEvent(); + void setVisibilityFromPlatformEvent(); + void setAvailabilityFromPlatformEvent(); + void setUIdFromPlatformEvent(); + void setAttendeesFromPlatformEvent(); + void setPositionFromPlatformEvent(); + void setPriorityFromPlatformEvent(); + void setCreatedDateFromPlatformEvent(); + void setCompletedDateFromPlatformEvent(); + void setProgressFromPlatformEvent(); + void setIsDetachedFromPlatformEvent(); + + private: + CalendarEvent::CalendarType getType(); + + calendar_record_h m_platformEvent; + CalendarEventPtr m_abstractEvent; + CalendarEvent::CalendarType m_calendarType; +}; + +typedef DPL::SharedPtr EventWrapperPtr; + +} +} +#endif /* _CALENDAR_EVENT_WRAPPER_H_ */ diff --git a/src/Calendar/ICalendar.cpp b/src/Calendar/ICalendar.cpp new file mode 100755 index 0000000..f58c596 --- /dev/null +++ b/src/Calendar/ICalendar.cpp @@ -0,0 +1,118 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "ICalendar.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +ICalendar::ICalendar() : + WrtDeviceApis::Commons::EventRequestReceiver(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + WrtDeviceApis::Commons::EventRequestReceiver(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + WrtDeviceApis::Commons::EventRequestReceiver(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + WrtDeviceApis::Commons::EventRequestReceiver(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + WrtDeviceApis::Commons::EventRequestReceiver(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + WrtDeviceApis::Commons::EventRequestReceiver(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + WrtDeviceApis::Commons::EventRequestReceiver(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + WrtDeviceApis::Commons::EventRequestReceiver(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + WrtDeviceApis::Commons::EventRequestReceiver(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + WrtDeviceApis::Commons::EventRequestReceiver(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + WrtDeviceApis::Commons::EventRequestReceiver(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + WrtDeviceApis::Commons::EventRequestReceiver(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + WrtDeviceApis::Commons::EventRequestReceiver(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + m_id(UNDEFINED_ID), + m_accountId(UNDEFINED_CALENDAR_ID), + m_name(""), + m_type(CalendarEvent::UNDEFINED_TYPE), + m_lastChangedVersion(-1), + m_isUnified(false) +{ +} + +ICalendar::~ICalendar() +{ +} + +void ICalendar::addEvent(IEventAddEventPtr &event) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(event); +} + +void ICalendar::addEvents(IEventAddEventsPtr &events) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(events); +} + +void ICalendar::updateEvent(IEventUpdateEventPtr &event) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(event); +} + +void ICalendar::updateEvents(IEventUpdateEventsPtr &events) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(events); +} + +void ICalendar::deleteEvent(IEventDeleteEventPtr &event) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(event); +} + +void ICalendar::deleteEvents(IEventDeleteEventsPtr &events) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(events); +} + +void ICalendar::findEvents(IEventFindEventsPtr &event) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(event); +} + +void ICalendar::createEventFromString(IEventCreateEventFromStringPtr &event) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(event); +} + +void ICalendar::exportEventToString(IEventExportEventToStringPtr &event) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(event); +} + +void ICalendar::watchChanges(IEventWatchChangesPtr &event) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(event); +} + +void ICalendar::clearWatch(IEventClearWatchPtr &event) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(event); +} + +void ICalendar::expandEventRecurrence(IEventExpandEventRecurrencePtr &event) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(event); +} + +void ICalendar::get(IEventGetPtr &event) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(event); +} + +} +} diff --git a/src/Calendar/ICalendar.h b/src/Calendar/ICalendar.h new file mode 100755 index 0000000..42e5a39 --- /dev/null +++ b/src/Calendar/ICalendar.h @@ -0,0 +1,162 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_ICALENDAR_H_ +#define _ABSTRACT_LAYER_ICALENDAR_H_ + +#include +#include +#include +#include +#include "CalendarEvent.h" +#include "IEventAddEvent.h" +#include "IEventAddEvents.h" +#include "IEventDeleteEvent.h" +#include "IEventDeleteEvents.h" +#include "IEventFindEvents.h" +#include "IEventUpdateEvent.h" +#include "IEventUpdateEvents.h" +#include "IEventCreateEventFromString.h" +#include "IEventExportEventToString.h" +#include "IEventWatchChanges.h" +#include "IEventClearWatch.h" +#include "IEventExpandEventRecurrence.h" +#include "IEventGet.h" +#include "OnEventsChanged.h" + +namespace DeviceAPI { +namespace Calendar { + +class ICalendar : public WrtDeviceApis::Commons::EventRequestReceiver< IEventAddEvent >, + public WrtDeviceApis::Commons::EventRequestReceiver< IEventAddEvents >, + public WrtDeviceApis::Commons::EventRequestReceiver< IEventDeleteEvent >, + public WrtDeviceApis::Commons::EventRequestReceiver< IEventDeleteEvents >, + public WrtDeviceApis::Commons::EventRequestReceiver< IEventUpdateEvent >, + public WrtDeviceApis::Commons::EventRequestReceiver< IEventUpdateEvents >, + public WrtDeviceApis::Commons::EventRequestReceiver< IEventFindEvents >, + public WrtDeviceApis::Commons::EventRequestReceiver< IEventCreateEventFromString >, + public WrtDeviceApis::Commons::EventRequestReceiver< IEventExportEventToString >, + public WrtDeviceApis::Commons::EventRequestReceiver< IEventWatchChanges >, + public WrtDeviceApis::Commons::EventRequestReceiver< IEventClearWatch >, + public WrtDeviceApis::Commons::EventRequestReceiver< IEventExpandEventRecurrence >, + public WrtDeviceApis::Commons::EventRequestReceiver< IEventGet > +{ + public: + ICalendar(); + virtual ~ICalendar(); + virtual void addEvent(IEventAddEventPtr &event); + virtual void addEvents(IEventAddEventsPtr &events); + virtual void updateEvent(IEventUpdateEventPtr &event); + virtual void updateEvents(IEventUpdateEventsPtr &events); + virtual void deleteEvent(IEventDeleteEventPtr &event); + virtual void deleteEvents(IEventDeleteEventsPtr &events); + virtual void findEvents(IEventFindEventsPtr &event); + virtual void createEventFromString(IEventCreateEventFromStringPtr &event); + virtual void exportEventToString(IEventExportEventToStringPtr &event); + virtual void watchChanges(IEventWatchChangesPtr &event); + virtual void clearWatch(IEventClearWatchPtr &event); + virtual void expandEventRecurrence(IEventExpandEventRecurrencePtr &event); + virtual void get(IEventGetPtr &event); + + virtual std::string getName() const + { + return m_name; + } + virtual void setName(const std::string &value) + { + m_name = value; + } + + virtual CalendarEvent::CalendarType getType() const + { + return m_type; + } + virtual void setType(const CalendarEvent::CalendarType value) + { + m_type = value; + } + + virtual std::string getId() const + { + return m_id; + } + virtual void setId(const int value) + { + std::stringstream ss; + ss< ICalendarPtr; + +} +} + +#endif /* _ABSTRACT_LAYER_ICALENDAR_H_ */ diff --git a/src/Calendar/ICalendarManager.cpp b/src/Calendar/ICalendarManager.cpp new file mode 100755 index 0000000..311a543 --- /dev/null +++ b/src/Calendar/ICalendarManager.cpp @@ -0,0 +1,58 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "ICalendarManager.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +ICalendarManager::ICalendarManager() : + WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendars >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + WrtDeviceApis::Commons::EventRequestReceiver< IEventGetDefaultCalendar >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + WrtDeviceApis::Commons::EventRequestReceiver< IEventGetUnifiedCalendar >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD), + WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendar >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD) +{ +} + +ICalendarManager::~ICalendarManager() +{ +} + +void ICalendarManager::getCalendars(const IEventGetCalendarsPtr &event) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(event); +} + +void ICalendarManager::getDefaultCalendar(const IEventGetDefaultCalendarPtr &event) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(event); +} + +void ICalendarManager::getUnifiedCalendar(const IEventGetUnifiedCalendarPtr &event) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(event); +} + +void ICalendarManager::getCalendar(const IEventGetCalendarPtr &event) +{ + WrtDeviceApis::Commons::EventRequestReceiver::PostRequest(event); +} + +} +} diff --git a/src/Calendar/ICalendarManager.h b/src/Calendar/ICalendarManager.h new file mode 100755 index 0000000..0edb95e --- /dev/null +++ b/src/Calendar/ICalendarManager.h @@ -0,0 +1,56 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_ICALENDAR_MANAGER_H_ +#define _ABSTRACT_LAYER_ICALENDAR_MANAGER_H_ + +#include "ICalendar.h" +#include "IEventGetCalendars.h" +#include "IEventGetDefaultCalendar.h" +#include "IEventGetUnifiedCalendar.h" +#include "IEventGetCalendar.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +class ICalendarManager : public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendars >, + public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetDefaultCalendar >, + public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetUnifiedCalendar >, + public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendar > +{ + public: + ICalendarManager(); + virtual ~ICalendarManager(); + virtual void getCalendars(const IEventGetCalendarsPtr &event); + virtual void getDefaultCalendar(const IEventGetDefaultCalendarPtr &event); + virtual void getUnifiedCalendar(const IEventGetUnifiedCalendarPtr &event); + virtual void getCalendar(const IEventGetCalendarPtr &event); + protected: + virtual void OnRequestReceived(const IEventGetCalendarsPtr &event) = 0; + virtual void OnRequestReceived(const IEventGetDefaultCalendarPtr &event) = 0; + virtual void OnRequestReceived(const IEventGetUnifiedCalendarPtr &event) = 0; + virtual void OnRequestReceived(const IEventGetCalendarPtr &event) = 0; +}; + +typedef DPL::SharedPtr ICalendarManagerPtr; + +} +} + +#endif /* _ABSTRACT_LAYER_ICALENDAR_MANAGER_H_ */ diff --git a/src/Calendar/IEventAddEvent.h b/src/Calendar/IEventAddEvent.h new file mode 100755 index 0000000..844fdc3 --- /dev/null +++ b/src/Calendar/IEventAddEvent.h @@ -0,0 +1,66 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _ABSTRACT_LAYER_IEVENT_ADD_EVENT_H_ +#define _ABSTRACT_LAYER_IEVENT_ADD_EVENT_H_ + +#include +#include "CalendarEvent.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +class IEventAddEvent : public WrtDeviceApis::Commons::IEvent +{ + CalendarEventPtr m_eventAdd; + bool m_result; + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + void setEvent(CalendarEventPtr value) + { + m_eventAdd = value; + } + CalendarEventPtr getEvent() const + { + return m_eventAdd; + } + IEventAddEvent() : m_eventAdd(NULL), + m_result(false) + { + } + ~IEventAddEvent() + { + } + virtual void clearOnCancel() + { + } +}; + +typedef DPL::SharedPtr IEventAddEventPtr; + +} +} +#endif /* _ABSTRACT_LAYER_IEVENT_ADD_EVENT_H_ */ diff --git a/src/Calendar/IEventAddEvents.h b/src/Calendar/IEventAddEvents.h new file mode 100755 index 0000000..f235214 --- /dev/null +++ b/src/Calendar/IEventAddEvents.h @@ -0,0 +1,78 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 _IEVENT_ADD_EVENTS_H_ +#define _IEVENT_ADD_EVENTS_H_ + +#include +#include "CalendarEvent.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +class IEventAddEvents : public WrtDeviceApis::Commons::IEvent +{ + CalendarEventListPtr m_events; + bool m_result; + CalendarEvent::CalendarType m_calendarType; + + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + + void setCalendarType(CalendarEvent::CalendarType value) + { + m_calendarType = value; + } + CalendarEvent::CalendarType getCalendarType() const + { + return m_calendarType; + } + + void setEvents(CalendarEventListPtr value) + { + m_events = value; + } + CalendarEventListPtr getEvents() const + { + return m_events; + } + + IEventAddEvents() : m_result(false), m_calendarType(CalendarEvent::EVENT_TYPE) + { + } + ~IEventAddEvents() + { + } + virtual void clearOnCancel() + { + } +}; + +typedef DPL::SharedPtr IEventAddEventsPtr; + +} +} +#endif /* _IEVENT_ADD_EVENTS_H_ */ diff --git a/src/Calendar/IEventClearWatch.h b/src/Calendar/IEventClearWatch.h new file mode 100755 index 0000000..04024d0 --- /dev/null +++ b/src/Calendar/IEventClearWatch.h @@ -0,0 +1,68 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 _IEVENT_CLEAR_WATCH_H_ +#define _IEVENT_CLEAR_WATCH_H_ + +#include +#include +#include "CalendarEvent.h" + +namespace DeviceAPI { +namespace Calendar { + +class IEventClearWatch : public WrtDeviceApis::Commons::IEvent +{ + long m_watchId; + bool m_result; + + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + + void setWatchId(long value) + { + m_watchId = value; + } + long getWatchId() const + { + return m_watchId; + } + + IEventClearWatch() : m_result(false) + { + } + ~IEventClearWatch() + { + } + virtual void clearOnCancel() + { + } +}; + +typedef DPL::SharedPtr IEventClearWatchPtr; + +} +} +#endif /* _IEVENT_CLEAR_WATCH_H_ */ diff --git a/src/Calendar/IEventCreateEventFromString.h b/src/Calendar/IEventCreateEventFromString.h new file mode 100755 index 0000000..d9058e0 --- /dev/null +++ b/src/Calendar/IEventCreateEventFromString.h @@ -0,0 +1,90 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 _IEVENT_CREATE_EVENT_FROM_STRING_H_ +#define _IEVENT_CREATE_EVENT_FROM_STRING_H_ + +#include +#include +#include "ICalendar.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +class IEventCreateEventFromString : public WrtDeviceApis::Commons::IEvent< + IEventCreateEventFromString> +{ + CalendarEventPtr m_event; + std::string m_eventString; + int m_format; + bool m_result; + + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + + std::string getEventString() const + { + return m_eventString; + } + void setEventString(std::string value) + { + m_eventString = value; + } + + void setEvent(CalendarEventPtr value) + { + m_event = value; + } + CalendarEventPtr getEvent() const + { + return m_event; + } + + void setFormat(int value) + { + m_format = value; + } + int getFormat() const + { + return m_format; + } + + IEventCreateEventFromString() : m_result(false) + { + } + ~IEventCreateEventFromString() + { + } + virtual void clearOnCancel() + { + } +}; + +typedef DPL::SharedPtr IEventCreateEventFromStringPtr; + +} +} +#endif /* _IEVENT_CREATE_EVENT_FROM_STRING_H_ */ diff --git a/src/Calendar/IEventDeleteEvent.h b/src/Calendar/IEventDeleteEvent.h new file mode 100755 index 0000000..89ecc6c --- /dev/null +++ b/src/Calendar/IEventDeleteEvent.h @@ -0,0 +1,68 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _ABSTRACT_LAYER_IEVENT_DELETE_EVENT_H_ +#define _ABSTRACT_LAYER_IEVENT_DELETE_EVENT_H_ + +#include +#include +#include "EventId.h" + +namespace DeviceAPI { +namespace Calendar { + +class IEventDeleteEvent : public WrtDeviceApis::Commons::IEvent +{ + EventIdPtr m_eventId; + bool m_result; + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + + void setEventId(EventIdPtr value) + { + m_eventId = value; + } + EventIdPtr getEventId() const + { + return m_eventId; + } + + IEventDeleteEvent() : m_eventId(NULL), + m_result(false) + { + } + ~IEventDeleteEvent() + { + } + virtual void clearOnCancel() + { + } +}; + +typedef DPL::SharedPtr IEventDeleteEventPtr; + +} +} +#endif /* _ABSTRACT_LAYER_IEVENT_DELETE_EVENT_H_ */ diff --git a/src/Calendar/IEventDeleteEvents.h b/src/Calendar/IEventDeleteEvents.h new file mode 100755 index 0000000..3e6eacf --- /dev/null +++ b/src/Calendar/IEventDeleteEvents.h @@ -0,0 +1,68 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 _IEVENT_DELETE_EVENTS_H_ +#define _IEVENT_DELETE_EVENTS_H_ + +#include +#include +#include "EventId.h" + +namespace DeviceAPI { +namespace Calendar { + +class IEventDeleteEvents : public WrtDeviceApis::Commons::IEvent +{ + EventIdListPtr m_eventIds; + bool m_result; + + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + + void setEventIds(EventIdListPtr value) + { + m_eventIds = value; + } + EventIdListPtr getEventIds() const + { + return m_eventIds; + } + + IEventDeleteEvents() : m_result(false) + { + } + ~IEventDeleteEvents() + { + } + virtual void clearOnCancel() + { + } +}; + +typedef DPL::SharedPtr IEventDeleteEventsPtr; + +} +} +#endif /* _IEVENT_DELETE_EVENTS_H_ */ diff --git a/src/Calendar/IEventExpandEventRecurrence.h b/src/Calendar/IEventExpandEventRecurrence.h new file mode 100755 index 0000000..84c6543 --- /dev/null +++ b/src/Calendar/IEventExpandEventRecurrence.h @@ -0,0 +1,102 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 _IEVENT_EXPAND_EVENT_RECURRENCE_H_ +#define _IEVENT_EXPAND_EVENT_RECURRENCE_H_ + +#include +#include "CalendarEvent.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +class IEventExpandEventRecurrence : public WrtDeviceApis::Commons::IEvent +{ + CalendarEventListPtr m_expandedEventList; //output + bool m_result; // ouput + CalendarEventPtr m_event; // input + long long int m_startDate; // input + long long int m_endDate; // input + + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + + CalendarEventListPtr getExpandedEventList() const + { + return m_expandedEventList; + } + + void setEvent(CalendarEventPtr value) + { + m_event = value; + } + CalendarEventPtr getEvent() const + { + return m_event; + } + + void setStartDate(long long int value) + { + m_startDate = value; + } + long long int getStartDate() const + { + return m_startDate; + } + + void setEndDate(long long int value) + { + m_endDate = value; + } + long long int getEndDate() const + { + return m_endDate; + } + + void addExpandedEvent(CalendarEventPtr value) + { + m_expandedEventList->push_back(value); + } + + IEventExpandEventRecurrence() : m_result(false) + { + CalendarEventListPtr events(new CalendarEventList()); + m_expandedEventList = events; + } + ~IEventExpandEventRecurrence() + { + } + virtual void clearOnCancel() + { + } +}; + +typedef DPL::SharedPtr IEventExpandEventRecurrencePtr; + +} +} + +#endif /* _IEVENT_EXPAND_EVENT_RECURRENCE_H_ */ diff --git a/src/Calendar/IEventExportEventToString.h b/src/Calendar/IEventExportEventToString.h new file mode 100755 index 0000000..8ca2f9f --- /dev/null +++ b/src/Calendar/IEventExportEventToString.h @@ -0,0 +1,88 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 _IEVENT_EXPORT_EVENT_TO_STRING_H_ +#define _IEVENT_EXPORT_EVENT_TO_STRING_H_ + +#include +#include +#include "CalendarEvent.h" + +namespace DeviceAPI { +namespace Calendar { + +class IEventExportEventToString : public WrtDeviceApis::Commons::IEvent +{ + std::string m_eventString; + CalendarEventPtr m_event; + int m_format; + bool m_result; + + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + + void setEvent(CalendarEventPtr value) + { + m_event = value; + } + CalendarEventPtr getEvent() const + { + return m_event; + } + + void setEventString(std::string value) + { + m_eventString = value; + } + std::string getEventString() const + { + return m_eventString; + } + + void setFormat(int value) + { + m_format = value; + } + int getFormat() const + { + return m_format; + } + + IEventExportEventToString() : m_result(false) + { + } + ~IEventExportEventToString() + { + } + virtual void clearOnCancel() + { + } +}; + +typedef DPL::SharedPtr IEventExportEventToStringPtr; + +} +} +#endif /* _IEVENT_EXPORT_EVENT_TO_STRING_H_ */ diff --git a/src/Calendar/IEventFindEvents.h b/src/Calendar/IEventFindEvents.h new file mode 100755 index 0000000..b340b43 --- /dev/null +++ b/src/Calendar/IEventFindEvents.h @@ -0,0 +1,143 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _ABSTRACT_LAYER_IEVENT_FIND_EVENTS_H_ +#define _ABSTRACT_LAYER_IEVENT_FIND_EVENTS_H_ + +#include +#include +#include "CalendarEvent.h" +#include +#include +#include + +namespace DeviceAPI { +namespace Calendar { + +class IEventFindEvents : public WrtDeviceApis::Commons::IEvent +{ + /* user is responsible to free objects inside list */ + CalendarEventListPtr m_events; + bool m_result; + CalendarEvent::CalendarType m_calendarType; + DeviceAPI::Tizen::FilterPtr m_genericFilter; + DeviceAPI::Tizen::SortModeArrayPtr m_sortModes; + std::vector m_attributesOfInterest; + bool m_genericFilterIsSet; + bool m_sortModesIsSet; + bool m_attributesOfInterestIsSet; + + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + + void setCalendarType(CalendarEvent::CalendarType value) + { + m_calendarType = value; + } + CalendarEvent::CalendarType getCalendarType() const + { + return m_calendarType; + } + + void addEvent(CalendarEventPtr value) + { + m_events->push_back(value); + } + + CalendarEventListPtr getEvents() + { + return m_events; + } + + DeviceAPI::Tizen::FilterPtr getGenericFilter() const + { + return m_genericFilter; + } + + void setGenericFilter(const DeviceAPI::Tizen::FilterPtr &value) + { + m_genericFilter = value; + m_genericFilterIsSet = true; + } + + DeviceAPI::Tizen::SortModeArrayPtr getSortModes() const + { + return m_sortModes; + } + + void setSortModes(const DeviceAPI::Tizen::SortModeArrayPtr &value) + { + m_sortModes = value; + m_sortModesIsSet = true; + } + + std::vector getAttributesOfInterest() const + { + return m_attributesOfInterest; + } + + void setAttributesOfInterest(const std::vector &value) + { + m_attributesOfInterest = value; + m_attributesOfInterestIsSet = true; + } + + bool getGenericFilterIsSet() const + { + return m_genericFilterIsSet; + } + + bool getSortModesIsSet() const + { + return m_sortModesIsSet; + } + + bool getAttributesOfInterestIsSet() const + { + return m_attributesOfInterestIsSet; + } + + IEventFindEvents() : m_result(false), + m_calendarType(CalendarEvent::EVENT_TYPE), + m_genericFilterIsSet(false), + m_sortModesIsSet(false), + m_attributesOfInterestIsSet(false) + { + CalendarEventListPtr events(new CalendarEventList()); + m_events = events; + } + ~IEventFindEvents() + { + } + virtual void clearOnCancel() + { + } +}; + +typedef DPL::SharedPtr IEventFindEventsPtr; + +} +} +#endif /* _ABSTRACT_LAYER_IEVENT_FIND_EVENTS_H_ */ diff --git a/src/Calendar/IEventGet.h b/src/Calendar/IEventGet.h new file mode 100755 index 0000000..0a33e3b --- /dev/null +++ b/src/Calendar/IEventGet.h @@ -0,0 +1,77 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _ABSTRACT_LAYER_IEVENT_GET_H_ +#define _ABSTRACT_LAYER_IEVENT_GET_H_ + +#include +#include +#include +#include "ICalendar.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +class IEventGet : public WrtDeviceApis::Commons::IEvent +{ + CalendarEventPtr m_item; // output parameter + bool m_result; + EventIdPtr m_itemId; // input parameter + + public: + bool getResult() const + { + return m_result; + } + void setResult(bool value) + { + m_result = value; + } + + EventIdPtr getItemId() const + { + return m_itemId; + } + void setItemId(EventIdPtr value) + { + m_itemId = value; + } + + CalendarEventPtr getItem() const + { + return m_item; + } + void setItem(CalendarEventPtr value) + { + m_item = value; + } + + IEventGet() : m_result(false) + { + } + ~IEventGet() + { + } +}; + +typedef DPL::SharedPtr IEventGetPtr; + +} +} +#endif /* _ABSTRACT_LAYER_IEVENT_GET_H_ */ diff --git a/src/Calendar/IEventGetCalendar.h b/src/Calendar/IEventGetCalendar.h new file mode 100755 index 0000000..04dd8a2 --- /dev/null +++ b/src/Calendar/IEventGetCalendar.h @@ -0,0 +1,89 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _ABSTRACT_LAYER_IEVENT_GET_CALENDAR_H_ +#define _ABSTRACT_LAYER_IEVENT_GET_CALENDAR_H_ + +#include +#include +#include "ICalendar.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +class IEventGetCalendar : public WrtDeviceApis::Commons::IEvent +{ + ICalendarPtr m_calendar; + bool m_result; + std::string m_id; + CalendarEvent::CalendarType m_type; + + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + + void setType(CalendarEvent::CalendarType value) + { + m_type = value; + } + CalendarEvent::CalendarType getType() const + { + return m_type; + } + + void setId(std::string &value) + { + m_id = value; + } + std::string getId() const + { + return m_id; + } + + void setCalendar(ICalendarPtr value) + { + m_calendar = value; + } + ICalendarPtr getCalendar() const + { + return m_calendar; + } + + IEventGetCalendar() : m_calendar(NULL), + m_result(false), + m_id(""), + m_type(CalendarEvent::UNDEFINED_TYPE) + { + } + ~IEventGetCalendar() + { + } +}; + +typedef DPL::SharedPtr IEventGetCalendarPtr; + +} +} +#endif /* _ABSTRACT_LAYER_IEVENT_GET_CALENDAR_H_ */ diff --git a/src/Calendar/IEventGetCalendars.h b/src/Calendar/IEventGetCalendars.h new file mode 100755 index 0000000..47308a8 --- /dev/null +++ b/src/Calendar/IEventGetCalendars.h @@ -0,0 +1,76 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _ABSTRACT_LAYER_IEVENT_GET_CALENDARS_H_ +#define _ABSTRACT_LAYER_IEVENT_GET_CALENDARS_H_ + +#include +#include +#include "ICalendar.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +class IEventGetCalendars : public WrtDeviceApis::Commons::IEvent +{ + std::vector m_calendars; + bool m_result; + CalendarEvent::CalendarType m_type; + + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + + void setType(CalendarEvent::CalendarType value) + { + m_type = value; + } + CalendarEvent::CalendarType getType() const + { + return m_type; + } + + void addCalendar(ICalendarPtr value) + { + m_calendars.push_back(value); + } + std::vector getCalendars() const + { + return m_calendars; + } + IEventGetCalendars() : m_result(false), + m_type(CalendarEvent::UNDEFINED_TYPE) + { + } + ~IEventGetCalendars() + { + } +}; + +typedef DPL::SharedPtr IEventGetCalendarsPtr; + +} +} +#endif /* _ABSTRACT_LAYER_IEVENT_GET_CALENDARS_H_ */ diff --git a/src/Calendar/IEventGetDefaultCalendar.h b/src/Calendar/IEventGetDefaultCalendar.h new file mode 100755 index 0000000..6df5681 --- /dev/null +++ b/src/Calendar/IEventGetDefaultCalendar.h @@ -0,0 +1,77 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _ABSTRACT_LAYER_IEVENT_GET_DEFAULT_CALENDAR_H_ +#define _ABSTRACT_LAYER_IEVENT_GET_DEFAULT_CALENDAR_H_ + +#include +#include "ICalendar.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +class IEventGetDefaultCalendar : public WrtDeviceApis::Commons::IEvent +{ + ICalendarPtr m_calendar; + bool m_result; + CalendarEvent::CalendarType m_type; + + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + + void setType(CalendarEvent::CalendarType value) + { + m_type = value; + } + CalendarEvent::CalendarType getType() const + { + return m_type; + } + + void setCalendar(ICalendarPtr value) + { + m_calendar = value; + } + ICalendarPtr getCalendar() const + { + return m_calendar; + } + + IEventGetDefaultCalendar() : m_calendar(NULL), + m_result(false), + m_type(CalendarEvent::UNDEFINED_TYPE) + { + } + ~IEventGetDefaultCalendar() + { + } +}; + +typedef DPL::SharedPtr IEventGetDefaultCalendarPtr; + +} +} +#endif /* _ABSTRACT_LAYER_IEVENT_GET_DEFAULT_CALENDAR_H_ */ diff --git a/src/Calendar/IEventGetUnifiedCalendar.h b/src/Calendar/IEventGetUnifiedCalendar.h new file mode 100755 index 0000000..2557dd9 --- /dev/null +++ b/src/Calendar/IEventGetUnifiedCalendar.h @@ -0,0 +1,77 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _ABSTRACT_LAYER_IEVENT_GET_UNIFIED_CALENDAR_H_ +#define _ABSTRACT_LAYER_IEVENT_GET_UNIFIED_CALENDAR_H_ + +#include +#include "ICalendar.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +class IEventGetUnifiedCalendar : public WrtDeviceApis::Commons::IEvent +{ + ICalendarPtr m_calendar; + bool m_result; + CalendarEvent::CalendarType m_type; + + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + + void setType(CalendarEvent::CalendarType value) + { + m_type = value; + } + CalendarEvent::CalendarType getType() const + { + return m_type; + } + + void setCalendar(ICalendarPtr value) + { + m_calendar = value; + } + ICalendarPtr getCalendar() const + { + return m_calendar; + } + + IEventGetUnifiedCalendar() : m_calendar(NULL), + m_result(false), + m_type(CalendarEvent::UNDEFINED_TYPE) + { + } + ~IEventGetUnifiedCalendar() + { + } +}; + +typedef DPL::SharedPtr IEventGetUnifiedCalendarPtr; + +} +} +#endif /* _ABSTRACT_LAYER_IEVENT_GET_UNIFIED_CALENDAR_H_ */ diff --git a/src/Calendar/IEventUpdateEvent.h b/src/Calendar/IEventUpdateEvent.h new file mode 100755 index 0000000..1a64c06 --- /dev/null +++ b/src/Calendar/IEventUpdateEvent.h @@ -0,0 +1,79 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _ABSTRACT_LAYER_IEVENT_UPDATE_EVENT_H_ +#define _ABSTRACT_LAYER_IEVENT_UPDATE_EVENT_H_ + +#include +#include "CalendarEvent.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +class IEventUpdateEvent : public WrtDeviceApis::Commons::IEvent +{ + CalendarEventPtr m_event; + bool m_result; + bool m_updateAllInstances; + + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + + void setEvent(CalendarEventPtr value) + { + m_event = value; + } + CalendarEventPtr getEvent() const + { + return m_event; + } + + void setUpdateAllInstances(bool value) + { + m_updateAllInstances = value; + } + bool getUpdateAllInstances() const + { + return m_updateAllInstances; + } + + IEventUpdateEvent() : m_event(NULL), + m_result(false), m_updateAllInstances(true) + { + } + ~IEventUpdateEvent() + { + } + virtual void clearOnCancel() + { + } +}; + +typedef DPL::SharedPtr IEventUpdateEventPtr; + +} +} +#endif /* _ABSTRACT_LAYER_IEVENT_UPDATE_EVENT_H_ */ diff --git a/src/Calendar/IEventUpdateEvents.h b/src/Calendar/IEventUpdateEvents.h new file mode 100755 index 0000000..678e8fd --- /dev/null +++ b/src/Calendar/IEventUpdateEvents.h @@ -0,0 +1,78 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 _IEVENT_UPDATE_EVENTS_H_ +#define _IEVENT_UPDATE_EVENTS_H_ + +#include +#include "CalendarEvent.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +class IEventUpdateEvents : public WrtDeviceApis::Commons::IEvent +{ + CalendarEventListPtr m_events; + bool m_result; + bool m_updateAllInstances; + + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + + void setEvents(CalendarEventListPtr value) + { + m_events = value; + } + CalendarEventListPtr getEvents() const + { + return m_events; + } + + void setUpdateAllInstances(bool value) + { + m_updateAllInstances = value; + } + bool getUpdateAllInstances() const + { + return m_updateAllInstances; + } + + IEventUpdateEvents() : m_result(false), m_updateAllInstances(true) + { + } + ~IEventUpdateEvents() + { + } + virtual void clearOnCancel() + { + } +}; + +typedef DPL::SharedPtr IEventUpdateEventsPtr; + +} +} +#endif /* _IEVENT_UPDATE_EVENTS_H_ */ diff --git a/src/Calendar/IEventWatchChanges.h b/src/Calendar/IEventWatchChanges.h new file mode 100755 index 0000000..5fef48a --- /dev/null +++ b/src/Calendar/IEventWatchChanges.h @@ -0,0 +1,89 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 _IEVENT_WATCH_CHANGES_H_ +#define _IEVENT_WATCH_CHANGES_H_ + +#include +#include +#include "CalendarEvent.h" +#include "OnEventsChanged.h" + +namespace DeviceAPI { +namespace Calendar { + +class IEventWatchChanges : public WrtDeviceApis::Commons::IEvent +{ + AttributeListPtr m_attributesOfInterest; + bool m_result; + long m_watchId; + OnEventsChangedEmitterPtr m_emitter; + + public: + void setResult(bool value) + { + m_result = value; + } + bool getResult() const + { + return m_result; + } + + void setAttributes(AttributeListPtr value) + { + m_attributesOfInterest = value; + } + AttributeListPtr getAttributes() const + { + return m_attributesOfInterest; + } + + void setWatchId(long value) + { + m_watchId = value; + } + long getWatchId() const + { + return m_watchId; + } + + void setEmitter(OnEventsChangedEmitterPtr value) + { + m_emitter = value; + } + OnEventsChangedEmitterPtr getEmitter() const + { + return m_emitter; + } + + IEventWatchChanges() : m_result(false) + { + } + ~IEventWatchChanges() + { + } + virtual void clearOnCancel() + { + } +}; + +typedef DPL::SharedPtr IEventWatchChangesPtr; + +} +} +#endif /* _IEVENT_WATCH_CHANGES_H_ */ diff --git a/src/Calendar/JSCalendar.cpp b/src/Calendar/JSCalendar.cpp new file mode 100755 index 0000000..13b346c --- /dev/null +++ b/src/Calendar/JSCalendar.cpp @@ -0,0 +1,1165 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include "ICalendar.h" +#include "EventId.h" +#include "CalendarFactory.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "JSCalendarManager.h" +#include "CalendarConverter.h" +#include "JSCalendar.h" +#include "JSCalendarEvent.h" +#include "JSCalendarTask.h" +#include "JSCalendarItemProperties.h" +#include "JSCalendarEventId.h" +#include "plugin_config.h" +#include "CalendarResponseDispatcher.h" +#include "CalendarMultiCallback.h" + +#include "CalendarAsyncCallbackManager.h" +#include "CalendarListenerManager.h" + + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + +#define TIZEN_CALENDAR_ATTRIBUTENAME "Calendar" + +namespace DeviceAPI { +namespace Calendar { + +JSClassDefinition JSCalendar::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_CALENDAR_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 JSCalendar::m_property[] = { + { TIZEN_CALENDAR_PROPERTY_NAME, JSCalendar::getPropertyName, + NULL, kJSPropertyAttributeReadOnly }, + /*{ TIZEN_CALENDAR_PROPERTY_ACCOUNT_SERVICE_ID, JSCalendar::getPropertyAccountServiceId, + NULL, kJSPropertyAttributeReadOnly },*/ + { TIZEN_CALENDAR_PROPERTY_ID, JSCalendar::getPropertyId, + NULL, kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCalendar::m_function[] = { + { CALENDAR_FUNCTION_API_ADD, add, kJSPropertyAttributeNone }, + { CALENDAR_FUNCTION_API_ADD_BATCH, addBatch, kJSPropertyAttributeNone }, + { CALENDAR_FUNCTION_API_UPDATE, update, kJSPropertyAttributeNone }, + { CALENDAR_FUNCTION_API_UPDATE_BATCH, updateBatch, kJSPropertyAttributeNone }, + { CALENDAR_FUNCTION_API_REMOVE, remove, kJSPropertyAttributeNone }, + { CALENDAR_FUNCTION_API_REMOVE_BATCH, removeBatch, kJSPropertyAttributeNone }, + { CALENDAR_FUNCTION_API_FIND, find, kJSPropertyAttributeNone }, + { CALENDAR_FUNCTION_API_ADD_CHANGE_LISTENER, addChangeListener, kJSPropertyAttributeNone }, + { CALENDAR_FUNCTION_API_REMOVE_CHANGE_LISTENER, removeChangeListener, kJSPropertyAttributeNone }, + { CALENDAR_FUNCTION_API_GET, get, kJSPropertyAttributeNone }, + + { 0, 0, 0 } +}; + +JSClassRef JSCalendar::m_jsClassRef = JSClassCreate(JSCalendar::getClassInfo()); + +void JSCalendar::initialize(JSContextRef context, JSObjectRef object) +{ + if (!JSObjectGetPrivate(object)) { + LogDebug("Create calendar private object."); + ICalendarPtr calendar = CalendarFactory::getInstance().createCalendarObject(); + CalendarPrivObject *priv = new CalendarPrivObject(context, calendar); + if (!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } else { + LogDebug("Private object already set."); + } +} + +void JSCalendar::finalize(JSObjectRef object) +{ + CalendarPrivObject *priv = static_cast(JSObjectGetPrivate(object)); + if (priv) { + delete priv; + JSObjectSetPrivate(object, NULL); + } +} + +const JSClassRef JSCalendar::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSCalendar::getClassInfo() +{ + return &m_classInfo; +} + +JSValueRef JSCalendar::add(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarPrivObject *privateObject = + static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_ADD); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try + { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + ICalendarPtr calendar = getCalendar(context, thisObject, NULL); + + if (argumentCount<1) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + if (CalendarEvent::EVENT_TYPE==calendar->getType()) { + if (!JSValueIsObjectOfClass(context, arguments[0], JSCalendarEvent::getClassRef())) { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + } else if (CalendarEvent::TASK_TYPE==calendar->getType()) { + if (!JSValueIsObjectOfClass(context, arguments[0], JSCalendarTask::getClassRef())) { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + } else { + ThrowMsg(ConversionException, "Wrong calendar type."); + } + + JSObjectRef arg = JSValueToObject(context, arguments[0], exception); + CalendarEventPtr event = JSCalendarEvent::getPrivateObject(arg); + if (!event) { + ThrowMsg(ConversionException, "Parameter conversion failed."); + } + + IEventAddEventPtr dplEvent(new IEventAddEvent()); + dplEvent->setEvent(event); + dplEvent->setForSynchronousCall(); + calendar->addEvent(dplEvent); + + if (dplEvent->getResult()) { + LogDebug("Add result successful."); + return JSValueMakeUndefined(context); + } else { + ThrowMsg(UnknownException, "Adding failed by unknown reason."); + } + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +JSValueRef JSCalendar::addBatch(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarPrivObject *privateObject = + static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_ADD_BATCH); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try + { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + ICalendarPtr calendar = getCalendar(context, thisObject, NULL); + + JSContextRef globalContext = privateObject->getContext(); + CalendarConverter converter(context); + + if (argumentCount<1) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + CalendarEventListPtr events; + if (!JSIsArrayValue(context, arguments[0])) { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + events = converter.toVectorOfEvents(arguments[0]); + if (!events) { + ThrowMsg(ConversionException, "First parameter conversion failed."); + } + + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext); + if (argumentCount>=2) { + cbm->setOnSuccess(converter.toFunctionOrNull(arguments[1])); + } + if (argumentCount>=3) { + cbm->setOnError(converter.toFunctionOrNull(arguments[2])); + } + + cbm->setObject(thisObject); + + LogDebug("Proceed the event to the platform."); + + IEventAddEventsPtr dplEvent(new IEventAddEvents()); + dplEvent->setCalendarType(calendar->getType()); + dplEvent->setEvents(events); + dplEvent->setPrivateData(DPL::StaticPointerCast(cbm)); + dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance()); + calendar->addEvents(dplEvent); + + CalendarAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext); + + return JSValueMakeUndefined(context); + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +JSValueRef JSCalendar::update(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarPrivObject *privateObject = + static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_UPDATE); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try + { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + ICalendarPtr calendar = getCalendar(context, thisObject, exception); + + if (argumentCount<1) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + if (argumentCount>=1) { + if (!JSValueIsObjectOfClass(context, arguments[0], JSCalendarEvent::getClassRef()) && + !JSValueIsObjectOfClass(context, arguments[0], JSCalendarTask::getClassRef())) { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + } else { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + + CalendarConverter converter(context); + + JSObjectRef arg = JSValueToObject(context, arguments[0], exception); + CalendarEventPtr item = JSCalendarEvent::getPrivateObject(arg); + if (!item) { + ThrowMsg(ConversionException, "Parameter conversion failed."); + } + + bool updateAllInstances = true; // Set the default value. + if (argumentCount>=2) { + updateAllInstances = converter.toBool(arguments[1]); + } + + IEventUpdateEventPtr dplEvent(new IEventUpdateEvent()); + dplEvent->setEvent(item); + dplEvent->setUpdateAllInstances(updateAllInstances); + dplEvent->setForSynchronousCall(); + calendar->updateEvent(dplEvent); + + if (dplEvent->getResult()) { + return JSValueMakeUndefined(context); + } else { + ThrowMsg(UnknownException, "Updating failed by unknown reason."); + } + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +JSValueRef JSCalendar::updateBatch(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarPrivObject *privateObject = + static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_UPDATE_BATCH); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try + { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + JSContextRef globalContext = privateObject->getContext(); + + ICalendarPtr calendar = getCalendar(context, thisObject, exception); + + CalendarConverter converter(context); + + if (argumentCount>=1) { + if (!JSIsArrayValue(context, arguments[0])) { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + } else { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + CalendarEventListPtr events; + events = converter.toVectorOfEvents(arguments[0]); + if (!events) { + ThrowMsg(ConversionException, "Third parameter conversion failed."); + } + + JSValueRef onSuccess = NULL; + if (argumentCount>=2) { + onSuccess = converter.toFunctionOrNull(arguments[1]); + } + JSValueRef onError = NULL; + if (argumentCount>=3) { + onError = converter.toFunctionOrNull(arguments[2]); + } + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, onSuccess, onError); + + bool updateAllInstances = true; // Set the default value. + if( argumentCount>=4 ) { + updateAllInstances = converter.toBool(arguments[3]); + } + + cbm->setObject(thisObject); + + LogDebug("Proceed the event to the platform."); + + IEventUpdateEventsPtr dplEvent(new IEventUpdateEvents()); + dplEvent->setEvents(events); + dplEvent->setUpdateAllInstances(updateAllInstances); + dplEvent->setPrivateData(DPL::StaticPointerCast(cbm)); + dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance()); + calendar->updateEvents(dplEvent); + + CalendarAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext); + + return JSValueMakeUndefined(context); + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +JSValueRef JSCalendar::remove(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarPrivObject *privateObject = + static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_REMOVE); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try + { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + ICalendarPtr calendar = getCalendar(context, thisObject, exception); + + EventIdPtr itemId; + CalendarConverter converter(context); + + if (CalendarEvent::EVENT_TYPE==calendar->getType()) { + if (argumentCount<1) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + if (!JSValueIsObjectOfClass(context, arguments[0], JSCalendarEventId::getClassRef())) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + itemId = JSCalendarEventId::getPrivateObject(JSValueToObject(context, arguments[0], NULL)); + if (!itemId) { + ThrowMsg(ConversionException, "Parameter conversion failed."); + } + itemId->setCalendarType(CalendarEvent::EVENT_TYPE); + } else if (CalendarEvent::TASK_TYPE==calendar->getType()) { + EventIdPtr result( new EventId() ); + if (argumentCount>=1) { + result->setUId(converter.toString(arguments[0])); + } + itemId = result; + itemId->setCalendarType(CalendarEvent::TASK_TYPE); + } else { + ThrowMsg(ConversionException, "Parameter conversion failed."); + } + + IEventDeleteEventPtr dplEvent(new IEventDeleteEvent()); + dplEvent->setEventId(itemId); + dplEvent->setForSynchronousCall(); + calendar->deleteEvent(dplEvent); + + if (dplEvent->getResult()) { + LogInfo("Successfully deleted."); + return JSValueMakeUndefined(context); + } else { + if (dplEvent->getExceptionCode() == ExceptionCodes::NotFoundException) { + ThrowMsg(NotFoundException, "Item not found."); + } else { + ThrowMsg(UnknownException, "Removing failed by unnkown reason."); + } + } + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +JSValueRef JSCalendar::removeBatch(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarPrivObject *privateObject = + static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_REMOVE_BATCH); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try + { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + ICalendarPtr calendar = getCalendar(context, thisObject, exception); + JSContextRef globalContext = privateObject->getContext(); + + CalendarConverter converter(context); + + if (argumentCount>=1) { + if (!JSIsArrayValue(context, arguments[0])) { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + } else { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + // Pick one array element to determine its type. + JSObjectRef objArg = converter.toJSObjectRef(arguments[0]); + JSValueRef element; + if (JSGetArrayLength(context, objArg)>0) { + element = JSGetArrayElement(context, objArg, 0); + } else { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + + EventIdListPtr itemIds; + if (JSValueIsObjectOfClass(context, element, JSCalendarEventId::getClassRef())) { + itemIds = converter.toVectorOfEventIds(arguments[0]); + if (!itemIds) { + ThrowMsg(ConversionException, "Parameter conversion failed."); + } + } else if (JSValueIsString(context, element)) { + std::vector idStrings = converter.toVectorOfStrings(arguments[0]); + EventIdListPtr result(new EventIdList()); + for (unsigned int i=0; isetUId(idStrings[i]); + idPtr->setCalendarType(CalendarEvent::TASK_TYPE); + result->push_back(idPtr); + } + itemIds = result; + } else { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + JSValueRef onSuccess = NULL; + if (argumentCount>=2) { + onSuccess = converter.toFunctionOrNull(arguments[1]); + } + JSValueRef onError = NULL; + if (argumentCount>=3) { + onError = converter.toFunctionOrNull(arguments[2]); + } + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, onSuccess, onError); + + cbm->setObject(thisObject); + + LogDebug("Proceed the event to the platform."); + + IEventDeleteEventsPtr dplEvent(new IEventDeleteEvents()); + dplEvent->setEventIds(itemIds); + dplEvent->setPrivateData(DPL::StaticPointerCast(cbm)); + dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance()); + calendar->deleteEvents(dplEvent); + + CalendarAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext); + + return JSValueMakeUndefined(context); + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +JSValueRef JSCalendar::find(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarPrivObject *privateObject = + static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_FIND); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try + { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + ICalendarPtr calendar = getCalendar(context, thisObject, exception); + + JSContextRef globalContext = privateObject->getContext(); + + Validator validator(context, exception); + CalendarConverter converter(context); + DeviceAPI::Tizen::FilterConverterFactory::ConverterType filterConverter = DeviceAPI::Tizen::FilterConverterFactory::getConverter(context); + + if (argumentCount<1) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + JSValueRef onSuccess = NULL; + if (argumentCount>=1) { + onSuccess = converter.toFunction(arguments[0]); + } + JSValueRef onError = NULL; + if (argumentCount>=2) { + onError = converter.toFunctionOrNull(arguments[1]); + } + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, onSuccess, onError); + + cbm->setObject(thisObject); + + LogDebug("Proceed the find event to the platform."); + + IEventFindEventsPtr dplEvent(new IEventFindEvents()); + dplEvent->setCalendarType(calendar->getType()); + dplEvent->setPrivateData(DPL::StaticPointerCast(cbm)); + dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance()); + + if (argumentCount>=3) { + if (JSValueIsObject(context, arguments[2])) { + dplEvent->setGenericFilter(filterConverter->toFilter(arguments[2])); + } else if (JSValueIsNull(context, arguments[2]) || JSValueIsUndefined(context, arguments[2])) { + LogDebug("Use default filter."); + } else { + ThrowMsg(ConversionException, "Wrong third parameter type."); + } + } + if (argumentCount>=4) { + if (JSValueIsObject(context, arguments[3])) { + // Though the sortMode is a single type, we save it in an array internally. + DeviceAPI::Tizen::SortModeArrayPtr sortModes(new DeviceAPI::Tizen::SortModeArray()); + sortModes->push_back(filterConverter->toSortMode(arguments[3])); + dplEvent->setSortModes(sortModes); + } else if (JSValueIsNull(context, arguments[3]) || JSValueIsUndefined(context, arguments[3])) { + LogDebug("Use default sort mode."); + } else { + ThrowMsg(ConversionException, "Wrong fourth parameter type."); + } + } + + calendar->findEvents(dplEvent); + + CalendarAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext); + + return JSValueMakeUndefined(context); + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +JSValueRef JSCalendar::get(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarPrivObject *privateObject = + static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_GET); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try + { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + ICalendarPtr calendar = getCalendar(context, thisObject, exception); + JSContextRef globalContext = privateObject->getContext(); + + EventIdPtr itemId; + CalendarConverter converter(context); + if (CalendarEvent::EVENT_TYPE==calendar->getType()) { + if (argumentCount<1) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + if (JSValueIsObjectOfClass(context, arguments[0], JSCalendarEventId::getClassRef())) { + itemId = JSCalendarEventId::getPrivateObject(JSValueToObject(context, arguments[0], NULL)); + if (!itemId) { + ThrowMsg(ConversionException, "Parameter conversion failed."); + } + itemId->setCalendarType(CalendarEvent::EVENT_TYPE); + } else { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + } else if (CalendarEvent::TASK_TYPE==calendar->getType()) { + EventIdPtr result( new EventId() ); + itemId = result; + if (argumentCount>=1) { + itemId->setUId(converter.toString(arguments[0])); + } + itemId->setCalendarType(CalendarEvent::TASK_TYPE); + } else { + ThrowMsg(ConversionException, "Wrong calendar type."); + } + + IEventGetPtr dplEvent(new IEventGet()); + dplEvent->setForSynchronousCall(); + dplEvent->setItemId(itemId); + calendar->get(dplEvent); + + // Process the found item. + if (dplEvent->getResult()) { + LogDebug("Successfully got an item."); + if (CalendarEvent::EVENT_TYPE==calendar->getType()) { + // Use global context for the expandRecurrence api in event. + return JSCalendarEvent::createJSCalendarEvent(globalContext, dplEvent->getItem()); + } else if (CalendarEvent::TASK_TYPE==calendar->getType()) { + return JSCalendarTask::createJSCalendarTask(context, dplEvent->getItem()); + } else { + ThrowMsg(UnknownException, "Wrong calendar type."); + } + } else { + if(ExceptionCodes::NotFoundException==dplEvent->getExceptionCode()) { + ThrowMsg(NotFoundException, "Item not found."); + } else { + ThrowMsg(UnknownException, "Getting an item failed by unknown reason."); + } + } + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +JSValueRef JSCalendar::addChangeListener(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarPrivObject *privateObject = + static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_ADD_CHANGE_LISTENER); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try + { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + ICalendarPtr calendar = getCalendar(context, thisObject, exception); + JSContextRef globalContext = privateObject->getContext(); + + CalendarConverter converter(context); + + if (argumentCount>=1) { + if (!JSValueIsObject(context, arguments[0])) { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + } else { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + + JSObjectRef objectCallbacks = converter.toJSObjectRef(arguments[0]); + CalendarChangeCallback result; + Validator validator(context); + + result.onAdded = JSUtils::getJSPropertyOrUndefined(context, objectCallbacks, "onitemsadded"); + if (validator.isNullOrUndefined(result.onAdded)) { + result.onAdded = NULL; + } else if(!validator.isCallback(result.onAdded)) { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + + result.onUpdated = JSUtils::getJSPropertyOrUndefined(context, objectCallbacks, "onitemsupdated"); + if (validator.isNullOrUndefined(result.onUpdated)) { + result.onUpdated = NULL; + } else if(!validator.isCallback(result.onUpdated)) { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + + result.onDeleted = JSUtils::getJSPropertyOrUndefined(context, objectCallbacks, "onitemsremoved"); + if (validator.isNullOrUndefined(result.onDeleted)) { + result.onDeleted = NULL; + } else if(!validator.isCallback(result.onDeleted)) { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + + if (!result.onAdded && !result.onUpdated && !result.onDeleted) { + ThrowMsg(ConversionException, "Wrong second parameter type."); + } + + JSCallbackManagerPtr onAddedCbm = JSCallbackManager::createObject(globalContext, result.onAdded, NULL); + JSCallbackManagerPtr onUpdatedCbm = JSCallbackManager::createObject(globalContext, result.onUpdated, NULL); + JSCallbackManagerPtr onDeletedCbm = JSCallbackManager::createObject(globalContext, result.onDeleted, NULL); + + LogDebug("Make change emitter and process sync operation."); + + CalendarChangeCallbackPrivateDataPtr privData(new CalendarChangeCallbackPrivateData( + onAddedCbm, onUpdatedCbm, onDeletedCbm)); + OnEventsChangedEmitterPtr emitter(new OnEventsChangedEmitter()); + emitter->setListener(&CalendarResponseDispatcher::getInstance()); + emitter->setEventPrivateData(DPL::StaticPointerCast(privData)); + + IEventWatchChangesPtr dplEvent(new IEventWatchChanges()); + dplEvent->setEmitter(emitter); + dplEvent->setForSynchronousCall(); + calendar->watchChanges(dplEvent); + + long watchId; + if (dplEvent->getResult()) { + watchId = dplEvent->getWatchId(); + + CalendarListenerCancellerPtr canceller = CalendarListenerCancellerPtr(new CalendarListenerCanceller(globalContext, thisObject, watchId)); + DeviceAPI::Common::IListenerItemPtr listenerItem = DPL::StaticPointerCast(canceller); + CalendarListenerManagerSingleton::Instance().registerListener(listenerItem, globalContext); + + LogDebug("Returning the watchId "<(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_REMOVE_CHANGE_LISTENER); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try + { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + ICalendarPtr calendar = getCalendar(context, thisObject, exception); + + JSContextRef globalContext = privateObject->getContext(); + + long watchId = -1; + CalendarConverter converter(context); + if (argumentCount>=1) { + watchId = converter.toLong(arguments[0]); + } else { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + LogDebug("Make sync operation with watchId: "<setWatchId(watchId); + dplEvent->setForSynchronousCall(); + calendar->clearWatch(dplEvent); + + CalendarListenerCancellerPtr canceller = CalendarListenerCancellerPtr(new CalendarListenerCanceller(globalContext, thisObject, watchId)); + DeviceAPI::Common::IListenerItemPtr listenerItem = DPL::StaticPointerCast(canceller); + CalendarListenerManagerSingleton::Instance().unregisterListener(listenerItem); + + return JSValueMakeUndefined(context); + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +JSValueRef JSCalendar::getPropertyName(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + ICalendarPtr calendar = getCalendar(context, object, exception); + Converter converter(context); + if(calendar->getIsUnified()) { + return JSValueMakeNull(context); + } else { + return converter.toJSValueRef(calendar->getName()); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSCalendar::getPropertyAccountServiceId(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + ICalendarPtr calendar = getCalendar(context, object, exception); + Converter converter(context); + if(calendar->getIsUnified()) { + return JSValueMakeNull(context); + } else { + return converter.toJSValueRefLong(calendar->getAccountId()); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSCalendar::getPropertyId(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + ICalendarPtr calendar = getCalendar(context, object, exception); + Converter converter(context); + if(calendar->getIsUnified()) { + return JSValueMakeNull(context); + } else { + return converter.toJSValueRef(calendar->getId()); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +ICalendarPtr JSCalendar::getCalendar(JSContextRef ctx, + const JSObjectRef object, + JSValueRef* exception) +{ + CalendarPrivObject *priv = + static_cast(JSObjectGetPrivate(object)); + if (priv) { + return priv->getObject(); + } + ThrowMsg(NullPointerException, "Private object is NULL."); +} + +} +} diff --git a/src/Calendar/JSCalendar.h b/src/Calendar/JSCalendar.h new file mode 100755 index 0000000..ee2486b --- /dev/null +++ b/src/Calendar/JSCalendar.h @@ -0,0 +1,206 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _JS_TIZEN_CALENDAR_H_ +#define _JS_TIZEN_CALENDAR_H_ + +#include +#include +#include +#include +#include "ICalendar.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +#define TIZEN_CALENDAR_PROPERTY_NAME "name" +//#define TIZEN_CALENDAR_PROPERTY_ACCOUNT_SERVICE_ID "accountServiceId" +#define TIZEN_CALENDAR_PROPERTY_ID "id" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject CalendarPrivObject; + +class JSCalendar +{ + 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 getPropertyAccountServiceId(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static JSValueRef getPropertyId(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + /** + * Add a calendar item. + */ + static JSValueRef add(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Add calendar items. + */ + static JSValueRef addBatch(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Update an item. + */ + static JSValueRef update(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Update items. + */ + static JSValueRef updateBatch(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Remove a calendar item. + */ + static JSValueRef remove(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Remove calendar items. + */ + static JSValueRef removeBatch(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Search for calendar items using tizen generic filter. + */ + static JSValueRef find(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Watch changes + */ + static JSValueRef addChangeListener(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Clear watch + */ + static JSValueRef removeChangeListener(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Get an item from id + */ + static JSValueRef get(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Returns calendar stored as private object + */ + static ICalendarPtr getCalendar(JSContextRef ctx, + const JSObjectRef object, + JSValueRef* exception); +}; + +} +} + +#endif /* _JS_TIZEN_CALENDAR_H_ */ + diff --git a/src/Calendar/JSCalendarAlarm.cpp b/src/Calendar/JSCalendarAlarm.cpp new file mode 100755 index 0000000..0dadf47 --- /dev/null +++ b/src/Calendar/JSCalendarAlarm.cpp @@ -0,0 +1,311 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#include "JSCalendarAlarm.h" +#include "CalendarConverter.h" +#include +#include +#include +#include +#include +#include +#include + + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; +using namespace DeviceAPI::Time; + +namespace DeviceAPI { +namespace Calendar { + +JSClassDefinition JSCalendarAlarm::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_INTERFACE_CALENDAR_ALARM, + 0, + m_property, + NULL, //m_function, + initialize, + finalize, + NULL, //hasProperty, + NULL, //getProperty, + NULL, //setProperty, + NULL, //deleteProperty, + NULL, //getPropertyNames, + NULL, //callAsFunction, + constructor, + NULL, //hasInstance, + NULL, //convertToType, +}; + +JSStaticValue JSCalendarAlarm::m_property[] = { + { TIZEN_CALENDAR_ALARM_ABSOLUTE_DATE, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_ALARM_BEFORE, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_ALARM_METHOD, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_ALARM_DESCRIPTION, getProperty, setProperty, kJSPropertyAttributeNone }, + + { 0, 0, 0, 0 } +}; + +JSClassRef JSCalendarAlarm::m_jsClassRef = JSClassCreate( + JSCalendarAlarm::getClassInfo()); + +const JSClassDefinition* JSCalendarAlarm::getClassInfo() +{ + return &(m_classInfo); +} + +JSClassRef JSCalendarAlarm::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +JSObjectRef JSCalendarAlarm::createJSCalendarAlarm(JSContextRef context, EventAlarmPtr alarm) +{ + EventAlarmPrivateObject *priv = new EventAlarmPrivateObject(context, alarm); + return JSObjectMake(context, getClassRef(), priv); +} + +EventAlarmPtr JSCalendarAlarm::getPrivateObject(JSObjectRef object) +{ + EventAlarmPrivateObject *priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + EventAlarmPtr result = priv->getObject(); + if (!result) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + return result; +} + +void JSCalendarAlarm::setPrivateObject(const EventAlarmPtr &alarm, + JSContextRef ctx, + const JSObjectRef object) +{ + Try + { + EventAlarmPrivateObject *priv = + static_cast(JSObjectGetPrivate(object)); + delete priv; + priv = new EventAlarmPrivateObject(ctx, alarm); + if (!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } + Catch(Exception) + { + LogError("Error during replacing alarm object."); + } +} + +JSObjectRef JSCalendarAlarm::constructor(JSContextRef context, + JSObjectRef constructor, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + if (argumentCount<1) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + CalendarConverter converter(context); + TimeUtilConverter timeConverter(context); + + EventAlarmPtr alarm( new EventAlarm() ); + + if (JSValueIsObjectOfClass(context, arguments[0], JSTZDate::getClassRef())){ + LogDebug("absoluteDate case"); + long long int absoluteDate = (long long int) (timeConverter.getTimeInMilliseconds(arguments[0])/1000); + alarm->setAbsoluteDate(absoluteDate); + alarm->setTimeZone(timeConverter.getPropertiesInTZDate(arguments[0]).timezone); + + if (argumentCount>=2) { + alarm->setMethod(converter.toEventAlarmType(converter.toString(arguments[1]))); + } + if (argumentCount>=3) { + alarm->setDescription(converter.toString(arguments[2])); + } + } else if (JSValueIsObjectOfClass(context, arguments[0], JSTimeDuration::getClassRef())){ + LogDebug("before case"); + alarm->setDuration(timeConverter.getDurationPropertis(arguments[0])); + + if (argumentCount>=2) { + alarm->setMethod(converter.toEventAlarmType(converter.toString(arguments[1]))); + } + if (argumentCount>=3) { + alarm->setDescription(converter.toString(arguments[2])); + } + } else { + ThrowMsg(ConversionException, "Wrong first parameter type."); + } + + return createJSCalendarAlarm(context, alarm); + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return NULL; +} + +void JSCalendarAlarm::initialize(JSContextRef context, + JSObjectRef object) +{ + if (!JSObjectGetPrivate(object)) { + LogDebug("Create calendar alarm private object."); + EventAlarmPtr alarm( new EventAlarm() ); + EventAlarmPrivateObject *priv = new EventAlarmPrivateObject(context, alarm); + if (!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } else { + LogDebug("Private object already set."); + } +} + +void JSCalendarAlarm::finalize(JSObjectRef object) +{ + EventAlarmPrivateObject* priv = static_cast(JSObjectGetPrivate(object)); + if (priv) { + delete priv; + JSObjectSetPrivate(object, NULL); + } +} + +JSValueRef JSCalendarAlarm::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + CalendarConverter converter(context); + Try + { + EventAlarmPrivateObject* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(NullPointerException, "Private object is NULL."); + } + EventAlarmPtr alarm = priv->getObject(); + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_ABSOLUTE_DATE)) { + if (!alarm) { + ThrowMsg(NullPointerException, "Alarm object is NULL."); + } + + if (UNDEFINED_TIME==alarm->getAbsoluteDate()) { + return JSValueMakeNull(context); + } else { + TimeUtilConverter timeConverter(context); + return timeConverter.toJSValueRefTZDate((double)(alarm->getAbsoluteDate()*1000.0), alarm->getTimeZone()); + } + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_BEFORE)) { + return JSTimeDuration::createJSObject(context, alarm->getDuration()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_DESCRIPTION)) { + return converter.toJSValueRef(alarm->getDescription()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_METHOD)) { + LogDebug("Alarm method: "<getMethod())); + return converter.toJSValueRef(converter.toTizenValue(alarm->getMethod())); + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarAlarm::setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + CalendarConverter converter(context); + Try + { + EventAlarmPrivateObject* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(NullPointerException, "Private object is NULL."); + } + EventAlarmPtr alarm = priv->getObject(); + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_ABSOLUTE_DATE)) { + if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) { + ThrowMsg(ConversionException, "Wrong absoluteDate type."); + } + TimeUtilConverter timeConverter(context); + long long int absoluteDate = (long long int) (timeConverter.getTimeInMilliseconds(value)/1000); + alarm->setAbsoluteDate(absoluteDate); + + if( alarm->getTimeZone().empty() ) { + std::string timeZone = timeConverter.getPropertiesInTZDate(value).timezone; + alarm->setTimeZone(timeZone); + } + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_BEFORE)) { + if (!JSValueIsObjectOfClass(context, value, JSTimeDuration::getClassRef())) { + ThrowMsg(ConversionException, "Wrong before type."); + } + TimeUtilConverter timeConverter(context); + alarm->setDuration(timeConverter.getDurationPropertis(value)); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_DESCRIPTION)) { + alarm->setDescription(converter.toString(value)); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_METHOD)) { + alarm->setMethod(converter.toEventAlarmType(converter.toString(value))); + return true; + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + return false; +} + +} +} diff --git a/src/Calendar/JSCalendarAlarm.h b/src/Calendar/JSCalendarAlarm.h new file mode 100755 index 0000000..57dfc07 --- /dev/null +++ b/src/Calendar/JSCalendarAlarm.h @@ -0,0 +1,108 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _JS_CALENDAR_ALARM_H_ +#define _JS_CALENDAR_ALARM_H_ + +#include +#include +#include "EventAlarm.h" + +namespace DeviceAPI { +namespace Calendar { + +#define TIZEN_INTERFACE_CALENDAR_ALARM "CalendarAlarm" + +#define TIZEN_CALENDAR_ALARM_ABSOLUTE_DATE "absoluteDate" +#define TIZEN_CALENDAR_ALARM_BEFORE "before" +#define TIZEN_CALENDAR_ALARM_METHOD "method" +#define TIZEN_CALENDAR_ALARM_DESCRIPTION "description" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject EventAlarmPrivateObject; + +class JSCalendarAlarm +{ + public: + + static const JSClassDefinition* getClassInfo(); + + static JSClassRef getClassRef(); + + static JSObjectRef createJSCalendarAlarm(JSContextRef context, EventAlarmPtr alarm); + + static EventAlarmPtr getPrivateObject(JSObjectRef object); + + static void setPrivateObject(const EventAlarmPtr &alarm, + JSContextRef ctx, + const JSObjectRef object); + + private: + + /** + * The callback invoked when an object is first created. + */ + static void initialize(JSContextRef context, JSObjectRef object); + + /** + * The callback invoked when an object is finalized. + */ + static void finalize(JSObjectRef object); + + /** + * Constructor for the CalendarAlarm interface. + */ + static JSObjectRef constructor(JSContextRef context, + JSObjectRef constructor, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + + static JSClassRef m_jsClassRef; + + /** + * This structure describes a statically declared function property. + */ + static JSStaticFunction m_function[]; + + /** + * This structure contains properties and callbacks that define a type of object. + */ + static JSClassDefinition m_classInfo; + + /** + * This member variable contains the initialization values for the static properties of this class. + * The values are given according to the data structure JSPropertySpec + */ + static JSStaticValue m_property[]; +}; +} +} + +#endif /* _JS_CALENDAR_ALARM_H_ */ diff --git a/src/Calendar/JSCalendarAttendee.cpp b/src/Calendar/JSCalendarAttendee.cpp new file mode 100755 index 0000000..67c0beb --- /dev/null +++ b/src/Calendar/JSCalendarAttendee.cpp @@ -0,0 +1,335 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#include "JSCalendarAttendee.h" +#include +#include +#include +#include +#include "CalendarConverter.h" + +#include +#include +#include +#include + + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + +namespace DeviceAPI { +namespace Calendar { + +JSClassDefinition JSCalendarAttendee::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_INTERFACE_CALENDAR_ATTENDEE, + 0, + m_property, + NULL, //m_function, + initialize, + finalize, + NULL, //hasProperty, + NULL, //getProperty, + NULL, //setProperty, + NULL, //deleteProperty, + NULL, //getPropertyNames, + NULL, //callAsFunction, + constructor, + NULL, //hasInstance, + NULL, //convertToType, +}; + +JSStaticValue JSCalendarAttendee::m_property[] = { + { TIZEN_ATTENDEE_NAME, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_ATTENDEE_URI, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_ATTENDEE_ROLE, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_ATTENDEE_STATUS, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_ATTENDEE_RSVP, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_ATTENDEE_TYPE, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_ATTENDEE_GROUP, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_ATTENDEE_DELEGATORURI, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_ATTENDEE_DELEGATEURI, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_ATTENDEE_CONTACT_REF, getProperty, setProperty, kJSPropertyAttributeNone }, + + { 0, 0, 0, 0 } +}; + +JSClassRef JSCalendarAttendee::m_jsClassRef = JSClassCreate( + JSCalendarAttendee::getClassInfo()); + +const JSClassDefinition* JSCalendarAttendee::getClassInfo() +{ + return &(m_classInfo); +} + +JSClassRef JSCalendarAttendee::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +JSObjectRef JSCalendarAttendee::createJSCalendarAttendee(JSContextRef context, EventAttendeePtr attendee) +{ + AttendeePrivateObject *priv = new AttendeePrivateObject(context, attendee); + return JSObjectMake(context, getClassRef(), priv); +} + +void JSCalendarAttendee::initialize(JSContextRef context, + JSObjectRef object) +{ + if (!JSObjectGetPrivate(object)) { + LogDebug("Create calendar attendee private object."); + EventAttendeePtr attendee( new EventAttendee() ); + AttendeePrivateObject *priv = new AttendeePrivateObject(context, attendee); + if (!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } else { + LogDebug("Private object already set."); + } +} + +void JSCalendarAttendee::finalize(JSObjectRef object) +{ + AttendeePrivateObject* priv = static_cast(JSObjectGetPrivate(object)); + if (priv) { + delete priv; + JSObjectSetPrivate(object, NULL); + } +} + +EventAttendeePtr JSCalendarAttendee::getPrivateObject(JSObjectRef object) +{ + AttendeePrivateObject *priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(NullPointerException, "Private object is null."); + } + EventAttendeePtr result = priv->getObject(); + if (!result) { + ThrowMsg(NullPointerException, "Private object is null."); + } + return result; +} + +void JSCalendarAttendee::setPrivateObject(const EventAttendeePtr &attendee, + JSContextRef ctx, + const JSObjectRef object) +{ + Try + { + AttendeePrivateObject *priv = + static_cast(JSObjectGetPrivate(object)); + delete priv; + priv = new AttendeePrivateObject(ctx, attendee); + if (!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } + Catch(Exception) + { + LogError("Error during replacing attendee object"); + } +} + +JSObjectRef JSCalendarAttendee::constructor(JSContextRef context, + JSObjectRef constructor, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + CalendarConverter converter(context); + EventAttendeePtr attendee; + + if (argumentCount==0) { + EventAttendeePtr result(new EventAttendee()); + attendee = result; + } else if (argumentCount==1) { + EventAttendeePtr result(new EventAttendee()); + attendee = result; + attendee->setURI(converter.toString(arguments[0])); + } else if (argumentCount>=2) { + if (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1])) { + EventAttendeePtr result(new EventAttendee()); + attendee = result; + } else { + if (!JSValueIsObject(context, arguments[1])) { + ThrowMsg(ConversionException, "Wrong second parameter type."); + } + + attendee = converter.toAttendee(arguments[1]); + if (!attendee) { + ThrowMsg(ConversionException, "Parameter conversion failed."); + } + } + attendee->setURI(converter.toString(arguments[0])); + } + + return createJSCalendarAttendee(context, attendee); + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return NULL; +} + +JSValueRef JSCalendarAttendee::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + CalendarConverter converter(context); + Try + { + AttendeePrivateObject* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(NullPointerException, "Private object is NULL."); + } + EventAttendeePtr attendee = priv->getObject(); + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_NAME)) { + return converter.toJSValueRef(attendee->getName()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_URI)) { + return converter.toJSValueRef(attendee->getURI()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_ROLE)) { + return converter.toJSValueRef(converter.toTizenValue(attendee->getRole())); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_STATUS)) { + return converter.toJSValueRef(converter.toTizenValue(attendee->getStatus())); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_RSVP)) { + return converter.toJSValueRef(attendee->getRSVP()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_TYPE)) { + return converter.toJSValueRef(converter.toTizenValue(attendee->getType())); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_GROUP)) { + return converter.toJSValueRef(attendee->getGroup()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_DELEGATORURI)) { + return converter.toJSValueRef(attendee->getDelegatorURI()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_DELEGATEURI)) { + return converter.toJSValueRef(attendee->getDelegateURI()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_CONTACT_REF)) { + DeviceAPI::Contact::ContactConverter contactConverter(context); + DeviceAPI::Contact::ContactRefPtr contactRefPtr( new DeviceAPI::Contact::ContactRef() ); + contactRefPtr->setContactId(attendee->getContactId()); + contactRefPtr->setAddressBookId(attendee->getAddressBookId()); + return contactConverter.toJSValueRef(contactRefPtr); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarAttendee::setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + CalendarConverter converter(context); + Try + { + AttendeePrivateObject* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(NullPointerException, "Attendee object is NULL."); + } + EventAttendeePtr attendee = priv->getObject(); + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_NAME)) { + std::string name = converter.toString(value); + attendee->setName(name); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_URI)) { + std::string uri = converter.toString(value); + attendee->setURI(uri); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_ROLE)) { + std::string role = converter.toString(value); + attendee->setRole(converter.toEventAttendeeRole(role)); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_STATUS)) { + std::string status = converter.toString(value); + attendee->setStatus(converter.toEventAttendeeStatus(status)); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_RSVP)) { + bool RSVP = converter.toBool(value); + attendee->setRSVP(RSVP); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_TYPE)) { + std::string type = converter.toString(value); + attendee->setType(converter.toEventAttendeeType(type)); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_GROUP)) { + std::string group = converter.toString(value); + attendee->setGroup(group); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_DELEGATORURI)) { + std::string delegatorURI = converter.toString(value); + attendee->setDelegatorURI(delegatorURI); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_DELEGATEURI)) { + std::string delegateURI = converter.toString(value); + attendee->setDelegateURI(delegateURI); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_CONTACT_REF)) { + if (!JSValueIsObjectOfClass(context, value, DeviceAPI::Contact::JSContactRef::getClassRef())) { + ThrowMsg(ConversionException, "Wrong contactRef type."); + } + + DeviceAPI::Contact::ContactConverter contactConverter(context); + attendee->setContactId(contactConverter.toContactRef(value)->getContactId()); + attendee->setAddressBookId(contactConverter.toContactRef(value)->getAddressBookId()); + return true; + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR); + return false; +} + +} +} diff --git a/src/Calendar/JSCalendarAttendee.h b/src/Calendar/JSCalendarAttendee.h new file mode 100755 index 0000000..7a1709c --- /dev/null +++ b/src/Calendar/JSCalendarAttendee.h @@ -0,0 +1,118 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _JS_CALENDAR_ATTENDEE_H_ +#define _JS_CALENDAR_ATTENDEE_H_ + +#include +#include +#include +#include +#include "CalendarEvent.h" +#include "EventAttendee.h" + +namespace DeviceAPI { +namespace Calendar { + +#define TIZEN_INTERFACE_CALENDAR_ATTENDEE "CalendarAttendee" + +#define TIZEN_ATTENDEE_NAME "name" +#define TIZEN_ATTENDEE_URI "uri" +#define TIZEN_ATTENDEE_ROLE "role" +#define TIZEN_ATTENDEE_STATUS "status" +#define TIZEN_ATTENDEE_RSVP "RSVP" +#define TIZEN_ATTENDEE_TYPE "type" +#define TIZEN_ATTENDEE_GROUP "group" +#define TIZEN_ATTENDEE_DELEGATORURI "delegatorURI" +#define TIZEN_ATTENDEE_DELEGATEURI "delegateURI" +#define TIZEN_ATTENDEE_CONTACT_REF "contactRef" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject AttendeePrivateObject; + +class JSCalendarAttendee +{ + public: + + static const JSClassDefinition* getClassInfo(); + + static JSClassRef getClassRef(); + + static JSObjectRef createJSCalendarAttendee(JSContextRef context, EventAttendeePtr event); + + static EventAttendeePtr getPrivateObject(JSObjectRef object); + + static void setPrivateObject(const EventAttendeePtr &attendee, + JSContextRef ctx, + const JSObjectRef object); + + private: + + /** + * The callback invoked when an object is first created. + */ + static void initialize(JSContextRef context, JSObjectRef object); + + /** + * The callback invoked when an object is finalized. + */ + static void finalize(JSObjectRef object); + + /** + * Constructor for the CalendarAttendee interface. + */ + static JSObjectRef constructor(JSContextRef context, + JSObjectRef constructor, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + + static JSClassRef m_jsClassRef; + + /** + * This structure describes a statically declared function property. + */ + static JSStaticFunction m_function[]; + + /** + * This structure contains properties and callbacks that define a type of object. + */ + static JSClassDefinition m_classInfo; + + /** + * This member variable contains the initialization values for the static properties of this class. + * The values are given according to the data structure JSPropertySpec + */ + static JSStaticValue m_property[]; +}; + +} +} + +#endif /* _JS_CALENDAR_ATTENDEE_H_ */ diff --git a/src/Calendar/JSCalendarEvent.cpp b/src/Calendar/JSCalendarEvent.cpp new file mode 100755 index 0000000..30a145d --- /dev/null +++ b/src/Calendar/JSCalendarEvent.cpp @@ -0,0 +1,425 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include "EventId.h" +#include "JSCalendarEvent.h" +#include "JSCalendarItemProperties.h" +#include "CalendarConverter.h" +#include "JSCalendarEventId.h" +#include "plugin_config.h" +#include "CalendarResponseDispatcher.h" +#include +#include +#include +#include +#include + +#include "CalendarAsyncCallbackManager.h" + + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; +using namespace DeviceAPI::Time; + +namespace DeviceAPI { +namespace Calendar { + +JSClassDefinition JSCalendarEvent::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_INTERFACE_CALENDAR_EVENT, + JSCalendarItemProperties::getClassRef(), + m_property, + m_function, + initialize, + finalize, + NULL, //hasProperty, + NULL, //getProperty, + NULL, //setProperty, + NULL, //DeleteProperty, + NULL, //GetPropertyNames, + NULL, //CallAsFunction, + constructor, + NULL, //HasInstance, + NULL //ConvertToType +}; + +JSStaticValue JSCalendarEvent::m_property[] = { + { TIZEN_CALENDAR_EVENT_ID, getPropertyId, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_CALENDAR_EVENT_IS_DETACHED, getPropertyIsDetached, NULL, kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCalendarEvent::m_function[] = { + { CALENDAR_FUNCTION_API_EXPAND_RECURRENCE, expandRecurrence, kJSPropertyAttributeNone }, + + { 0, 0, 0 } +}; + +JSClassRef JSCalendarEvent::m_jsClassRef = JSClassCreate(JSCalendarEvent::getClassInfo()); + +ICalendarPtr JSCalendarEvent::m_calendar = CalendarFactory::getInstance().createCalendarObject(); + +void JSCalendarEvent::initialize(JSContextRef context, + JSObjectRef object) +{ + if (!JSObjectGetPrivate(object)) { + LogDebug("Create calendar event private object."); + CalendarEventPtr event( new CalendarEvent() ); + CalendarEventPrivObject *priv = new CalendarEventPrivObject(context, event); + if (!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } else { + LogDebug("Private object already set."); + } + + if (m_calendar) { + m_calendar->setType(CalendarEvent::EVENT_TYPE); + LogDebug("Calendar object type is set to event."); + } +} + +void JSCalendarEvent::finalize(JSObjectRef object) +{ + CalendarEventPrivObject* priv = static_cast(JSObjectGetPrivate(object)); + if (priv) { + delete priv; + JSObjectSetPrivate(object, NULL); + } +} + +JSObjectRef JSCalendarEvent::constructor(JSContextRef context, + JSObjectRef constructor, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + CalendarEventPrivObject* privateObject = static_cast(JSObjectGetPrivate(constructor)); + JSContextRef globalContext = privateObject->getContext(); + + CalendarConverter converter(globalContext); + CalendarEventPtr event; + + if (argumentCount==0) { + CalendarEventPtr result(new CalendarEvent()); + event = result; + } else if (argumentCount==1) { + LogInfo("eventInitDict case"); + if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) { + CalendarEventPtr result(new CalendarEvent()); + event = result; + } else if (JSValueIsObject(context, arguments[0])) { + event = converter.toEvent(arguments[0]); + if (!event) { + ThrowMsg(ConversionException, "Parameter conversion failed."); + } + } else { + ThrowMsg(ConversionException, "Parameter conversion failed."); + } + } else if (argumentCount>=2) { + LogInfo("event stringRepresentation case"); + std::string eventStr; + CalendarEvent::VObjectFormat format = CalendarEvent::UNDEFINED_FORMAT; + eventStr = converter.toString(arguments[0]); + format = converter.toVObjectFormat(converter.toString(arguments[1])); + + IEventCreateEventFromStringPtr dplEvent(new IEventCreateEventFromString()); + dplEvent->setEventString(eventStr); + dplEvent->setFormat(format); + dplEvent->setForSynchronousCall(); + m_calendar->createEventFromString(dplEvent); + + // Process the returned object. + if (dplEvent->getResult()) { + LogInfo("Successfully created an event."); + event = dplEvent->getEvent(); + } else { + if (dplEvent->getExceptionCode()==ExceptionCodes::InvalidArgumentException) { + ThrowMsg(InvalidArgumentException, "Wrong string to convert."); + } else { + ThrowMsg(UnknownException, "Converting string failed."); + } + } + } + + return createJSCalendarEvent(globalContext, event); + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return NULL; +} + +JSObjectRef JSCalendarEvent::createJSCalendarEvent(JSContextRef context, CalendarEventPtr event) +{ + CalendarEventPrivObject *priv = new CalendarEventPrivObject(context, event); + return JSObjectMake(context, getClassRef(), priv); +} + +const JSClassRef JSCalendarEvent::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSCalendarEvent::getClassInfo() +{ + return &m_classInfo; +} + +CalendarEventPtr JSCalendarEvent::getPrivateObject(JSObjectRef object) +{ + CalendarEventPrivObject *priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(NullPointerException, "Private object is null"); + } + CalendarEventPtr result = priv->getObject(); + if (!result) { + ThrowMsg(NullPointerException, "Private object is null"); + } + return result; +} + +void JSCalendarEvent::setPrivateObject(const CalendarEventPtr &event, + JSContextRef ctx, + const JSObjectRef object) +{ + Try + { + CalendarEventPrivObject *priv = + static_cast(JSObjectGetPrivate(object)); + delete priv; + priv = new CalendarEventPrivObject(ctx, event); + if (!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } + Catch(Exception) + { + LogError("Error during replacing event object"); + } +} + +JSValueRef JSCalendarEvent::expandRecurrence(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarEventPrivObject *privateObject = + static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_EXPAND_RECURRENCE); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try + { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + CalendarEventPtr event = privateObject->getObject(); + if (!event) { + ThrowMsg(ConversionException, "Parameter conversion failed."); + } + + JSContextRef globalContext = privateObject->getContext(); + CalendarConverter converter(context); + + std::time_t startDate = 0; + std::time_t endDate = INT_MAX; // about 60 years in 4 bytes system. + TimeUtilConverter timeConverter(context); + if (argumentCount>=1) { + if (JSValueIsObjectOfClass(context, arguments[0], JSTZDate::getClassRef())) { + startDate = (long long int) (timeConverter.getTimeInMilliseconds(arguments[0])/1000); + LogInfo("startDate: "<=2) { + if (JSValueIsObjectOfClass(context, arguments[1], JSTZDate::getClassRef())) { + endDate = (long long int) (timeConverter.getTimeInMilliseconds(arguments[1])/1000); + LogInfo("endDate: "< 3 ? converter.toFunctionOrNull(arguments[3]) : NULL; + + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, NULL, onError); + + Validator validator(context); + if (validator.isCallback(arguments[2])) { + cbm->setOnSuccess(arguments[2]); + } else { + ThrowMsg(ConversionException, "Wrong third parameter type."); + } + + cbm->setObject(thisObject); + + LogDebug("Proceed the expand event to the platform."); + + IEventExpandEventRecurrencePtr dplEvent(new IEventExpandEventRecurrence()); + dplEvent->setPrivateData(DPL::StaticPointerCast(cbm)); + dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance()); + dplEvent->setEvent(event); + dplEvent->setStartDate(startDate); + dplEvent->setEndDate(endDate); + m_calendar->expandEventRecurrence(dplEvent); + + CalendarAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext); + + return JSValueMakeUndefined(context); + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +JSValueRef JSCalendarEvent::getPropertyId(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarEventPrivObject *privateObject = + static_cast(JSObjectGetPrivate(object)); + CalendarEventPtr event = privateObject->getObject(); + + EventIdPtr eventId( new EventId() ); + + if (UNDEFINED_ITEM_ID==event->getId()) { + return JSValueMakeNull(context); + } else { + eventId->setUId(event->getUId()); + } + + std::stringstream ss; + std::time_t rid = event->getRecurrenceId(); + ss<setRecurrenceId(ss.str()); + return JSCalendarEventId::createJSCalendarEventId(context, eventId); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSCalendarEvent::getPropertyIsDetached(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarEventPtr event = getPrivateObject(object); + if(CalendarEvent::EVENT_TYPE != event->getCalendarType()) { + return JSValueMakeUndefined(context); + } + + Converter converter(context); + return converter.toJSValueRef(event->getIsDetached()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarEvent::validate(JSContextRef ctx, + const JSObjectRef object, + JSValueRef* exception) +{ + CalendarEventPrivObject *priv = + static_cast(JSObjectGetPrivate(object)); + if (priv == NULL) { + return false; + } + CalendarEventPtr event = priv->getObject(); + if (!event) { + return false; + } + return event->validate(); +} + +} +} diff --git a/src/Calendar/JSCalendarEvent.h b/src/Calendar/JSCalendarEvent.h new file mode 100755 index 0000000..cdbd0c4 --- /dev/null +++ b/src/Calendar/JSCalendarEvent.h @@ -0,0 +1,132 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_EVENT_H_ +#define _JS_CALENDAR_EVENT_H_ + +#include +#include "CalendarEvent.h" +#include "ICalendar.h" +#include "CalendarFactory.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +#define TIZEN_INTERFACE_CALENDAR_EVENT "CalendarEvent" + +#define TIZEN_CALENDAR_EVENT_ID "id" +#define TIZEN_CALENDAR_EVENT_LAST_MODIFICATION_DATE "lastModificationDate" +#define TIZEN_CALENDAR_EVENT_IS_DETACHED "isDetached" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject CalendarEventPrivObject; + +class JSCalendarEvent +{ + public: + + static const JSClassDefinition* getClassInfo(); + + static const JSClassRef getClassRef(); + + static CalendarEventPtr getPrivateObject(JSObjectRef object); + + static void setPrivateObject(const CalendarEventPtr &event, + JSContextRef ctx, + const JSObjectRef object); + + static bool validate(JSContextRef ctx, + const JSObjectRef object, + JSValueRef* exception); + + static JSObjectRef createJSCalendarEvent(JSContextRef context, CalendarEventPtr event); + + 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 calendar object to be used for asynchronous platform function invocation. + */ + static ICalendarPtr m_calendar; + + /** + * The callback invoked when an object is first created. + */ + static void initialize(JSContextRef context, + JSObjectRef object); + + /** + * The callback invoked when an object is finalized. + */ + static void finalize(JSObjectRef object); + + /** + * Constructor for the CalendarEvent interface. + */ + static JSObjectRef constructor(JSContextRef context, + JSObjectRef constructor, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Expand event instances from a recurring event + */ + static JSValueRef expandRecurrence(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Getters and setters for properties + */ + static JSValueRef getPropertyId(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static JSValueRef getPropertyIsDetached(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); +}; + +} +} + +#endif /* _JS_CALENDAR_EVENT_H_ */ diff --git a/src/Calendar/JSCalendarEventId.cpp b/src/Calendar/JSCalendarEventId.cpp new file mode 100755 index 0000000..09e7397 --- /dev/null +++ b/src/Calendar/JSCalendarEventId.cpp @@ -0,0 +1,267 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#include "JSCalendarEventId.h" +#include "CalendarConverter.h" +#include +#include +#include +#include +#include +#include +#include + + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + +namespace DeviceAPI { +namespace Calendar { + +JSClassDefinition JSCalendarEventId::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_INTERFACE_CALENDAR_EVENT_ID, + 0, + m_property, + NULL, //m_function, + initialize, + finalize, + NULL, //hasProperty, + NULL, //getProperty, + NULL, //setProperty, + NULL, //deleteProperty, + NULL, //getPropertyNames, + NULL, //callAsFunction, + constructor, + NULL, //hasInstance, + NULL, //convertToType, +}; + +JSStaticValue JSCalendarEventId::m_property[] = { + { TIZEN_CALENDAR_EVENT_ID_UID, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_EVENT_ID_RECURRENCEID, getProperty, setProperty, kJSPropertyAttributeNone }, + { 0, 0, 0, 0 } +}; + +JSClassRef JSCalendarEventId::m_jsClassRef = JSClassCreate( + JSCalendarEventId::getClassInfo()); + +const JSClassDefinition* JSCalendarEventId::getClassInfo() +{ + return &(m_classInfo); +} + +JSClassRef JSCalendarEventId::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +EventIdPtr JSCalendarEventId::getPrivateObject(JSObjectRef object) +{ + EventIdPrivateObject *priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(NullPointerException, "Private object is null"); + } + EventIdPtr result = priv->getObject(); + if (!result) { + ThrowMsg(NullPointerException, "Private object is null"); + } + return result; +} + +void JSCalendarEventId::setPrivateObject(const EventIdPtr &eventId, + JSContextRef ctx, + const JSObjectRef object) +{ + Try + { + EventIdPrivateObject *priv = + static_cast(JSObjectGetPrivate(object)); + delete priv; + priv = new EventIdPrivateObject(ctx, eventId); + if (!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } + Catch(Exception) + { + LogError("Error during replacing event id object."); + } +} + +JSObjectRef JSCalendarEventId::createJSCalendarEventId(JSContextRef context, EventIdPtr eventId) +{ + EventIdPrivateObject *priv = new EventIdPrivateObject(context, eventId); + return JSObjectMake(context, getClassRef(), priv); +} + +void JSCalendarEventId::initialize(JSContextRef context, + JSObjectRef object) +{ + if (!JSObjectGetPrivate(object)) { + LogDebug("Create calendar event id private object."); + EventIdPtr eventId( new EventId() ); + EventIdPrivateObject *priv = new EventIdPrivateObject(context, eventId); + if (!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } else { + LogDebug("Private object already set."); + } +} + +void JSCalendarEventId::finalize(JSObjectRef object) +{ + EventIdPrivateObject* priv = static_cast(JSObjectGetPrivate(object)); + if (priv) { + delete priv; + JSObjectSetPrivate(object, NULL); + } +} + +JSObjectRef JSCalendarEventId::constructor(JSContextRef context, + JSObjectRef constructor, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + CalendarConverter converter(context); + EventIdPtr eventId; + + if (argumentCount==0) { + EventIdPtr result( new EventId()); + eventId = result; + } else if (argumentCount==1) { + EventIdPtr result( new EventId()); + eventId = result; + eventId->setUId(converter.toString(arguments[0])); + } else if (argumentCount>=2) { + EventIdPtr result( new EventId()); + eventId = result; + eventId->setUId(converter.toString(arguments[0])); + eventId->setRecurrenceId(converter.toString(arguments[1])); + } + + return createJSCalendarEventId(context, eventId); + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return NULL; +} + +JSValueRef JSCalendarEventId::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + EventIdPrivateObject* priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(NullPointerException, "Private object is NULL."); + } + + EventIdPtr eventId = priv->getObject(); + if (!eventId) { + ThrowMsg(NullPointerException, "EventId is NULL."); + } + + Converter converter(context); + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_EVENT_ID_UID)) { + if (eventId->getUId()==UNDEFINED_ID) { + return JSValueMakeNull(context); + } else { + return converter.toJSValueRef(eventId->getUId()); + } + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_EVENT_ID_RECURRENCEID)) { + if (eventId->getRecurrenceId()==UNDEFINED_ID) { + return JSValueMakeNull(context); + } else { + return converter.toJSValueRef(eventId->getRecurrenceId()); + } + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarEventId::setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + EventIdPrivateObject* priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(NullPointerException, "Private object is NULL."); + } + + EventIdPtr eventId = priv->getObject(); + Converter converter(context); + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_EVENT_ID_UID)) { + std::string uid = converter.toString(value); + eventId->setUId(uid); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_EVENT_ID_RECURRENCEID)) { + std::string recurrenceId = converter.toString(value); + eventId->setRecurrenceId(recurrenceId); + return true; + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR); + return false; +} + +} +} diff --git a/src/Calendar/JSCalendarEventId.h b/src/Calendar/JSCalendarEventId.h new file mode 100755 index 0000000..b068ffe --- /dev/null +++ b/src/Calendar/JSCalendarEventId.h @@ -0,0 +1,107 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _JS_CALEMDAR_EVENT_ID_H_ +#define _JS_CALEMDAR_EVENT_ID_H_ + +#include +#include +#include "EventId.h" + +namespace DeviceAPI { +namespace Calendar { + +#define TIZEN_INTERFACE_CALENDAR_EVENT_ID "CalendarEventId" + +#define TIZEN_CALENDAR_EVENT_ID_UID "uid" +#define TIZEN_CALENDAR_EVENT_ID_RECURRENCEID "rid" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject EventIdPrivateObject; + +class JSCalendarEventId +{ + public: + + static const JSClassDefinition* getClassInfo(); + + static JSClassRef getClassRef(); + + static JSObjectRef createJSCalendarEventId(JSContextRef context, EventIdPtr eventId); + + static EventIdPtr getPrivateObject(JSObjectRef object); + + static void setPrivateObject(const EventIdPtr &eventId, + JSContextRef ctx, + const JSObjectRef object); + + private: + + /** + * The callback invoked when an object is first created. + */ + static void initialize(JSContextRef context, JSObjectRef object); + + /** + * The callback invoked when an object is finalized. + */ + static void finalize(JSObjectRef object); + + /** + * Constructor for the CalendarEventId interface. + */ + static JSObjectRef constructor(JSContextRef context, + JSObjectRef constructor, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + + static JSClassRef m_jsClassRef; + + /** + * This structure describes a statically declared function property. + */ + static JSStaticFunction m_function[]; + + /** + * This structure contains properties and callbacks that define a type of object. + */ + static JSClassDefinition m_classInfo; + + /** + * This member variable contains the initialization values for the static properties of this class. + * The values are given according to the data structure JSPropertySpec + */ + static JSStaticValue m_property[]; +}; + +} +} + +#endif /* _JS_CALEMDAR_EVENT_ID_H_ */ diff --git a/src/Calendar/JSCalendarItemProperties.cpp b/src/Calendar/JSCalendarItemProperties.cpp new file mode 100755 index 0000000..5035cc6 --- /dev/null +++ b/src/Calendar/JSCalendarItemProperties.cpp @@ -0,0 +1,1422 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "EventAlarm.h" +#include "EventId.h" +#include "ICalendar.h" +#include "CalendarFactory.h" +#include +#include "JSCalendarItemProperties.h" +#include "CalendarConverter.h" +#include "JSCalendarEventId.h" +#include "JSCalendarAlarm.h" +#include "JSCalendarRecurrenceRule.h" +#include "JSCalendarAttendee.h" +#include "JSCalendarEvent.h" +#include "JSCalendarTask.h" +#include "plugin_config.h" + + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; +using namespace DeviceAPI::Time; + +namespace DeviceAPI { +namespace Calendar { + +#define TIZEN_CALENDAR_ITEM_PROPERTIES_ATTRIBUTENAME "CalendarItemProperties" + +JSClassDefinition JSCalendarItemProperties::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_CALENDAR_ITEM_PROPERTIES_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 JSCalendarItemProperties::m_property[] = { + // Item Properties + { TIZEN_CALENDAR_ITEM_DESCRIPTION, getPropertyDescription, setPropertyDescription, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_ITEM_SUMMARY, getPropertySummary, setPropertySummary, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_ITEM_START_DATE, getPropertyStartTime, setPropertyStartTime, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_ITEM_LOCATION, getPropertyLocation, setPropertyLocation, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_ITEM_GEOLOCATION, getPropertyGeolocation, setPropertyGeolocation, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_ITEM_ORGANIZER, getPropertyOrganizer, setPropertyOrganizer, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_ITEM_VISIBILITY, getPropertyVisibility, setPropertyVisibility, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_ITEM_STATUS, getPropertyStatus, setPropertyStatus, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_ITEM_ALARMS, getPropertyAlarms, setPropertyAlarms, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_ITEM_CATEGORIES, getPropertyCategories, setPropertyCategories, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_ITEM_DURATION, getPropertyDuration, setPropertyDuration, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_ITEM_IS_ALL_DAY, getPropertyIsAllDay, setPropertyIsAllDay, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_ITEM_ATTENDEES, getPropertyAttendees, setPropertyAttendees, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_EVENT_RECURRENCE_RULE, getPropertyRecurrenceRule, setPropertyRecurrenceRule, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_EVENT_AVAILABILITY, getPropertyAvailability, setPropertyAvailability, kJSPropertyAttributeNone }, + { TIZEN_CALENDAR_TASK_DUE_DATE, getPropertyDueDate, setPropertyDueDate, kJSPropertyAttributeNone }, + { 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 }, + { TIZEN_CALENDAR_EVENT_LAST_MODIFICATION_DATE, getPropertyLastModificationDate, NULL, kJSPropertyAttributeReadOnly }, + { TIZEN_CALENDAR_ITEM_CALENDAR_ID, getPropertyCalendarId, NULL, kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCalendarItemProperties::m_function[] = { + { CALENDAR_FUNCTION_API_CONVERT_TO_STRING, convertToString, kJSPropertyAttributeNone }, + { CALENDAR_FUNCTION_API_CLONE, clone, kJSPropertyAttributeNone }, + + { 0, 0, 0 } +}; + +JSClassRef JSCalendarItemProperties::m_jsClassRef = JSClassCreate(JSCalendarItemProperties::getClassInfo()); + +void JSCalendarItemProperties::initialize(JSContextRef context, + JSObjectRef object) +{ + if (!JSObjectGetPrivate(object)) { + LogDebug("Create calendar item private object."); + CalendarEventPtr item( new CalendarEvent() ); + CalendarItemPropertiesPrivObject *priv = new CalendarItemPropertiesPrivObject(context, item); + if (!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } else { + LogDebug("Private object already set."); + } +} + +void JSCalendarItemProperties::finalize(JSObjectRef object) +{ + CalendarItemPropertiesPrivObject *priv = static_cast(JSObjectGetPrivate(object)); + if (priv) { + delete priv; + JSObjectSetPrivate(object, NULL); + } +} + +const JSClassRef JSCalendarItemProperties::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSCalendarItemProperties::getClassInfo() +{ + return &m_classInfo; +} + +CalendarEventPtr JSCalendarItemProperties::getPrivateObject(JSObjectRef object) +{ + CalendarItemPropertiesPrivObject *priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(NullPointerException, "Private object is null"); + } + CalendarEventPtr result = priv->getObject(); + if (!result) { + ThrowMsg(NullPointerException, "Private object is null"); + } + return result; +} + +void JSCalendarItemProperties::setPrivateObject(const CalendarEventPtr &event, + JSContextRef ctx, + const JSObjectRef object) +{ + Try + { + CalendarItemPropertiesPrivObject *priv = + static_cast(JSObjectGetPrivate(object)); + delete priv; + priv = new CalendarItemPropertiesPrivObject(ctx, event); + if (!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } + Catch(Exception) + { + LogError("Error during replacing event object"); + } +} + +JSObjectRef JSCalendarItemProperties::createJSCalendarItemProperties(JSContextRef context, CalendarEventPtr item) +{ + CalendarItemPropertiesPrivObject *priv = new CalendarItemPropertiesPrivObject(context, item); + return JSObjectMake(context, getClassRef(), priv); +} + +JSValueRef JSCalendarItemProperties::convertToString(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarItemPropertiesPrivObject *privateObject = + static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_CONVERT_TO_STRING); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try + { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + CalendarEventPtr item = privateObject->getObject(); + if (!item) { + ThrowMsg(ConversionException, "Parameter conversion failed."); + } + + CalendarConverter converter(context); + + CalendarEvent::VObjectFormat format = CalendarEvent::UNDEFINED_FORMAT; + if (argumentCount>=1) { + format = converter.toVObjectFormat(converter.toString(arguments[0])); + } else { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + ICalendarPtr calendar = CalendarFactory::getInstance().createCalendarObject(); + calendar->setType(item->getCalendarType()); + + IEventExportEventToStringPtr dplEvent(new IEventExportEventToString()); + dplEvent->setEvent(item); + dplEvent->setFormat(format); + dplEvent->setForSynchronousCall(); + calendar->exportEventToString(dplEvent); + + if (dplEvent->getResult()) { + return converter.toJSValueRef(dplEvent->getEventString()); + } else { + ThrowMsg(UnknownException, "Converting to string failed by unknown reason."); + } + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +JSValueRef JSCalendarItemProperties::clone(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarItemPropertiesPrivObject *privateObject = + static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_CLONE); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try + { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + CalendarEventPtr item = privateObject->getObject(); // item to copy + if (!item) { + ThrowMsg(ConversionException, "Parameter conversion failed."); + } + JSContextRef globalContext = privateObject->getContext(); + + // Call the copy constructor. + CalendarEventPtr clonedItem( new CalendarEvent(*item)); + + // Reset the id. + clonedItem->resetId(); + clonedItem->setRecurrenceId(UNDEFINED_ITEM_ID); + + if (CalendarEvent::TASK_TYPE==clonedItem->getCalendarType()) { + return JSCalendarTask::createJSCalendarTask(context, clonedItem); + } else if (CalendarEvent::EVENT_TYPE==clonedItem->getCalendarType()) { + // Use global context for potential async api invocation. + return JSCalendarEvent::createJSCalendarEvent(globalContext, clonedItem); + } else { + ThrowMsg(ConversionException, "Wrong object type."); + } + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch (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()); + } +} + +JSValueRef JSCalendarItemProperties::getPropertyDescription(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + Converter converter(context); + CalendarEventPtr event = getPrivateObject(object); + return converter.toJSValueRef(event->getDescription()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyDescription(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + Converter converter(context); + CalendarEventPtr event = getPrivateObject(object); + std::string description = converter.toString(value); + event->setDescription(description); + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertySummary(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + Converter converter(context); + CalendarEventPtr event = getPrivateObject(object); + return converter.toJSValueRef(event->getSubject()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertySummary(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + Converter converter(context); + CalendarEventPtr event = getPrivateObject(object); + std::string subject = converter.toString(value); + event->setSubject(subject); + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyStartTime(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarItemPropertiesPrivObject *privateObject = + static_cast(JSObjectGetPrivate(object)); + TimeUtilConverter timeConverter(context); + CalendarEventPtr event = privateObject->getObject(); + + LogInfo("start time before converted to TZDate: "<getStartTime()<<", time zone: "<getTimeZone()); + if (UNDEFINED_TIME==event->getStartTime()) { + return JSValueMakeUndefined(context); + } else { + return timeConverter.toJSValueRefTZDate((double)(event->getStartTime()*1000.0), event->getTimeZone()); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyStartTime(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + CalendarEventPtr event = getPrivateObject(object); + TimeUtilConverter converter(context); + std::time_t duration = event->getEndTime() - event->getStartTime(); + if (duration<0) { + duration = 0; + } + + long long int startTime = (long long int) (converter.getTimeInMilliseconds(value)/1000); + event->setStartTime(startTime); + event->setEndTime(startTime + duration); + + std::string timeZone = converter.getPropertiesInTZDate(value).timezone; + event->setTimeZone(timeZone); + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyLocation(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + Converter converter(context); + CalendarEventPtr event = getPrivateObject(object); + return converter.toJSValueRef(event->getLocation()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyLocation(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + Converter converter(context); + CalendarEventPtr event = getPrivateObject(object); + std::string location = converter.toString(value); + event->setLocation(location); + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyCategories(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarConverter converter(context); + CalendarEventPtr event = getPrivateObject(object); + StringArrayPtr categories = event->getCategories(); + if (categories) { + return converter.toJSValueRef(categories); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyCategories(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + CalendarEventPtr event = getPrivateObject(object); + CalendarConverter converter(context); + event->setCategories(converter.toStringArray(value)); + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyStatus(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarConverter converter(context); + CalendarEventPtr event = getPrivateObject(object); + std::string status = converter.toTizenValue(event->getStatus()); + return converter.toJSValueRef(status); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyStatus(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + CalendarEventPtr event(NULL); + Try + { + event = getPrivateObject(object); + CalendarConverter converter(context); + CalendarEvent::EventStatus status = + converter.toEventStatus(converter.toString(value)); + event->setStatus(status); + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyAlarms(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarEventPtr event = getPrivateObject(object); + + JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL); + if (NULL == jsResult) { + ThrowMsg(NullPointerException, "Can not create array object."); + } + for( unsigned int i=0; igetAlarms()->size(); i++) { + if (!JSSetArrayElement(context, jsResult, i, JSCalendarAlarm::createJSCalendarAlarm(context, event->getAlarms()->at(i)))) { + ThrowMsg(UnknownException, "Can not insert value into array."); + } + } + return jsResult; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyAlarms(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + CalendarEventPtr event(NULL); + Try + { + event = getPrivateObject(object); + CalendarConverter converter(context); + + EventAlarmListPtr alarms = converter.toVectorOfEventAlarmsFromReference(value); + + event->setAlarms(alarms); + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyOrganizer(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + Converter converter(context); + CalendarEventPtr event = getPrivateObject(object); + return converter.toJSValueRef(event->getOrganizer()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyOrganizer(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + Converter converter(context); + CalendarEventPtr event = getPrivateObject(object); + std::string organizer = converter.toString(value); + event->setOrganizer(organizer); + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyVisibility(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarConverter converter(context); + CalendarEventPtr event = getPrivateObject(object); + std::string visibility = converter.toTizenValue(event->getVisibility()); + return converter.toJSValueRef(visibility); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyVisibility(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + CalendarEventPtr event(NULL); + Try + { + event = getPrivateObject(object); + CalendarConverter converter(context); + CalendarEvent::EventVisibility visibility = + converter.toEventVisibility(converter.toString(value)); + event->setVisibility(visibility); + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyGeolocation(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarEventPtr event = getPrivateObject(object); + DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation( + new DeviceAPI::Tizen::SimpleCoordinates(event->getLatitude(), event->getLongitude()) ); + + return DeviceAPI::Tizen::JSSimpleCoordinates::createJSObject(context, geoLocation); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyGeolocation(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + CalendarEventPtr event = getPrivateObject(object); + DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation = + DeviceAPI::Tizen::JSSimpleCoordinates::getSimpleCoordinates(context, value); + + event->setLatitude(geoLocation->getLatitude()); + event->setLongitude(geoLocation->getLongitude()); + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyDuration(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarEventPtr event = getPrivateObject(object); + + TimeUtilConverter converter(context); + long length = event->getEndTime() - event->getStartTime(); // in seconds only + LogDebug("event->getStartTime():"<< event->getStartTime() << ", length:" << length); + return converter.makeMillisecondDurationObject( length*1000 ); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyDuration(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + CalendarEventPtr event = getPrivateObject(object); + TimeUtilConverter converter(context); + long length = converter.getDurationLength(value); + int unit = converter.getDurationUnit(value); + if (length < 0) { + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::INVALID_VALUES_ERROR); + return false; + } + if( SECONDS_UNIT==unit ) { + event->setEndTime(event->getStartTime() + length); + } else if ( MINUTES_UNIT==unit ) { + event->setEndTime(event->getStartTime() + length*60); + } else if ( HOURS_UNIT==unit ) { + event->setEndTime(event->getStartTime() + length*60*60); + } else if ( DAYS_UNIT==unit ) { + event->setEndTime(event->getStartTime() + length*24*60*60); + } else if ( MSECS_UNIT==unit ) { + event->setEndTime(event->getStartTime() + length/1000); + } else { + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::INVALID_VALUES_ERROR); + return false; + } + + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyRecurrenceRule(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarItemPropertiesPrivObject *priv = + static_cast(JSObjectGetPrivate(object)); + + CalendarEventPtr event = getPrivateObject(object); + EventRecurrenceRulePtr rrule; + if (event->getIsDetached()) { + LogDebug("This is a detached event."); + return JSValueMakeUndefined(context); + } else { + rrule = event->getRecurrenceRule(); + } + + if (EventRecurrenceRule::NO_RECURRENCE==rrule->getFrequency()) { + return JSValueMakeUndefined(context); + } else { + return JSCalendarRecurrenceRule::createJSCalendarRecurrenceRule(priv->getContext(), rrule); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyRecurrenceRule(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + CalendarEventPtr event(NULL); + Try + { + event = getPrivateObject(object); + if (event->getIsDetached()) { + LogWarning("Can't set the recurrenceRule of a detached event!"); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::NOT_SUPPORTED_ERROR); + } + event->setRecurrenceRule(JSCalendarRecurrenceRule::getPrivateObject(JSValueToObject(context, value, NULL))); + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyIsAllDay(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarConverter converter(context); + CalendarEventPtr event = getPrivateObject(object); + return converter.toJSValueRef(event->getIsAllDay()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyIsAllDay(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + CalendarEventPtr event = getPrivateObject(object); + Converter converter(context); + event->setIsAllDay(converter.toBool(value)); + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyAvailability(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarConverter converter(context); + CalendarEventPtr event = getPrivateObject(object); + std::string availability = converter.toTizenValue(event->getAvailability()); + return converter.toJSValueRef(availability); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyAvailability(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + CalendarEventPtr event(NULL); + Try + { + event = getPrivateObject(object); + CalendarConverter converter(context); + CalendarEvent::EventAvailability availability = + converter.toEventAvailability(converter.toString(value)); + event->setAvailability(availability); + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyAttendees(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarEventPtr event = getPrivateObject(object); + EventAttendeeListPtr attendees = event->getAttendees(); + if (attendees) { + JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL); + if (NULL == jsResult) { + ThrowMsg(NullPointerException, "Can not create array object."); + } + for(unsigned int i=0; isize(); i++) { + if (!JSSetArrayElement(context, jsResult, i, JSCalendarAttendee::createJSCalendarAttendee(context, attendees->at(i)))) { + ThrowMsg(UnknownException, "Can not insert value into array."); + } + } + return jsResult; + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyAttendees(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + CalendarEventPtr event = getPrivateObject(object); + CalendarConverter converter(context); + event->setAttendees(converter.toVectorOfAttendeesFromReference(value)); + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyDueDate(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarItemPropertiesPrivObject *privateObject = + static_cast(JSObjectGetPrivate(object)); + CalendarEventPtr task = privateObject->getObject(); + if(CalendarEvent::TASK_TYPE != task->getCalendarType()) { + return JSValueMakeUndefined(context); + } + if (!task) { + ThrowMsg(NullPointerException, "Task object is NULL."); + } + + if (UNDEFINED_TIME==task->getEndTime()) { + return JSValueMakeUndefined(context); + } else { + TimeUtilConverter timeConverter(context); + return timeConverter.toJSValueRefTZDate((double)(task->getEndTime()*1000.0), task->getTimeZone()); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyDueDate(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + CalendarEventPtr task = getPrivateObject(object); + if (!task) { + ThrowMsg(NullPointerException, "Task object is NULL."); + } + if(CalendarEvent::TASK_TYPE != task->getCalendarType()) { + ThrowMsg(InvalidArgumentException, "Wrong type of calendar."); + } + if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + TimeUtilConverter converter(context); + long long int dueDate = (long long int) (converter.getTimeInMilliseconds(value)/1000); + + task->setEndTime(dueDate); + + if( task->getTimeZone().empty() ) { + std::string timeZone = converter.getPropertiesInTZDate(value).timezone; + task->setTimeZone(timeZone); + } + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyCompletedDate(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarItemPropertiesPrivObject *privateObject = + static_cast(JSObjectGetPrivate(object)); + CalendarEventPtr task = privateObject->getObject(); + if(CalendarEvent::TASK_TYPE != task->getCalendarType()) { + return JSValueMakeUndefined(context); + } + if (!task) { + ThrowMsg(NullPointerException, "Task object is NULL."); + } + + if (UNDEFINED_TIME==task->getCompletedDate()) { + return JSValueMakeUndefined(context); + } else { + TimeUtilConverter timeConverter(context); + return timeConverter.toJSValueRefTZDate((double)(task->getCompletedDate()*1000.0), task->getTimeZone()); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyCompletedDate(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + CalendarEventPtr task = getPrivateObject(object); + if (!task) { + ThrowMsg(NullPointerException, "Task object is NULL."); + } + if(CalendarEvent::TASK_TYPE != task->getCalendarType()) { + ThrowMsg(InvalidArgumentException, "Wrong calendar type."); + } + if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + TimeUtilConverter converter(context); + long long int completedDate = (long long int) (converter.getTimeInMilliseconds(value)/1000); + + task->setCompletedDate(completedDate); + + if( task->getTimeZone().empty() ) { + std::string timeZone = converter.getPropertiesInTZDate(value).timezone; + task->setTimeZone(timeZone); + } + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyProgress(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + 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("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyProgress(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + 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("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyPriority(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarConverter converter(context); + CalendarEventPtr item = getPrivateObject(object); + if (!item) { + ThrowMsg(NullPointerException, "Item object is NULL."); + } + + std::string priority = converter.toTizenValue(item->getPriority()); + return converter.toJSValueRef(priority); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyPriority(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + CalendarEventPtr item = getPrivateObject(object); + Try + { + CalendarConverter converter(context); + CalendarEvent::TaskPriority priority = + converter.toTaskPriority(converter.toString(value)); + item->setPriority(priority); + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyEndDate(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarItemPropertiesPrivObject *privateObject = + static_cast(JSObjectGetPrivate(object)); + CalendarEventPtr event = privateObject->getObject(); + if(CalendarEvent::EVENT_TYPE != event->getCalendarType()) { + return JSValueMakeUndefined(context); + } + if (!event) { + ThrowMsg(NullPointerException, "Event object is NULL."); + } + + if (UNDEFINED_TIME==event->getEndTime()) { + return JSValueMakeUndefined(context); + } else { + TimeUtilConverter timeConverter(context); + return timeConverter.toJSValueRefTZDate((double)(event->getEndTime()*1000.0), event->getTimeZone()); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::setPropertyEndDate(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + Try + { + CalendarEventPtr event = getPrivateObject(object); + if (!event) { + ThrowMsg(NullPointerException, "Event object is NULL."); + } + if(CalendarEvent::EVENT_TYPE != event->getCalendarType()) { + ThrowMsg(InvalidArgumentException, "Wrong calendar type."); + } + if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + TimeUtilConverter converter(context); + long long int endDate = (long long int) (converter.getTimeInMilliseconds(value)/1000); + + event->setEndTime(endDate); + + if( event->getTimeZone().empty() ) { + std::string timeZone = converter.getPropertiesInTZDate(value).timezone; + event->setTimeZone(timeZone); + } + return true; + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR); + } + + return false; +} + +JSValueRef JSCalendarItemProperties::getPropertyLastModificationDate(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarEventPtr item = getPrivateObject(object); + if (!item) { + ThrowMsg(NullPointerException, "Item object is NULL."); + } + + if (UNDEFINED_TIME==item->getLastModifiedDate()) { + return JSValueMakeNull(context); + } else { + TimeUtilConverter timeConverter(context); + return timeConverter.toJSValueRefTZDate((double)(item->getLastModifiedDate()*1000.0), item->getTimeZone()); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSCalendarItemProperties::getPropertyCalendarId(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarEventPtr item = getPrivateObject(object); + + if (UNDEFINED_CALENDAR_ID==item->getCalendarId()) { + return JSValueMakeNull(context); + } else { + CalendarConverter converter(context); + std::stringstream ss; + ss<getCalendarId(); + return converter.toJSValueRef(ss.str()); + } + + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarItemProperties::validate(JSContextRef ctx, + const JSObjectRef object, + JSValueRef* exception) +{ + CalendarItemPropertiesPrivObject *priv = + static_cast(JSObjectGetPrivate(object)); + if (priv == NULL) { + return false; + } + CalendarEventPtr event = priv->getObject(); + if (!event) { + return false; + } + return event->validate(); +} + +} +} diff --git a/src/Calendar/JSCalendarItemProperties.h b/src/Calendar/JSCalendarItemProperties.h new file mode 100755 index 0000000..aeb107c --- /dev/null +++ b/src/Calendar/JSCalendarItemProperties.h @@ -0,0 +1,328 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_PROPERTIES_H_ +#define _JS_CALENDAR_ITEM_PROPERTIES_H_ + +#include +#include "CalendarEvent.h" +#include + +namespace DeviceAPI { +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" +#define TIZEN_CALENDAR_ITEM_CALENDAR_ID "calendarId" + +// 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 CalendarItemPropertiesPrivObject; + +class JSCalendarItemProperties +{ + public: + + static const JSClassDefinition* getClassInfo(); + + static const JSClassRef getClassRef(); + + static CalendarEventPtr getPrivateObject(JSObjectRef object); + + static void setPrivateObject(const CalendarEventPtr &event, + JSContextRef ctx, + const JSObjectRef object); + + static JSObjectRef createJSCalendarItemProperties(JSContextRef context, CalendarEventPtr geo); + + static bool validate(JSContextRef ctx, + const JSObjectRef object, + JSValueRef* exception); + + private: + /** + * This member variable contains the values which has to be passed when + * the this class is embedded into JS Engine. + */ + static JSClassDefinition m_classInfo; + + /** + * This structure describes a statically declared function property. + */ + static JSStaticFunction m_function[]; + + /** + * This member variable contains the initialization values for the + * properties of this class. The values are given according to the + * data structure JSPropertySpec. + */ + static JSStaticValue m_property[]; + + static JSClassRef m_jsClassRef; + + /** + * The callback invoked when an object is first created. + */ + static void initialize(JSContextRef context, + JSObjectRef object); + + /** + * The callback invoked when an object is finalized. + */ + static void finalize(JSObjectRef object); + + /** + * Export a string from item + */ + static JSValueRef convertToString(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Copy item object contents except id + */ + static JSValueRef clone(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Getters and setters for properties + */ + static JSValueRef getPropertyDescription(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertyDescription(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPropertySummary(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertySummary(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPropertyStartTime(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertyStartTime(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPropertyLocation(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertyLocation(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPropertyGeolocation(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertyGeolocation(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPropertyOrganizer(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertyOrganizer(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPropertyVisibility(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertyVisibility(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPropertyStatus(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertyStatus(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPropertyAlarms(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertyAlarms(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPropertyCategories(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertyCategories(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPropertyIsAllDay(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertyIsAllDay(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPropertyDuration(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertyDuration(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPropertyAttendees(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertyAttendees(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPropertyAvailability(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertyAvailability(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPropertyRecurrenceRule(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertyRecurrenceRule(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + static JSValueRef getPropertyDueDate(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static bool setPropertyDueDate(JSContextRef context, + JSObjectRef object, + 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, + JSValueRef* exception); + static bool setPropertyPriority(JSContextRef context, + JSObjectRef object, + 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); + static JSValueRef getPropertyLastModificationDate(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + static JSValueRef getPropertyCalendarId(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); +}; + +} +} + +#endif + diff --git a/src/Calendar/JSCalendarManager.cpp b/src/Calendar/JSCalendarManager.cpp new file mode 100755 index 0000000..f01ec9d --- /dev/null +++ b/src/Calendar/JSCalendarManager.cpp @@ -0,0 +1,419 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include "ICalendar.h" +#include "ICalendarManager.h" +#include "CalendarFactory.h" + +#include +#include +#include +#include +#include +#include + +#include "JSCalendarManager.h" +#include "JSCalendar.h" +#include "CalendarConverter.h" +#include "CalendarResponseDispatcher.h" +#include "plugin_config.h" + +#include "CalendarAsyncCallbackManager.h" + + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + +#define TIZEN_CALENDAR_MANAGER_ATTRIBUTENAME "calendar" + +namespace DeviceAPI { +namespace Calendar { + +JSClassDefinition JSCalendarManager::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_CALENDAR_MANAGER_ATTRIBUTENAME, + 0, + NULL, + m_function, + initialize, + finalize, + NULL, //HasProperty, + NULL, //GetProperty, + NULL, //SetProperty, + NULL, //DeleteProperty, + NULL, //GetPropertyNames, + NULL, //CallAsFunction, + NULL, //CallAsConstructor, + NULL, //HasInstance, + NULL //ConvertToType +}; + +JSStaticFunction JSCalendarManager::m_function[] = { + { CALENDAR_FUNCTION_API_GET_CALENDARS, getCalendars, kJSPropertyAttributeNone }, + { CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR, getDefaultCalendar, kJSPropertyAttributeNone }, + { CALENDAR_FUNCTION_API_GET_UNIFIED_CALENDAR, getUnifiedCalendar, kJSPropertyAttributeNone }, + { CALENDAR_FUNCTION_API_GET_CALENDAR, + getCalendar, kJSPropertyAttributeNone }, + + { 0, 0, 0 } +}; + +JSClassRef JSCalendarManager::m_jsClassRef = JSClassCreate( + JSCalendarManager::getClassInfo()); + +void JSCalendarManager::initialize(JSContextRef context, + JSObjectRef object) +{ + if (!JSObjectGetPrivate(object)) { + LogDebug("Create calendar manager private object."); + ICalendarManagerPtr calendarManager = CalendarFactory::getInstance().createCalendarManagerObject(); + CalendarManagerPrivObject *privateObject = new CalendarManagerPrivObject(context, calendarManager); + if (!JSObjectSetPrivate(object, static_cast(privateObject))) { + delete privateObject; + } + } else { + LogDebug("Private object already set."); + } +} + +void JSCalendarManager::finalize(JSObjectRef object) +{ + CalendarManagerPrivObject *priv = static_cast(JSObjectGetPrivate(object)); + if (priv) { + delete priv; + JSObjectSetPrivate(object, NULL); + } +} + +JSValueRef JSCalendarManager::getCalendars(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarManagerPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_GET_CALENDARS); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + CalendarConverter converter(context); + + JSContextRef globalContext = privateObject->getContext(); + + JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext); + + CalendarEvent::CalendarType calendarType = CalendarEvent::UNDEFINED_TYPE; + if (argumentCount>=1) { + calendarType = converter.toCalendarType(converter.toString(arguments[0])); + } + + if (argumentCount>=2) { + cbm->setOnSuccess(converter.toFunction(arguments[1])); + } else { + ThrowMsg(ConversionException, "Wrong parameter count."); + } + + if (argumentCount>=3) { + cbm->setOnError(converter.toFunctionOrNull(arguments[2])); + } + + cbm->setObject(thisObject); + + IEventGetCalendarsPtr dplEvent(new IEventGetCalendars()); + dplEvent->setType(calendarType); + dplEvent->setPrivateData(DPL::StaticPointerCast(cbm)); + dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance()); + privateObject->getObject()->getCalendars(dplEvent); + + CalendarAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext); + + return JSValueMakeUndefined(context); + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +JSValueRef JSCalendarManager::getDefaultCalendar(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarManagerPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + // Global context should be passed to the calendar object. + JSContextRef globalContext = privateObject->getContext(); + + CalendarConverter converter(globalContext); + CalendarEvent::CalendarType calendarType = CalendarEvent::UNDEFINED_TYPE; + if (argumentCount>=1) { + calendarType = converter.toCalendarType(converter.toString(arguments[0])); + } else { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + IEventGetDefaultCalendarPtr dplEvent(new IEventGetDefaultCalendar()); + dplEvent->setForSynchronousCall(); + dplEvent->setType(calendarType); + privateObject->getObject()->getDefaultCalendar(dplEvent); + + if (dplEvent->getResult()) { + if( dplEvent->getCalendar() ) { + return converter.toJSValueRefCalendar(dplEvent->getCalendar()); + } else { + LogError("Default calendar not found."); + } + } else { + ThrowMsg(UnknownException, "Getting a default calendar failed by unknown reason."); + } + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return JSValueMakeUndefined(context); +} + +JSValueRef JSCalendarManager::getUnifiedCalendar(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarManagerPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_GET_UNIFIED_CALENDAR); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + // Global context should be passed to the calendar object. + JSContextRef globalContext = privateObject->getContext(); + + CalendarConverter converter(globalContext); + CalendarEvent::CalendarType calendarType = CalendarEvent::UNDEFINED_TYPE; + if (argumentCount>=1) { + calendarType = converter.toCalendarType(converter.toString(arguments[0])); + } else { + ThrowMsg(ConversionException, "Wrong parameter type."); + } + + IEventGetUnifiedCalendarPtr dplEvent(new IEventGetUnifiedCalendar()); + dplEvent->setForSynchronousCall(); + dplEvent->setType(calendarType); + privateObject->getObject()->getUnifiedCalendar(dplEvent); + + if (dplEvent->getResult()) { + if( dplEvent->getCalendar() ) { + LogDebug("Successfully got a unified calendar."); + return converter.toJSValueRefCalendar(dplEvent->getCalendar()); + } else { + LogError("Unified calendar not found."); + } + } else { + ThrowMsg(UnknownException, "Getting a unified calendar failed by unknown reason."); + } + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return JSValueMakeUndefined(context); +} + +JSValueRef JSCalendarManager::getCalendar(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + CalendarManagerPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); + + AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_GET_CALENDAR); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + Try { + if (!privateObject) { + ThrowMsg(ConversionException, "Object is null."); + } + + // Global context should be passed to the calendar object. + JSContextRef globalContext = privateObject->getContext(); + + CalendarConverter converter(globalContext); + + CalendarEvent::CalendarType calendarType = CalendarEvent::UNDEFINED_TYPE; + if (argumentCount>=1) { + calendarType = converter.toCalendarType(converter.toString(arguments[0])); + } else { + ThrowMsg(ConversionException, "Wrong parameter count."); + } + + std::string calendarId; + if (argumentCount>=2) { + calendarId = converter.toString(arguments[1]); + } + + IEventGetCalendarPtr dplEvent(new IEventGetCalendar()); + dplEvent->setForSynchronousCall(); + dplEvent->setId(calendarId); + dplEvent->setType(calendarType); + privateObject->getObject()->getCalendar(dplEvent); + + // Process the result. + if (dplEvent->getResult()) { + if( dplEvent->getCalendar() ) { + return converter.toJSValueRefCalendar(dplEvent->getCalendar()); + } else { + ThrowMsg(NotFoundException, "Calendar not found."); + } + } else { + ThrowMsg(UnknownException, "Getting a calendar failed by unknown reason."); + } + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch (NotFoundException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } +} + +const JSClassRef JSCalendarManager::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSCalendarManager::getClassInfo() +{ + return &m_classInfo; +} + +} +} diff --git a/src/Calendar/JSCalendarManager.h b/src/Calendar/JSCalendarManager.h new file mode 100755 index 0000000..0fa49d9 --- /dev/null +++ b/src/Calendar/JSCalendarManager.h @@ -0,0 +1,173 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _JS_TIZEN_CALENDAR_MANAGER_H_ +#define _JS_TIZEN_CALENDAR_MANAGER_H_ + +#include +#include +#include "ICalendarManager.h" +#include "ICalendar.h" + +namespace DeviceAPI { +namespace Calendar { + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject CalendarManagerPrivObject; + +#define TIZEN_CALENDAR_PROPERTY_VCALENDAR_20_FORMAT "ICALENDAR_20" +#define TIZEN_CALENDAR_PROPERTY_VCALENDAR_10_FORMAT "VCALENDAR_10" + +#define TIZEN_CALENDAR_PROPERTY_TENTATIVE_STATUS "TENTATIVE" +#define TIZEN_CALENDAR_PROPERTY_CONFIRMED_STATUS "CONFIRMED" +#define TIZEN_CALENDAR_PROPERTY_CANCELLED_STATUS "CANCELLED" +#define TIZEN_CALENDAR_PROPERTY_NEEDS_ACTION_STATUS "NEEDS_ACTION" +#define TIZEN_CALENDAR_PROPERTY_IN_PROCESS_STATUS "IN_PROCESS" +#define TIZEN_CALENDAR_PROPERTY_COMPLETED_STATUS "COMPLETED" +#define TIZEN_CALENDAR_PROPERTY_PENDING_STATUS "PENDING" +#define TIZEN_CALENDAR_PROPERTY_ACCEPTED_STATUS "ACCEPTED" +#define TIZEN_CALENDAR_PROPERTY_DECLINED_STATUS "DECLINED" +#define TIZEN_CALENDAR_PROPERTY_DELEGATED_STATUS "DELEGATED" + +#define TIZEN_CALENDAR_PROPERTY_HIGH_PRIORITY "HIGH" +#define TIZEN_CALENDAR_PROPERTY_MEDIUM_PRIORITY "MEDIUM" +#define TIZEN_CALENDAR_PROPERTY_LOW_PRIORITY "LOW" + +#define TIZEN_CALENDAR_PROPERTY_PUBLIC_VISIBILITY "PUBLIC" +#define TIZEN_CALENDAR_PROPERTY_PRIVATE_VISIBILITY "PRIVATE" +#define TIZEN_CALENDAR_PROPERTY_CONFIDENTIAL_VISIBILITY "CONFIDENTIAL" + +#define TIZEN_CALENDAR_PROPERTY_BUSY "BUSY" +#define TIZEN_CALENDAR_PROPERTY_BUSY_UNAVAILABLE_FB "BUSY_UNAVAILABLE" +#define TIZEN_CALENDAR_PROPERTY_FREE "FREE" +#define TIZEN_CALENDAR_PROPERTY_BUSY_TENTATIVE "BUSY_TENTATIVE" + +#define TIZEN_CALENDAR_PROPERTY_REQ_PARTICIPANT_ROLE "REQ_PARTICIPANT" +#define TIZEN_CALENDAR_PROPERTY_OPT_PARTICIPANT_ROLE "OPT_PARTICIPANT" +#define TIZEN_CALENDAR_PROPERTY_NON_PARTICIPANT_ROLE "NON_PARTICIPANT" +#define TIZEN_CALENDAR_PROPERTY_CHAIR_ROLE "CHAIR" + +#define TIZEN_CALENDAR_PROPERTY_INDIVIDUAL_TYPE "INDIVIDUAL" +#define TIZEN_CALENDAR_PROPERTY_GROUP_TYPE "GROUP" +#define TIZEN_CALENDAR_PROPERTY_RESOURCE_TYPE "RESOURCE" +#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_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_DISPLAY_ALARM "DISPLAY" +#define TIZEN_CALENDAR_PROPERTY_SOUND_ALARM "SOUND" + +#define TIZEN_CALENDAR_PROPERTY_TYPE_EVENT "EVENT" +#define TIZEN_CALENDAR_PROPERTY_TYPE_TASK "TASK" + +class JSCalendarManager +{ + public: + enum TizenAlarmType + { + NO_ALARM = 0, + SILENT_ALARM = 1, + SOUND_ALARM = 2, + INVALID_ALARM = 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 Calendars. + */ + static JSValueRef getCalendars(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Get a default calendar. + */ + static JSValueRef getDefaultCalendar(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Get a unified calendar. + */ + static JSValueRef getUnifiedCalendar(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Get a calendar. + */ + static JSValueRef getCalendar(JSContextRef context, + JSObjectRef object, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); +}; + +} +} +#endif /* _JS_TIZEN_CALENDAR_MANAGER_H_ */ diff --git a/src/Calendar/JSCalendarRecurrenceRule.cpp b/src/Calendar/JSCalendarRecurrenceRule.cpp new file mode 100755 index 0000000..ae2d298 --- /dev/null +++ b/src/Calendar/JSCalendarRecurrenceRule.cpp @@ -0,0 +1,338 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#include "JSCalendarRecurrenceRule.h" +#include +#include +#include +#include +#include "CalendarConverter.h" +#include +#include + + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; +using namespace DeviceAPI::Time; + +namespace DeviceAPI { +namespace Calendar { + +JSClassDefinition JSCalendarRecurrenceRule::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_INTERFACE_CALENDAR_RECURRENCE_RULE, + 0, + m_property, + NULL, //m_function, + initialize, + finalize, + NULL, //hasProperty, + NULL, //getProperty, + NULL, //setProperty, + NULL, //deleteProperty, + NULL, //getPropertyNames, + NULL, //callAsFunction, + constructor, + NULL, //hasInstance, + NULL, //convertToType, +}; + +JSStaticValue JSCalendarRecurrenceRule::m_property[] = { + { TIZEN_RECURRENCE_RULE_FREQUENCY, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_RECURRENCE_RULE_INTERVAL, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_RECURRENCE_RULE_UNTIL_DATE, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_RECURRENCE_RULE_OCCURRENCE_COUNT, getProperty, setProperty, kJSPropertyAttributeNone }, +// { TIZEN_RECURRENCE_RULE_DAYS_OF_THE_MONTH, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_RECURRENCE_RULE_DAYS_OF_THE_WEEK, getProperty, setProperty, kJSPropertyAttributeNone }, +// { TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR, getProperty, setProperty, kJSPropertyAttributeNone }, +// { TIZEN_RECURRENCE_RULE_WEEKS_OF_THE_YEAR, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_RECURRENCE_RULE_SET_POSITIONS, getProperty, setProperty, kJSPropertyAttributeNone }, + { TIZEN_RECURRENCE_RULE_EXCEPTIONS, getProperty, setProperty, kJSPropertyAttributeNone }, + + { 0, 0, 0, 0 } +}; + +JSClassRef JSCalendarRecurrenceRule::m_jsClassRef = JSClassCreate( + JSCalendarRecurrenceRule::getClassInfo()); + +const JSClassDefinition* JSCalendarRecurrenceRule::getClassInfo() +{ + return &(m_classInfo); +} + +JSClassRef JSCalendarRecurrenceRule::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +JSObjectRef JSCalendarRecurrenceRule::createJSCalendarRecurrenceRule(JSContextRef context, EventRecurrenceRulePtr rule) +{ + RecurrenceRulePrivateObject *priv = new RecurrenceRulePrivateObject(context, rule); + return JSObjectMake(context, getClassRef(), priv); +} + +void JSCalendarRecurrenceRule::initialize(JSContextRef context, JSObjectRef object) +{ + if (!JSObjectGetPrivate(object)) { + LogDebug("Create calendar rrule private object."); + EventRecurrenceRulePtr rrule( new EventRecurrenceRule() ); + RecurrenceRulePrivateObject *priv = new RecurrenceRulePrivateObject(context, rrule); + if (!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } else { + LogDebug("Private object already set."); + } +} + +void JSCalendarRecurrenceRule::finalize(JSObjectRef object) +{ + RecurrenceRulePrivateObject* priv = static_cast(JSObjectGetPrivate(object)); + if (priv) { + delete priv; + JSObjectSetPrivate(object, NULL); + } +} + +EventRecurrenceRulePtr JSCalendarRecurrenceRule::getPrivateObject(JSObjectRef object) +{ + RecurrenceRulePrivateObject *priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(NullPointerException, "Private object is null."); + } + EventRecurrenceRulePtr result = priv->getObject(); + if (!result) { + ThrowMsg(NullPointerException, "Private object is null."); + } + return result; +} + +void JSCalendarRecurrenceRule::setPrivateObject(const EventRecurrenceRulePtr &rrule, + JSContextRef ctx, + const JSObjectRef object) +{ + Try + { + RecurrenceRulePrivateObject *priv = + static_cast(JSObjectGetPrivate(object)); + delete priv; + priv = new RecurrenceRulePrivateObject(ctx, rrule); + if (!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } + Catch(Exception) + { + LogError("Error during replacing rrule object."); + } +} + +JSObjectRef JSCalendarRecurrenceRule::constructor(JSContextRef context, + JSObjectRef constructor, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + CalendarConverter converter(context); + EventRecurrenceRulePtr rrule; + + if (argumentCount==0) { + EventRecurrenceRulePtr result( new EventRecurrenceRule()); + rrule = result; + } else if (argumentCount==1) { + EventRecurrenceRulePtr result( new EventRecurrenceRule()); + rrule = result; + rrule->setFrequency(converter.toRecurrenceFrequency(converter.toString(arguments[0]))); + } else if (argumentCount>=2) { + if (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1])) { + EventRecurrenceRulePtr result( new EventRecurrenceRule()); + rrule = result; + } else { + if (!JSValueIsObject(context, arguments[1])) { + ThrowMsg(ConversionException, "Wrong second parameter type."); + } + + rrule = converter.toEventRecurrenceRule(arguments[1]); + if (!rrule) { + ThrowMsg(ConversionException, "Parameter conversion failed."); + } + } + rrule->setFrequency(converter.toRecurrenceFrequency(converter.toString(arguments[0]))); + } + + return createJSCalendarRecurrenceRule(context, rrule); + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return NULL; +} + +JSValueRef JSCalendarRecurrenceRule::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + CalendarConverter converter(context); + TimeUtilConverter timeConverter(context); + Try + { + RecurrenceRulePrivateObject* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(NullPointerException, "Private object is NULL."); + } + EventRecurrenceRulePtr rrule = priv->getObject(); + if (!rrule) { + ThrowMsg(NullPointerException, "recurrenceRule is NULL."); + } + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_FREQUENCY)) { + return converter.toJSValueRef(converter.toTizenValue(rrule->getFrequency())); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_INTERVAL)) { + return converter.toJSValueRef(rrule->getInterval()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_UNTIL_DATE)) { + if (UNDEFINED_TIME==rrule->getEndDate()) { + return JSValueMakeNull(context); + } else { + return timeConverter.toJSValueRefTZDate((double)(rrule->getEndDate()*1000.0), rrule->getTimeZone()); + } + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_OCCURRENCE_COUNT)) { + return converter.toJSValueRefLong(rrule->getOccurrenceCount()); + //} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_MONTH)) { + //return converter.toJSValueRef(rrule->getDaysOfTheMonth()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_WEEK)) { + return converter.toJSValueRef(rrule->getDaysOfTheWeek()); + //} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR)) { + //return converter.toJSValueRef(rrule->getDaysOfTheYear()); + //} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_WEEKS_OF_THE_YEAR)) { + //return converter.toJSValueRef(rrule->getWeeksOfTheYear()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_SET_POSITIONS)) { + return converter.toJSValueRefNumberArray(rrule->getSetPositions()); + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_EXCEPTIONS)) { + return converter.toJSValueRefTZDateArray(rrule->getExceptions()); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarRecurrenceRule::setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + CalendarConverter converter(context); + Try + { + RecurrenceRulePrivateObject* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(NullPointerException, "Private object is NULL."); + } + EventRecurrenceRulePtr rrule = priv->getObject(); + + if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_FREQUENCY)) { + std::string frequency = converter.toString(value); + rrule->setFrequency(converter.toRecurrenceFrequency(frequency)); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_INTERVAL)) { + int interval = converter.toInt(value); + rrule->setInterval(interval); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_UNTIL_DATE)) { + if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) { + ThrowMsg(ConversionException, "Wrong untilDate type."); + } + TimeUtilConverter timeConverter(context); + long long int untilDate = (long long int) (timeConverter.getTimeInMilliseconds(value)/1000); + rrule->setEndDate(untilDate); +/* + if( rrule->getTimeZone().empty() ) { + std::string timeZone = timeConverter.getPropertiesInTZDate(value).timezone; + rrule->setTimeZone(timeZone); + } +*/ + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_OCCURRENCE_COUNT)) { + long occurrenceCount = converter.toLong(value); + rrule->setOccurrenceCount(occurrenceCount); + return true; + /*} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_MONTH)) { + std::vector daysOfTheMonth = converter.toVectorOfInts(value); + rrule->setDaysOfTheMonth(daysOfTheMonth); + return true;*/ + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_WEEK)) { + rrule->setDaysOfTheWeek(converter.toStringArray(value)); + return true; + /*} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR)) { + std::vector daysOfTheYear = converter.toVectorOfInts(value); + rrule->setDaysOfTheYear(daysOfTheYear); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_WEEKS_OF_THE_YEAR)) { + std::vector weekOfTheYear = converter.toVectorOfInts(value); + rrule->setWeeksOfTheYear(weekOfTheYear); + return true;*/ + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_SET_POSITIONS)) { + rrule->setSetPositions(converter.toNumberArray(value)); + return true; + } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_EXCEPTIONS)) { + rrule->setExceptions(converter.toTZDateArray(value)); + return true; + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR); + return false; +} + +} +} diff --git a/src/Calendar/JSCalendarRecurrenceRule.h b/src/Calendar/JSCalendarRecurrenceRule.h new file mode 100755 index 0000000..683c7b8 --- /dev/null +++ b/src/Calendar/JSCalendarRecurrenceRule.h @@ -0,0 +1,118 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _JS_CALENDAR_RECURRENCE_RULE_H_ +#define _JS_CALENDAR_RECURRENCE_RULE_H_ + +#include +#include +#include +#include +#include "CalendarEvent.h" +#include "EventRecurrenceRule.h" + +namespace DeviceAPI { +namespace Calendar { + +#define TIZEN_INTERFACE_CALENDAR_RECURRENCE_RULE "CalendarRecurrenceRule" + +#define TIZEN_RECURRENCE_RULE_FREQUENCY "frequency" +#define TIZEN_RECURRENCE_RULE_INTERVAL "interval" +#define TIZEN_RECURRENCE_RULE_UNTIL_DATE "untilDate" +#define TIZEN_RECURRENCE_RULE_OCCURRENCE_COUNT "occurrenceCount" +//#define TIZEN_RECURRENCE_RULE_DAYS_OF_THE_MONTH "daysOfTheMonth" +#define TIZEN_RECURRENCE_RULE_DAYS_OF_THE_WEEK "daysOfTheWeek" +//#define TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR "daysOfTheYear" +//#define TIZEN_RECURRENCE_RULE_WEEKS_OF_THE_YEAR "weeksOfTheYear" +#define TIZEN_RECURRENCE_RULE_SET_POSITIONS "setPositions" +#define TIZEN_RECURRENCE_RULE_EXCEPTIONS "exceptions" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject RecurrenceRulePrivateObject; + +class JSCalendarRecurrenceRule +{ + public: + + static const JSClassDefinition* getClassInfo(); + + static JSClassRef getClassRef(); + + static JSObjectRef createJSCalendarRecurrenceRule(JSContextRef context, EventRecurrenceRulePtr rule); + + static EventRecurrenceRulePtr getPrivateObject(JSObjectRef object); + + static void setPrivateObject(const EventRecurrenceRulePtr &rrule, + JSContextRef ctx, + const JSObjectRef object); + + private: + + /** + * The callback invoked when an object is first created. + */ + static void initialize(JSContextRef context, JSObjectRef object); + + /** + * The callback invoked when an object is finalized. + */ + static void finalize(JSObjectRef object); + + /** + * Constructor for the CalendarRecurrenceRule interface. + */ + static JSObjectRef constructor(JSContextRef context, + JSObjectRef constructor, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + + static JSClassRef m_jsClassRef; + + /** + * This structure describes a statically declared function property. + */ + static JSStaticFunction m_function[]; + + /** + * This structure contains properties and callbacks that define a type of object. + */ + static JSClassDefinition m_classInfo; + + /** + * This member variable contains the initialization values for the static properties of this class. + * The values are given according to the data structure JSPropertySpec + */ + static JSStaticValue m_property[]; +}; + +} +} + +#endif /* _JS_CALENDAR_RECURRENCE_RULE_H_ */ diff --git a/src/Calendar/JSCalendarTask.cpp b/src/Calendar/JSCalendarTask.cpp new file mode 100755 index 0000000..acb0db0 --- /dev/null +++ b/src/Calendar/JSCalendarTask.cpp @@ -0,0 +1,280 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include "EventId.h" +#include "ICalendar.h" +#include "CalendarFactory.h" +#include "JSCalendarTask.h" +#include "JSCalendarItemProperties.h" +#include "CalendarConverter.h" +#include "JSCalendarEventId.h" +#include +#include +#include +#include + + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; +using namespace DeviceAPI::Time; + +namespace DeviceAPI { +namespace Calendar { + +JSClassDefinition JSCalendarTask::m_classInfo = { + 0, + kJSClassAttributeNone, + TIZEN_INTERFACE_CALENDAR_TASK, + JSCalendarItemProperties::getClassRef(), + m_property, + NULL, //m_function, + initialize, + finalize, + NULL, //hasProperty, + NULL, //getProperty, + NULL, //setProperty, + NULL, //DeleteProperty, + NULL, //GetPropertyNames, + NULL, //CallAsFunction, + constructor, + NULL, //HasInstance, + NULL //ConvertToType +}; + +JSStaticValue JSCalendarTask::m_property[] = { + //Task properties + { TIZEN_CALENDAR_TASK_ID, getPropertyId, NULL, kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSClassRef JSCalendarTask::m_jsClassRef = JSClassCreate(JSCalendarTask::getClassInfo()); + +ICalendarPtr JSCalendarTask::m_calendar = CalendarFactory::getInstance().createCalendarObject(); + +void JSCalendarTask::initialize(JSContextRef context, + JSObjectRef object) +{ + if (!JSObjectGetPrivate(object)) { + LogDebug("Create calendar task private object."); + CalendarEventPtr task( new CalendarEvent() ); + CalendarTaskPrivObject *priv = new CalendarTaskPrivObject(context, task); + if (!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } else { + LogDebug("Private object already set."); + } + + if (m_calendar) { + m_calendar->setType(CalendarEvent::TASK_TYPE); + LogDebug("Calendar object type is set to task."); + } +} + +void JSCalendarTask::finalize(JSObjectRef object) +{ + CalendarTaskPrivObject* priv = static_cast(JSObjectGetPrivate(object)); + if (priv) { + delete priv; + JSObjectSetPrivate(object, NULL); + } +} + +JSObjectRef JSCalendarTask::constructor(JSContextRef context, + JSObjectRef constructor, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + CalendarConverter converter(context); + CalendarEventPtr task; + + if (argumentCount==0) { + CalendarEventPtr result(new CalendarEvent()); + task = result; + } else if (argumentCount==1) { + LogInfo("taskInitDict case"); + if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) { + CalendarEventPtr result(new CalendarEvent()); + task = result; + } else if (JSValueIsObject(context, arguments[0])) { + task = converter.toEvent(arguments[0]); + if (!task) { + ThrowMsg(ConversionException, "Parameter conversion failed."); + } + } else { + ThrowMsg(ConversionException, "Parameter conversion failed."); + } + } else if (argumentCount>=2) { + LogInfo("task stringRepresentation case"); + std::string eventStr; + CalendarEvent::VObjectFormat format = CalendarEvent::UNDEFINED_FORMAT; + eventStr = converter.toString(arguments[0]); + format = converter.toVObjectFormat(converter.toString(arguments[1])); + + IEventCreateEventFromStringPtr dplEvent(new IEventCreateEventFromString()); + dplEvent->setEventString(eventStr); + dplEvent->setFormat(format); + dplEvent->setForSynchronousCall(); + m_calendar->createEventFromString(dplEvent); + + // Process the returned object. + if (dplEvent->getResult()) { + LogInfo("Successfully created a task."); + task = dplEvent->getEvent(); + } else { + if (dplEvent->getExceptionCode()==ExceptionCodes::InvalidArgumentException) { + ThrowMsg(InvalidArgumentException, "Wrong string to convert."); + } else { + ThrowMsg(UnknownException, "Converting string failed."); + } + } + } + + task->setCalendarType(CalendarEvent::TASK_TYPE); + return createJSCalendarTask(context, task); + } + Catch(UnsupportedException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage()); + } + Catch(InvalidArgumentException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage()); + } + Catch(ConversionException) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage()); + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage()); + } + + return NULL; +} + +JSObjectRef JSCalendarTask::createJSCalendarTask(JSContextRef context, CalendarEventPtr task) +{ + CalendarTaskPrivObject *priv = new CalendarTaskPrivObject(context, task); + return JSObjectMake(context, getClassRef(), priv); +} + +const JSClassRef JSCalendarTask::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSCalendarTask::getClassInfo() +{ + return &m_classInfo; +} + +CalendarEventPtr JSCalendarTask::getPrivateObject(JSObjectRef object) +{ + CalendarTaskPrivObject *priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + ThrowMsg(NullPointerException, "Private object is null"); + } + CalendarEventPtr result = priv->getObject(); + if (!result) { + ThrowMsg(NullPointerException, "Private object is null"); + } + return result; +} + +void JSCalendarTask::setPrivateObject(const CalendarEventPtr &event, + JSContextRef ctx, + const JSObjectRef object) +{ + Try + { + CalendarTaskPrivObject *priv = + static_cast(JSObjectGetPrivate(object)); + delete priv; + priv = new CalendarTaskPrivObject(ctx, event); + if (!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } + Catch(Exception) + { + LogError("Error during replacing task object"); + } +} + +JSValueRef JSCalendarTask::getPropertyId(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + CalendarTaskPrivObject *privateObject = + static_cast(JSObjectGetPrivate(object)); + CalendarEventPtr task = privateObject->getObject(); + + if (task->getUId()==UNDEFINED_ID) { + return JSValueMakeNull(context); + } else { + return Converter(context).toJSValueRef(task->getUId()); + } + } + Catch(Exception) + { + LogWarning("Exception: "<<_rethrown_exception.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCalendarTask::validate(JSContextRef ctx, + const JSObjectRef object, + JSValueRef* exception) +{ + CalendarTaskPrivObject *priv = + static_cast(JSObjectGetPrivate(object)); + if (priv == NULL) { + return false; + } + CalendarEventPtr event = priv->getObject(); + if (!event) { + return false; + } + return event->validate(); +} + +} +} diff --git a/src/Calendar/JSCalendarTask.h b/src/Calendar/JSCalendarTask.h new file mode 100755 index 0000000..edffa6f --- /dev/null +++ b/src/Calendar/JSCalendarTask.h @@ -0,0 +1,115 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_TASK_H_ +#define _JS_CALENDAR_TASK_H_ + +#include +#include "CalendarEvent.h" +#include + +namespace DeviceAPI { +namespace Calendar { + +#define TIZEN_INTERFACE_CALENDAR_TASK "CalendarTask" + +#define TIZEN_CALENDAR_TASK_ID "id" +#define TIZEN_CALENDAR_TASK_LAST_MODIFICATION_DATE "lastModificationDate" + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject CalendarTaskPrivObject; + +class JSCalendarTask +{ + public: + + static const JSClassDefinition* getClassInfo(); + + static const JSClassRef getClassRef(); + + static CalendarEventPtr getPrivateObject(JSObjectRef object); + + static void setPrivateObject(const CalendarEventPtr &event, + JSContextRef ctx, + const JSObjectRef object); + + static bool validate(JSContextRef ctx, + const JSObjectRef object, + JSValueRef* exception); + + static JSObjectRef createJSCalendarTask(JSContextRef context, CalendarEventPtr task); + + 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 calendar object to be used for asynchronous platform function invocation. + */ + static ICalendarPtr m_calendar; + + /** + * The callback invoked when an object is first created. + */ + static void initialize(JSContextRef context, + JSObjectRef object); + + /** + * The callback invoked when an object is finalized. + */ + static void finalize(JSObjectRef object); + + /** + * Constructor for the CalendarTask interface. + */ + static JSObjectRef constructor(JSContextRef context, + JSObjectRef constructor, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + /** + * Getters and setters for properties + */ + static JSValueRef getPropertyId(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); +}; + +} +} + +#endif /* _JS_CALENDAR_TASK_H_ */ diff --git a/src/Calendar/JSNumberArray.cpp b/src/Calendar/JSNumberArray.cpp new file mode 100755 index 0000000..f1eb3a4 --- /dev/null +++ b/src/Calendar/JSNumberArray.cpp @@ -0,0 +1,600 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include "JSNumberArray.h" + +#define FUNCTION_CONCAT "concat" +#define FUNCTION_JOIN "join" +#define FUNCTION_POP "pop" +#define FUNCTION_PUSH "push" +#define FUNCTION_REVERSE "reverse" +#define FUNCTION_SHIFT "shift" +#define FUNCTION_SLICE "slice" +#define FUNCTION_SORT "sort" +#define FUNCTION_SPLICE "splice" +#define FUNCTION_TOSTRING "toString" +#define FUNCTION_UNSHIFT "unshift" +#define FUNCTION_VALUEOF "valueOf" +#define ARRAY "Array" +#define ATTRIBUTE_LENGTH "length" + +namespace DeviceAPI { +namespace Calendar { + + +using namespace DeviceAPI::Common; +using namespace WrtDeviceApis::CommonsJavaScript; + +JSClassDefinition JSNumberArray::m_classInfo = { + 0, + kJSClassAttributeNone, + ARRAY, + 0, + m_property, + m_function, + initialize, + finalize, + hasProperty, + getProperty, + setProperty, + NULL, //deleteProperty, + getPropertyNames, + NULL, //callAsFunction, + NULL, //callAsConstructor, + NULL, //hasInstance, + NULL, //convertToType, +}; + +JSStaticValue JSNumberArray::m_property[] = { + { ATTRIBUTE_LENGTH, getLength, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSNumberArray::m_function[] = { + { FUNCTION_CONCAT, concat, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_JOIN, join, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_POP, pop, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_PUSH, push, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_REVERSE, reverse, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_SHIFT, shift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_SLICE, slice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_SORT, sort, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_SPLICE, splice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_TOSTRING, toString, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_UNSHIFT, unshift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_VALUEOF, valueOf, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSClassRef JSNumberArray::m_jsClassRef = JSClassCreate( + JSNumberArray::getClassInfo()); + +JSValueRef JSNumberArray::getLength(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + JSNumberArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + NumberArrayPtr numbers = priv->getObject(); + if (numbers) { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + return converter->toJSValueRef(numbers->size()); + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("invalid conversion"); + } + return JSValueMakeUndefined(context); +} + +JSObjectRef JSNumberArray::createArray(JSContextRef context, + const NumberArrayPtr &numbers) +{ + JSNumberArrayPriv *priv = new JSNumberArrayPriv(context, numbers); + return JSObjectMake(context, getClassRef(), priv); +} + +const JSClassDefinition* JSNumberArray::getClassInfo() +{ + return &(m_classInfo); +} + +JSClassRef JSNumberArray::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +bool JSNumberArray::isObjectOfClass(JSContextRef context, JSValueRef value) +{ + return JSValueIsObjectOfClass(context, value, getClassRef()); +} + +NumberArrayPtr JSNumberArray::getNumberArray(JSContextRef context, JSValueRef value) +{ + if (!isObjectOfClass(context, value)) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + JSObjectRef object = JSValueToObject(context, value, NULL); + if (!object) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + JSNumberArrayPriv* priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + return priv->getObject(); +} + +void JSNumberArray::initialize(JSContextRef context, + JSObjectRef object) +{ +} + +void JSNumberArray::finalize(JSObjectRef object) +{ + JSNumberArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + delete priv; + JSObjectSetPrivate(object, NULL); +} + +bool JSNumberArray::hasProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName) +{ + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + Try + { + size_t index = converter->toSizeT(propertyName); + JSNumberArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + NumberArrayPtr numbers = priv->getObject(); + if (index < numbers->size()) { + return true; + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + //not reporting error is intended + } + return false; +} + +JSValueRef JSNumberArray::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + + Try + { + size_t index = converter->toSizeT(propertyName); + JSNumberArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + NumberArrayPtr numbers = priv->getObject(); + if (index < numbers->size()) { + long long int result = numbers->at(index); + LogInfo("index: "<toJSValueRef(result); + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("invalid property"); + } + return JSValueMakeUndefined(context); +} + +bool JSNumberArray::setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + + Try + { + size_t index = converter->toSizeT(propertyName); + long long int number = 0; + if (!JSValueIsUndefined(context, value)) { + number = converter->toLongLong(value); + } + JSNumberArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + NumberArrayPtr numbers = priv->getObject(); + if (!numbers) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + if (numbers->size() <= index) { + numbers->resize(index + 1); + } + (*numbers)[index] = number; + return true; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch"); + } + return false; +} + +void JSNumberArray::getPropertyNames(JSContextRef context, + JSObjectRef object, + JSPropertyNameAccumulatorRef propertyNames) +{ + Converter converter(context); + + Try + { + JSNumberArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + NumberArrayPtr numbers = priv->getObject(); + + int count = numbers->size(); + + for(int i=0; i < count; i++) + { + ScopedJSStringRef name(converter.toJSStringRef(converter.toString(i))); + JSPropertyNameAccumulatorAddName(propertyNames, name.get()); + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("invalid property"); + } +} + +JSValueRef JSNumberArray::concat(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + NumberArrayPtr numbers = NumberArrayPtr(new NumberArray()); + JSNumberArrayPriv *newPrivateObject = new JSNumberArrayPriv( + context, + numbers); + JSValueRef result = JSObjectMake(context, + getClassRef(), newPrivateObject); + + //copy current numbers + JSNumberArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + NumberArrayPtr currentNumbers = priv->getObject(); + for (size_t i = 0; i < currentNumbers->size(); ++i) { + numbers->push_back(currentNumbers->at(i)); + } + + //copy submitted arrays + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + for (size_t i = 0; i < argumentCount; ++i) { + if (!JSIsArrayValue(context, arguments[i])) { + Throw(WrtDeviceApis::Commons::ConversionException); + } + // process array of numbers + JSObjectRef arrayObj = converter->toJSObjectRef(arguments[i]); + unsigned int len = JSGetArrayLength(context, arrayObj); + for (unsigned int e = 0; e < len; ++e) { + JSValueRef att = JSGetArrayElement(context, arrayObj, e); + numbers->push_back(converter->toLong(att)); + } + } + return result; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch"); +} + +JSValueRef JSNumberArray::join(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + std::string result; + std::string separator(","); + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSNumberArrayPriv* priv = static_cast(JSObjectGetPrivate(thisObject)); + NumberArrayPtr currentNumbers = priv->getObject(); + if (argumentCount > 0 && JSValueIsString(context, arguments[0])) { + separator = converter->toString(arguments[0]); + LogDebug("Separator: "<size(); ++i) { + if (i != 0) { + result += separator; + } + std::stringstream ss; + ss<at(i); + result += ss.str(); + } + LogDebug("Resulting string: "<toJSValueRef(result); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch"); +} + +JSValueRef JSNumberArray::pop(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSNumberArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + NumberArrayPtr currentNumbers = priv->getObject(); + if (currentNumbers->size() > 0) { + long long int result = currentNumbers->at( + currentNumbers->size() - 1); + currentNumbers->pop_back(); + return converter->toJSValueRef(result); + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSNumberArray::push(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSNumberArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + NumberArrayPtr currentNumbers = priv->getObject(); + for (size_t i = 0; i < argumentCount; ++i) { + currentNumbers->push_back(converter->toLong(arguments[i])); + } + return converter->toJSValueRef(currentNumbers->size()); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch"); +} + +JSValueRef JSNumberArray::reverse(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSNumberArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + NumberArrayPtr currentNumbers = priv->getObject(); + std::reverse(currentNumbers->begin(), currentNumbers->end()); + return thisObject; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSNumberArray::shift(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSNumberArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + NumberArrayPtr currentNumbers = priv->getObject(); + if (currentNumbers->size() > 0) { + long long int result = currentNumbers->at(0); + currentNumbers->erase(currentNumbers->begin()); + return converter->toJSValueRef(result); + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSNumberArray::slice(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + if (argumentCount < 1) { + return JSValueMakeUndefined(context); + } + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + NumberArrayPtr numbers = NumberArrayPtr(new NumberArray()); + JSNumberArrayPriv *newPrivateObject = new JSNumberArrayPriv( + context, + numbers); + JSValueRef result = JSObjectMake(context, + getClassRef(), newPrivateObject); + + //copy current numbers + JSNumberArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + NumberArrayPtr currentNumbers = priv->getObject(); + std::size_t first = converter->toSizeT(arguments[0]); + std::size_t last = currentNumbers->size() - 1; + if (argumentCount > 1) { + last = converter->toSizeT(arguments[1]); + if (last >= currentNumbers->size()) { + last = currentNumbers->size() - 1; + } + } + for (size_t i = first; i <= last; ++i) { + numbers->push_back(currentNumbers->at(i)); + } + + return result; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch"); +} + +JSValueRef JSNumberArray::sort(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSNumberArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + NumberArrayPtr currentNumbers = priv->getObject(); + std::sort(currentNumbers->begin(), currentNumbers->end()); + return thisObject; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSNumberArray::splice(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + return JSValueMakeUndefined(context); +} + +JSValueRef JSNumberArray::toString(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + return join(context, function, thisObject, 0, arguments, exception); +} + +JSValueRef JSNumberArray::unshift(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + return JSValueMakeUndefined(context); +} + +JSValueRef JSNumberArray::valueOf(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + return JSValueMakeUndefined(context); +} + +} // Calendar +} // DeviceAPI diff --git a/src/Calendar/JSNumberArray.h b/src/Calendar/JSNumberArray.h new file mode 100755 index 0000000..676279b --- /dev/null +++ b/src/Calendar/JSNumberArray.h @@ -0,0 +1,181 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _TIZEN_CALENDAR_JS_NUMBER_ARRAY_H_ +#define _TIZEN_CALENDAR_JS_NUMBER_ARRAY_H_ + +#include +#include +#include +#include "CalendarEvent.h" + +namespace DeviceAPI { +namespace Calendar { + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSNumberArrayPriv; + +class JSNumberArray +{ +public: + + static const JSClassDefinition* getClassInfo(); + + static JSClassRef getClassRef(); + + static JSObjectRef createArray(JSContextRef context, + const NumberArrayPtr &Numbers); + + static bool isObjectOfClass(JSContextRef context, JSValueRef value); + + static NumberArrayPtr getNumberArray(JSContextRef context, JSValueRef value); + +private: + + /** + * The callback invoked when an object is first created. + */ + static void initialize(JSContextRef context, + JSObjectRef object); + + /** + * The callback invoked when an object is finalized. + */ + static void finalize(JSObjectRef object); + + static JSValueRef getLength(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool hasProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName); + + static JSValueRef getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + + static void getPropertyNames(JSContextRef context, + JSObjectRef object, + JSPropertyNameAccumulatorRef propertyNames); + + static JSValueRef concat(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef join(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef pop(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef push(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef reverse(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef shift(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef slice(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef sort(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef splice(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef toString(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef unshift(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef valueOf(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + static bool checkValue(const long long int &value); + + static JSClassRef m_jsClassRef; + /** + * This structure describes a statically declared function property. + */ + static JSStaticFunction m_function[]; + + /** + * This structure contains properties and callbacks that define a type of object. + */ + static JSClassDefinition m_classInfo; + + /** + * This member variable contains the initialization values for the static properties of this class. + * The values are given according to the data structure JSPropertySpec + */ + static JSStaticValue m_property[]; +}; + +} // Calendar +} // DeviceAPI + +#endif // _TIZEN_CALENDAR_JS_NUMBER_ARRAY_H_ diff --git a/src/Calendar/JSStringArray.cpp b/src/Calendar/JSStringArray.cpp new file mode 100755 index 0000000..6f18ea6 --- /dev/null +++ b/src/Calendar/JSStringArray.cpp @@ -0,0 +1,595 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include "CalendarConverter.h" +#include "JSStringArray.h" + +#define FUNCTION_CONCAT "concat" +#define FUNCTION_JOIN "join" +#define FUNCTION_POP "pop" +#define FUNCTION_PUSH "push" +#define FUNCTION_REVERSE "reverse" +#define FUNCTION_SHIFT "shift" +#define FUNCTION_SLICE "slice" +#define FUNCTION_SORT "sort" +#define FUNCTION_SPLICE "splice" +#define FUNCTION_TOSTRING "toString" +#define FUNCTION_UNSHIFT "unshift" +#define FUNCTION_VALUEOF "valueOf" +#define ARRAY "Array" +#define ATTRIBUTE_LENGTH "length" + +namespace DeviceAPI { +namespace Calendar { + + +using namespace DeviceAPI::Common; +using namespace WrtDeviceApis::CommonsJavaScript; + +JSClassDefinition JSStringArray::m_classInfo = { + 0, + kJSClassAttributeNone, + ARRAY, + 0, + m_property, + m_function, + initialize, + finalize, + hasProperty, + getProperty, + setProperty, + NULL, //deleteProperty, + getPropertyNames, + NULL, //callAsFunction, + NULL, //callAsConstructor, + NULL, //hasInstance, + NULL, //convertToType, +}; + +JSStaticValue JSStringArray::m_property[] = { + { ATTRIBUTE_LENGTH, getLength, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSStringArray::m_function[] = { + { FUNCTION_CONCAT, concat, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_JOIN, join, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_POP, pop, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_PUSH, push, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_REVERSE, reverse, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_SHIFT, shift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_SLICE, slice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_SORT, sort, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_SPLICE, splice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_TOSTRING, toString, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_UNSHIFT, unshift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_VALUEOF, valueOf, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSClassRef JSStringArray::m_jsClassRef = JSClassCreate( + JSStringArray::getClassInfo()); + +JSValueRef JSStringArray::getLength(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + JSStringArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + StringArrayPtr strs = priv->getObject(); + if (strs) { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + return converter->toJSValueRef(strs->size()); + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("invalid conversion"); + } + return JSValueMakeUndefined(context); +} + +JSObjectRef JSStringArray::createArray(JSContextRef context, + const StringArrayPtr &strs) +{ + JSStringArrayPriv *priv = new JSStringArrayPriv(context, strs); + return JSObjectMake(context, getClassRef(), priv); +} + +const JSClassDefinition* JSStringArray::getClassInfo() +{ + return &(m_classInfo); +} + +JSClassRef JSStringArray::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +bool JSStringArray::isObjectOfClass(JSContextRef context, JSValueRef value) +{ + return JSValueIsObjectOfClass(context, value, getClassRef()); +} + +StringArrayPtr JSStringArray::getStringArray(JSContextRef context, JSValueRef value) +{ + if (!isObjectOfClass(context, value)) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + JSObjectRef object = JSValueToObject(context, value, NULL); + if (!object) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + JSStringArrayPriv* priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + return priv->getObject(); +} + +void JSStringArray::initialize(JSContextRef context, + JSObjectRef object) +{ +} + +void JSStringArray::finalize(JSObjectRef object) +{ + JSStringArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + delete priv; + JSObjectSetPrivate(object, NULL); +} + +bool JSStringArray::hasProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName) +{ + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + Try + { + size_t index = converter->toSizeT(propertyName); + JSStringArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + StringArrayPtr strs = priv->getObject(); + if (index < strs->size()) { + return true; + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + //not reporting error is intended + } + return false; +} + +JSValueRef JSStringArray::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + Try + { + size_t index = converter->toSizeT(propertyName); + JSStringArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + StringArrayPtr strs = priv->getObject(); + if (index < strs->size()) { + std::string result = strs->at(index); + if (!result.empty()) { + return converter->toJSValueRef(result); + } + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("invalid property"); + } + return JSValueMakeUndefined(context); +} + +bool JSStringArray::setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + Try + { + size_t index = converter->toSizeT(propertyName); + std::string str; + if (!JSValueIsUndefined(context, value)) { + str = converter->toString(value); + } + JSStringArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + StringArrayPtr strs = priv->getObject(); + if (!strs) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + if (strs->size() <= index) { + strs->resize(index + 1); + } + (*strs)[index] = str; + return true; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch"); + } + return false; +} + +void JSStringArray::getPropertyNames(JSContextRef context, + JSObjectRef object, + JSPropertyNameAccumulatorRef propertyNames) +{ + CalendarConverter converter(context); + + Try + { + JSStringArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + StringArrayPtr strings = priv->getObject(); + + int count = strings->size(); + + for(int i=0; i < count; i++) + { + ScopedJSStringRef name(converter.toJSStringRef(converter.toString(i))); + JSPropertyNameAccumulatorAddName(propertyNames, name.get()); + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("invalid property"); + } +} + +JSValueRef JSStringArray::concat(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + StringArrayPtr strs = StringArrayPtr(new StringArray()); + JSStringArrayPriv *newPrivateObject = new JSStringArrayPriv( + context, + strs); + JSValueRef result = JSObjectMake(context, + getClassRef(), newPrivateObject); + + //copy current strs + JSStringArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + StringArrayPtr currentStrings = priv->getObject(); + for (size_t i = 0; i < currentStrings->size(); ++i) { + strs->push_back(currentStrings->at(i)); + } + + //copy submitted arrays + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + for (size_t i = 0; i < argumentCount; ++i) { + if (!JSIsArrayValue(context, arguments[i])) { + Throw(WrtDeviceApis::Commons::ConversionException); + } + // process array of strings + JSObjectRef arrayObj = converter->toJSObjectRef(arguments[i]); + unsigned int len = JSGetArrayLength(context, arrayObj); + for (unsigned int e = 0; e < len; ++e) { + JSValueRef att = JSGetArrayElement(context, arrayObj, e); + strs->push_back(converter->toString(att)); + } + } + return result; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch"); +} + +JSValueRef JSStringArray::join(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + std::string result; + std::string separator(","); + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSStringArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + StringArrayPtr currentStrings = priv->getObject(); + if (argumentCount > 0 && JSValueIsString(context, arguments[0])) { + separator = converter->toString(arguments[0]); + } + for (size_t i = 0; i < currentStrings->size(); ++i) { + if (i != 0) { + result += separator; + } + result += currentStrings->at(i); + } + return converter->toJSValueRef(result); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch"); +} + +JSValueRef JSStringArray::pop(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSStringArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + StringArrayPtr currentStrings = priv->getObject(); + if (currentStrings->size() > 0) { + std::string result = currentStrings->at( + currentStrings->size() - 1); + currentStrings->pop_back(); + return converter->toJSValueRef(result); + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSStringArray::push(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSStringArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + StringArrayPtr currentStrings = priv->getObject(); + for (size_t i = 0; i < argumentCount; ++i) { + currentStrings->push_back(converter->toString(arguments[i])); + } + return converter->toJSValueRef(currentStrings->size()); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch"); +} + +JSValueRef JSStringArray::reverse(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSStringArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + StringArrayPtr currentStrings = priv->getObject(); + std::reverse(currentStrings->begin(), currentStrings->end()); + return thisObject; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSStringArray::shift(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSStringArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + StringArrayPtr currentStrings = priv->getObject(); + if (currentStrings->size() > 0) { + std::string result = currentStrings->at(0); + currentStrings->erase(currentStrings->begin()); + return converter->toJSValueRef(result); + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSStringArray::slice(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + if (argumentCount < 1) { + return JSValueMakeUndefined(context); + } + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + StringArrayPtr strs = StringArrayPtr(new StringArray()); + JSStringArrayPriv *newPrivateObject = new JSStringArrayPriv( + context, + strs); + JSValueRef result = JSObjectMake(context, + getClassRef(), newPrivateObject); + + //copy current strs + JSStringArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + StringArrayPtr currentStrings = priv->getObject(); + std::size_t first = converter->toSizeT(arguments[0]); + std::size_t last = currentStrings->size() - 1; + if (argumentCount > 1) { + last = converter->toSizeT(arguments[1]); + if (last >= currentStrings->size()) { + last = currentStrings->size() - 1; + } + } + for (size_t i = first; i <= last; ++i) { + strs->push_back(currentStrings->at(i)); + } + + return result; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch"); +} + +JSValueRef JSStringArray::sort(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSStringArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + StringArrayPtr currentStrings = priv->getObject(); + std::sort(currentStrings->begin(), currentStrings->end()); + return thisObject; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSStringArray::splice(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + return JSValueMakeUndefined(context); +} + +JSValueRef JSStringArray::toString(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + return join(context, function, thisObject, 0, arguments, exception); +} + +JSValueRef JSStringArray::unshift(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + return JSValueMakeUndefined(context); +} + +JSValueRef JSStringArray::valueOf(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + return JSValueMakeUndefined(context); +} + +} // Calendar +} // DeviceAPI diff --git a/src/Calendar/JSStringArray.h b/src/Calendar/JSStringArray.h new file mode 100755 index 0000000..4a4825c --- /dev/null +++ b/src/Calendar/JSStringArray.h @@ -0,0 +1,180 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _TIZEN_CALENDAR_JS_STRING_ARRAY_H_ +#define _TIZEN_CALENDAR_JS_STRING_ARRAY_H_ + +#include +#include +#include +#include "CalendarEvent.h" + +namespace DeviceAPI { +namespace Calendar { + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSStringArrayPriv; + +class JSStringArray +{ +public: + + static const JSClassDefinition* getClassInfo(); + + static JSClassRef getClassRef(); + + static JSObjectRef createArray(JSContextRef context, + const StringArrayPtr &Strings); + + static bool isObjectOfClass(JSContextRef context, JSValueRef value); + + static StringArrayPtr getStringArray(JSContextRef context, JSValueRef value); + +private: + + /** + * The callback invoked when an object is first created. + */ + static void initialize(JSContextRef context, + JSObjectRef object); + + /** + * The callback invoked when an object is finalized. + */ + static void finalize(JSObjectRef object); + + static JSValueRef getLength(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool hasProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName); + + static JSValueRef getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + + static void getPropertyNames(JSContextRef context, + JSObjectRef object, + JSPropertyNameAccumulatorRef propertyNames); + + static JSValueRef concat(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef join(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef pop(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef push(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef reverse(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef shift(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef slice(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef sort(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef splice(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef toString(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef unshift(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef valueOf(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + static bool checkValue(const std::string &value); + + static JSClassRef m_jsClassRef; + /** + * This structure describes a statically declared function property. + */ + static JSStaticFunction m_function[]; + + /** + * This structure contains properties and callbacks that define a type of object. + */ + static JSClassDefinition m_classInfo; + + /** + * This member variable contains the initialization values for the static properties of this class. + * The values are given according to the data structure JSPropertySpec + */ + static JSStaticValue m_property[]; +}; + +} // Calendar +} // DeviceAPI + +#endif // _TIZEN_CALENDAR_JS_STRING_ARRAY_H_ \ No newline at end of file diff --git a/src/Calendar/JSTZDateArray.cpp b/src/Calendar/JSTZDateArray.cpp new file mode 100755 index 0000000..200d89f --- /dev/null +++ b/src/Calendar/JSTZDateArray.cpp @@ -0,0 +1,611 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include "JSTZDateArray.h" +#include + +#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 DeviceAPI { +namespace Calendar { + + +using namespace DeviceAPI::Common; +using namespace DeviceAPI::Time; +using namespace WrtDeviceApis::CommonsJavaScript; + +JSClassDefinition JSTZDateArray::m_classInfo = { + 0, + kJSClassAttributeNone, + ARRAY, + 0, + m_property, + m_function, + initialize, + finalize, + hasProperty, + getProperty, + setProperty, + NULL, //deleteProperty, + getPropertyNames, + NULL, //callAsFunction, + NULL, //callAsConstructor, + NULL, //hasInstance, + NULL, //convertToType, +}; + +JSStaticValue JSTZDateArray::m_property[] = { + { ATTRIBUTE_LENGTH, getLength, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSTZDateArray::m_function[] = { + { FUNCTION_CONCAT, concat, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_JOIN, join, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_POP, pop, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_PUSH, push, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_REVERSE, reverse, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_SHIFT, shift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_SLICE, slice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_SORT, sort, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_SPLICE, splice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_TOSTRING, toString, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_UNSHIFT, unshift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { FUNCTION_VALUEOF, valueOf, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSClassRef JSTZDateArray::m_jsClassRef = JSClassCreate( + JSTZDateArray::getClassInfo()); + +JSValueRef JSTZDateArray::getLength(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + Try + { + JSTZDateArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + NumberArrayPtr numbers = priv->getObject(); + if (numbers) { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + return converter->toJSValueRef(numbers->size()); + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("invalid conversion"); + } + return JSValueMakeUndefined(context); +} + +JSObjectRef JSTZDateArray::createArray(JSContextRef context, + const NumberArrayPtr &numbers) +{ + JSTZDateArrayPriv *priv = new JSTZDateArrayPriv(context, numbers); + return JSObjectMake(context, getClassRef(), priv); +} + +const JSClassDefinition* JSTZDateArray::getClassInfo() +{ + return &(m_classInfo); +} + +JSClassRef JSTZDateArray::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +bool JSTZDateArray::isObjectOfClass(JSContextRef context, JSValueRef value) +{ + return JSValueIsObjectOfClass(context, value, getClassRef()); +} + +NumberArrayPtr JSTZDateArray::getTZDateArray(JSContextRef context, JSValueRef value) +{ + if (!isObjectOfClass(context, value)) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + JSObjectRef object = JSValueToObject(context, value, NULL); + if (!object) { + Throw(WrtDeviceApis::Commons::InvalidArgumentException); + } + JSTZDateArrayPriv* priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + return priv->getObject(); +} + +void JSTZDateArray::initialize(JSContextRef context, + JSObjectRef object) +{ +} + +void JSTZDateArray::finalize(JSObjectRef object) +{ + JSTZDateArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + delete priv; + JSObjectSetPrivate(object, NULL); +} + +bool JSTZDateArray::hasProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName) +{ + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + Try + { + size_t index = converter->toSizeT(propertyName); + JSTZDateArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + NumberArrayPtr numbers = priv->getObject(); + if (index < numbers->size()) { + return true; + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + //not reporting error is intended + } + return false; +} + +JSValueRef JSTZDateArray::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + TimeUtilConverter timeConverter(context); + + Try + { + size_t index = converter->toSizeT(propertyName); + JSTZDateArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + NumberArrayPtr numbers = priv->getObject(); + if (index < numbers->size()) { + long long int result = numbers->at(index); + LogInfo("index: "<toSizeT(propertyName); + long long int number = 0; + if (!JSValueIsUndefined(context, value)) { + number = timeConverter.getTimeInMilliseconds(value)/1000; + } + JSTZDateArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + NumberArrayPtr numbers = priv->getObject(); + if (!numbers) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + if (numbers->size() <= index) { + numbers->resize(index + 1); + } + (*numbers)[index] = number; + return true; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch"); + } + return false; +} + +void JSTZDateArray::getPropertyNames(JSContextRef context, + JSObjectRef object, + JSPropertyNameAccumulatorRef propertyNames) +{ + Converter converter(context); + + Try + { + JSTZDateArrayPriv* priv = + static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::NullPointerException); + } + NumberArrayPtr numbers = priv->getObject(); + + int count = numbers->size(); + + for(int i=0; i < count; i++) + { + ScopedJSStringRef name(converter.toJSStringRef(converter.toString(i))); + JSPropertyNameAccumulatorAddName(propertyNames, name.get()); + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("invalid property"); + } +} + +JSValueRef JSTZDateArray::concat(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + NumberArrayPtr numbers = NumberArrayPtr(new NumberArray()); + JSTZDateArrayPriv *newPrivateObject = new JSTZDateArrayPriv( + context, + numbers); + JSValueRef result = JSObjectMake(context, getClassRef(), newPrivateObject); + + //copy current numbers + JSTZDateArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + NumberArrayPtr currentNumbers = priv->getObject(); + for (size_t i = 0; i < currentNumbers->size(); ++i) { + numbers->push_back(currentNumbers->at(i)); + } + + //copy submitted arrays + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + TimeUtilConverter timeConverter(context); + for (size_t i = 0; i < argumentCount; ++i) { + if (!JSIsArrayValue(context, arguments[i])) { + Throw(WrtDeviceApis::Commons::ConversionException); + } + // process array of numbers + JSObjectRef arrayObj = converter->toJSObjectRef(arguments[i]); + unsigned int len = JSGetArrayLength(context, arrayObj); + for (unsigned int e = 0; e < len; ++e) { + JSValueRef att = JSGetArrayElement(context, arrayObj, e); + + long long int number = 0; + if (!JSValueIsUndefined(context, att)) { + number = timeConverter.getTimeInMilliseconds(att)/1000; + } + LogDebug("Concatenating a number: "<push_back(number); + } + } + return result; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch"); +} + +JSValueRef JSTZDateArray::join(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + std::string result; + std::string separator(","); + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSTZDateArrayPriv* priv = static_cast(JSObjectGetPrivate(thisObject)); + TimeUtilConverter timeConverter(context); + + NumberArrayPtr currentNumbers = priv->getObject(); + if (argumentCount > 0 && JSValueIsString(context, arguments[0])) { + separator = converter->toString(arguments[0]); + LogDebug("Separator: "<size(); ++i) { + if (i != 0) { + result += separator; + } + std::stringstream ss; + ss<at(i); + result += ss.str(); + } + LogDebug("Resulting string: "<toJSValueRef(result); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch"); +} + +JSValueRef JSTZDateArray::pop(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + TimeUtilConverter timeConverter(context); + + JSTZDateArrayPriv* priv = static_cast(JSObjectGetPrivate(thisObject)); + NumberArrayPtr currentNumbers = priv->getObject(); + if (currentNumbers->size() > 0) { + long long int result = currentNumbers->at(currentNumbers->size() - 1); + currentNumbers->pop_back(); + return timeConverter.toJSValueRefTZDate((double)(result*1000.0), ""); + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSTZDateArray::push(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + TimeUtilConverter timeConverter(context); + + JSTZDateArrayPriv* priv = static_cast(JSObjectGetPrivate(thisObject)); + NumberArrayPtr currentNumbers = priv->getObject(); + for (size_t i = 0; i < argumentCount; ++i) { + long long int number = 0; + if (!JSValueIsUndefined(context, arguments[i])) { + number = timeConverter.getTimeInMilliseconds(arguments[i])/1000; + } + LogDebug("Pushing a TZDate number: "<push_back(number); + } + return timeConverter.toJSValueRef(currentNumbers->size()); + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch"); +} + +JSValueRef JSTZDateArray::reverse(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSTZDateArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + NumberArrayPtr currentNumbers = priv->getObject(); + std::reverse(currentNumbers->begin(), currentNumbers->end()); + return thisObject; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSTZDateArray::shift(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSTZDateArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + NumberArrayPtr currentNumbers = priv->getObject(); + if (currentNumbers->size() > 0) { + long long int result = currentNumbers->at(0); + currentNumbers->erase(currentNumbers->begin()); + return converter->toJSValueRef(result); + } + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSTZDateArray::slice(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + if (argumentCount < 1) { + return JSValueMakeUndefined(context); + } + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + NumberArrayPtr numbers = NumberArrayPtr(new NumberArray()); + JSTZDateArrayPriv *newPrivateObject = new JSTZDateArrayPriv(context, numbers); + JSValueRef result = JSObjectMake(context, getClassRef(), newPrivateObject); + + //copy current numbers + JSTZDateArrayPriv* priv = static_cast(JSObjectGetPrivate(thisObject)); + NumberArrayPtr currentNumbers = priv->getObject(); + std::size_t first = converter->toSizeT(arguments[0]); + std::size_t last = currentNumbers->size() - 1; + if (argumentCount > 1) { + last = converter->toSizeT(arguments[1]); + if (last >= currentNumbers->size()) { + last = currentNumbers->size() - 1; + } + } + + for (size_t i = first; i <= last; ++i) { + numbers->push_back(currentNumbers->at(i)); + } + + return result; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch"); +} + +JSValueRef JSTZDateArray::sort(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + Try + { + WrtDeviceApis::CommonsJavaScript::BasicConverter converter = + WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context); + JSTZDateArrayPriv* priv = + static_cast(JSObjectGetPrivate(thisObject)); + NumberArrayPtr currentNumbers = priv->getObject(); + std::sort(currentNumbers->begin(), currentNumbers->end()); + return thisObject; + } + Catch(WrtDeviceApis::Commons::Exception) + { + LogError("error occured"); + } + return JSValueMakeUndefined(context); +} + +JSValueRef JSTZDateArray::splice(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + return JSValueMakeUndefined(context); +} + +JSValueRef JSTZDateArray::toString(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + return join(context, function, thisObject, 0, arguments, exception); +} + +JSValueRef JSTZDateArray::unshift(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + return JSValueMakeUndefined(context); +} + +JSValueRef JSTZDateArray::valueOf(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) +{ + return JSValueMakeUndefined(context); +} + +} // Calendar +} // DeviceAPI diff --git a/src/Calendar/JSTZDateArray.h b/src/Calendar/JSTZDateArray.h new file mode 100755 index 0000000..added2e --- /dev/null +++ b/src/Calendar/JSTZDateArray.h @@ -0,0 +1,181 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _TIZEN_CALENDAR_JS_TZDATE_ARRAY_H_ +#define _TIZEN_CALENDAR_JS_TZDATE_ARRAY_H_ + +#include +#include +#include +#include "CalendarEvent.h" + +namespace DeviceAPI { +namespace Calendar { + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSTZDateArrayPriv; + +class JSTZDateArray +{ +public: + + static const JSClassDefinition* getClassInfo(); + + static JSClassRef getClassRef(); + + static JSObjectRef createArray(JSContextRef context, + const NumberArrayPtr &Numbers); + + static bool isObjectOfClass(JSContextRef context, JSValueRef value); + + static NumberArrayPtr getTZDateArray(JSContextRef context, JSValueRef value); + +private: + + /** + * The callback invoked when an object is first created. + */ + static void initialize(JSContextRef context, + JSObjectRef object); + + /** + * The callback invoked when an object is finalized. + */ + static void finalize(JSObjectRef object); + + static JSValueRef getLength(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool hasProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName); + + static JSValueRef getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + + static void getPropertyNames(JSContextRef context, + JSObjectRef object, + JSPropertyNameAccumulatorRef propertyNames); + + static JSValueRef concat(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef join(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef pop(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef push(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef reverse(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef shift(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef slice(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef sort(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef splice(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef toString(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef unshift(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + static JSValueRef valueOf(JSContextRef context, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); + + static bool checkValue(const long long int &value); + + static JSClassRef m_jsClassRef; + /** + * This structure describes a statically declared function property. + */ + static JSStaticFunction m_function[]; + + /** + * This structure contains properties and callbacks that define a type of object. + */ + static JSClassDefinition m_classInfo; + + /** + * This member variable contains the initialization values for the static properties of this class. + * The values are given according to the data structure JSPropertySpec + */ + static JSStaticValue m_property[]; +}; + +} // Calendar +} // DeviceAPI + +#endif // _TIZEN_CALENDAR_JS_TZDATE_ARRAY_H_ \ No newline at end of file diff --git a/src/Calendar/OnEventsChanged.h b/src/Calendar/OnEventsChanged.h new file mode 100755 index 0000000..38238aa --- /dev/null +++ b/src/Calendar/OnEventsChanged.h @@ -0,0 +1,96 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _ON_EVENTS_CHANGED_H_ +#define _ON_EVENTS_CHANGED_H_ + +#include +#include +#include +#include +#include +#include "CalendarEvent.h" + +namespace DeviceAPI { +namespace Calendar { + +class OnEventsChanged : public WrtDeviceApis::Commons::ListenerEvent +{ + public: + typedef enum + { + ON_ADD, + ON_UPDATE, + ON_DELETE, + //ON_CALENDAR_RESET + } EventChangeStatus; + + void setResult (bool value) { + m_result = value; + } + bool getResult() const { + return m_result; + } + + void setCalendarType(CalendarEvent::CalendarType value) + { + m_calendarType = value; + } + CalendarEvent::CalendarType getCalendarType() const + { + return m_calendarType; + } + + CalendarEventListPtr getEventList() const { + return m_eventList; + } + + void setStatus(EventChangeStatus value) { + m_status = value; + } + EventChangeStatus getStatus() const { + return m_status; + } + + void addEvent(CalendarEventPtr value) { + m_eventList->push_back(value); + } + + OnEventsChanged() : m_result(false) { + CalendarEventListPtr events(new CalendarEventList()); + m_eventList = events; + } + ~OnEventsChanged() { + } + + private: + CalendarEventListPtr m_eventList; + EventChangeStatus m_status; + bool m_result; + CalendarEvent::CalendarType m_calendarType; +}; + +typedef DPL::SharedPtr OnEventsChangedPtr; +typedef WrtDeviceApis::Commons::ListenerEventEmitter OnEventsChangedEmitter; +typedef DPL::SharedPtr OnEventsChangedEmitterPtr; +typedef WrtDeviceApis::Commons::Emitters OnEventsChangedEmitters; + +} +} + +#endif //_ON_EVENTS_CHANGED_H_ diff --git a/src/Calendar/config.xml b/src/Calendar/config.xml new file mode 100755 index 0000000..9a389c7 --- /dev/null +++ b/src/Calendar/config.xml @@ -0,0 +1,20 @@ + + + + libwrt-plugins-tizen-calendar.so + calendar.install.uri + SAMSUNG plugin group + SAMSUNG certificate authority + AAAABBBBCCCCDDDEEEE0000 + + + http://tizen.org/privilege/calendar.read + calendar.read + + + + http://tizen.org/privilege/calendar.write + calendar.write + + + \ No newline at end of file diff --git a/src/Calendar/plugin_config.cpp b/src/Calendar/plugin_config.cpp new file mode 100755 index 0000000..2a89106 --- /dev/null +++ b/src/Calendar/plugin_config.cpp @@ -0,0 +1,267 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include + +#include "plugin_config.h" + +#define CALENDAR_FEATURE_API_READ "http://tizen.org/privilege/calendar.read" +#define CALENDAR_FEATURE_API_WRITE "http://tizen.org/privilege/calendar.write" + +#define CALENDAR_DEVICE_CAP_READ "calendar.read" +#define CALENDAR_DEVICE_CAP_WRITE "calendar.write" + +using namespace WrtDeviceApis::Commons; + +namespace DeviceAPI { +namespace Calendar { + +static FunctionMapping createCalendarFunctions(); + +static FunctionMapping CalendarFunctions = createCalendarFunctions(); + +DEFINE_FUNCTION_GETTER(Calendar, CalendarFunctions); + +static FunctionMapping createCalendarFunctions() +{ + /** + * Device capabilities + */ + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_CALENDAR_READ, CALENDAR_DEVICE_CAP_READ); + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_CALENDAR_WRITE, CALENDAR_DEVICE_CAP_WRITE); + + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_CALENDAR_READ); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_CALENDAR_READ, DEVICE_CAP_CALENDAR_READ); + + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_CALENDAR_WRITE); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_CALENDAR_WRITE, DEVICE_CAP_CALENDAR_WRITE); + + /** + * Api Features + */ + ACE_CREATE_FEATURE(FEATURE_CALENDAR_READ, CALENDAR_FEATURE_API_READ); + ACE_CREATE_FEATURE(FEATURE_CALENDAR_WRITE, CALENDAR_FEATURE_API_WRITE); + + ACE_CREATE_FEATURE_LIST(CALENDAR_FEATURES_CALENDAR_READ); + ACE_ADD_API_FEATURE(CALENDAR_FEATURES_CALENDAR_READ, FEATURE_CALENDAR_READ); + + ACE_CREATE_FEATURE_LIST(CALENDAR_FEATURES_CALENDAR_WRITE); + ACE_ADD_API_FEATURE(CALENDAR_FEATURES_CALENDAR_WRITE, FEATURE_CALENDAR_WRITE); + + /** + * Functions + */ + FunctionMapping calendarMapping; + + //getCalendars + AceFunction getCalendarsFunc = ACE_CREATE_FUNCTION( + FUNCTION_GET_CALENDARS, + CALENDAR_FUNCTION_API_GET_CALENDARS, + CALENDAR_FEATURES_CALENDAR_READ, + DEVICE_LIST_CALENDAR_READ); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_GET_CALENDARS, + getCalendarsFunc)); + + //getDefaultCalendar + AceFunction getDefaultCalendarFunc = ACE_CREATE_FUNCTION( + FUNCTION_GET_DEFAULT_CALENDAR, + CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR, + CALENDAR_FEATURES_CALENDAR_READ, + DEVICE_LIST_CALENDAR_READ); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR, + getDefaultCalendarFunc)); + + //getUnifiedCalendar + AceFunction getUnifiedCalendarFunc = ACE_CREATE_FUNCTION( + FUNCTION_GET_UNIFIED_CALENDAR, + CALENDAR_FUNCTION_API_GET_UNIFIED_CALENDAR, + CALENDAR_FEATURES_CALENDAR_READ, + DEVICE_LIST_CALENDAR_READ); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_GET_UNIFIED_CALENDAR, + getUnifiedCalendarFunc)); + + //getCalendar + AceFunction getCalendarFunc = ACE_CREATE_FUNCTION( + FUNCTION_GET_CALENDAR, + CALENDAR_FUNCTION_API_GET_CALENDAR, + CALENDAR_FEATURES_CALENDAR_READ, + DEVICE_LIST_CALENDAR_READ); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_GET_CALENDAR, + getCalendarFunc)); + + //find + AceFunction findFunc = ACE_CREATE_FUNCTION( + FUNCTION_FIND, + CALENDAR_FUNCTION_API_FIND, + CALENDAR_FEATURES_CALENDAR_READ, + DEVICE_LIST_CALENDAR_READ); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_FIND, + findFunc)); + + //add + AceFunction addFunc = ACE_CREATE_FUNCTION( + FUNCTION_ADD, + CALENDAR_FUNCTION_API_ADD, + CALENDAR_FEATURES_CALENDAR_WRITE, + DEVICE_LIST_CALENDAR_WRITE); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_ADD, + addFunc)); + + //addBatch + AceFunction addBatchFunc = ACE_CREATE_FUNCTION( + FUNCTION_ADD_BATCH, + CALENDAR_FUNCTION_API_ADD_BATCH, + CALENDAR_FEATURES_CALENDAR_WRITE, + DEVICE_LIST_CALENDAR_WRITE); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_ADD_BATCH, + addBatchFunc)); + + //update + AceFunction updateFunc = ACE_CREATE_FUNCTION( + FUNCTION_UPDATE, + CALENDAR_FUNCTION_API_UPDATE, + CALENDAR_FEATURES_CALENDAR_WRITE, + DEVICE_LIST_CALENDAR_WRITE); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_UPDATE, + updateFunc)); + + //updateBatch + AceFunction updateBatchFunc = ACE_CREATE_FUNCTION( + FUNCTION_UPDATE_BATCH, + CALENDAR_FUNCTION_API_UPDATE_BATCH, + CALENDAR_FEATURES_CALENDAR_WRITE, + DEVICE_LIST_CALENDAR_WRITE); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_UPDATE_BATCH, + updateBatchFunc)); + + //remove + AceFunction removeFunc = ACE_CREATE_FUNCTION( + FUNCTION_REMOVE, + CALENDAR_FUNCTION_API_REMOVE, + CALENDAR_FEATURES_CALENDAR_WRITE, + DEVICE_LIST_CALENDAR_WRITE); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_REMOVE, + removeFunc)); + + //removeBatch + AceFunction removeBatchFunc = ACE_CREATE_FUNCTION( + FUNCTION_REMOVE_BATCH, + CALENDAR_FUNCTION_API_REMOVE_BATCH, + CALENDAR_FEATURES_CALENDAR_WRITE, + DEVICE_LIST_CALENDAR_WRITE); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_REMOVE_BATCH, + removeBatchFunc)); + + //convertToString + AceFunction convertToStringFunc = ACE_CREATE_FUNCTION( + FUNCTION_CONVERT_TO_STRING, + CALENDAR_FUNCTION_API_CONVERT_TO_STRING, + CALENDAR_FEATURES_CALENDAR_READ, + DEVICE_LIST_CALENDAR_READ); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_CONVERT_TO_STRING, + convertToStringFunc)); + + //addChangeListener + AceFunction addChangeListenerFunc = ACE_CREATE_FUNCTION( + FUNCTION_ADD_CHANGE_LISTENER, + CALENDAR_FUNCTION_API_ADD_CHANGE_LISTENER, + CALENDAR_FEATURES_CALENDAR_READ, + DEVICE_LIST_CALENDAR_READ); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_ADD_CHANGE_LISTENER, + addChangeListenerFunc)); + + //removeChangeListener + AceFunction removeChangeListenerFunc = ACE_CREATE_FUNCTION( + FUNCTION_REMOVE_CHANGE_LISTENER, + CALENDAR_FUNCTION_API_REMOVE_CHANGE_LISTENER, + CALENDAR_FEATURES_CALENDAR_READ, + DEVICE_LIST_CALENDAR_READ); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_REMOVE_CHANGE_LISTENER, + removeChangeListenerFunc)); + + //expandRecurrence + AceFunction expandRecurrenceFunc = ACE_CREATE_FUNCTION( + FUNCTION_EXPAND_RECURRENCE, + CALENDAR_FUNCTION_API_EXPAND_RECURRENCE, + CALENDAR_FEATURES_CALENDAR_READ, + DEVICE_LIST_CALENDAR_READ); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_EXPAND_RECURRENCE, + expandRecurrenceFunc)); + + //get + AceFunction getFunc = ACE_CREATE_FUNCTION( + FUNCTION_GET, + CALENDAR_FUNCTION_API_GET, + CALENDAR_FEATURES_CALENDAR_READ, + DEVICE_LIST_CALENDAR_READ); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_GET, + getFunc)); + + //clone + AceFunction cloneFunc = ACE_CREATE_FUNCTION( + FUNCTION_CLONE, + CALENDAR_FUNCTION_API_CLONE, + CALENDAR_FEATURES_CALENDAR_READ, + DEVICE_LIST_CALENDAR_READ); + + calendarMapping.insert(std::make_pair( + CALENDAR_FUNCTION_API_CLONE, + getFunc)); + + return calendarMapping; +} + +} +} diff --git a/src/Calendar/plugin_config.h b/src/Calendar/plugin_config.h new file mode 100755 index 0000000..f553673 --- /dev/null +++ b/src/Calendar/plugin_config.h @@ -0,0 +1,58 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_PLUGIN_CONFIG_H_ +#define _CALENDAR_PLUGIN_CONFIG_H_ + +#include +#include + +namespace DeviceAPI { +namespace Calendar { + +// Functions from calendar manager +#define CALENDAR_FUNCTION_API_GET_CALENDARS "getCalendars" +#define CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR "getDefaultCalendar" +#define CALENDAR_FUNCTION_API_GET_UNIFIED_CALENDAR "getUnifiedCalendar" +#define CALENDAR_FUNCTION_API_GET_CALENDAR "getCalendar" + +// Functions from calendar +#define CALENDAR_FUNCTION_API_ADD "add" +#define CALENDAR_FUNCTION_API_ADD_BATCH "addBatch" +#define CALENDAR_FUNCTION_API_UPDATE "update" +#define CALENDAR_FUNCTION_API_UPDATE_BATCH "updateBatch" +#define CALENDAR_FUNCTION_API_REMOVE "remove" +#define CALENDAR_FUNCTION_API_REMOVE_BATCH "removeBatch" +#define CALENDAR_FUNCTION_API_FIND "find" +#define CALENDAR_FUNCTION_API_CONVERT_TO_STRING "convertToString" +#define CALENDAR_FUNCTION_API_ADD_CHANGE_LISTENER "addChangeListener" +#define CALENDAR_FUNCTION_API_REMOVE_CHANGE_LISTENER "removeChangeListener" +#define CALENDAR_FUNCTION_API_EXPAND_RECURRENCE "expandRecurrence" +#define CALENDAR_FUNCTION_API_GET "get" +#define CALENDAR_FUNCTION_API_CLONE "clone" + +DECLARE_FUNCTION_GETTER(Calendar); + +#define CALENDAR_CHECK_ACCESS(functionName) \ + aceCheckAccess >( \ + getCalendarFunctionData, \ + functionName) +} +} + +#endif // _CALENDAR_PLUGIN_CONFIG_H_ diff --git a/src/Calendar/plugin_initializer.cpp b/src/Calendar/plugin_initializer.cpp new file mode 100755 index 0000000..c037436 --- /dev/null +++ b/src/Calendar/plugin_initializer.cpp @@ -0,0 +1,115 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 + +#include +#include +#include +#include "JSCalendarManager.h" +#include "JSCalendarEvent.h" +#include "JSCalendarTask.h" +#include "JSCalendarAttendee.h" +#include "JSCalendarRecurrenceRule.h" +#include "JSCalendarEventId.h" +#include "JSCalendarAlarm.h" + +#include "CalendarAsyncCallbackManager.h" +#include "CalendarListenerManager.h" + +namespace DeviceAPI { +namespace Calendar { + +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; + +void on_widget_start_callback(int widgetId) +{ + LogDebug("[Tizen\\Calendar] on_widget_start_callback (" << widgetId << ")"); + + Try { + WrtAccessSingleton::Instance().initialize(widgetId); + } Catch (Exception) { + LogError("WrtAccess initialization failed"); + } +} + +void on_widget_stop_callback(int widgetId) +{ + LogDebug("[Tizen\\Calendar] on_widget_stop_callback (" << widgetId << ")"); + + Try { + WrtAccessSingleton::Instance().deinitialize(widgetId); + } Catch (Exception) { + LogError("WrtAccess deinitialization failed"); + } +} + +void on_frame_load_callback(const void * context) +{ + LogDebug("[Tizen\\Calendar] on_frame_load_callback (" << context << ")"); +} + +void on_frame_unload_callback(const void * context) +{ + LogDebug("[Tizen\\Calendar] on_frame_unload_callback (" << context << ")"); + + CalendarAsyncCallbackManagerSingleton::Instance().unregisterContext(static_cast(context)); + CalendarListenerManagerSingleton::Instance().unregisterContext(static_cast(context)); +} + +PLUGIN_ON_WIDGET_START(on_widget_start_callback) +PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback) + +PLUGIN_ON_FRAME_LOAD(on_frame_load_callback) +PLUGIN_ON_FRAME_UNLOAD(on_frame_unload_callback) + +PLUGIN_CLASS_MAP_BEGIN +PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, + "calendar", + (js_class_template_getter)JSCalendarManager::getClassRef, + NULL) +PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, + TIZEN_INTERFACE_CALENDAR_EVENT, + (js_class_template_getter)JSCalendarEvent::getClassRef, + NULL) +PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, + TIZEN_INTERFACE_CALENDAR_TASK, + (js_class_template_getter)JSCalendarTask::getClassRef, + NULL) +PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, + TIZEN_INTERFACE_CALENDAR_ATTENDEE, + (js_class_template_getter)JSCalendarAttendee::getClassRef, + NULL) +PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, + TIZEN_INTERFACE_CALENDAR_RECURRENCE_RULE, + (js_class_template_getter)JSCalendarRecurrenceRule::getClassRef, + NULL) +PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, + TIZEN_INTERFACE_CALENDAR_EVENT_ID, + (js_class_template_getter)JSCalendarEventId::getClassRef, + NULL) +PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, + TIZEN_INTERFACE_CALENDAR_ALARM, + (js_class_template_getter)JSCalendarAlarm::getClassRef, + NULL) +PLUGIN_CLASS_MAP_END + +} +} + diff --git a/src/Callhistory/CMakeLists.txt b/src/Callhistory/CMakeLists.txt new file mode 100755 index 0000000..b3aed2b --- /dev/null +++ b/src/Callhistory/CMakeLists.txt @@ -0,0 +1,74 @@ +SET(TARGET_NAME ${callhistory_target}) +SET(DESTINATION_NAME ${callhistory_dest}) +SET(TARGET_IMPL_NAME ${callhistory_impl}) + +PKG_SEARCH_MODULE(contacts-service REQUIRED contacts-service2) +PKG_SEARCH_MODULE(glib REQUIRED glib-2.0) +PKG_SEARCH_MODULE(libpcrecpp REQUIRED libpcrecpp) + +INCLUDE_DIRECTORIES( + ${TOP}/Common + ${TOP}/Tizen + ${TOP}/Contact + ${contacts-service_INCLUDE_DIRS} + ${glib_INCLUDE_DIRS} + ${libpcrecpp_INCLUDE_DIRS} + ) + +SET(CMAKE_INSTALL_RPATH + ${CMAKE_INSTALL_RPATH} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest} + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME} +) + +SET(SRCS_IMPL + CallHistoryEntryProperties.cpp + CallHistoryFactory.cpp + EventCallHistoryListener.cpp + EventFindCallHistory.cpp + ICallHistory.cpp + ICallHistoryEntry.cpp + CallHistory.cpp + CallHistoryEntry.cpp + CallHistoryFilter.cpp + CallHistoryMultiCallback.cpp + CallHistoryStaticController.cpp + CallHistoryListenerManager.cpp + CallHistoryAsyncCallbackManager.cpp + Converter.cpp + JSCallHistory.cpp + JSCallHistoryEntry.cpp + JSRemoteParty.cpp + ResponseDispatcher.cpp +) + +ADD_LIBRARY(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL}) + +TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME} + ${LIBS_COMMON} + ${contacts-service_LIBRARIES} + ${capicall_LIBRARIES} + ${glib_LIBRARIES} + ${libpcrecpp_LIBRARIES} +) + +SET(SRCS + plugin_config.cpp + plugin_initializer.cpp +) + +ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS}) + +TARGET_LINK_LIBRARIES(${TARGET_NAME} + ${TARGET_IMPL_NAME} + ${tizen_impl} + ${timeutil_impl} +) + +INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) +INSTALL( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/callhistory + FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE +) \ No newline at end of file diff --git a/src/Callhistory/CallHistory.cpp b/src/Callhistory/CallHistory.cpp new file mode 100755 index 0000000..776097e --- /dev/null +++ b/src/Callhistory/CallHistory.cpp @@ -0,0 +1,880 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "CallHistory.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "CallHistoryDefine.h" + +#include "CallHistoryFilter.h" + +using namespace DeviceAPI::Tizen; +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DPL; + +namespace DeviceAPI { +namespace CallHistory { + +std::vector CallHistory::m_watchers; + +CallHistory::CallHistory() +{ + LogDebug("Enter "); + if (contacts_connect2() == CONTACTS_ERROR_NONE) { + LogDebug("Successful to connect Call history DB "); + } else { + LogDebug("Failed to connect Call history DB "); + } + + EventCallHistoryPtr event(new EventCallHistory()); + event->setCmdType(EventCallHistory::CONNECT); + event->setForSynchronousCall(); + EventRequestReceiver::PostRequest(event); +} + +CallHistory::~CallHistory() +{ + LogDebug("Enter "); + + if (contacts_disconnect2() == CONTACTS_ERROR_NONE) { + LogDebug("Successful to disconnect Call history DB "); + } else { + LogDebug("Failed to disconnect Call history DB "); + } + + int ret = CONTACTS_ERROR_NONE; + std::vector::iterator it = CallHistory::m_watchers.begin(); + + if (m_watchers.size() > 0) { + for (;it < CallHistory::m_watchers.end();) { + ret = contacts_db_remove_changed_cb(_contacts_phone_log._uri, callhistoryListenerCB, it->Get()); + + if (ret != CONTACTS_ERROR_NONE) { + LogDebug("callhistory remove listener error [" << ret << "]"); + } + + it = CallHistory::m_watchers.erase(it); + } + LogDebug("CallHistory Watcher is removed. (" << CallHistory::m_watchers.size() << ")"); + } + + EventCallHistoryPtr event(new EventCallHistory()); + event->setCmdType(EventCallHistory::DISCONNECT); + event->setForSynchronousCall(); + EventRequestReceiver::PostRequest(event); +} + +void CallHistory::callhistoryListenerCB(const char* view_uri, void* user_data) +{ + LogDebug("enter"); + if (user_data != NULL) { + ((CallHistory::Watcher*)user_data)->addedListenerCB(); + ((CallHistory::Watcher*)user_data)->changedListenerCB(); + } +} + +void CallHistory::removeBatchCB(int error, void *user_data) +{ + LogDebug("enter"); + if (user_data != NULL) { + CallHistory* chManager = (CallHistory *)((EventCallHistoryPtrs *)user_data)->getThisPtr(); + + if (chManager) { + EventRemoveBatchPtr event = ((EventCallHistoryPtrs *)user_data)->getEventPtrs(); + chManager->callRemoveBatchEvent(error, event); + } + } + return; +} + +void CallHistory::removeAllCB(int error, void *user_data) +{ + LogDebug("enter"); + if (user_data != NULL) { + CallHistory* chManager = (CallHistory *)((EventCallHistoryPtrs *)user_data)->getThisPtr(); + + if (chManager) { + EventRemoveAllPtr event = ((EventCallHistoryPtrs *)user_data)->getEventPtrs(); + chManager->callRemoveAllEvent(error, event); + } + } + return; +} + +bool CallHistory::convertCallHistory(callhistory_query_s *query_log, CallHistoryEntryListPtr &callEntries) +{ + if (query_log == NULL || callEntries == NULL) + return false; + + CallHistoryEntryPropertiesPtr callHistoryItem(new CallHistoryEntryProperties()); + StringArrayPtr stringArray(new StringArray()); + RemotePartyPtr remoteParty(new RemoteParty()); + RemotePartyListPtr remotePartyList(new RemotePartyList()); + + std::string callType(""); + std::string tags(""); + std::string direction(""); + std::string number(""); + + if (query_log->phone_number != NULL) { + number.append(query_log->phone_number); + } + + switch(query_log->calllog_type) { + case CONTACTS_PLOG_TYPE_VOICE_INCOMMING: + callType.append(STR_TIZEN_TEL); + tags.append(STR_CALL_VOICE); + direction.append(STR_RECEIVED); + break; + case CONTACTS_PLOG_TYPE_VOICE_OUTGOING: + callType.append(STR_TIZEN_TEL); + tags.append(STR_CALL_VOICE); + direction.append(STR_DIALED); + break; + case CONTACTS_PLOG_TYPE_VOICE_INCOMMING_SEEN: + callType.append(STR_TIZEN_TEL); + tags.append(STR_CALL_VOICE); + direction.append(STR_MISSED); + break; + case CONTACTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN: + callType.append(STR_TIZEN_TEL); + tags.append(STR_CALL_VOICE); + direction.append(STR_MISSED_NEW); + break; + case CONTACTS_PLOG_TYPE_VOICE_REJECT: + callType.append(STR_TIZEN_TEL); + tags.append(STR_CALL_VOICE); + direction.append(STR_REJECTED); + break; + case CONTACTS_PLOG_TYPE_VOICE_BLOCKED: + callType.append(STR_TIZEN_TEL); + tags.append(STR_CALL_VOICE); + direction.append(STR_BLOCKED); + break; + case CONTACTS_PLOG_TYPE_VIDEO_INCOMMING: + callType.append(STR_TIZEN_TEL); + tags.append(STR_CALL_VIDEO); + direction.append(STR_RECEIVED); + break; + case CONTACTS_PLOG_TYPE_VIDEO_OUTGOING: + callType.append(STR_TIZEN_TEL); + tags.append(STR_CALL_VIDEO); + direction.append(STR_DIALED); + break; + case CONTACTS_PLOG_TYPE_VIDEO_INCOMMING_SEEN: + callType.append(STR_TIZEN_TEL); + tags.append(STR_CALL_VIDEO); + direction.append(STR_MISSED); + break; + case CONTACTS_PLOG_TYPE_VIDEO_INCOMMING_UNSEEN: + callType.append(STR_TIZEN_TEL); + tags.append(STR_CALL_VIDEO); + direction.append(STR_MISSED_NEW); + break; + case CONTACTS_PLOG_TYPE_VIDEO_REJECT: + callType.append(STR_TIZEN_TEL); + tags.append(STR_CALL_VIDEO); + direction.append(STR_REJECTED); + break; + case CONTACTS_PLOG_TYPE_VIDEO_BLOCKED: + callType.append(STR_TIZEN_TEL); + tags.append(STR_CALL_VIDEO); + direction.append(STR_BLOCKED); + break; + default: + return false; + } + + callHistoryItem->setEntryId(query_log->calllog_db_id); + callHistoryItem->setCallType(callType); + stringArray->push_back(tags); + callHistoryItem->setTags(stringArray); + + remoteParty->setRemoteParty(number); + std::stringstream personIdStream; + personIdStream << query_log->person_db_id; + remoteParty->setPersonId(personIdStream.str()); + + remotePartyList->push_back(remoteParty); + callHistoryItem->setRemoteParties(remotePartyList); + + callHistoryItem->setStartTime(query_log->timestamp); + callHistoryItem->setDuration((unsigned long)(query_log->duration_sec)); + callHistoryItem->setDirection(direction); + + callEntries->insert(callEntries->end(), callHistoryItem); + + return true; +} + +void CallHistory::find(const EventFindCallHistoryPtr& event) +{ + EventRequestReceiver::PostRequest(event); +} + +bool CallHistory::remove(const unsigned long entryId) +{ + try { + int ret = contacts_db_delete_record(_contacts_phone_log._uri, (int)entryId); + + if (ret == CONTACTS_ERROR_NONE) { + return true; + } else { + return false; + } + } catch (const Commons::PlatformException& ex) { + ThrowMsg(Commons::PlatformException, ex.GetMessage()); + } +} + +void CallHistory::removeBatch(const EventRemoveBatchPtr& event) +{ + EventRequestReceiver::PostRequest(event); +} + +void CallHistory::removeAll(const EventRemoveAllPtr& event) +{ + EventRequestReceiver::PostRequest(event); +} + +long CallHistory::addListener(const EventCallHistoryListenerEmitterPtr& emitter) +{ + int ret =0; + if (CallHistory::m_watchers.size() == 0) { + WatcherPtr watcher(new Watcher(0, emitter)); + ret = contacts_db_add_changed_cb(_contacts_phone_log._uri, callhistoryListenerCB, watcher.Get()); + + if (ret == CONTACTS_ERROR_NONE) { + CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList()); + + contacts_query_h query = NULL; + contacts_filter_h filter = NULL; + contacts_list_h recordList = NULL; + + contacts_query_create(_contacts_phone_log._uri, &query); + contacts_filter_create(_contacts_phone_log._uri, &filter); + contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED); + + contacts_query_set_filter(query, filter); + contacts_query_set_sort(query, _contacts_phone_log.id, false); + ret = contacts_db_get_records_with_query(query, 0, 1, &recordList); + + if (ret != CONTACTS_ERROR_NONE) { + LogDebug("callhistory query error [" << ret << "]"); + } + + if (parseRecord(&recordList, callHistoryListPtr)) { + if (callHistoryListPtr->size() > 0) { + watcher->setCurrentLogId((*callHistoryListPtr)[0]->getEntryId()); + } + } + contacts_list_destroy(recordList, true); + contacts_query_destroy(query); + contacts_filter_destroy(filter); + + MissedCallListPtr missedCallList(updateCurrentMissedCall()); + watcher->setMissedCallList(missedCallList); + } + + watcher->setHandle(static_cast(emitter->getId())); + CallHistory::m_watchers.push_back(watcher); + return watcher->getHandle(); + } else { + return 0; + } +} + +void CallHistory::removeListener(const long id) +{ + std::vector::iterator it = CallHistory::m_watchers.begin(); + bool flag = false; + int ret = CONTACTS_ERROR_NONE; + + for (;it < CallHistory::m_watchers.end();) { + if (id == (*it)->getHandle()) { + flag = true; + ret = contacts_db_remove_changed_cb(_contacts_phone_log._uri, callhistoryListenerCB, it->Get()); + + if (ret != CONTACTS_ERROR_NONE) { + LogDebug("callhistory remove listener error [" << ret << "]"); + } + + it = CallHistory::m_watchers.erase(it); + continue; + } + ++it; + } + + LogDebug("CallHistory Watcher is removed. (" << CallHistory::m_watchers.size() << ")"); + + if (!flag) { + ThrowMsg(Commons::InvalidArgumentException, "Invalid values error : handle"); + } +} + +bool CallHistory::parseRecord(contacts_list_h *recordList, CallHistoryEntryListPtr &callEntries) +{ + int ret = CONTACTS_ERROR_NONE; + unsigned int total = 0; + contacts_record_h record = NULL; + callhistory_query_s query_data; + int logType = 0; + int time = 0; + + contacts_list_get_count(*recordList, &total); + + LogDebug("total [" << total << "]"); + + for (int i = 0; i < total; i++) { + ret = contacts_list_get_current_record_p(*recordList, &record); + + if (record == NULL) { + ret = contacts_list_next(*recordList); + if (ret != CONTACTS_ERROR_NONE && ret != CONTACTS_ERROR_NO_DATA) { + LogDebug("callhistory parse error [" << ret << "]"); + return false; + } else { + continue; + } + } + + memset(&query_data, 0x00, sizeof(callhistory_query_s)); + + if (ret == CONTACTS_ERROR_NONE) { + contacts_record_get_int(record, _contacts_phone_log.id, &(query_data.calllog_db_id)); + contacts_record_get_int(record, _contacts_phone_log.log_type , &logType); + contacts_record_get_int(record, _contacts_phone_log.person_id, &(query_data.person_db_id)); + contacts_record_get_str_p(record, _contacts_phone_log.address, &(query_data.phone_number)); + contacts_record_get_int(record, _contacts_phone_log.log_time, &time); + contacts_record_get_int(record, _contacts_phone_log.extra_data1, &(query_data.duration_sec)); + query_data.calllog_type = static_cast(logType); + query_data.timestamp = static_cast(time); + convertCallHistory(&query_data, callEntries); + } + + ret = contacts_list_next(*recordList); + if (ret != CONTACTS_ERROR_NONE && ret != CONTACTS_ERROR_NO_DATA) { + LogDebug("callhistory parse error [" << ret << "]"); + return false; + } + } + + return true; + +} + +unsigned int CallHistory::convertAttrName(std::string &name) +{ + std::string attrName(""); + if (name.compare(STR_RP_REMOTEPARTY) == 0) { + return _contacts_phone_log.address; + } else if (name.compare(STR_START_TIME) == 0) { + return _contacts_phone_log.log_time; + } else if (name.compare(STR_DURATION) == 0) { + return _contacts_phone_log.extra_data1; + } else if (name.compare(STR_DIRECTION) == 0) { + return _contacts_phone_log.log_type; + } else if (name.compare(STR_ENTRY_ID) == 0) { + return _contacts_phone_log.id; + } else { + return 0; + } +} + +MissedCallListPtr CallHistory::updateCurrentMissedCall() +{ + CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList()); + MissedCallListPtr missedCallList(new MissedCallList()); + int ret = CONTACTS_ERROR_NONE; + + contacts_query_h query = NULL; + contacts_filter_h filter = NULL; + contacts_list_h recordList = NULL; + + contacts_query_create(_contacts_phone_log._uri, &query); + contacts_filter_create(_contacts_phone_log._uri, &filter); + contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN); + contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_INCOMMING_UNSEEN); + + contacts_query_set_filter(query, filter); + contacts_query_set_sort(query, _contacts_phone_log.log_time, false); + ret = contacts_db_get_records_with_query(query, 0, 0, &recordList); + + if (ret != CONTACTS_ERROR_NONE) { + LogDebug("callhistory query error [" << ret << "]"); + } + + if (parseRecord(&recordList, callHistoryListPtr)) { + LogDebug("result counter [" << callHistoryListPtr->size() << "]"); + CallHistoryEntryList::iterator it = callHistoryListPtr->begin(); + + for (;it != callHistoryListPtr->end(); ++it) { + missedCallList->push_back((*it)->getEntryId()); + } + LogDebug("missed Call size (" << missedCallList->size() << ")"); + } + + contacts_list_destroy(recordList, true); + contacts_query_destroy(query); + contacts_filter_destroy(filter); + + return missedCallList; +} + +void CallHistory::OnRequestReceived(const EventCallHistoryPtr& event) +{ + try { + if (event->getCmdType() == EventCallHistory::CONNECT) { + if (contacts_connect2() == CONTACTS_ERROR_NONE) { + LogDebug("Successful to connect Call history DB by sub thread"); + } else { + LogDebug("Failed to connect Call history DB by sub thread"); + } + } else if (event->getCmdType() == EventCallHistory::DISCONNECT) { + if (contacts_disconnect2() == CONTACTS_ERROR_NONE) { + LogDebug("Successful to disconnect Call history DB by sub thread"); + } else { + LogDebug("Failed to disconnect Call history DB by sub thread"); + } + } + } catch (const Commons::PlatformException& ex) { + LogError("Exception: " << ex.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } +} + +void CallHistory::OnRequestReceived(const EventFindCallHistoryPtr& event) +{ + try { + LogDebug("enter"); + CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList()); + int ret = CONTACTS_ERROR_NONE; + + contacts_query_h query = NULL; + contacts_filter_h filter = NULL; + contacts_list_h recordList = NULL; + bool isAscending = false; + int limit = 0; + int offset = 0; + + contacts_query_create(_contacts_phone_log._uri, &query); + contacts_filter_create(_contacts_phone_log._uri, &filter); + + CallHistoryFilterPtr filtering(new CallHistoryFilter(filter)); + IFilterVisitorPtr filterTraversal = DPL::StaticPointerCast(filtering); + + if (event->getFilterIsSet()) { + FilterPtr filterPtr = event->getFilter(); + filterPtr->travel(filterTraversal, 0); + + contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED); + } else { + contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED); + } + contacts_query_set_filter(query, filter); + + if (event->getSortModesIsSet()) { + if (event->getSortMode()->getOrder() == DeviceAPI::Tizen::ASCENDING_SORT_ORDER) { + isAscending = true; + } else { + isAscending = false; + } + std::string attriName(event->getSortMode()->getAttributeName()); + contacts_query_set_sort(query, convertAttrName(attriName), isAscending); + } else { + contacts_query_set_sort(query, _contacts_phone_log.id, isAscending); + } + + if (event->getLimitIsSet()) { + limit = static_cast(event->getLimit()); + } + + if (event->getOffsetIsSet()) { + offset = static_cast(event->getOffset()); + } + + ret = contacts_db_get_records_with_query(query, offset, limit, &recordList); + + if (ret != CONTACTS_ERROR_NONE) { + LogDebug("callhistory query error [" << ret << "]"); + } + + if (parseRecord(&recordList, callHistoryListPtr)) { + event->setResult(callHistoryListPtr); + } + + contacts_list_destroy(recordList, true); + contacts_query_destroy(query); + contacts_filter_destroy(filter); + } catch (const Commons::PlatformException& ex) { + LogError("Exception: " << ex.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } +} + +void CallHistory::OnRequestReceived(const EventRemoveBatchPtr& event) +{ + int* list = NULL; + + try { + std::vector entryIds = event->getEntryIds(); + unsigned int cnt = 0; + int ret = CONTACTS_ERROR_NONE; + list = new int[entryIds.size()]; + + for (cnt = 0; cnt < entryIds.size(); cnt++) { + list[cnt] = static_cast(entryIds[cnt]); + } + + if (entryIds.size() > 0) { + EventRemoveBatchDataPtr eventData( new EventCallHistoryPtrs(event, this)); + + JSCallbackManagerPtr data = DPL::DynamicPointerCast(event->getPrivateData()); + if (data != NULL) { + if (data->getOnSuccess() != NULL) { + ret = contacts_db_delete_records_async(_contacts_phone_log._uri, list, entryIds.size(), removeBatchCB, eventData.Get()); + if (ret == CONTACTS_ERROR_NONE) { + m_removeBatchEvent.push_back(eventData); + event->switchToManualAnswer(); + } else { + LogDebug("callhistory remove Batch error [" << ret << "]"); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } + } else { + ret = contacts_db_delete_records(_contacts_phone_log._uri, list, entryIds.size()); + if (ret != CONTACTS_ERROR_NONE) { + LogDebug("callhistory remove Batch error [" << ret << "]"); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } + } + } else { + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } + } + + } catch (const Commons::PlatformException& ex) { + LogError("Exception: " << ex.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } + + if (list != NULL) { + delete[] list; + list = NULL; + } +} + +void CallHistory::OnRequestReceived(const EventRemoveAllPtr& event) +{ + int* list = NULL; + + try { + int ret = CONTACTS_ERROR_NONE; + contacts_list_h record_list = NULL; + contacts_record_h record = NULL; + unsigned int total = 0; + unsigned int cnt = 0; + int value = 0; + + ret = contacts_db_get_all_records(_contacts_phone_log._uri, 0, 0, &record_list); + + if (record_list == NULL) { + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + return; + } + + contacts_list_get_count(record_list, &total); + + list = new int[total]; + LogDebug("total [" << total << "]"); + for (unsigned int i = 0; i < total; i++) { + ret = contacts_list_get_current_record_p(record_list, &record); + + if (record == NULL) { + ret = contacts_list_next(record_list); + if ( !(ret==CONTACTS_ERROR_NONE || ret==CONTACTS_ERROR_NO_DATA) ){ + LogDebug("callhistory remove All error [" << ret << "]"); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } + continue; + } + + if (ret == CONTACTS_ERROR_NONE) { + ret = contacts_record_get_int(record, _contacts_phone_log.id , &value); + if (ret == CONTACTS_ERROR_NONE) { + list[cnt] = value; + cnt++; + } + } + value = 0; + ret = contacts_list_next(record_list); + if ( !(ret==CONTACTS_ERROR_NONE || ret==CONTACTS_ERROR_NO_DATA) ){ + LogDebug("callhistory remove All error [" << ret << "]"); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } + } + + LogDebug("cnt [" << cnt << "]"); + + if (cnt > 0) { + EventRemoveAllDataPtr eventData( new EventCallHistoryPtrs(event, this)); + + JSCallbackManagerPtr data = DPL::DynamicPointerCast(event->getPrivateData()); + if (data != NULL) { + if (data->getOnSuccess() != NULL) { + ret = contacts_db_delete_records_async(_contacts_phone_log._uri, list, cnt, removeAllCB, eventData.Get()); + if (ret == CONTACTS_ERROR_NONE) { + m_removeAllEvent.push_back(eventData); + event->switchToManualAnswer(); + } else { + LogDebug("callhistory remove All error [" << ret << "]"); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } + } else { + ret = contacts_db_delete_records(_contacts_phone_log._uri, list, cnt); + if (ret != CONTACTS_ERROR_NONE) { + LogDebug("callhistory remove All error [" << ret << "]"); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } + } + } + } + + contacts_list_destroy(record_list, true); + } catch (const Commons::PlatformException& ex) { + LogError("Exception: " << ex.GetMessage()); + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } + + if (list != NULL) { + delete[] list; + list = NULL; + } +} + +void CallHistory::callRemoveBatchEvent(int error, const EventRemoveBatchPtr &event) +{ + if (error != CONTACTS_ERROR_NONE) { + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } + + EventRequestReceiver::ManualAnswer(event); + + std::vector::iterator it; + for (it = m_removeBatchEvent.begin(); it != m_removeBatchEvent.end(); ++it) { + if ((*it)->getEventPtrs() == event) { + m_removeBatchEvent.erase(it); + LogDebug("event is removed. (" << m_removeBatchEvent.size() << ")"); + break; + } + } +} + +void CallHistory::callRemoveAllEvent(int error, const EventRemoveAllPtr &event) +{ + if (error != CONTACTS_ERROR_NONE) { + event->setExceptionCode(Commons::ExceptionCodes::PlatformException); + } + + EventRequestReceiver::ManualAnswer(event); + + std::vector::iterator it; + for (it = m_removeAllEvent.begin(); it != m_removeAllEvent.end(); ++it) { + if ((*it)->getEventPtrs() == event) { + m_removeAllEvent.erase(it); + LogDebug("event is removed. (" << m_removeAllEvent.size() << ")"); + break; + } + } +} + +CallHistory::Watcher::Watcher(long handle, const EventCallHistoryListenerEmitterPtr& emitter) : + m_handle(handle), + m_emitter(emitter), + m_currentLogId(0) +{ + m_missedCallList = MissedCallListPtr(new MissedCallList()); + if (contacts_connect2() == CONTACTS_ERROR_NONE) { + LogDebug("Successful to connect Call history DB "); + } else { + LogDebug("Failed to connect Call history DB "); + } +} + +CallHistory::Watcher::~Watcher() +{ + if (contacts_disconnect2() == CONTACTS_ERROR_NONE) { + LogDebug("Successful to disconnect Call history DB "); + } else { + LogDebug("Failed to disconnect Call history DB "); + } +} + +void CallHistory::Watcher::stateHasChanged(CallHistoryEntryListPtr &entryList, EventCallHistoryListener::ResultStates state) +{ + if (entryList == NULL) + return; + + EventCallHistoryListenerPtr event(new EventCallHistoryListener()); + event->setResultState(state); + event->setResult(entryList); + m_emitter->emit(event); +} + +bool CallHistory::Watcher::parseRecord(contacts_list_h *recordList, CallHistoryEntryListPtr &entryList) +{ + CallHistory* callHistory = (CallHistory *) this; + if (callHistory != NULL) { + return callHistory->parseRecord(recordList, entryList); + } + return false; +} + +bool CallHistory::Watcher::addMissedCall(CallHistoryEntryListPtr &entryList) +{ + if (entryList != NULL) { + CallHistoryEntryList::iterator it = entryList->begin(); + for (; it != entryList->end(); it++) { + if ((*it)->getDirection().compare(STR_MISSED_NEW) == 0) { + m_missedCallList->push_back((*it)->getEntryId()); + } + } + return true; + } + return false; +} + +bool CallHistory::Watcher::updateCurrentMissedCall() +{ + CallHistory* callHistory = (CallHistory *) this; + if (callHistory != NULL) { + setMissedCallList(callHistory->updateCurrentMissedCall()); + return true; + } + return false; +} + +void CallHistory::Watcher::addedListenerCB() +{ + CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList()); + int ret = CONTACTS_ERROR_NONE; + + contacts_query_h query = NULL; + contacts_filter_h filter = NULL; + contacts_list_h recordList = NULL; + + contacts_query_create(_contacts_phone_log._uri, &query); + contacts_filter_create(_contacts_phone_log._uri, &filter); + contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED); + contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + contacts_filter_add_int(filter, _contacts_phone_log.id, CONTACTS_MATCH_GREATER_THAN, static_cast(getCurrentLogId())); + + contacts_query_set_filter(query, filter); + contacts_query_set_sort(query, _contacts_phone_log.id, false); + ret = contacts_db_get_records_with_query(query, 0, 0, &recordList); + + if (ret != CONTACTS_ERROR_NONE) { + LogDebug("callhistory query error [" << ret << "]"); + } + + if (parseRecord(&recordList, callHistoryListPtr)) { + if (callHistoryListPtr->size() > 0) { + setCurrentLogId((*callHistoryListPtr)[0]->getEntryId()); + stateHasChanged(callHistoryListPtr, EventCallHistoryListener::ADDED); + addMissedCall(callHistoryListPtr); + } + } + + contacts_list_destroy(recordList, true); + contacts_query_destroy(query); + contacts_filter_destroy(filter); +} + +void CallHistory::Watcher::changedListenerCB() +{ + MissedCallListPtr missedCallListPtr(getMissedCallList()); + CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList()); + int ret = CONTACTS_ERROR_NONE; + + contacts_query_h query = NULL; + contacts_filter_h filter = NULL; + contacts_list_h recordList = NULL; + + if (missedCallListPtr->size() > 0) { + contacts_query_create(_contacts_phone_log._uri, &query); + contacts_filter_create(_contacts_phone_log._uri, &filter); + contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED); + contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + + MissedCallList::iterator itM = missedCallListPtr->begin(); + + do { + if (itM != missedCallListPtr->begin()) { + contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR); + } + contacts_filter_add_int(filter, _contacts_phone_log.id, CONTACTS_MATCH_EQUAL, static_cast(*itM)); + itM++; + } while(itM < missedCallListPtr->end()); + + contacts_query_set_filter(query, filter); + contacts_query_set_sort(query, _contacts_phone_log.id, false); + ret = contacts_db_get_records_with_query(query, 0, 0, &recordList); + + if (ret != CONTACTS_ERROR_NONE) { + LogDebug("callhistory query error [" << ret << "]"); + } + + if (parseRecord(&recordList, callHistoryListPtr)) { + CallHistoryEntryList::iterator itC = callHistoryListPtr->begin(); + + for (;itC != callHistoryListPtr->end();) { + if ((*itC)->getDirection().compare(STR_MISSED) != 0) { + itC = callHistoryListPtr->erase(itC); + continue; + } + ++itC; + } + + if (callHistoryListPtr->size() > 0) { + updateCurrentMissedCall(); + stateHasChanged(callHistoryListPtr, EventCallHistoryListener::CHANGED); + } + } + + contacts_list_destroy(recordList, true); + contacts_query_destroy(query); + contacts_filter_destroy(filter); + } + +} + +} +} + diff --git a/src/Callhistory/CallHistory.h b/src/Callhistory/CallHistory.h new file mode 100755 index 0000000..d219db1 --- /dev/null +++ b/src/Callhistory/CallHistory.h @@ -0,0 +1,160 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_PLATFORM_CALLHISTORY_H_ +#define TIZENAPIS_PLATFORM_CALLHISTORY_H_ + +#include +#include +#include + +#include "ICallHistory.h" +#include "CallHistoryFactory.h" +#include "EventCallHistoryTemplate.h" +#include "EventCallHistory.h" +#include "EventFindCallHistory.h" +#include "EventRemoveBatch.h" +#include "EventRemoveAll.h" +#include "EventCallHistoryListener.h" +#include "CallHistoryEntryProperties.h" +#include "RemoteParty.h" +#include + +namespace DeviceAPI { +namespace CallHistory { + +typedef DPL::SharedPtr> EventRemoveBatchDataPtr; +typedef DPL::SharedPtr> EventRemoveAllDataPtr; + +typedef std::vector MissedCallList; +typedef DPL::SharedPtr MissedCallListPtr; + +typedef struct +{ + int calllog_db_id; + contacts_phone_log_type_e calllog_type; + int person_db_id; + char* phone_number; + time_t timestamp; + int duration_sec; +} callhistory_query_s; + +class CallHistory : public ICallHistory +{ +public: + CallHistory(); + ~CallHistory(); + + static void callhistoryListenerCB(const char* view_uri, void* user_data); + static void removeBatchCB(int error, void *user_data); + static void removeAllCB(int error, void *user_data); + + void find(const EventFindCallHistoryPtr& event); + bool remove(const unsigned long entryId); + void removeBatch(const EventRemoveBatchPtr& event); + void removeAll(const EventRemoveAllPtr& event); + long addListener(const EventCallHistoryListenerEmitterPtr& emitter); + void removeListener(const long id); + + class Watcher + { + private: + long m_handle; + EventCallHistoryListenerEmitterPtr m_emitter; + unsigned int m_currentLogId; + MissedCallListPtr m_missedCallList; + + public: + Watcher(long handle, const EventCallHistoryListenerEmitterPtr& emitter); + ~Watcher(); + + void setHandle(long handle) + { + m_handle = handle; + } + + long getHandle() + { + return m_handle; + } + + void setCurrentLogId(unsigned int logId) + { + m_currentLogId = logId; + } + + unsigned int getCurrentLogId() + { + return m_currentLogId; + } + + void setMissedCallList(const MissedCallListPtr &missedCallList) + { + m_missedCallList = missedCallList; + } + + MissedCallListPtr getMissedCallList() + { + return m_missedCallList; + } + + EventCallHistoryListenerEmitterPtr getEmitter() + { + return m_emitter; + } + + void emit(const EventCallHistoryListenerPtr& event) + { + m_emitter->emit(event); + } + + void stateHasChanged(CallHistoryEntryListPtr &entryList, EventCallHistoryListener::ResultStates state); + bool parseRecord(contacts_list_h *recordList, CallHistoryEntryListPtr &entryList); + bool addMissedCall(CallHistoryEntryListPtr &entryList); + bool updateCurrentMissedCall(); + void addedListenerCB(); + void changedListenerCB(); + }; + typedef DPL::SharedPtr WatcherPtr; + +private: + bool convertCallHistory(callhistory_query_s *query_log, CallHistoryEntryListPtr &callEntries); + bool parseRecord(contacts_list_h *recordList, CallHistoryEntryListPtr &callEntries); + unsigned int convertAttrName(std::string &name); + MissedCallListPtr updateCurrentMissedCall(); + + std::vector m_removeBatchEvent; + std::vector m_removeAllEvent; + + void callRemoveBatchEvent(int error, const EventRemoveBatchPtr &event); + void callRemoveAllEvent(int error, const EventRemoveAllPtr &event); + +protected: + void OnRequestReceived(const EventCallHistoryPtr& event); + void OnRequestReceived(const EventFindCallHistoryPtr& event); + void OnRequestReceived(const EventRemoveBatchPtr& event); + void OnRequestReceived(const EventRemoveAllPtr& event); + +private: + static std::vector m_watchers; +}; + +} +} + +#endif diff --git a/src/Callhistory/CallHistoryAsyncCallbackManager.cpp b/src/Callhistory/CallHistoryAsyncCallbackManager.cpp new file mode 100755 index 0000000..244c58d --- /dev/null +++ b/src/Callhistory/CallHistoryAsyncCallbackManager.cpp @@ -0,0 +1,29 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "CallHistoryAsyncCallbackManager.h" +#include + +using namespace DPL; + +IMPLEMENT_SINGLETON(DeviceAPI::CallHistory::CallHistoryAsyncCallbackManager) + +namespace DeviceAPI { +namespace CallHistory { + +} // Tizen1_0 +} // TizenApis diff --git a/src/Callhistory/CallHistoryAsyncCallbackManager.h b/src/Callhistory/CallHistoryAsyncCallbackManager.h new file mode 100755 index 0000000..dca7c9c --- /dev/null +++ b/src/Callhistory/CallHistoryAsyncCallbackManager.h @@ -0,0 +1,46 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _TIZEN_CALLHISTORY_ASYNC_CALLBACK_MANAGER_H_ +#define _TIZEN_CALLHISTORY_ASYNC_CALLBACK_MANAGER_H_ + +#include +#include + +namespace DeviceAPI { +namespace CallHistory { + +class CallHistoryAsyncCallbackManager : public DeviceAPI::Common::AsyncCallbackManager +{ +public: + CallHistoryAsyncCallbackManager() + { + } + + virtual ~CallHistoryAsyncCallbackManager() + { + } + + friend class DPL::Singleton; +}; + +typedef DPL::Singleton CallHistoryAsyncCallbackManagerSingleton; + +} // Tizen1_0 +} // TizenApis + +#endif // _TIZEN_CALLHISTORY_ASYNC_CALLBACK_MANAGER_H_ \ No newline at end of file diff --git a/src/Callhistory/CallHistoryDefine.h b/src/Callhistory/CallHistoryDefine.h new file mode 100755 index 0000000..783b656 --- /dev/null +++ b/src/Callhistory/CallHistoryDefine.h @@ -0,0 +1,69 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_CALLHISTORY_DEFINE_H_ +#define TIZENAPIS_API_CALLHISTORY_DEFINE_H_ + +namespace { + +#define STR_TIZEN_TEL "TEL" +#define STR_TIZEN_XMPP "XMPP" +#define STR_TIZEN_SIP "SIP" + +#define STR_CALL "CALL" +#define STR_CALL_VOICE "VOICECALL" +#define STR_CALL_VIDEO "VIDEOCALL" +#define STR_CALL_EMERGENCY "EMERGENCYCALL" + +#define STR_DIALED "DIALED" +#define STR_RECEIVED "RECEIVED" +#define STR_MISSED_NEW "MISSEDNEW" +#define STR_MISSED "MISSED" +#define STR_REJECTED "REJECTED" +#define STR_BLOCKED "BLOCKED" + +#define STR_ENTRY_ID "uid" +#define STR_SERVICE_ID "serviceId" +#define STR_CALL_TYPE "type" +#define STR_TAGS "features" +#define STR_REMOTE_PARTIES "remoteParties" +#define STR_FORWARDEDFROM "forwardedFrom" +#define STR_START_TIME "startTime" +#define STR_DURATION "duration" +#define STR_END_REASON "endReason" +#define STR_DIRECTION "direction" +#define STR_RECORDING "recording" +#define STR_COST "cost" +#define STR_CURRENCY "currency" + +#define STR_REMOTE_PARTY "remoteParty" +#define STR_PERSIONID "personId" + +#define STR_RP_REMOTEPARTY "remoteParties.remoteParty" +#define STR_RP_PERSONID "remoteParties.personId" + +#define STR_LOG_ID "id" +#define STR_NUMBER "number" +#define STR_LOG_TIME "log_time" +#define STR_LOG_TYPE "log_type" +#define STR_DATA1 "data1" +#define STR_PERSON_ID "person_id" + +} + +#endif diff --git a/src/Callhistory/CallHistoryEntry.cpp b/src/Callhistory/CallHistoryEntry.cpp new file mode 100755 index 0000000..6ba1a88 --- /dev/null +++ b/src/Callhistory/CallHistoryEntry.cpp @@ -0,0 +1,89 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#include "CallHistoryEntry.h" + +#include +#include +#include +#include + +using namespace DeviceAPI::Tizen; +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; +using namespace DPL; + +namespace DeviceAPI { +namespace CallHistory { + +CallHistoryEntry::CallHistoryEntry() +{ + if (contacts_connect2() == CONTACTS_ERROR_NONE) { + LogDebug("Successful to connect Call history DB "); + } else { + LogDebug("Failed to connect Call history DB "); + } +} + +CallHistoryEntry::~CallHistoryEntry() +{ + if (contacts_disconnect2() == CONTACTS_ERROR_NONE) { + LogDebug("Successful to disconnect Call history DB "); + } else { + LogDebug("Failed to disconnect Call history DB "); + } +} + +void CallHistoryEntry::setMarkSeen(const unsigned long entryId) +{ + contacts_record_h record = NULL; + int ret = -1; + int logType = 0; + + ret = contacts_db_get_record (_contacts_phone_log._uri, (int)entryId, &record); + + if (ret != CONTACTS_ERROR_NONE) { + ThrowMsg(Commons::ConversionException, "Type missmatch error"); + return; + } + + contacts_record_get_int (record, _contacts_phone_log.log_type, &logType); + + if (logType == 5) { + contacts_record_set_int (record, _contacts_phone_log.log_type, 6); + } else if (logType == 7) { + contacts_record_set_int (record, _contacts_phone_log.log_type, 8); + } else { + contacts_record_destroy(record, true); + ThrowMsg(Commons::ConversionException, "Type missmatch error"); + return; + } + + ret = contacts_db_update_record (record); + + if (ret != CONTACTS_ERROR_NONE) { + contacts_record_destroy(record, true); + ThrowMsg(Commons::ConversionException, "Type missmatch error"); + return; + } + + contacts_record_destroy(record, true); +} + +} +} diff --git a/src/Callhistory/CallHistoryEntry.h b/src/Callhistory/CallHistoryEntry.h new file mode 100755 index 0000000..61139ea --- /dev/null +++ b/src/Callhistory/CallHistoryEntry.h @@ -0,0 +1,44 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_PLATFORM_CALLHISTORYENTRY_H_ +#define TIZENAPIS_PLATFORM_CALLHISTORYENTRY_H_ + +#include +#include +#include + +#include "ICallHistoryEntry.h" +#include "CallHistoryFactory.h" + +namespace DeviceAPI { +namespace CallHistory { + +class CallHistoryEntry : public ICallHistoryEntry +{ +public: + CallHistoryEntry(); + ~CallHistoryEntry(); + + void setMarkSeen(const unsigned long entryId); +}; + +} +} + +#endif diff --git a/src/Callhistory/CallHistoryEntryProperties.cpp b/src/Callhistory/CallHistoryEntryProperties.cpp new file mode 100755 index 0000000..2456926 --- /dev/null +++ b/src/Callhistory/CallHistoryEntryProperties.cpp @@ -0,0 +1,183 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "CallHistoryEntryProperties.h" + +namespace DeviceAPI { +namespace CallHistory { + +CallHistoryEntryProperties::CallHistoryEntryProperties() : + m_entryId(0), + m_serviceId(""), + m_callType(""), + m_startTime(0), + m_duration(0), + m_endReason(""), + m_direction(""), + m_cost(0), + m_currency(""), + m_filterMark(false) +{ + m_tags = StringArrayPtr(new StringArray()); + m_remoteParties = RemotePartyListPtr(new RemotePartyList()); + m_forwardedFrom = RemotePartyPtr(new RemoteParty()); + m_recording = StringArrayPtr(new StringArray()); +} + +void CallHistoryEntryProperties::setEntryId(const unsigned long EntryId) +{ + m_entryId = EntryId; +} + +void CallHistoryEntryProperties::setServiceId(const std::string ServiceId) +{ + m_serviceId = ServiceId; +} + +void CallHistoryEntryProperties::setCallType(const std::string CallType) +{ + m_callType = CallType; +} + +void CallHistoryEntryProperties::setTags(const StringArrayPtr &Tags) +{ + m_tags = Tags; +} + +void CallHistoryEntryProperties::setRemoteParties(const RemotePartyListPtr &RemoteParties) +{ + m_remoteParties = RemoteParties; +} + +void CallHistoryEntryProperties::setForwardedFrom(const RemotePartyPtr &ForwardedFrom) +{ + m_forwardedFrom = ForwardedFrom; +} + +void CallHistoryEntryProperties::setStartTime(const time_t StartTime) +{ + m_startTime = StartTime; +} + +void CallHistoryEntryProperties::setDuration(const unsigned long Duration) +{ + m_duration = Duration; +} + +void CallHistoryEntryProperties::setEndReason(const std::string EndReason) +{ + m_endReason = EndReason; +} + +void CallHistoryEntryProperties::setDirection(const std::string Direction) +{ + m_direction = Direction; +} + +void CallHistoryEntryProperties::setRecording(const StringArrayPtr &Recording) +{ + m_recording = Recording; +} + +void CallHistoryEntryProperties::setCost(const unsigned long Cost) +{ + m_cost = Cost; +} + +void CallHistoryEntryProperties::setCurrency(const std::string Currency) +{ + m_currency = Currency; +} + + +void CallHistoryEntryProperties::setFilterMark(const bool Mark) +{ + m_filterMark = Mark; +} + +unsigned long CallHistoryEntryProperties::getEntryId() const +{ + return m_entryId; +} + +std::string CallHistoryEntryProperties::getServiceId() const +{ + return m_serviceId; +} + +std::string CallHistoryEntryProperties::getCallType() const +{ + return m_callType; +} + +StringArrayPtr CallHistoryEntryProperties::getTags() const +{ + return m_tags; +} + +RemotePartyListPtr CallHistoryEntryProperties::getRemoteParties() const +{ + return m_remoteParties; +} + +RemotePartyPtr CallHistoryEntryProperties::getForwardedFrom() const +{ + return m_forwardedFrom; +} + +time_t CallHistoryEntryProperties::getStartTime() const +{ + return m_startTime; +} + +unsigned long CallHistoryEntryProperties::getDuration() const +{ + return m_duration; +} + +std::string CallHistoryEntryProperties::getEndReason() const +{ + return m_endReason; +} + +std::string CallHistoryEntryProperties::getDirection() const +{ + return m_direction; +} + +StringArrayPtr CallHistoryEntryProperties::getRecording() const +{ + return m_recording; +} + +unsigned long CallHistoryEntryProperties::getCost() const +{ + return m_cost; +} + +std::string CallHistoryEntryProperties::getCurrency() const +{ + return m_currency; +} + +bool CallHistoryEntryProperties::getFilterMark() const +{ + return m_filterMark; +} + +} +} diff --git a/src/Callhistory/CallHistoryEntryProperties.h b/src/Callhistory/CallHistoryEntryProperties.h new file mode 100755 index 0000000..c197633 --- /dev/null +++ b/src/Callhistory/CallHistoryEntryProperties.h @@ -0,0 +1,91 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_CALLHISTORY_ENTRY_PROPERTIES_H_ +#define TIZENAPIS_API_CALLHISTORY_ENTRY_PROPERTIES_H_ + +#include +#include +#include +#include "RemoteParty.h" + +namespace DeviceAPI { +namespace CallHistory { + +class CallHistoryEntryProperties; +typedef DPL::SharedPtr CallHistoryEntryPropertiesPtr; +typedef std::vector CallHistoryEntryList; +typedef DPL::SharedPtr CallHistoryEntryListPtr; +typedef std::vector StringArray; +typedef DPL::SharedPtr StringArrayPtr; + +class CallHistoryEntryProperties +{ +private: + unsigned long m_entryId; + std::string m_serviceId; + std::string m_callType; + StringArrayPtr m_tags; + RemotePartyListPtr m_remoteParties; + RemotePartyPtr m_forwardedFrom; + time_t m_startTime; + unsigned long m_duration; + std::string m_endReason; + std::string m_direction; + StringArrayPtr m_recording; + unsigned long m_cost; + std::string m_currency; + + bool m_filterMark; + +public: + void setEntryId(const unsigned long EntryId); + void setServiceId(const std::string ServiceId); + void setCallType(const std::string CallType); + void setTags(const StringArrayPtr &Tags); + void setRemoteParties(const RemotePartyListPtr &RemoteParties); + void setForwardedFrom(const RemotePartyPtr &ForwardedFrom); + void setStartTime(const time_t StartTime); + void setDuration(const unsigned long Duration); + void setEndReason(const std::string EndReason); + void setDirection(const std::string Direction); + void setRecording(const StringArrayPtr &Recording); + void setCost(const unsigned long Cost); + void setCurrency(const std::string Currency); + void setFilterMark(const bool mark); + + unsigned long getEntryId() const; + std::string getServiceId() const; + std::string getCallType() const; + StringArrayPtr getTags() const; + RemotePartyListPtr getRemoteParties() const; + RemotePartyPtr getForwardedFrom() const; + time_t getStartTime() const; + unsigned long getDuration() const; + std::string getEndReason() const; + std::string getDirection() const; + StringArrayPtr getRecording() const; + unsigned long getCost() const; + std::string getCurrency() const; + bool getFilterMark() const; + + CallHistoryEntryProperties(); +}; +} +} +#endif \ No newline at end of file diff --git a/src/Callhistory/CallHistoryFactory.cpp b/src/Callhistory/CallHistoryFactory.cpp new file mode 100755 index 0000000..92fbe61 --- /dev/null +++ b/src/Callhistory/CallHistoryFactory.cpp @@ -0,0 +1,49 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "CallHistory.h" +#include "CallHistoryEntry.h" +#include "CallHistoryFactory.h" + +namespace DeviceAPI { +namespace CallHistory { + +CallHistoryFactory& CallHistoryFactory::getInstance() +{ + static CallHistoryFactory theInstance; + return theInstance; +} + +ICallHistoryPtr CallHistoryFactory::getCallHistoryObject() +{ + ICallHistoryPtr result(new CallHistory()); + return result; +} + +ICallHistoryEntryPtr CallHistoryFactory::getCallHistoryEntryObject() +{ + ICallHistoryEntryPtr result(new CallHistoryEntry()); + return result; +} + +CallHistoryFactory::CallHistoryFactory() +{ +} + +} +} diff --git a/src/Callhistory/CallHistoryFactory.h b/src/Callhistory/CallHistoryFactory.h new file mode 100755 index 0000000..0eac6db --- /dev/null +++ b/src/Callhistory/CallHistoryFactory.h @@ -0,0 +1,43 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_CALLHISTORY_FACTORY_H_ +#define _ABSTRACT_LAYER_CALLHISTORY_FACTORY_H_ + +#include +#include "ICallHistory.h" +#include "ICallHistoryEntry.h" + +namespace DeviceAPI { +namespace CallHistory { + +class CallHistoryFactory : public DPL::Noncopyable +{ +public: + static CallHistoryFactory& getInstance(); + ICallHistoryPtr getCallHistoryObject(); + ICallHistoryEntryPtr getCallHistoryEntryObject(); + +protected: + CallHistoryFactory(); +}; + +} +} + +#endif \ No newline at end of file diff --git a/src/Callhistory/CallHistoryFilter.cpp b/src/Callhistory/CallHistoryFilter.cpp new file mode 100755 index 0000000..ef553af --- /dev/null +++ b/src/Callhistory/CallHistoryFilter.cpp @@ -0,0 +1,301 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include + +#include "CallHistoryDefine.h" +#include "CallHistoryFilter.h" + +using namespace std; +using namespace DeviceAPI::Tizen; + +namespace DeviceAPI { +namespace CallHistory { + +CallHistoryFilter::CallHistoryFilter(contacts_filter_h filter) +{ + m_filterStack.push(filter); +} + +CallHistoryFilter::~CallHistoryFilter() +{ + contacts_filter_h filter = NULL; + while (m_filterStack.size() > 1) { + filter = m_filterStack.top(); + contacts_filter_destroy(filter); + m_filterStack.pop(); + } +} + +void CallHistoryFilter::visitPreComposite(FilterType& type, int depth) +{ + LogDebug(" type [" << type << "] depth[" << depth << "]"); + contacts_filter_h filter = NULL; + contacts_filter_create(_contacts_phone_log._uri, &filter); + if (filter != NULL) { + m_filterStack.push(filter); + } + LogDebug("filter stack size [" << m_filterStack.size() << "]"); +} + +void CallHistoryFilter::visitInComposite(FilterType& type, int depth) +{ + LogDebug("type [" << type << "] depth[" << depth << "]"); + contacts_filter_h filter = m_filterStack.top(); + if(type == DeviceAPI::Tizen::UNION_FILTER) + contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR); + else if(type == DeviceAPI::Tizen::INTERSECTION_FILTER) + contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + + LogDebug("filter stack size [" << m_filterStack.size() << "]"); +} + +void CallHistoryFilter::visitPostComposite(FilterType& type, int depth) +{ + LogDebug(" type [" << type << "] depth[" << depth << "]"); + contacts_filter_h filter = m_filterStack.top(); + if (m_filterStack.size() > 1) { + m_filterStack.pop(); + contacts_filter_h filterParent = m_filterStack.top(); + contacts_filter_add_filter(filterParent, filter); + contacts_filter_destroy(filter); + } + LogDebug("filter stack size [" << m_filterStack.size() << "]"); +} + +void CallHistoryFilter::visitAttribute(std::string& attrName, MatchFlag& matchFlag, DeviceAPI::Tizen::AnyPtr& matchValue, int depth) +{ + std::string str (""); + contacts_match_str_flag_e mFlag; + + if (matchValue == NULL) { + return; + } + + LogDebug("attrName [" << attrName << "] matchValue[" << matchValue->toString() << "] depth[" << depth << "]"); + contacts_filter_h filter = m_filterStack.top(); + contacts_filter_h subFilter = NULL; + contacts_filter_create(_contacts_phone_log._uri, &subFilter); + + switch (matchFlag) { + case MATCH_EXACTLY: + mFlag = CONTACTS_MATCH_EXACTLY; + break; + case MATCH_FULLSTRING: + mFlag = CONTACTS_MATCH_FULLSTRING; + break; + case MATCH_CONTAINS: + mFlag = CONTACTS_MATCH_CONTAINS; + break; + case MATCH_STARTSWITH: + mFlag = CONTACTS_MATCH_STARTSWITH; + break; + case MATCH_ENDSWITH: + mFlag = CONTACTS_MATCH_ENDSWITH; + break; + case MATCH_EXISTS: + mFlag = CONTACTS_MATCH_EXISTS; + break; + default: + mFlag = CONTACTS_MATCH_EXACTLY; + } + + if (attrName.compare(STR_DIRECTION) == 0) { + if (matchValue->toString().compare(STR_RECEIVED) == 0) { + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_INCOMMING); + contacts_filter_add_filter(filter, subFilter); + } else if (matchValue->toString().compare(STR_DIALED) == 0) { + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_OUTGOING); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_OUTGOING); + contacts_filter_add_filter(filter, subFilter); + } else if (matchValue->toString().compare(STR_MISSED) == 0) { + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING_SEEN); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_INCOMMING_SEEN); + contacts_filter_add_filter(filter, subFilter); + } else if (matchValue->toString().compare(STR_MISSED_NEW) == 0) { + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_INCOMMING_UNSEEN); + contacts_filter_add_filter(filter, subFilter); + } else if (matchValue->toString().compare(STR_REJECTED) == 0) { + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_REJECT); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_REJECT); + contacts_filter_add_filter(filter, subFilter); + } else if (matchValue->toString().compare(STR_BLOCKED) == 0) { + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_BLOCKED); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED); + contacts_filter_add_filter(filter, subFilter); + } else { + contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_NONE); + } + } else if (attrName.compare(STR_TAGS) == 0) { + if (matchValue->toString().compare(STR_CALL) == 0) { + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_AND); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED); + contacts_filter_add_filter(filter, subFilter); + } else if (matchValue->toString().compare(STR_CALL_VOICE) == 0) { + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_OUTGOING); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING_SEEN); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_REJECT); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_BLOCKED); + contacts_filter_add_filter(filter, subFilter); + } else if (matchValue->toString().compare(STR_CALL_VIDEO) == 0) { + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_INCOMMING); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_OUTGOING); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_INCOMMING_UNSEEN); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_INCOMMING_SEEN); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_REJECT); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED); + contacts_filter_add_filter(filter, subFilter); + } else { + contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_NONE); + } + } else if (attrName.compare(STR_RP_REMOTEPARTY) == 0) { + contacts_filter_add_str(filter, _contacts_phone_log.address, mFlag, matchValue->toString().c_str()); + } else if (attrName.compare(STR_RP_PERSONID) == 0) { + contacts_filter_add_str(filter, _contacts_phone_log.person_id, mFlag, matchValue->toString().c_str()); + } else if (attrName.compare(STR_START_TIME) == 0) { + if(matchValue->getType() == PrimitiveType_Time) { + contacts_filter_add_int(filter, _contacts_phone_log.log_time, CONTACTS_MATCH_EQUAL, static_cast(matchValue->getTimeT())); + } + } else if (attrName.compare(STR_DURATION) == 0) { + contacts_filter_add_str(filter, _contacts_phone_log.extra_data1, mFlag, matchValue->toString().c_str()); + } else if (attrName.compare(STR_CALL_TYPE) == 0) { + if (matchValue->toString().compare(STR_TIZEN_TEL) == 0) { + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_AND); + contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED); + contacts_filter_add_filter(filter, subFilter); + } else { + contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_NONE); + } + } else if (attrName.compare(STR_ENTRY_ID) == 0) { + contacts_filter_add_str(filter, _contacts_phone_log.id, mFlag, matchValue->toString().c_str()); + } else { + contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_NONE); + } + + contacts_filter_destroy(subFilter); +} + +void CallHistoryFilter::visitAttributeRange(std::string& attrName, AnyPtr& initialValue, AnyPtr& endValue, int depth) +{ + if(initialValue == NULL || endValue == NULL) + return; + + LogDebug("attrName [" << attrName << "] initialValue[" << initialValue->toString() << "] endValue[" << endValue->toString() << "] depth[" << depth <<"]"); + contacts_filter_h filter = m_filterStack.top(); + + unsigned int propertyId = 0; + int iValue = 0; + int eValue = 0; + + if (attrName.compare(STR_RP_REMOTEPARTY) == 0) { + propertyId = _contacts_phone_log.address; + } else if (attrName.compare(STR_RP_PERSONID) == 0) { + propertyId = _contacts_phone_log.person_id; + } else if (attrName.compare(STR_START_TIME) == 0) { + propertyId = _contacts_phone_log.log_time; + } else if (attrName.compare(STR_DURATION) == 0) { + propertyId = _contacts_phone_log.extra_data1; + } else if (attrName.compare(STR_ENTRY_ID) == 0) { + propertyId = _contacts_phone_log.id; + } else { + return; + } + + if (!initialValue->isNullOrUndefined()) { + if (propertyId != _contacts_phone_log.address) { + if(initialValue->getType() == PrimitiveType_Time) { + iValue = static_cast(initialValue->getTimeT()); + } else { + iValue = atoi(initialValue->toString().c_str()); + } + } + LogDebug("attrName [" << attrName << "] initialValue[" << initialValue->toString() << "] iValue[" << iValue << "]"); + } + + if (!endValue->isNullOrUndefined()) { + if (propertyId != _contacts_phone_log.address) { + if(endValue->getType() == PrimitiveType_Time) { + eValue = static_cast(endValue->getTimeT()); + } else { + eValue = atoi(endValue->toString().c_str()); + } + } + LogDebug("attrName [" << attrName << "] endValue[" << endValue->toString() << "] eValue[" << eValue << "]"); + } + + contacts_filter_h subFilter = NULL; + contacts_filter_create(_contacts_phone_log._uri, &subFilter); + + if (propertyId == _contacts_phone_log.address) { + if (!initialValue->isNullOrUndefined() && endValue->isNullOrUndefined()) { + contacts_filter_add_str(filter, propertyId, CONTACTS_MATCH_STARTSWITH, initialValue->toString().c_str()); + } else if (initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) { + contacts_filter_add_str(filter, propertyId, CONTACTS_MATCH_ENDSWITH, endValue->toString().c_str()); + } else if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) { + contacts_filter_add_str(subFilter, propertyId, CONTACTS_MATCH_STARTSWITH, initialValue->toString().c_str()); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_AND); + contacts_filter_add_str(subFilter, propertyId, CONTACTS_MATCH_ENDSWITH, endValue->toString().c_str()); + contacts_filter_add_filter(filter, subFilter); + } + } else { + if (!initialValue->isNullOrUndefined() && endValue->isNullOrUndefined()) { + contacts_filter_add_int(filter, propertyId, CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, iValue); + } else if (initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) { + contacts_filter_add_int(filter, propertyId, CONTACTS_MATCH_LESS_THAN, eValue); + } else if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) { + contacts_filter_add_int(subFilter, propertyId, CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, iValue); + contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_AND); + contacts_filter_add_int(subFilter, propertyId, CONTACTS_MATCH_LESS_THAN, eValue); + contacts_filter_add_filter(filter, subFilter); + } + } + contacts_filter_destroy(subFilter); +} + +contacts_filter_h CallHistoryFilter::getResult() const +{ + LogDebug("filter stack size [" << m_filterStack.size() << "]"); + contacts_filter_h filter = m_filterStack.top(); + return filter; +} + +} +} diff --git a/src/Callhistory/CallHistoryFilter.h b/src/Callhistory/CallHistoryFilter.h new file mode 100755 index 0000000..df72f19 --- /dev/null +++ b/src/Callhistory/CallHistoryFilter.h @@ -0,0 +1,66 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_PLATFORM_CALLHISTORY_FILTER_H_ +#define TIZENAPIS_PLATFORM_CALLHISTORY_FILTER_H_ + +#include +#include +#include +#include "time.h" + +#include "IFilterVisitor.h" +#include "CallHistoryEntryProperties.h" +#include "CallHistoryDefine.h" +#include + +namespace DeviceAPI { +namespace CallHistory { + +class CallHistoryFilter: public DeviceAPI::Tizen::IFilterVisitor +{ +private: + std::stack m_filterStack; + +public: + CallHistoryFilter(contacts_filter_h filter); + ~CallHistoryFilter(); + + void visitPreComposite(DeviceAPI::Tizen::FilterType& type, int depth); + + void visitInComposite(DeviceAPI::Tizen::FilterType& type, int depth); + + void visitPostComposite(DeviceAPI::Tizen::FilterType& type, int depth); + + void visitAttribute(std::string& attrName, + DeviceAPI::Tizen::MatchFlag& matchFlag, + DeviceAPI::Tizen::AnyPtr& matchValue, + int depth); + + void visitAttributeRange(std::string& attrName, + DeviceAPI::Tizen::AnyPtr& initialValue, + DeviceAPI::Tizen::AnyPtr& endValue, + int depth); + + contacts_filter_h getResult() const; +}; + +typedef DPL::SharedPtr CallHistoryFilterPtr; + +} +} +#endif diff --git a/src/Callhistory/CallHistoryListenerManager.cpp b/src/Callhistory/CallHistoryListenerManager.cpp new file mode 100755 index 0000000..0922c13 --- /dev/null +++ b/src/Callhistory/CallHistoryListenerManager.cpp @@ -0,0 +1,29 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "CallHistoryListenerManager.h" +#include + +using namespace DPL; + +IMPLEMENT_SINGLETON(DeviceAPI::CallHistory::CallHistoryListenerManager) + +namespace DeviceAPI { +namespace CallHistory { + +} // Tizen1_0 +} // TizenApis diff --git a/src/Callhistory/CallHistoryListenerManager.h b/src/Callhistory/CallHistoryListenerManager.h new file mode 100755 index 0000000..4907537 --- /dev/null +++ b/src/Callhistory/CallHistoryListenerManager.h @@ -0,0 +1,79 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _TIZEN_CALLHISTORY_LISTENER_MANAGER_H_ +#define _TIZEN_CALLHISTORY_LISTENER_MANAGER_H_ + +#include +#include +#include +#include +#include +#include +#include "JSCallHistory.h" + +namespace DeviceAPI { +namespace CallHistory { + +class CallHistoryListenerManager : public DeviceAPI::Common::IListenerController +{ +public: + CallHistoryListenerManager() + { + } + + virtual ~CallHistoryListenerManager() + { + } +}; +typedef DPL::Singleton CallHistoryListenerManagerSingleton; + +class CallHistoryListenerCanceller : public DeviceAPI::Common::IListenerItem +{ +public: + CallHistoryListenerCanceller(JSContextRef context, JSObjectRef object, long watchId) : + DeviceAPI::Common::IListenerItem(context, object, watchId) + { + } + + virtual ~CallHistoryListenerCanceller() + { + } + + virtual void cancelListener() + { + JSCallHistoryPriv *priv = static_cast (JSObjectGetPrivate(m_object)); + + if (!priv) { + LogWarning("Object has no private object"); + return; + } + + try { + ICallHistoryPtr callHistory(priv->getObject()); + callHistory->removeListener(m_watchId); + } Catch(WrtDeviceApis::Commons::Exception) { + LogError("Error on platform : " << _rethrown_exception.GetMessage()); + } + } +}; +typedef DPL::SharedPtr CallHistoryListenerCancellerPtr; + +} // Tizen1_0 +} // TizenApis + +#endif // _TIZEN_CALLHISTORY_LISTENER_MANAGER_H_ \ No newline at end of file diff --git a/src/Callhistory/CallHistoryMultiCallback.cpp b/src/Callhistory/CallHistoryMultiCallback.cpp new file mode 100755 index 0000000..d5ad8f3 --- /dev/null +++ b/src/Callhistory/CallHistoryMultiCallback.cpp @@ -0,0 +1,42 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "CallHistoryMultiCallback.h" + + +namespace DeviceAPI { +namespace CallHistory { + +EventCallHistoryListenerPrivateData::EventCallHistoryListenerPrivateData( + const JSCallbackManagerPtr& onAdded, const JSCallbackManagerPtr& onChanged) : + m_onAdded(onAdded), m_onChanged(onChanged) +{ +} + +JSCallbackManagerPtr EventCallHistoryListenerPrivateData::getOnAdded() const +{ + return m_onAdded; +} + +JSCallbackManagerPtr EventCallHistoryListenerPrivateData::getOnChanged() const +{ + return m_onChanged; +} + +} +} + diff --git a/src/Callhistory/CallHistoryMultiCallback.h b/src/Callhistory/CallHistoryMultiCallback.h new file mode 100755 index 0000000..a4a3780 --- /dev/null +++ b/src/Callhistory/CallHistoryMultiCallback.h @@ -0,0 +1,61 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_CALLHISTORY_MULTI_CALLBACK_H_ +#define TIZENAPIS_TIZEN_CALLHISTORY_MULTI_CALLBACK_H_ + +#include +#include +#include +#include + +using namespace WrtDeviceApis::CommonsJavaScript; + +namespace DeviceAPI { +namespace CallHistory { + +struct CallHistoryChangeCB +{ + JSValueRef onAdded; + JSValueRef onChanged; + + CallHistoryChangeCB() : + onAdded(NULL), + onChanged(NULL) + { } +}; + +class EventCallHistoryListenerPrivateData : public WrtDeviceApis::Commons::IEventPrivateData +{ +public: + EventCallHistoryListenerPrivateData(const JSCallbackManagerPtr& onAdded, + const JSCallbackManagerPtr& onChanged); + + JSCallbackManagerPtr getOnAdded() const; + JSCallbackManagerPtr getOnChanged() const; + +private: + JSCallbackManagerPtr m_onAdded; + JSCallbackManagerPtr m_onChanged; +}; + +typedef DPL::SharedPtr EventCallHistoryListenerPrivateDataPtr; + +} +} + +#endif diff --git a/src/Callhistory/CallHistoryStaticController.cpp b/src/Callhistory/CallHistoryStaticController.cpp new file mode 100755 index 0000000..bb31144 --- /dev/null +++ b/src/Callhistory/CallHistoryStaticController.cpp @@ -0,0 +1,79 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include "CallHistoryStaticController.h" +#include "Converter.h" + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; + +namespace DeviceAPI { +namespace CallHistory { + +CallHistoryStaticController& CallHistoryStaticController::getInstance() +{ + static CallHistoryStaticController controller; + return controller; +} + +CallHistoryStaticController::CallHistoryStaticController() : + WrtDeviceApis::Commons::EventListener(ThreadEnum::NULL_THREAD) +{ +} + +void CallHistoryStaticController::onAnswerReceived(const EventCallHistoryListenerPtr& event) +{ + EventCallHistoryListenerPrivateDataPtr multiCallbacks = + DPL::DynamicPointerCast(event->getPrivateData()); + + if (multiCallbacks == NULL) { + return; + } + + if ((multiCallbacks->getOnAdded() == NULL) || (multiCallbacks->getOnChanged() == NULL)) { + return; + } + + JSCallbackManagerPtr defaultCbm = multiCallbacks->getOnAdded(); + JSContextRef context = defaultCbm->getContext(); + Converter converter(context); + + try { + JSValueRef result = converter.toJSValueRef(event->getResult(), context); + + switch (event->getResultState()) { + case EventCallHistoryListener::ADDED : + multiCallbacks->getOnAdded()->callOnSuccess(result); + break; + case EventCallHistoryListener::CHANGED : + multiCallbacks->getOnChanged()->callOnSuccess(result); + break; + } + } catch(ConversionException) { + LogError("Conversion exception while processing EventCallHistoryListener"); + } +} + +} +} diff --git a/src/Callhistory/CallHistoryStaticController.h b/src/Callhistory/CallHistoryStaticController.h new file mode 100755 index 0000000..15d48c0 --- /dev/null +++ b/src/Callhistory/CallHistoryStaticController.h @@ -0,0 +1,43 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_TIZEN_CALL_STATIC_CONTROLLER_H_ +#define TIZENAPIS_TIZEN_CALL_STATIC_CONTROLLER_H_ + +#include +#include +#include "EventCallHistoryListener.h" + +namespace DeviceAPI { +namespace CallHistory { + +class CallHistoryStaticController : + public WrtDeviceApis::Commons::EventListener +{ +public: + static CallHistoryStaticController& getInstance(); + + void onAnswerReceived(const EventCallHistoryListenerPtr& event); + +protected: + CallHistoryStaticController(); +}; +} +} + +#endif + diff --git a/src/Callhistory/Converter.cpp b/src/Callhistory/Converter.cpp new file mode 100755 index 0000000..433ccef --- /dev/null +++ b/src/Callhistory/Converter.cpp @@ -0,0 +1,265 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 + +#include +#include +#include +#include +#include +#include "CallHistoryDefine.h" +#include "JSCallHistoryEntry.h" +#include "JSRemoteParty.h" + +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; + +namespace DeviceAPI { +namespace CallHistory { + +Converter::Converter(JSContextRef context) : WrtDeviceApis::CommonsJavaScript::Converter(context) +{ + static bool init = initializeAllowedProperties(); + (void) init; +} + +std::vector Converter::toVectorOfULongs(const JSValueRef& jsValue) +{ + return toVectorOfT_(jsValue, &Converter::toULong); +} + +CallHistoryEntryList Converter::toVectorOfCallHistoryEntryProperties(const JSValueRef& jsValue) +{ + if (JSValueIsNull(m_context, jsValue) || JSValueIsUndefined(m_context, jsValue)) { + ThrowMsg(Commons::ConversionException, "Undefined history entry"); + } + + if (!JSIsArrayValue(m_context, jsValue)) { + ThrowMsg(Commons::ConversionException, "Argument is not an JS array."); + } + + try { + CallHistoryEntryList result; + JSObjectRef objArg = toJSObjectRef(jsValue); + for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); ++i) { + JSValueRef element = JSGetArrayElement(m_context, objArg, i); + result.push_back(toCallHistoryEntryProperties(element)); + } + return result; + } catch (Commons::ConversionException& ex) { + ThrowMsg(Commons::ConversionException, ex.GetMessage()); + } catch (Commons::InvalidArgumentException& ex) { + ThrowMsg(Commons::InvalidArgumentException, ex.GetMessage()); + } catch (Commons::Exception& ex) { + ThrowMsg(Commons::Exception, ex.GetMessage()); + } + +} + +StringArrayPtr Converter::toStringArray(const JSValueRef &jsValue) +{ + StringArrayPtr result(new StringArray()); + try { + if (!JSValueIsNull(m_context, jsValue)) { + JSObjectRef jsObject = toJSObjectRef(jsValue); + + for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) { + JSValueRef element = JSGetArrayElement(m_context, jsObject, i); + result->push_back(toString(element)); + } + } + } catch (Commons::ConversionException& ex) { + ThrowMsg(Commons::ConversionException, ex.GetMessage()); + } catch (Commons::InvalidArgumentException& ex) { + ThrowMsg(Commons::InvalidArgumentException, ex.GetMessage()); + } catch (Commons::Exception& ex) { + ThrowMsg(Commons::Exception, ex.GetMessage()); + } + return result; +} + +RemotePartyListPtr Converter::toRemotePartyList(const JSValueRef &jsValue) +{ + RemotePartyListPtr result(new RemotePartyList()); + try { + if (!JSValueIsNull(m_context, jsValue)) { + JSObjectRef jsObject = toJSObjectRef(jsValue); + + for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) { + JSValueRef element = JSGetArrayElement(m_context, jsObject, i); + result->push_back(toRemoteParty(element)); + } + } + } catch (Commons::ConversionException& ex) { + ThrowMsg(Commons::ConversionException, ex.GetMessage()); + } catch (Commons::InvalidArgumentException& ex) { + ThrowMsg(Commons::InvalidArgumentException, ex.GetMessage()); + } catch (Commons::Exception& ex) { + ThrowMsg(Commons::Exception, ex.GetMessage()); + } + return result; +} + +RemotePartyPtr Converter::toRemoteParty(const JSValueRef &jsValue) +{ + try { + return JSRemoteParty::getRemoteParty(m_context, jsValue); + } catch (Commons::ConversionException& ex) { + ThrowMsg(Commons::ConversionException, ex.GetMessage()); + } catch (Commons::Exception& ex) { + ThrowMsg(Commons::Exception, ex.GetMessage()); + } +} + +CallHistoryEntryPropertiesPtr Converter::toCallHistoryEntryProperties(const JSValueRef &jsValue) +{ + try { + return JSCallHistoryEntry::getCallHistoryEntry(m_context, jsValue); + } catch (Commons::ConversionException& ex) { + ThrowMsg(Commons::ConversionException, ex.GetMessage()); + } catch (Commons::Exception& ex) { + ThrowMsg(Commons::Exception, ex.GetMessage()); + } +} + +EventCallHistoryListenerPrivateDataPtr + Converter::toEventCallHistoryListenerPrivateData(const JSValueRef &jsValue, JSContextRef context) +{ + if (JSValueIsNull(m_context, jsValue) || JSValueIsUndefined(m_context, jsValue)) { + ThrowMsg(Commons::ConversionException, "Type missmatch error : Listener callback is null or undefined"); + } + if (!JSValueIsObject(m_context, jsValue) || JSObjectIsFunction(m_context, toJSObjectRef(jsValue))) { + ThrowMsg(Commons::ConversionException, "Type missmatch error : Listener callback"); + } + + JSObjectRef objectCallbacks = toJSObjectRef(jsValue); + CallHistoryChangeCB result; + + result.onAdded = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onadded"); + result.onChanged = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onchanged"); + + JSCallbackManagerPtr onAddedCbm = JSCallbackManager::createObject(context); + JSCallbackManagerPtr onChangedCbm = JSCallbackManager::createObject(context); + + if (!JSValueIsNull(m_context, result.onAdded) && !JSValueIsUndefined(m_context, result.onAdded)) { + if (JSObjectIsFunction(m_context, toJSObjectRef(result.onAdded))) { + onAddedCbm->setOnSuccess(result.onAdded); + } else { + ThrowMsg(Commons::ConversionException, "Type missmatch error : onadded callback"); + } + } + + if (!JSValueIsNull(m_context, result.onChanged) && !JSValueIsUndefined(m_context, result.onChanged)) { + if (JSObjectIsFunction(m_context, toJSObjectRef(result.onChanged))) { + onChangedCbm->setOnSuccess(result.onChanged); + } else { + ThrowMsg(Commons::ConversionException, "Type missmatch error : onchanged callback"); + } + } + + return EventCallHistoryListenerPrivateDataPtr(new EventCallHistoryListenerPrivateData(onAddedCbm, onChangedCbm)); +} + +JSValueRef Converter::toJSValueRef(const CallHistoryEntryListPtr& arg, JSContextRef context) +{ + JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL); + if (!jsResult) { + ThrowMsg(Commons::ConversionException, "Could not create js array object"); + } + CallHistoryEntryProperties tmpCallEntry; + + try { + for (size_t i = 0; i < (*arg).size(); i++) { + tmpCallEntry = *((*arg)[i]); + JSObjectRef jsObject = JSCallHistoryEntry::createJSObject(context, tmpCallEntry); + if (!jsObject) { + ThrowMsg(Commons::ConversionException, "Could not create JS object."); + } + + if (!JSSetArrayElement(m_context, jsResult, i, jsObject)) { + ThrowMsg(Commons::ConversionException, "Could not insert value into js array"); + } + } + } catch (Commons::ConversionException& ex) { + ThrowMsg(Commons::ConversionException, ex.GetMessage()); + } catch (Commons::InvalidArgumentException& ex) { + ThrowMsg(Commons::InvalidArgumentException, ex.GetMessage()); + } catch (Commons::Exception& ex) { + ThrowMsg(Commons::Exception, ex.GetMessage()); + } + return jsResult; +} + +JSValueRef Converter::toJSValueRef(const StringArrayPtr &arg, JSContextRef context) +{ + JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL); + if (!jsResult) { + ThrowMsg(Commons::ConversionException, "Could not create js array object"); + } + + for (size_t i = 0; i < (*arg).size(); i++) { + if (!JSSetArrayElement(m_context, jsResult, i, toJSValueRef((*arg)[i]))) { + ThrowMsg(Commons::ConversionException, "Could not insert value into js array"); + } + } + + return jsResult; +} + +JSValueRef Converter::toJSValueRef(const RemotePartyListPtr& arg, JSContextRef context) +{ + JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL); + if (!jsResult) { + ThrowMsg(Commons::ConversionException, "Could not create js array object"); + } + + RemoteParty tmpRemoteParty; + + try { + for (size_t i = 0; i < (*arg).size(); i++) { + tmpRemoteParty = *((*arg)[i]); + JSObjectRef jsObject = JSRemoteParty::createJSObject(context, tmpRemoteParty); + if (!jsObject) { + ThrowMsg(Commons::ConversionException, "Could not create JS object."); + } + + if (!JSSetArrayElement(m_context, jsResult, i, jsObject)) { + ThrowMsg(Commons::ConversionException, "Could not insert value into js array"); + } + } + } catch (Commons::ConversionException& ex) { + ThrowMsg(Commons::ConversionException, ex.GetMessage()); + } catch (Commons::InvalidArgumentException& ex) { + ThrowMsg(Commons::InvalidArgumentException, ex.GetMessage()); + } catch (Commons::Exception& ex) { + ThrowMsg(Commons::Exception, ex.GetMessage()); + } + return jsResult; +} + +bool Converter::initializeAllowedProperties() +{ + return true; +} + +} +} + diff --git a/src/Callhistory/Converter.h b/src/Callhistory/Converter.h new file mode 100755 index 0000000..fafb483 --- /dev/null +++ b/src/Callhistory/Converter.h @@ -0,0 +1,72 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZEN_APIS_CALL_CONVERTER_H_ +#define TIZEN_APIS_CALL_CONVERTER_H_ + +#include +#include +#include +#include +#include +#include "CallHistoryEntryProperties.h" +#include "RemoteParty.h" +#include +#include "CallHistoryMultiCallback.h" + +namespace DeviceAPI { +namespace CallHistory { + +class Converter : public WrtDeviceApis::CommonsJavaScript::Converter +{ +public: + using WrtDeviceApis::CommonsJavaScript::Converter::toJSValueRef; + +public: + explicit Converter(JSContextRef context); + + std::vector toVectorOfULongs(const JSValueRef& jsValue); + + CallHistoryEntryList toVectorOfCallHistoryEntryProperties(const JSValueRef& jsValue); + + StringArrayPtr toStringArray(const JSValueRef &jsValue); + + RemotePartyListPtr toRemotePartyList(const JSValueRef &jsValue); + + RemotePartyPtr toRemoteParty(const JSValueRef &jsValue); + + CallHistoryEntryPropertiesPtr toCallHistoryEntryProperties(const JSValueRef &jsValue); + + EventCallHistoryListenerPrivateDataPtr toEventCallHistoryListenerPrivateData(const JSValueRef &jsValue, JSContextRef context); + + JSValueRef toJSValueRef(const CallHistoryEntryListPtr &arg, JSContextRef context); + + JSValueRef toJSValueRef(const StringArrayPtr &arg, JSContextRef context); + + JSValueRef toJSValueRef(const RemotePartyListPtr& arg, JSContextRef context); + +private: + bool initializeAllowedProperties(); +}; + +typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory ConverterFactory; +typedef ConverterFactory::ConverterType ConverterPtr; +} +} + +#endif \ No newline at end of file diff --git a/src/Callhistory/EventCallHistory.h b/src/Callhistory/EventCallHistory.h new file mode 100755 index 0000000..269a2de --- /dev/null +++ b/src/Callhistory/EventCallHistory.h @@ -0,0 +1,49 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_API_CALL_EVENT_CALLHISTORY_H_ +#define TIZENAPIS_API_CALL_EVENT_CALLHISTORY_H_ + +#include +#include + +namespace DeviceAPI { +namespace CallHistory { + +class EventCallHistory : public WrtDeviceApis::Commons::IEvent +{ +public: + typedef enum { + NONE, + CONNECT, + DISCONNECT, + } CmdType; +private: + CmdType m_cmdType; + +public: + void setCmdType(const CmdType cmd) {m_cmdType = cmd;} + CmdType getCmdType() const {return m_cmdType;} + + EventCallHistory() : m_cmdType(EventCallHistory::NONE) {} +}; + +typedef DPL::SharedPtr EventCallHistoryPtr; +} +} +#endif \ No newline at end of file diff --git a/src/Callhistory/EventCallHistoryListener.cpp b/src/Callhistory/EventCallHistoryListener.cpp new file mode 100755 index 0000000..22ec3f0 --- /dev/null +++ b/src/Callhistory/EventCallHistoryListener.cpp @@ -0,0 +1,48 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "EventCallHistoryListener.h" + +namespace DeviceAPI { +namespace CallHistory { + +EventCallHistoryListener::EventCallHistoryListener() +{ +} + +void EventCallHistoryListener::setResultState(const ResultStates state) +{ + m_resultState = state; +} + +void EventCallHistoryListener::setResult (const CallHistoryEntryListPtr &entryList) +{ + m_entryList = entryList; +} + +EventCallHistoryListener::ResultStates EventCallHistoryListener::getResultState() const +{ + return m_resultState; +} + +CallHistoryEntryListPtr EventCallHistoryListener::getResult() const +{ + return m_entryList; +} + +} +} diff --git a/src/Callhistory/EventCallHistoryListener.h b/src/Callhistory/EventCallHistoryListener.h new file mode 100755 index 0000000..f62f2cb --- /dev/null +++ b/src/Callhistory/EventCallHistoryListener.h @@ -0,0 +1,59 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_CALL_EVENT_CALLHISTORY_LISTENER_H_ +#define TIZENAPIS_API_CALL_EVENT_CALLHISTORY_LISTENER_H_ + +#include +#include +#include +#include +#include +#include "CallHistoryEntryProperties.h" + +namespace DeviceAPI { +namespace CallHistory { + +class EventCallHistoryListener : public WrtDeviceApis::Commons::ListenerEvent +{ +public: + typedef enum { + ADDED, + CHANGED + } ResultStates; + +private: + ResultStates m_resultState; + CallHistoryEntryListPtr m_entryList; + +public: + void setResultState(const ResultStates state); + void setResult(const CallHistoryEntryListPtr &entryList); + ResultStates getResultState() const; + CallHistoryEntryListPtr getResult() const; + + EventCallHistoryListener(); +}; + +typedef DPL::SharedPtr EventCallHistoryListenerPtr; +typedef WrtDeviceApis::Commons::ListenerEventEmitter EventCallHistoryListenerEmitter; +typedef DPL::SharedPtr EventCallHistoryListenerEmitterPtr; + +} +} + +#endif \ No newline at end of file diff --git a/src/Callhistory/EventCallHistoryTemplate.h b/src/Callhistory/EventCallHistoryTemplate.h new file mode 100755 index 0000000..ee04a9d --- /dev/null +++ b/src/Callhistory/EventCallHistoryTemplate.h @@ -0,0 +1,49 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_EVENT_CALLHISTORY_TEMPLATE_H_ +#define TIZENAPIS_API_EVENT_CALLHISTORY_TEMPLATE_H_ + +#include +#include +#include + +namespace DeviceAPI { +namespace CallHistory { + +template +class EventCallHistoryTemplate : public WrtDeviceApis::Commons::IEvent +{ +public: + EventCallHistoryTemplate() { } +}; + +template +class EventCallHistoryPtrs +{ +private: + DPL::SharedPtr eventPtr; + void * thisPtr; +public: + DPL::SharedPtr getEventPtrs() const {return eventPtr;} + void *getThisPtr() {return thisPtr;} + EventCallHistoryPtrs(const DPL::SharedPtr &event, void *myPtr) : eventPtr(event), thisPtr(myPtr) {} +}; + +} +} +#endif //TIZENAPIS_API_EVENT_CALLHISTORY_TEMPLATE_H_ \ No newline at end of file diff --git a/src/Callhistory/EventFindCallHistory.cpp b/src/Callhistory/EventFindCallHistory.cpp new file mode 100755 index 0000000..8731ab2 --- /dev/null +++ b/src/Callhistory/EventFindCallHistory.cpp @@ -0,0 +1,112 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "EventFindCallHistory.h" + +using namespace DeviceAPI::Tizen; + +namespace DeviceAPI { +namespace CallHistory { + +EventFindCallHistory::EventFindCallHistory() : m_filterIsSet(false), + m_sortModesIsSet(false), + m_limitIsSet(false), + m_offsetIsSet(false) +{ +} + +void EventFindCallHistory::setFilter(const FilterPtr &filter) +{ + m_filter = filter; + m_filterIsSet = true; +} + +void EventFindCallHistory::setSortMode(const SortModePtr &sortMode) +{ + m_sortModes = sortMode; + m_sortModesIsSet = true; +} + +void EventFindCallHistory::setLimit(const unsigned long limit) +{ + if (limit > 0) { + m_limit = limit; + m_limitIsSet = true; + } +} + +void EventFindCallHistory::setOffset(const unsigned long offset) +{ + if (offset > 0) { + m_offset = offset; + m_offsetIsSet = true; + } +} + +void EventFindCallHistory::setResult(const CallHistoryEntryListPtr &callEntries) +{ + m_callEntries = callEntries; +} + +FilterPtr EventFindCallHistory::getFilter() const +{ + return m_filter; +} + +SortModePtr EventFindCallHistory::getSortMode() const +{ + return m_sortModes; +} + +unsigned long EventFindCallHistory::getLimit() const +{ + return m_limit; +} + +unsigned long EventFindCallHistory::getOffset() const +{ + return m_offset; +} + +bool EventFindCallHistory::getFilterIsSet() const +{ + return m_filterIsSet; +} + +bool EventFindCallHistory::getSortModesIsSet() const +{ + return m_sortModesIsSet; +} + +bool EventFindCallHistory::getLimitIsSet() const +{ + return m_limitIsSet; +} + +bool EventFindCallHistory::getOffsetIsSet() const +{ + return m_offsetIsSet; +} + +CallHistoryEntryListPtr EventFindCallHistory::getResult() const +{ + return m_callEntries; +} + +} +} \ No newline at end of file diff --git a/src/Callhistory/EventFindCallHistory.h b/src/Callhistory/EventFindCallHistory.h new file mode 100755 index 0000000..7520f10 --- /dev/null +++ b/src/Callhistory/EventFindCallHistory.h @@ -0,0 +1,69 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_API_CALL_EVENT_FIND_CALLHISTORY_H_ +#define TIZENAPIS_API_CALL_EVENT_FIND_CALLHISTORY_H_ + +#include +#include +#include +#include +#include +#include "CallHistoryEntryProperties.h" + +namespace DeviceAPI { +namespace CallHistory { + +class EventFindCallHistory : public WrtDeviceApis::Commons::IEvent +{ + private: + CallHistoryEntryListPtr m_callEntries; + DeviceAPI::Tizen::FilterPtr m_filter; + DeviceAPI::Tizen::SortModePtr m_sortModes; + unsigned long m_limit; + unsigned long m_offset; + bool m_filterIsSet; + bool m_sortModesIsSet; + bool m_limitIsSet; + bool m_offsetIsSet; + + public: + void setFilter(const DeviceAPI::Tizen::FilterPtr &filter); + void setSortMode(const DeviceAPI::Tizen::SortModePtr &sortMode); + void setLimit(const unsigned long limit); + void setOffset(const unsigned long offset); + void setResult(const CallHistoryEntryListPtr &callEntries); + + DeviceAPI::Tizen::FilterPtr getFilter() const; + DeviceAPI::Tizen::SortModePtr getSortMode() const; + unsigned long getLimit() const; + unsigned long getOffset() const; + bool getFilterIsSet() const; + bool getSortModesIsSet() const; + bool getLimitIsSet() const; + bool getOffsetIsSet() const; + CallHistoryEntryListPtr getResult() const; + + EventFindCallHistory(); +}; + +typedef DPL::SharedPtr EventFindCallHistoryPtr; +} +} + +#endif \ No newline at end of file diff --git a/src/Callhistory/EventRemoveAll.h b/src/Callhistory/EventRemoveAll.h new file mode 100755 index 0000000..3eb03c9 --- /dev/null +++ b/src/Callhistory/EventRemoveAll.h @@ -0,0 +1,38 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef TIZENAPIS_API_CALL_EVENT_REMOVE_ALL_H_ +#define TIZENAPIS_API_CALL_EVENT_REMOVE_ALL_H_ + +#include +#include +#include "EventCallHistoryTemplate.h" + +namespace DeviceAPI { +namespace CallHistory { + +class EventRemoveAll : public EventCallHistoryTemplate +{ +public: + EventRemoveAll() {} +}; + +typedef DPL::SharedPtr EventRemoveAllPtr; +} +} + +#endif \ No newline at end of file diff --git a/src/Callhistory/EventRemoveBatch.h b/src/Callhistory/EventRemoveBatch.h new file mode 100755 index 0000000..f1aa873 --- /dev/null +++ b/src/Callhistory/EventRemoveBatch.h @@ -0,0 +1,46 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_API_CALL_EVENT_REMOVE_BATCH_H_ +#define TIZENAPIS_API_CALL_EVENT_REMOVE_BATCH_H_ + +#include +#include +#include +#include "EventCallHistoryTemplate.h" + +namespace DeviceAPI { +namespace CallHistory { + +class EventRemoveBatch : public EventCallHistoryTemplate +{ + private: + std::vector m_entryIds; + + public: + void setEntryIds(const std::vector &entryIds) { m_entryIds = entryIds; } + std::vector getEntryIds() const { return m_entryIds; } + + EventRemoveBatch() {} +}; + +typedef DPL::SharedPtr EventRemoveBatchPtr; +} +} + +#endif \ No newline at end of file diff --git a/src/Callhistory/ICallHistory.cpp b/src/Callhistory/ICallHistory.cpp new file mode 100755 index 0000000..4b1de7b --- /dev/null +++ b/src/Callhistory/ICallHistory.cpp @@ -0,0 +1,39 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "ICallHistory.h" + +namespace DeviceAPI { +namespace CallHistory { + +using namespace WrtDeviceApis::Commons; + +ICallHistory::ICallHistory() : + EventRequestReceiver(ThreadEnum::CALLHISTORY_THREAD), + EventRequestReceiver(ThreadEnum::CALLHISTORY_THREAD), + EventRequestReceiver(ThreadEnum::CALLHISTORY_THREAD), + EventRequestReceiver(ThreadEnum::CALLHISTORY_THREAD) +{ +} + +ICallHistory::~ICallHistory() +{ +} + +} +} diff --git a/src/Callhistory/ICallHistory.h b/src/Callhistory/ICallHistory.h new file mode 100755 index 0000000..ce52b4a --- /dev/null +++ b/src/Callhistory/ICallHistory.h @@ -0,0 +1,64 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_ICALLHISTORY_H_ +#define TIZENAPIS_API_ICALLHISTORY_H_ + +#include +#include +#include "EventCallHistory.h" +#include "EventFindCallHistory.h" +#include "EventRemoveBatch.h" +#include "EventRemoveAll.h" +#include "EventCallHistoryListener.h" + +namespace DeviceAPI { +namespace CallHistory { + +class ICallHistory : public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver, + public WrtDeviceApis::Commons::EventRequestReceiver +{ +public: + virtual ~ICallHistory(); + + virtual void find(const EventFindCallHistoryPtr& event) = 0; + + virtual bool remove(const unsigned long entryId) = 0; + + virtual void removeBatch(const EventRemoveBatchPtr& event) = 0; + + virtual void removeAll(const EventRemoveAllPtr& event) = 0; + + virtual long addListener(const EventCallHistoryListenerEmitterPtr& emitter) = 0; + + virtual void removeListener(const long id) = 0; + +protected: + ICallHistory(); + virtual void OnRequestReceived(const EventCallHistoryPtr& event) = 0; + virtual void OnRequestReceived(const EventFindCallHistoryPtr& event) = 0; + virtual void OnRequestReceived(const EventRemoveBatchPtr& event) = 0; + virtual void OnRequestReceived(const EventRemoveAllPtr& event) = 0; +}; +typedef DPL::SharedPtr ICallHistoryPtr; +} +} + +#endif diff --git a/src/Callhistory/ICallHistoryEntry.cpp b/src/Callhistory/ICallHistoryEntry.cpp new file mode 100755 index 0000000..245f64f --- /dev/null +++ b/src/Callhistory/ICallHistoryEntry.cpp @@ -0,0 +1,35 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#include "ICallHistoryEntry.h" + +using namespace WrtDeviceApis::Commons; + +namespace DeviceAPI { +namespace CallHistory { + +ICallHistoryEntry::ICallHistoryEntry() +{ +} + +ICallHistoryEntry::~ICallHistoryEntry() +{ +} + +} +} diff --git a/src/Callhistory/ICallHistoryEntry.h b/src/Callhistory/ICallHistoryEntry.h new file mode 100755 index 0000000..13a50e3 --- /dev/null +++ b/src/Callhistory/ICallHistoryEntry.h @@ -0,0 +1,42 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_API_ICALLHISTORYENTRY_H_ +#define TIZENAPIS_API_ICALLHISTORYENTRY_H_ + +#include +#include + +namespace DeviceAPI { +namespace CallHistory { + + +class ICallHistoryEntry +{ +public: + virtual ~ICallHistoryEntry(); + + virtual void setMarkSeen(const unsigned long entryId) = 0; + +protected: + ICallHistoryEntry(); +}; +typedef DPL::SharedPtr ICallHistoryEntryPtr; +} +} +#endif diff --git a/src/Callhistory/JSCallHistory.cpp b/src/Callhistory/JSCallHistory.cpp new file mode 100755 index 0000000..57c4e1a --- /dev/null +++ b/src/Callhistory/JSCallHistory.cpp @@ -0,0 +1,532 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include "EventFindCallHistory.h" +#include "EventRemoveBatch.h" +#include "EventRemoveAll.h" +#include "EventCallHistoryListener.h" +#include "CallHistoryFactory.h" +#include "ICallHistory.h" +#include +#include +#include + +#include "JSCallHistoryEntry.h" +#include "JSCallHistory.h" +#include "CallHistoryStaticController.h" +#include "CallHistoryMultiCallback.h" +#include "ResponseDispatcher.h" +#include "Converter.h" +#include "plugin_config.h" +#include "CallHistoryAsyncCallbackManager.h" +#include "CallHistoryListenerManager.h" + +using namespace std; +using namespace DPL; +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Tizen; +using namespace DeviceAPI::Common; + +namespace DeviceAPI { +namespace CallHistory { + + +JSClassRef JSCallHistory::m_jsClassRef = NULL; + +JSClassDefinition JSCallHistory::m_classInfo = +{ + 0, + kJSClassAttributeNone, + "callhistory", + NULL, + m_property, + m_function, + initialize, + finalize, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + hasInstance, + NULL +}; + +JSStaticValue JSCallHistory::m_property[] = { + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCallHistory::m_function[] = +{ + { "find", JSCallHistory::find, kJSPropertyAttributeNone }, + { "remove", JSCallHistory::remove, kJSPropertyAttributeNone }, + { "removeBatch", JSCallHistory::removeBatch, kJSPropertyAttributeNone }, + { "removeAll", JSCallHistory::removeAll, kJSPropertyAttributeNone }, + { "addChangeListener", JSCallHistory::addChangeListener, kJSPropertyAttributeNone }, + { "removeChangeListener", JSCallHistory::removeChangeListener, kJSPropertyAttributeNone }, + { 0, 0, 0 } +}; + +const JSClassRef JSCallHistory::getClassRef() { + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSCallHistory::getClassInfo(){ + return &m_classInfo; +} + +void JSCallHistory::initialize(JSContextRef context, JSObjectRef object) { + JSCallHistoryPriv* priv = static_cast(JSObjectGetPrivate(object)); + + if (priv == NULL) { + ICallHistoryPtr CallHistory(CallHistoryFactory::getInstance().getCallHistoryObject()); + priv = new JSCallHistoryPriv(context, CallHistory); + if(!JSObjectSetPrivate(object, static_cast(priv))) { + delete priv; + } + } +} + +void JSCallHistory::finalize(JSObjectRef object) { + JSCallHistoryPriv* priv = static_cast(JSObjectGetPrivate(object)); + if (priv != NULL) { + JSObjectSetPrivate(object, NULL); + delete priv; + } +} + +JSObjectRef JSCallHistory::createJSObject(JSContextRef context, JSObjectRef object) +{ + ICallHistoryPtr CallHistory(CallHistoryFactory::getInstance().getCallHistoryObject()); + JSCallHistoryPriv* priv = new JSCallHistoryPriv(context, CallHistory); + + return JSObjectMake(context, getClassRef(), priv); +} + +bool JSCallHistory::hasInstance(JSContextRef context, JSObjectRef constructor, + JSValueRef possibleInstance, JSValueRef* exception) { + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} + +JSValueRef JSCallHistory::find(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception) { + + AceSecurityStatus status = CALLHISTORY_CHECK_ACCESS( + CALL_HISTORY_FUNCTION_API_FIND); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + if (argumentCount < 1) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error"); + } + + JSCallHistoryPriv *priv = static_cast (JSObjectGetPrivate(thisObject)); + + if (!priv) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer"); + } + + JSContextRef gContext = priv->getContext(); + WrtDeviceApis::CommonsJavaScript::Converter converter(context); + Validator check(context, exception); + + JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext)); + + try { + if (argumentCount >= 1) { + if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : success callback "); + } else if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[0]))) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : success callback "); + } + cbm->setOnSuccess(arguments[0]); + } + + if (argumentCount >= 2) { + if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1])) { + if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[1]))) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : error callback "); + } + cbm->setOnError(arguments[1]); + } + } + + if (argumentCount >= 3) { + if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])) { + if (!JSValueIsObject(context, arguments[2])) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : filter"); + } + } + } + + cbm->setObject(thisObject); + + FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context); + + EventFindCallHistoryPtr event(new EventFindCallHistory()); + ICallHistoryPtr callHistory(priv->getObject()); + + event->setPrivateData(StaticPointerCast (cbm)); + event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); + + if (argumentCount >= 3) { + if (!check.isNullOrUndefined(arguments[2])) { + FilterPtr filter = filterConverter->toFilter(arguments[2]); + event ->setFilter(filter); + } + } + + if (argumentCount >= 4) { + if (!check.isNullOrUndefined(arguments[3])) { + event->setSortMode(filterConverter->toSortMode(arguments[3])); + } + } + + if (argumentCount >= 5) { + if (!check.isNullOrUndefined(arguments[4])) { + event->setLimit(converter.toULong(arguments[4])); + } + } + + if (argumentCount >= 6) { + if (!check.isNullOrUndefined(arguments[5])) { + event->setOffset(converter.toULong(arguments[5])); + } + } + callHistory->find(event); + CallHistoryAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, gContext); + } catch(const WrtDeviceApis::Commons::ConversionException& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage()); + } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) { + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage())); + } catch(const WrtDeviceApis::Commons::PlatformException& ex) { + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage())); + } catch(const WrtDeviceApis::Commons::Exception& ex) { + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage())); + } + + return JSValueMakeUndefined(context); +} + +JSValueRef JSCallHistory::remove(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception) { + + AceSecurityStatus status = CALLHISTORY_CHECK_ACCESS( + CALL_HISTORY_FUNCTION_API_REMOVE); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + if (argumentCount < 1) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error"); + } + + JSCallHistoryPriv *priv = static_cast (JSObjectGetPrivate(thisObject)); + + if (!priv) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer"); + } + + Converter converter(context); + + try { + if (!JSValueIsObjectOfClass(context, arguments[0], JSCallHistoryEntry::getClassRef())) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : CallHistoryEntry"); + } + + ICallHistoryPtr callHistory(priv->getObject()); + CallHistoryEntryPropertiesPtr entry = converter.toCallHistoryEntryProperties(arguments[0]); + callHistory->remove(entry->getEntryId()); + } catch(const WrtDeviceApis::Commons::ConversionException& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage()); + } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()); + } catch(const WrtDeviceApis::Commons::PlatformException& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()); + } catch(const WrtDeviceApis::Commons::Exception& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()); + } + + return JSValueMakeUndefined(context); +} + +JSValueRef JSCallHistory::removeBatch(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception) { + + AceSecurityStatus status = CALLHISTORY_CHECK_ACCESS( + CALL_HISTORY_FUNCTION_API_REMOVE_BATCH); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + if (argumentCount < 1) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error"); + } + + JSCallHistoryPriv *priv = static_cast (JSObjectGetPrivate(thisObject)); + + if (!priv) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer"); + } + + JSContextRef gContext = priv->getContext(); + Converter converter(context); + + JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext)); + try { + if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Invalid values error : CallHistoryEntry array"); + } else if (!JSIsArrayValue(context, arguments[0])) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : CallHistoryEntry array"); + } + + if (argumentCount >= 2) { + if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1])) { + if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[1]))) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : success callback"); + } + cbm->setOnSuccess(arguments[1]); + } + } + + if (argumentCount >= 3) { + if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])) { + if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[2]))) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : error callback"); + } + cbm->setOnError(arguments[2]); + } + } + + cbm->setObject(thisObject); + + EventRemoveBatchPtr event(new EventRemoveBatch()); + ICallHistoryPtr callHistory(priv->getObject()); + + event->setPrivateData(StaticPointerCast (cbm)); + event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); + + CallHistoryEntryList entryList = converter.toVectorOfCallHistoryEntryProperties(arguments[0]); + + std::vector entryIds; + + if (entryList.size() > 0) { + for (unsigned int i = 0; i < entryList.size(); i++) { + entryIds.push_back(entryList[i]->getEntryId()); + } + event->setEntryIds(entryIds); + callHistory->removeBatch(event); + CallHistoryAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, gContext); + } else { + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error : Entry array is empty")); + } + } catch(const WrtDeviceApis::Commons::ConversionException& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage()); + } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) { + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage())); + } catch(const WrtDeviceApis::Commons::PlatformException& ex) { + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage())); + } catch(const WrtDeviceApis::Commons::Exception& ex) { + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage())); + } + + return JSValueMakeUndefined(context); +} + +JSValueRef JSCallHistory::removeAll(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception) { + + AceSecurityStatus status = CALLHISTORY_CHECK_ACCESS( + CALL_HISTORY_FUNCTION_API_REMOVE_ALL); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + JSCallHistoryPriv *priv = static_cast (JSObjectGetPrivate(thisObject)); + + if (!priv) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer"); + } + + JSContextRef gContext = priv->getContext(); + Converter converter(context); + + JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext)); + + try { + if (argumentCount >= 1) { + if (!JSValueIsNull(context, arguments[0]) && !JSValueIsUndefined(context, arguments[0])) { + if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[0]))) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : success callback"); + } + cbm->setOnSuccess(arguments[0]); + } + } + + if (argumentCount >= 2) { + if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1])) { + if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[1]))) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : error callback"); + } + cbm->setOnError(arguments[1]); + } + } + + cbm->setObject(thisObject); + EventRemoveAllPtr event(new EventRemoveAll()); + ICallHistoryPtr callHistory(priv->getObject()); + + event->setPrivateData(StaticPointerCast (cbm)); + event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); + callHistory->removeAll(event); + CallHistoryAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, gContext); + } catch(const WrtDeviceApis::Commons::ConversionException& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage()); + } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) { + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage())); + } catch(const WrtDeviceApis::Commons::PlatformException& ex) { + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage())); + } catch(const WrtDeviceApis::Commons::Exception& ex) { + cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage())); + } + + return JSValueMakeUndefined(context); +} + +JSValueRef JSCallHistory::deleteRecording(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception) { + + return JSValueMakeUndefined(context); +} + +JSValueRef JSCallHistory::addChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception) { + + AceSecurityStatus status = CALLHISTORY_CHECK_ACCESS( + CALL_HISTORY_FUNCTION_API_ADDLISTENER); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + if (argumentCount < 1) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error"); + } + + JSCallHistoryPriv *priv = static_cast (JSObjectGetPrivate(thisObject)); + + if (!priv) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer"); + } + + JSContextRef gContext = priv->getContext(); + Converter converter(context); + + try { + long id = 0; + if (argumentCount >= 1) { + EventCallHistoryListenerPrivateDataPtr privData(converter.toEventCallHistoryListenerPrivateData(arguments[0], gContext)); + + EventCallHistoryListenerEmitterPtr emitter(new EventCallHistoryListenerEmitter); + emitter->setListener(&CallHistoryStaticController::getInstance()); + emitter->setEventPrivateData(DPL::StaticPointerCast(privData)); + + ICallHistoryPtr callHistory(priv->getObject()); + id = callHistory->addListener(emitter); + + CallHistoryListenerCancellerPtr canceller = CallHistoryListenerCancellerPtr(new CallHistoryListenerCanceller(gContext, thisObject, id)); + DeviceAPI::Common::IListenerItemPtr listenerItem = DPL::StaticPointerCast(canceller); + CallHistoryListenerManagerSingleton::Instance().registerListener(listenerItem, gContext); + } + + return converter.toJSValueRefLong(id); + } catch(const WrtDeviceApis::Commons::ConversionException& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage()); + } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()); + } catch(const WrtDeviceApis::Commons::PlatformException& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()); + } catch(const WrtDeviceApis::Commons::Exception& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()); + } +} + +JSValueRef JSCallHistory::removeChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], JSValueRef* exception) { + + AceSecurityStatus status = CALLHISTORY_CHECK_ACCESS( + CALL_HISTORY_FUNCTION_API_REMOVELISTENER); + + TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + + if (argumentCount < 1) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error"); + } + + JSCallHistoryPriv *priv = static_cast (JSObjectGetPrivate(thisObject)); + + if (!priv) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer"); + } + + JSContextRef gContext = priv->getContext(); + Converter converter(context); + Validator check(context, exception); + + try { + long id = 0; + if (argumentCount >= 1) { + if (check.isNullOrUndefined(arguments[0])) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error : handle"); + } + + id = static_cast(converter.toLong(arguments[0])); + } + + if (id != 0) { + ICallHistoryPtr callHistory(priv->getObject()); + callHistory->removeListener(id); + } else { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error : handle"); + } + + CallHistoryListenerCancellerPtr canceller = CallHistoryListenerCancellerPtr(new CallHistoryListenerCanceller(gContext, thisObject, id)); + DeviceAPI::Common::IListenerItemPtr listenerItem = DPL::StaticPointerCast(canceller); + CallHistoryListenerManagerSingleton::Instance().unregisterListener(listenerItem); + } catch(const WrtDeviceApis::Commons::ConversionException& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage()); + } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()); + } catch(const WrtDeviceApis::Commons::PlatformException& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()); + } catch(const WrtDeviceApis::Commons::Exception& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()); + } + + return JSValueMakeUndefined(context); +} + +} +} + diff --git a/src/Callhistory/JSCallHistory.h b/src/Callhistory/JSCallHistory.h new file mode 100755 index 0000000..7f8c0be --- /dev/null +++ b/src/Callhistory/JSCallHistory.h @@ -0,0 +1,93 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZEN_APIS_JS_CALLHISTORY_H_ +#define TIZEN_APIS_JS_CALLHISTORY_H_ + +#include +#include +#include "ICallHistory.h" + +namespace DeviceAPI { +namespace CallHistory { + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSCallHistoryPriv; + +class JSCallHistory +{ +public: + static const JSClassDefinition* getClassInfo(); + + static const JSClassRef getClassRef(); + + static JSObjectRef createJSObject(JSContextRef context, JSObjectRef object); +private: + static void initialize(JSContextRef context, JSObjectRef object); + + static void finalize(JSObjectRef object); + + static JSValueRef getProperty(JSContextRef context, JSObjectRef object, + JSStringRef propertyName, JSValueRef* exception); + + static bool hasInstance(JSContextRef context, JSObjectRef constructor, + JSValueRef possibleInstance, JSValueRef* exception); + + + static JSValueRef find(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef remove(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef removeBatch(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef removeAll(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef deleteRecording(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef addChangeListener(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + static JSValueRef removeChangeListener(JSContextRef context, JSObjectRef object, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef* exception); + + static JSClassDefinition m_classInfo; + + static JSStaticValue m_property[]; + + static JSStaticFunction m_function[]; + + static JSClassRef m_jsClassRef; + +}; + +} +} + +#endif + diff --git a/src/Callhistory/JSCallHistoryEntry.cpp b/src/Callhistory/JSCallHistoryEntry.cpp new file mode 100755 index 0000000..9219327 --- /dev/null +++ b/src/Callhistory/JSCallHistoryEntry.cpp @@ -0,0 +1,226 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include "CallHistoryEntryProperties.h" +#include "CallHistoryFactory.h" +#include "ICallHistoryEntry.h" +#include "CallHistoryDefine.h" +#include +#include +#include +#include "JSCallHistoryEntry.h" +#include "JSRemoteParty.h" +#include "Converter.h" + +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + +namespace DeviceAPI { +namespace CallHistory { + +JSClassDefinition JSCallHistoryEntry::m_classInfo = { + 0, + kJSClassAttributeNone, + "callhistoryentry", + 0, + m_property, + 0, + initialize, + finalize, + NULL, //HasProperty, + getProperty, + NULL, //SetProperty, + NULL, //DeleteProperty, + NULL, //GetPropertyNames, + NULL, //CallAsFunction, + NULL, //CallAsConstructor, + hasInstance, + NULL, //ConvertToType +}; + +JSStaticValue JSCallHistoryEntry::m_property[] = { + { STR_ENTRY_ID, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { STR_CALL_TYPE, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { STR_TAGS, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { STR_REMOTE_PARTIES, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { STR_START_TIME, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { STR_DURATION, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { STR_DIRECTION, getProperty, setProperty, kJSPropertyAttributeNone }, + { 0, 0, 0, 0 } +}; + +const JSClassRef JSCallHistoryEntry::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSCallHistoryEntry::getClassInfo() +{ + return &m_classInfo; +} + +JSClassRef JSCallHistoryEntry::m_jsClassRef = JSClassCreate(JSCallHistoryEntry::getClassInfo()); + +JSObjectRef JSCallHistoryEntry::createJSObject(JSContextRef context, + const CallHistoryEntryProperties &entryInfo) +{ + CallHistoryEntryPropertiesPtr callHistoryEntryProps(new CallHistoryEntryProperties(entryInfo)); + JSCallHistoryEntryPriv *priv = new JSCallHistoryEntryPriv(context, CallHistoryEntryPropertiesPtr(callHistoryEntryProps)); + if (!priv) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Can not new an object"); + } + return JSObjectMake(context, getClassRef(), priv); +} + +CallHistoryEntryPropertiesPtr JSCallHistoryEntry::getCallHistoryEntry(JSContextRef context, JSValueRef value) +{ + if (!JSValueIsObjectOfClass(context, value, getClassRef())) { + Throw(WrtDeviceApis::Commons::ConversionException); + } + JSObjectRef object = JSValueToObject(context, value, NULL); + if (!object) { + Throw(WrtDeviceApis::Commons::ConversionException); + } + JSCallHistoryEntryPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::ConversionException); + } + return priv->getObject(); +} + +void JSCallHistoryEntry::initialize(JSContextRef context, JSObjectRef object) +{ +} + +void JSCallHistoryEntry::finalize(JSObjectRef object) +{ + JSCallHistoryEntryPriv* priv = static_cast(JSObjectGetPrivate(object)); + if (priv != NULL) { + JSObjectSetPrivate(object, NULL); + delete priv; + } +} + +JSValueRef JSCallHistoryEntry::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + JSCallHistoryEntryPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer"); + } + + try { + CallHistoryEntryPropertiesPtr entryInfo = priv->getObject(); + Converter convert(context); + + if (JSStringIsEqualToUTF8CString(propertyName, STR_ENTRY_ID)) { + std::ostringstream stream; + stream << entryInfo->getEntryId(); + std::string idStr = stream.str(); + return convert.toJSValueRef(idStr); + } else if (JSStringIsEqualToUTF8CString(propertyName, STR_CALL_TYPE)) { + return convert.toJSValueRef(entryInfo->getCallType()); + } else if (JSStringIsEqualToUTF8CString(propertyName, STR_TAGS)) { + return convert.toJSValueRef(entryInfo->getTags(), context); + } else if (JSStringIsEqualToUTF8CString(propertyName, STR_REMOTE_PARTIES)) { + return convert.toJSValueRef(entryInfo->getRemoteParties(), context); + } else if (JSStringIsEqualToUTF8CString(propertyName, STR_START_TIME)) { + return convert.toJSValueRef(entryInfo->getStartTime()); + } else if (JSStringIsEqualToUTF8CString(propertyName, STR_DURATION)) { + return convert.toJSValueRef(entryInfo->getDuration()); + } else if (JSStringIsEqualToUTF8CString(propertyName, STR_DIRECTION)) { + return convert.toJSValueRef(entryInfo->getDirection()); + } else if (JSStringIsEqualToUTF8CString(propertyName, STR_DURATION)) { + return convert.toJSValueRef(entryInfo->getDuration()); + } + } catch(const WrtDeviceApis::Commons::ConversionException& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage()); + } catch(const WrtDeviceApis::Commons::Exception& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSCallHistoryEntry::setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception) +{ + JSCallHistoryEntryPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer"); + } + + Converter converter(context); + try { + if (JSStringIsEqualToUTF8CString(propertyName, STR_DIRECTION)) { + CallHistoryEntryPropertiesPtr entryInfo = priv->getObject(); + if (entryInfo != NULL) { + ICallHistoryEntryPtr callHistoryEntry(CallHistoryFactory::getInstance().getCallHistoryEntryObject()); + std::string direction(converter.toString(value)); + + if (callHistoryEntry != NULL) { + if((entryInfo->getDirection().compare(STR_MISSED_NEW) == 0) && (direction.compare(STR_MISSED) == 0)) { + callHistoryEntry->setMarkSeen(entryInfo->getEntryId()); + entryInfo->setDirection(STR_MISSED); + } else { + Throw(WrtDeviceApis::Commons::ConversionException); + } + + return true; + } else { + Throw(WrtDeviceApis::Commons::Exception); + } + } else { + Throw(WrtDeviceApis::Commons::Exception); + } + } else { + Throw(WrtDeviceApis::Commons::ConversionException); + } + } catch(const WrtDeviceApis::Commons::ConversionException& ex) { + JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error"); + } catch (const WrtDeviceApis::Commons::Exception& ex) { + JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error"); + } + + return false; +} +bool JSCallHistoryEntry::hasInstance(JSContextRef context, + JSObjectRef constructor, + JSValueRef possibleInstance, + JSValueRef* exception) +{ + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} +} +} + diff --git a/src/Callhistory/JSCallHistoryEntry.h b/src/Callhistory/JSCallHistoryEntry.h new file mode 100755 index 0000000..52b14da --- /dev/null +++ b/src/Callhistory/JSCallHistoryEntry.h @@ -0,0 +1,75 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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_CALLINFO_H_ +#define TIZENAPIS_TIZEN_JS_CALLINFO_H_ + +#include +#include +#include "CallHistoryEntryProperties.h" + +namespace DeviceAPI { +namespace CallHistory { + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSCallHistoryEntryPriv; + +class JSCallHistoryEntry +{ +public: + static const JSClassDefinition* getClassInfo(); + + static const JSClassRef getClassRef(); + + static JSObjectRef createJSObject(JSContextRef context, + const CallHistoryEntryProperties &entryInfo); + + static CallHistoryEntryPropertiesPtr getCallHistoryEntry(JSContextRef context, JSValueRef value); + +private: + static void initialize(JSContextRef context, + JSObjectRef object); + + static void finalize(JSObjectRef object); + + static JSValueRef getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool setProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef value, + JSValueRef* exception); + + static bool hasInstance(JSContextRef context, + JSObjectRef constructor, + JSValueRef possibleInstance, + JSValueRef* exception); + + static JSClassDefinition m_classInfo; + + static JSStaticValue m_property[]; + + static JSClassRef m_jsClassRef; +}; +} +} + +#endif + diff --git a/src/Callhistory/JSRemoteParty.cpp b/src/Callhistory/JSRemoteParty.cpp new file mode 100755 index 0000000..3b35b12 --- /dev/null +++ b/src/Callhistory/JSRemoteParty.cpp @@ -0,0 +1,157 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include "CallHistoryDefine.h" +#include "RemoteParty.h" +#include "JSRemoteParty.h" +#include "Converter.h" + +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + +namespace DeviceAPI { +namespace CallHistory { + +JSClassDefinition JSRemoteParty::m_classInfo = { + 0, + kJSClassAttributeNone, + "remoteparty", + 0, + m_property, + 0, + initialize, + finalize, + NULL, //HasProperty, + getProperty, + NULL, //SetProperty, + NULL, //DeleteProperty, + NULL, //GetPropertyNames, + NULL, //CallAsFunction, + NULL, //CallAsConstructor, + hasInstance, + NULL, //ConvertToType +}; + +JSStaticValue JSRemoteParty::m_property[] = { + { STR_REMOTE_PARTY, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { STR_PERSIONID, getProperty, NULL, kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +const JSClassRef JSRemoteParty::getClassRef() +{ + if (!m_jsClassRef) { + m_jsClassRef = JSClassCreate(&m_classInfo); + } + return m_jsClassRef; +} + +const JSClassDefinition* JSRemoteParty::getClassInfo() +{ + return &m_classInfo; +} + +JSClassRef JSRemoteParty::m_jsClassRef = JSClassCreate(JSRemoteParty::getClassInfo()); + +JSObjectRef JSRemoteParty::createJSObject(JSContextRef context, + const RemoteParty &remoteParty) +{ + RemotePartyPtr RemotePartyProps(new RemoteParty(remoteParty)); + JSRemotePartyPriv *priv = new JSRemotePartyPriv(context, RemotePartyPtr(RemotePartyProps)); + if (!priv) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Can not new an object"); + } + return JSObjectMake(context, getClassRef(), priv); +} + +RemotePartyPtr JSRemoteParty::getRemoteParty(JSContextRef context, JSValueRef value) +{ + if (!JSValueIsObjectOfClass(context, value, getClassRef())) { + Throw(WrtDeviceApis::Commons::ConversionException); + } + JSObjectRef object = JSValueToObject(context, value, NULL); + if (!object) { + Throw(WrtDeviceApis::Commons::ConversionException); + } + JSRemotePartyPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + Throw(WrtDeviceApis::Commons::ConversionException); + } + return priv->getObject(); +} + +void JSRemoteParty::initialize(JSContextRef context, JSObjectRef object) +{ +} + +void JSRemoteParty::finalize(JSObjectRef object) +{ + JSRemotePartyPriv* priv = static_cast(JSObjectGetPrivate(object)); + if (priv != NULL) { + JSObjectSetPrivate(object, NULL); + delete priv; + } +} + +JSValueRef JSRemoteParty::getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception) +{ + JSRemotePartyPriv *priv = static_cast(JSObjectGetPrivate(object)); + if (!priv) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer"); + } + + try { + RemotePartyPtr remoteParty = priv->getObject(); + Converter convert(context); + + if (JSStringIsEqualToUTF8CString(propertyName, STR_REMOTE_PARTY)) { + return convert.toJSValueRef(remoteParty->getRemoteParty()); + } else if (JSStringIsEqualToUTF8CString(propertyName, STR_PERSIONID)) { + return convert.toJSValueRef(remoteParty->getPersonId()); + } + } catch(const WrtDeviceApis::Commons::ConversionException& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage()); + } catch(const WrtDeviceApis::Commons::Exception& ex) { + return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()); + } + return JSValueMakeUndefined(context); +} + +bool JSRemoteParty::hasInstance(JSContextRef context, + JSObjectRef constructor, + JSValueRef possibleInstance, + JSValueRef* exception) +{ + return JSValueIsObjectOfClass(context, possibleInstance, getClassRef()); +} +} +} + diff --git a/src/Callhistory/JSRemoteParty.h b/src/Callhistory/JSRemoteParty.h new file mode 100755 index 0000000..9019f4c --- /dev/null +++ b/src/Callhistory/JSRemoteParty.h @@ -0,0 +1,69 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_TIZEN_JS_REMOTEPARTY_H_ +#define TIZENAPIS_TIZEN_JS_REMOTEPARTY_H_ + +#include +#include +#include "RemoteParty.h" + +namespace DeviceAPI { +namespace CallHistory { + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSRemotePartyPriv; + +class JSRemoteParty +{ +public: + static const JSClassDefinition* getClassInfo(); + + static const JSClassRef getClassRef(); + + static JSObjectRef createJSObject(JSContextRef context, + const RemoteParty &remoteParty); + + static RemotePartyPtr getRemoteParty(JSContextRef context, JSValueRef value); + +private: + static void initialize(JSContextRef context, + JSObjectRef object); + + static void finalize(JSObjectRef object); + + static JSValueRef getProperty(JSContextRef context, + JSObjectRef object, + JSStringRef propertyName, + JSValueRef* exception); + + static bool hasInstance(JSContextRef context, + JSObjectRef constructor, + JSValueRef possibleInstance, + JSValueRef* exception); + + static JSClassDefinition m_classInfo; + + static JSStaticValue m_property[]; + + static JSClassRef m_jsClassRef; +}; +} +} + +#endif + diff --git a/src/Callhistory/RemoteParty.h b/src/Callhistory/RemoteParty.h new file mode 100755 index 0000000..3e37d93 --- /dev/null +++ b/src/Callhistory/RemoteParty.h @@ -0,0 +1,53 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_API_REMOTEPARTY_H_ +#define TIZENAPIS_API_REMOTEPARTY_H_ + +#include +#include +#include + +namespace DeviceAPI { +namespace CallHistory { + +class RemoteParty; +typedef DPL::SharedPtr RemotePartyPtr; +typedef std::vector RemotePartyList; +typedef DPL::SharedPtr RemotePartyListPtr; + +class RemoteParty +{ +private: + std::string m_remoteParty; + std::string m_personId; + +public: + void setRemoteParty(const std::string remoteParty) { m_remoteParty = remoteParty; } + void setPersonId(const std::string personId) { m_personId = personId; } + + std::string getRemoteParty() const { return m_remoteParty; } + std::string getPersonId() const { return m_personId; } + + + RemoteParty() : m_remoteParty(""), m_personId("") {} +}; +} +} + +#endif \ No newline at end of file diff --git a/src/Callhistory/ResponseDispatcher.cpp b/src/Callhistory/ResponseDispatcher.cpp new file mode 100755 index 0000000..0347d9d --- /dev/null +++ b/src/Callhistory/ResponseDispatcher.cpp @@ -0,0 +1,127 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include + +#include +#include +#include +#include +#include +#include +#include "JSCallHistory.h" +#include "Converter.h" +#include "CallHistoryAsyncCallbackManager.h" + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; +using namespace DeviceAPI::Common; + + +namespace DeviceAPI { +namespace CallHistory { + +ResponseDispatcher& ResponseDispatcher::getInstance() +{ + static ResponseDispatcher dispatcher; + return dispatcher; +} + +ResponseDispatcher::ResponseDispatcher() : + EventAnswerReceiver(ThreadEnum::NULL_THREAD), + EventAnswerReceiver(ThreadEnum::NULL_THREAD), + EventAnswerReceiver(ThreadEnum::NULL_THREAD) +{ +} + +void ResponseDispatcher::OnAnswerReceived(const EventFindCallHistoryPtr& event) +{ + JSCallbackManagerPtr data = DPL::DynamicPointerCast(event->getPrivateData()); + if (!data) + return; + + CallHistoryAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(data); + + if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) { + Converter converter(data->getContext()); + try { + data->callOnSuccess(converter.toJSValueRef(event->getResult(), data->getContext())); + } catch(WrtDeviceApis::Commons::ConversionException) { + data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::UNKNOWN_ERROR, "Unknown error")); + } catch(WrtDeviceApis::Commons::Exception) { + data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::UNKNOWN_ERROR, "Unknown error")); + } + } else { + JSObjectRef jsException = NULL; + if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) { + jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error"); + } else { + jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::UNKNOWN_ERROR, "Unknown error"); + } + data->callOnError(jsException); + } +} + +void ResponseDispatcher::OnAnswerReceived(const EventRemoveBatchPtr& event) +{ + JSCallbackManagerPtr data = DPL::DynamicPointerCast(event->getPrivateData()); + if (!data) + return; + + CallHistoryAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(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::UNKNOWN_ERROR, "Unknown error"); + } + data->callOnError(jsException); + } +} + +void ResponseDispatcher::OnAnswerReceived(const EventRemoveAllPtr& event) +{ + JSCallbackManagerPtr data = DPL::DynamicPointerCast(event->getPrivateData()); + if (!data) + return; + + CallHistoryAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(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::UNKNOWN_ERROR, "Unknown error"); + } + data->callOnError(jsException); + } +} + +} +} + diff --git a/src/Callhistory/ResponseDispatcher.h b/src/Callhistory/ResponseDispatcher.h new file mode 100755 index 0000000..e7a6436 --- /dev/null +++ b/src/Callhistory/ResponseDispatcher.h @@ -0,0 +1,50 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef TIZENAPIS_TIZEN_CALL_RESPONSEDISPATCHER_H_ +#define TIZENAPIS_TIZEN_CALL_RESPONSEDISPATCHER_H_ + +#include +#include +#include "EventFindCallHistory.h" +#include "EventRemoveBatch.h" +#include "EventRemoveAll.h" + +namespace DeviceAPI { +namespace CallHistory { + +class ResponseDispatcher : + public WrtDeviceApis::Commons::EventAnswerReceiver, + public WrtDeviceApis::Commons::EventAnswerReceiver, + public WrtDeviceApis::Commons::EventAnswerReceiver +{ +public: + static ResponseDispatcher& getInstance(); + + void OnAnswerReceived(const EventFindCallHistoryPtr& event); + void OnAnswerReceived(const EventRemoveBatchPtr& event); + void OnAnswerReceived(const EventRemoveAllPtr& event); + +protected: + ResponseDispatcher(); +}; +} +} + +#endif + diff --git a/src/Callhistory/config.xml b/src/Callhistory/config.xml new file mode 100755 index 0000000..6c048df --- /dev/null +++ b/src/Callhistory/config.xml @@ -0,0 +1,20 @@ + + + + libwrt-plugins-tizen-callhistory.so + callhistory.install.uri + SAMSUNG plugin group + SAMSUNG certificate authority + AAAABBBBCCCCDDDEEEE0000 + + + http://tizen.org/privilege/callhistory.read + callhistory.read + + + + http://tizen.org/privilege/callhistory.write + callhistory.write + + + diff --git a/src/Callhistory/plugin_config.cpp b/src/Callhistory/plugin_config.cpp new file mode 100755 index 0000000..55ff988 --- /dev/null +++ b/src/Callhistory/plugin_config.cpp @@ -0,0 +1,128 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include + +#include +#include +#include +#include + +#define CALL_HISTORY_FEATURE_API_READ "http://tizen.org/privilege/callhistory.read" +#define CALL_HISTORY_FEATURE_API_WRITE "http://tizen.org/privilege/callhistory.write" + +namespace DeviceAPI { +namespace CallHistory { + +const char* CALL_HISTORY_DEVICE_CAP_READ = "callhistory.read"; +const char* CALL_HISTORY_DEVICE_CAP_WRITE = "callhistory.write"; + +const char* CALL_HISTORY_FUNCTION_API_FIND = "find"; +const char* CALL_HISTORY_FUNCTION_API_REMOVE = "remove"; +const char* CALL_HISTORY_FUNCTION_API_REMOVE_BATCH = "removeBatch"; +const char* CALL_HISTORY_FUNCTION_API_REMOVE_ALL = "removeAll"; +const char* CALL_HISTORY_FUNCTION_API_ADDLISTENER = "addListener"; +const char* CALL_HISTORY_FUNCTION_API_REMOVELISTENER = "removeListener"; + + +static WrtDeviceApis::Commons::FunctionMapping createCallHistoryFunctions(); + +static WrtDeviceApis::Commons::FunctionMapping CallHistoryFunctions = createCallHistoryFunctions(); + +DEFINE_FUNCTION_GETTER(CallHistory, CallHistoryFunctions); + +static WrtDeviceApis::Commons::FunctionMapping createCallHistoryFunctions() +{ + using namespace WrtDeviceApis::Commons; + + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_CALL_HISTORY_READ, CALL_HISTORY_DEVICE_CAP_READ); + ACE_CREATE_DEVICE_CAP(DEVICE_CAP_CALL_HISTORY_WRITE, CALL_HISTORY_DEVICE_CAP_WRITE); + + ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST); + + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_CALL_HISTORY_READ); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_CALL_HISTORY_READ, DEVICE_CAP_CALL_HISTORY_READ); + + ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_CALL_HISTORY_WRITE); + ACE_ADD_DEVICE_CAP(DEVICE_LIST_CALL_HISTORY_WRITE, DEVICE_CAP_CALL_HISTORY_WRITE); + + ACE_CREATE_FEATURE(FEATURE_CALL_HISTORY_READ, CALL_HISTORY_FEATURE_API_READ); + ACE_CREATE_FEATURE(FEATURE_CALL_HISTORY_WRITE, CALL_HISTORY_FEATURE_API_WRITE); + + ACE_CREATE_FEATURE_LIST(CALL_FEATURES_CALL_HISTORY_READ); + ACE_ADD_API_FEATURE(CALL_FEATURES_CALL_HISTORY_READ, FEATURE_CALL_HISTORY_READ); + + ACE_CREATE_FEATURE_LIST(CALL_FEATURES_CALL_HISTORY_WRITE); + ACE_ADD_API_FEATURE(CALL_FEATURES_CALL_HISTORY_WRITE, FEATURE_CALL_HISTORY_WRITE); + + FunctionMapping CallHistoryMapping; + + AceFunction findFunc = ACE_CREATE_FUNCTION( + FUNCTION_FIND, + CALL_HISTORY_FUNCTION_API_FIND, + CALL_FEATURES_CALL_HISTORY_READ, + EMPTY_DEVICE_LIST); + + CallHistoryMapping.insert(std::make_pair(CALL_HISTORY_FUNCTION_API_FIND, findFunc)); + + AceFunction removeFunc = ACE_CREATE_FUNCTION( + FUNCTION_REMOVE, + CALL_HISTORY_FUNCTION_API_REMOVE, + CALL_FEATURES_CALL_HISTORY_WRITE, + EMPTY_DEVICE_LIST); + + CallHistoryMapping.insert(std::make_pair(CALL_HISTORY_FUNCTION_API_REMOVE, removeFunc)); + + AceFunction removeBatchFunc = ACE_CREATE_FUNCTION( + FUNCTION_REMOVE_BATCH, + CALL_HISTORY_FUNCTION_API_REMOVE_BATCH, + CALL_FEATURES_CALL_HISTORY_WRITE, + EMPTY_DEVICE_LIST); + + CallHistoryMapping.insert(std::make_pair(CALL_HISTORY_FUNCTION_API_REMOVE_BATCH, removeBatchFunc)); + + AceFunction removeAllFunc = ACE_CREATE_FUNCTION( + FUNCTION_REMOVE_ALL, + CALL_HISTORY_FUNCTION_API_REMOVE_ALL, + CALL_FEATURES_CALL_HISTORY_WRITE, + EMPTY_DEVICE_LIST); + + CallHistoryMapping.insert(std::make_pair(CALL_HISTORY_FUNCTION_API_REMOVE_ALL, removeAllFunc)); + + AceFunction addListenerFunc = ACE_CREATE_FUNCTION( + FUNCTION_ADD_LISTENER, + CALL_HISTORY_FUNCTION_API_ADDLISTENER, + CALL_FEATURES_CALL_HISTORY_READ, + EMPTY_DEVICE_LIST); + + CallHistoryMapping.insert(std::make_pair(CALL_HISTORY_FUNCTION_API_ADDLISTENER, addListenerFunc)); + + AceFunction removeListenerFunc = ACE_CREATE_FUNCTION( + FUNCTION_REMOVE_LISTENER, + CALL_HISTORY_FUNCTION_API_REMOVELISTENER, + CALL_FEATURES_CALL_HISTORY_READ, + EMPTY_DEVICE_LIST); + + CallHistoryMapping.insert(std::make_pair(CALL_HISTORY_FUNCTION_API_REMOVELISTENER, removeListenerFunc)); + + return CallHistoryMapping; +} + +} +} diff --git a/src/Callhistory/plugin_config.h b/src/Callhistory/plugin_config.h new file mode 100755 index 0000000..327ce5d --- /dev/null +++ b/src/Callhistory/plugin_config.h @@ -0,0 +1,50 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 _CALLHISTORY_PLUGIN_CONFIG_H_ +#define _CALLHISTORY_PLUGIN_CONFIG_H_ + +#include + +namespace DeviceAPI { +namespace CallHistory { + +extern const char* CALL_HISTORY_FUNCTION_API_FIND; +extern const char* CALL_HISTORY_FUNCTION_API_REMOVE; +extern const char* CALL_HISTORY_FUNCTION_API_REMOVE_BATCH; +extern const char* CALL_HISTORY_FUNCTION_API_REMOVE_ALL; +extern const char* CALL_HISTORY_FUNCTION_API_ADDLISTENER; +extern const char* CALL_HISTORY_FUNCTION_API_REMOVELISTENER; + +DECLARE_FUNCTION_GETTER(CallHistory); + +} +} + +namespace WrtDeviceApis { +namespace Commons { + +#define CALLHISTORY_CHECK_ACCESS(functionName) \ + WrtDeviceApis::Commons::aceCheckAccess >( \ + getCallHistoryFunctionData, \ + functionName) +} +} + +#endif diff --git a/src/Callhistory/plugin_initializer.cpp b/src/Callhistory/plugin_initializer.cpp new file mode 100755 index 0000000..cec8ccb --- /dev/null +++ b/src/Callhistory/plugin_initializer.cpp @@ -0,0 +1,75 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 +#include +#include +#include +#include "JSCallHistory.h" +#include "CallHistoryAsyncCallbackManager.h" +#include "CallHistoryListenerManager.h" + +#define CALLHISTORY "callhistory" + +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; + +void on_widget_start_callback(int widgetId) { + LogDebug("[Tizen\\callhistory] on_widget_start_callback (" << widgetId << ")"); + try { + WrtAccessSingleton::Instance().initialize(widgetId); + } catch(WrtDeviceApis::Commons::Exception) { + LogError("WrtAccess initialization failed"); + } +} + +void on_widget_stop_callback(int widgetId) { + LogDebug("[Tizen\\callhistory] on_widget_stop_callback (" << widgetId << ")"); + try { + WrtAccessSingleton::Instance().deinitialize(widgetId); + } catch(WrtDeviceApis::Commons::Exception) { + LogError("WrtAccess deinitialization failed"); + } +} + +void on_frame_load_callback(const void * context) +{ + LogDebug("[Tizen\\callhistory] on_frame_load_callback (" << context << ")"); +} + +void on_frame_unload_callback(const void * context) +{ + LogDebug("[Tizen\\callhistory] on_frame_unload_callback (" << context << ")"); + + DeviceAPI::CallHistory::CallHistoryAsyncCallbackManagerSingleton::Instance().unregisterContext(static_cast(context)); + DeviceAPI::CallHistory::CallHistoryListenerManagerSingleton::Instance().unregisterContext(static_cast(context)); +} + +PLUGIN_ON_WIDGET_START(on_widget_start_callback) +PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback) +PLUGIN_ON_FRAME_LOAD(on_frame_load_callback) +PLUGIN_ON_FRAME_UNLOAD(on_frame_unload_callback) + +PLUGIN_CLASS_MAP_BEGIN + PLUGIN_CLASS_MAP_ADD_CLASS( + WRT_JS_EXTENSION_OBJECT_TIZEN, + CALLHISTORY, + (js_class_template_getter)DeviceAPI::CallHistory::JSCallHistory::getClassRef, + NULL) +PLUGIN_CLASS_MAP_END + diff --git a/src/Common/ArgumentValidationChecker.cpp b/src/Common/ArgumentValidationChecker.cpp new file mode 100755 index 0000000..1f23103 --- /dev/null +++ b/src/Common/ArgumentValidationChecker.cpp @@ -0,0 +1,139 @@ +// +// Tizen Web Device API +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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 "ArgumentValidationChecker.h" +#include "JSTizenException.h" + + +#include +#include + +#undef LOG_TAG +#define LOG_TAG "TIZEN_DEVICEAPI" + +using namespace std; + +namespace DeviceAPI { +namespace Common { + + +void ArgumentValidationChecker::check(JSContextRef ctx, int argumentCount, const JSValueRef arguments [ ], int convertedArgumentCount, JSValueRef convertedArguments [ ], Option option, ...){ + va_list var_args; + va_start (var_args, option); + Option opt = option; + int index = 0; + while( opt != END){ + Type type = static_cast(va_arg(var_args, int)); + JSObjectRef testObject = NULL; + bool nullable = ((opt & NULLABLE) == NULLABLE ); + JSValueRef jsException = NULL; + + if( index >= convertedArgumentCount ){ + LOGE("invalid argument check code"); + va_end (var_args); + return; + } + + if( argumentCount <= index ){ + if( !nullable ) + convertedArguments[index] = JSValueMakeUndefined(ctx); + else + convertedArguments[index] = JSValueMakeNull(ctx); + testObject = NULL; + }else{ + convertedArguments[index] = arguments[index]; + if( JSValueIsObject(ctx, arguments[index]) ) + testObject = JSValueToObject(ctx, arguments[index], NULL); + else + testObject = NULL; + } + + if( JSValueIsNull(ctx, convertedArguments[index]) && nullable){ + if( type == ArgumentValidationChecker::UserDefine) + va_arg(var_args, JSClassRef); + if( type == ArgumentValidationChecker::SelfCheck) + va_arg(var_args, SelfChecker); + + opt = static_cast