Merge remote-tracking branch 'data-control/tizen'
authorWonYoung Choi <wy80.choi@samsung.com>
Thu, 10 Aug 2017 00:50:01 +0000 (09:50 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Thu, 10 Aug 2017 00:50:01 +0000 (09:50 +0900)
Change-Id: I78d789c1beb9e690c9add0283f99152a7f2f499f

318 files changed:
.gitattributes [deleted file]
.gitignore [deleted file]
LICENSE [deleted file]
packaging/csapi-data-control.manifest [deleted file]
packaging/csapi-data-control.spec [deleted file]
src/Tizen.Account.AccountManager/Interop/Interop.Account.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Interop/Interop.AccountProvider.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Interop/Interop.AccountService.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Interop/Interop.Libraries.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.csproj [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.snk [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/Account.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountEnums.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountErrorFactory.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountProvider.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSubscriberEventArgs.cs [new file with mode: 0644]
src/Tizen.Applications.Alarm/Interop/Interop.Alarm.cs [new file with mode: 0755]
src/Tizen.Applications.Alarm/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Applications.Alarm/Tizen.Applications.Alarm.csproj [new file with mode: 0755]
src/Tizen.Applications.Alarm/Tizen.Applications.Alarm.snk [new file with mode: 0755]
src/Tizen.Applications.Alarm/Tizen.Applications/Alarm.cs [new file with mode: 0755]
src/Tizen.Applications.Alarm/Tizen.Applications/AlarmErrorFactory.cs [new file with mode: 0755]
src/Tizen.Applications.Alarm/Tizen.Applications/AlarmManager.cs [new file with mode: 0755]
src/Tizen.Applications.AttachPanel/Interop/Interop.AttachPanel.cs [new file with mode: 0755]
src/Tizen.Applications.AttachPanel/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel.csproj [new file with mode: 0755]
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel.snk [new file with mode: 0644]
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/AttachPanel.cs [new file with mode: 0755]
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/AttachPanelInternal.cs [new file with mode: 0755]
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/ContentCategory.cs [new file with mode: 0755]
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/EventType.cs [new file with mode: 0755]
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/ResultEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/StateEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/StateType.cs [new file with mode: 0755]
src/Tizen.Applications.Badge/GlobalSuppressions.cs [new file with mode: 0755]
src/Tizen.Applications.Badge/Interop/Interop.Badge.cs [new file with mode: 0755]
src/Tizen.Applications.Badge/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Applications.Badge/Tizen.Applications.Badge.csproj [new file with mode: 0755]
src/Tizen.Applications.Badge/Tizen.Applications.Badge.snk [new file with mode: 0755]
src/Tizen.Applications.Badge/Tizen.Applications/Badge.cs [new file with mode: 0755]
src/Tizen.Applications.Badge/Tizen.Applications/BadgeControl.cs [new file with mode: 0755]
src/Tizen.Applications.Badge/Tizen.Applications/BadgeErrorFactory.cs [new file with mode: 0755]
src/Tizen.Applications.Badge/Tizen.Applications/BadgeEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Interop/Interop.AppControl.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs [new file with mode: 0644]
src/Tizen.Applications.Common/Interop/Interop.Bundle.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Interop/Interop.Glib.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Interop/Interop.Libc.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications.Common.csproj [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications.Common.snk [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/DefaultCoreBackend.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/EventType.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/ICoreBackend.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/AppControlData.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/AppControlLaunchMode.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/AppControlOperations.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/AppControlReceivedEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/AppControlReplyCallback.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/AppControlReplyResult.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/Application.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/ApplicationDisabledEventArgs.cs [new file with mode: 0644]
src/Tizen.Applications.Common/Tizen.Applications/ApplicationEnabledEventArgs.cs [new file with mode: 0644]
src/Tizen.Applications.Common/Tizen.Applications/ApplicationEventState.cs [new file with mode: 0644]
src/Tizen.Applications.Common/Tizen.Applications/ApplicationInfo.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/ApplicationInfoFilter.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/ApplicationInfoMetadataFilter.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/ApplicationLaunchedEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/ApplicationManager.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/ApplicationRunningContext.cs [new file with mode: 0644]
src/Tizen.Applications.Common/Tizen.Applications/ApplicationTerminatedEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/ApplicationType.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/Bundle.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/DeviceOrientation.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/DeviceOrientationEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/DirectoryInfo.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/LocaleChangedEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/LowBatteryEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/LowBatteryStatus.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/LowMemoryEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/LowMemoryStatus.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/ReceivedAppControl.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/RecentApplicationControl.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/RecentApplicationInfo.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/RegionFormatChangedEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/ResourceManager.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/SafeAppControlHandle.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/SafeBundleHandle.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/TizenSynchronizationContext.cs [new file with mode: 0644]
src/Tizen.Applications.DataControl/Tizen.Applications.DataControl.sln [deleted file]
src/Tizen.Applications.MessagePort/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Applications.MessagePort/Interop/Interop.MessagePort.cs [new file with mode: 0755]
src/Tizen.Applications.MessagePort/Tizen.Applications.MessagePort.csproj [new file with mode: 0755]
src/Tizen.Applications.MessagePort/Tizen.Applications.MessagePort.snk [new file with mode: 0755]
src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/MessagePort.cs [new file with mode: 0755]
src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/MessagePortErrorFactory.cs [new file with mode: 0755]
src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/MessageReceivedEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/RemoteValues.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Interop/Interop.Notification.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notification.csproj [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notification.snk [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/Notification.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationAccessorySet.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationAccessorySetBinder.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationActiveStyle.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationBinder.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationButtonAction.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationEnumerations.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationErrorFactory.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationIndicatorStyle.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationLockStyle.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationMakerBase.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationManager.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationProgress.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationProgressBinder.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationReplyAction.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationSafeHandle.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationStyle.cs [new file with mode: 0755]
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationStyleBinder.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Interop/Interop.NotificationEventListener.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener.csproj [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener.snk [new file with mode: 0644]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationAccessoryArgsBinder.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationButtonActionArgsBinder.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationDeleteEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationDeleteEventArgsBinder.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsAccessory.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsActiveStyle.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsBinder.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsButtonAction.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsEnumerations.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsIndicatorStyle.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsLockStyle.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsProgress.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsReplyAction.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsStyle.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventListenerErrorFactory.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationProgressArgsBinder.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationReplyActionArgsBinder.cs [new file with mode: 0755]
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationStyleArgsBinder.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Interop/Interop.Package.cs [new file with mode: 0644]
src/Tizen.Applications.PackageManager/Interop/Interop.PackageManager.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications.PackageManager.csproj [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications.PackageManager.snk [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/CertCompareResultType.cs [new file with mode: 0644]
src/Tizen.Applications.PackageManager/Tizen.Applications/CertificateType.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/InstallationMode.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/Package.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/PackageCertificate.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/PackageDrm.cs [new file with mode: 0644]
src/Tizen.Applications.PackageManager/Tizen.Applications/PackageEventState.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/PackageEventType.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/PackageFilter.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManagerEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/PackageSizeInformation.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/PackageType.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/PermissionType.cs [new file with mode: 0644]
src/Tizen.Applications.PackageManager/Tizen.Applications/SafePackageManagerHandle.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/SafePackageManagerRequestHandle.cs [new file with mode: 0755]
src/Tizen.Applications.PackageManager/Tizen.Applications/StorageType.cs [new file with mode: 0755]
src/Tizen.Applications.Preference/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Applications.Preference/Interop/Interop.Preference.cs [new file with mode: 0755]
src/Tizen.Applications.Preference/Tizen.Applications.Preference.csproj [new file with mode: 0755]
src/Tizen.Applications.Preference/Tizen.Applications.Preference.snk [new file with mode: 0755]
src/Tizen.Applications.Preference/Tizen.Applications/Preference.cs [new file with mode: 0755]
src/Tizen.Applications.Preference/Tizen.Applications/PreferenceChangedEventArgs.cs [new file with mode: 0755]
src/Tizen.Applications.Service/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Applications.Service/Interop/Interop.Service.cs [new file with mode: 0755]
src/Tizen.Applications.Service/Tizen.Applications.CoreBackend/ServiceCoreBackend.cs [new file with mode: 0755]
src/Tizen.Applications.Service/Tizen.Applications.Service.csproj [new file with mode: 0755]
src/Tizen.Applications.Service/Tizen.Applications.Service.snk [new file with mode: 0755]
src/Tizen.Applications.Service/Tizen.Applications/ServiceApplication.cs [new file with mode: 0755]
src/Tizen.Applications.ToastMessage/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Applications.ToastMessage/Interop/Interop.ToastMessage.cs [new file with mode: 0755]
src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.csproj [new file with mode: 0755]
src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.snk [new file with mode: 0755]
src/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessage.cs [new file with mode: 0755]
src/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessageErrorFactory.cs [new file with mode: 0755]
src/Tizen.Applications.UI/Interop/Interop.Application.cs [new file with mode: 0755]
src/Tizen.Applications.UI/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs [new file with mode: 0755]
src/Tizen.Applications.UI/Tizen.Applications.UI.csproj [new file with mode: 0755]
src/Tizen.Applications.UI/Tizen.Applications.UI.snk [new file with mode: 0755]
src/Tizen.Applications.UI/Tizen.Applications/CoreUIApplication.cs [new file with mode: 0755]
src/Tizen.Context/Interop/Interop.AppHistory.cs [new file with mode: 0644]
src/Tizen.Context/Interop/Interop.Libraries.cs [new file with mode: 0644]
src/Tizen.Context/Tizen.Context.AppHistory/AppHistoryErrorFactory.cs [new file with mode: 0644]
src/Tizen.Context/Tizen.Context.AppHistory/AppStatistics.cs [new file with mode: 0644]
src/Tizen.Context/Tizen.Context.AppHistory/AppStatisticsData.cs [new file with mode: 0644]
src/Tizen.Context/Tizen.Context.AppHistory/BatteryStatistics.cs [new file with mode: 0644]
src/Tizen.Context/Tizen.Context.AppHistory/BatteryStatisticsData.cs [new file with mode: 0644]
src/Tizen.Context/Tizen.Context.AppHistory/UsageStatistics.cs [new file with mode: 0644]
src/Tizen.Context/Tizen.Context.AppHistory/UsageStatisticsData.cs [new file with mode: 0644]
src/Tizen.Context/Tizen.Context.csproj [new file with mode: 0644]
src/Tizen.Context/Tizen.Context.snk [new file with mode: 0644]
src/Tizen.Convergence/Interop/Interop.Common.cs [new file with mode: 0755]
src/Tizen.Convergence/Interop/Interop.Internal.Conv.Channel.cs [new file with mode: 0755]
src/Tizen.Convergence/Interop/Interop.Internal.Conv.Device.cs [new file with mode: 0755]
src/Tizen.Convergence/Interop/Interop.Internal.Conv.Manager.cs [new file with mode: 0755]
src/Tizen.Convergence/Interop/Interop.Internal.Conv.Payload.cs [new file with mode: 0755]
src/Tizen.Convergence/Interop/Interop.Internal.Conv.Service.cs [new file with mode: 0755]
src/Tizen.Convergence/Interop/Interop.Libc.cs [new file with mode: 0755]
src/Tizen.Convergence/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence.csproj [new file with mode: 0644]
src/Tizen.Convergence/Tizen.Convergence.snk [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/InternalAppCommunicationService.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/InternalChannel.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/InternalDevice.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/InternalDeviceFinder.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/InternalDeviceFoundEventArgs.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/InternalErrorFactory.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/InternalPayload.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/InternalService.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/InternalServiceErrorOccuredEventArgs.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/InternalServiceEventOccuredEventArgs.cs [new file with mode: 0755]
src/Tizen.Network.Bluetooth/Interop/Interop.Bluetooth.cs [new file with mode: 0755]
src/Tizen.Network.Bluetooth/Interop/Interop.Glib.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Interop/Interop.Libc.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Interop/Interop.Libraries.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth.csproj [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth.snk [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAdapter.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAdapterImpl.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAudio.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAudioImpl.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAvrcp.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAvrcpImpl.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothData.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothDevice.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothEnumerations.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothError.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothEventArgs.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGattImpl.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothHid.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothHidImpl.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothLeAdapter.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothLeAdapterImpl.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothProfile.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothServerSocket.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothSocket.cs [new file with mode: 0644]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothStructs.cs [new file with mode: 0644]
src/Tizen.Network.Connection/Interop/Interop.Connection.cs [new file with mode: 0755]
src/Tizen.Network.Connection/Interop/Interop.Libraries.cs [new file with mode: 0644]
src/Tizen.Network.Connection/Tizen.Network.Connection.csproj [new file with mode: 0644]
src/Tizen.Network.Connection/Tizen.Network.Connection.snk [new file with mode: 0644]
src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs [new file with mode: 0755]
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionError.cs [new file with mode: 0755]
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs [new file with mode: 0755]
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionManager.cs [new file with mode: 0755]
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs [new file with mode: 0755]
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfileManager.cs [new file with mode: 0755]
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionTypes.cs [new file with mode: 0755]
src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs [new file with mode: 0755]
src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs [new file with mode: 0755]
src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Database.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Filter.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Libraries.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Interop/Interop.Calendar.List.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Query.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Record.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Reminder.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Service.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Vcalendar.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar.csproj [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar.nuspec [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarDatabase.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarErrorFactory.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarFilter.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarList.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarManager.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarQuery.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarRecord.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarReminder.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarStructs.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarTypes.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarVcalendar.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarViews.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/NamespaceDoc.cs [new file with mode: 0644]
src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/ReminderEventArgs.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Interop/Interop.Activity.cs [new file with mode: 0755]
src/Tizen.Pims.Contacts/Interop/Interop.Contacts.cs [new file with mode: 0755]
src/Tizen.Pims.Contacts/Interop/Interop.Database.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Interop/Interop.Filter.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Interop/Interop.Group.cs [new file with mode: 0755]
src/Tizen.Pims.Contacts/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Pims.Contacts/Interop/Interop.List.cs [new file with mode: 0755]
src/Tizen.Pims.Contacts/Interop/Interop.Person.cs [new file with mode: 0755]
src/Tizen.Pims.Contacts/Interop/Interop.PhoneLog.cs [new file with mode: 0755]
src/Tizen.Pims.Contacts/Interop/Interop.Query.cs [new file with mode: 0755]
src/Tizen.Pims.Contacts/Interop/Interop.Record.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Interop/Interop.Setting.cs [new file with mode: 0755]
src/Tizen.Pims.Contacts/Interop/Interop.Sim.cs [new file with mode: 0755]
src/Tizen.Pims.Contacts/Interop/Interop.Vcard.cs [new file with mode: 0755]
src/Tizen.Pims.Contacts/Tizen.Pims.Contacts.csproj [new file with mode: 0644]
src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsDatabase.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsErrorFactory.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsFilter.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsList.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsManager.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsQuery.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsRecord.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsVcard.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsViews.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/DBStatusChangedEventArgs.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NameDisplayOrderChangedEventArgs.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NameSortingOrderChangedEventArgs.cs [new file with mode: 0644]
src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NamespaceDoc.cs [new file with mode: 0644]

diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644 (file)
index 3400ba9..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# Set default behaviour, in case users don't have core.autocrlf set.
-* text=auto
-
-# Explicitly declare text files we want to always be normalized and converted 
-# to native line endings on checkout.
-*.cs text
-
-# Declare files that will always have CRLF line endings on checkout.
-*.sln text eol=crlf
-
-# Denote all files that are truly binary and should not be modified.
-*.png binary
-*.jpg binary
-*.jpeg binary
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
deleted file mode 100644 (file)
index 46619d5..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-bin/
-obj/
-*.exe
-*.dll
-*.csproj.user
-*.lock.json
-.vs/
diff --git a/LICENSE b/LICENSE
deleted file mode 100644 (file)
index d645695..0000000
--- a/LICENSE
+++ /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 [yyyy] [name of copyright owner]
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT 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/packaging/csapi-data-control.manifest b/packaging/csapi-data-control.manifest
deleted file mode 100755 (executable)
index 75b0fa5..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
-    <request>
-        <domain name="_"/>
-    </request>
-</manifest>
diff --git a/packaging/csapi-data-control.spec b/packaging/csapi-data-control.spec
deleted file mode 100755 (executable)
index d933f13..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-Name:       csapi-data-control
-Summary:    Tizen data-control API for C#
-Version:    1.0.8
-Release:    1
-Group:      Development/Libraries
-License:    Apache-2.0
-URL:        https://www.tizen.org
-Source0:    %{name}-%{version}.tar.gz
-Source1:    %{name}.manifest
-
-AutoReqProv: no
-ExcludeArch: aarch64
-
-BuildRequires: dotnet-build-tools
-
-# C# API Requires
-BuildRequires: csapi-tizen-nuget
-BuildRequires: csapi-application-common-nuget
-
-%define Assemblies Tizen.Applications.DataControl
-
-%description
-%{summary}
-
-%dotnet_import_sub_packages
-
-%prep
-%setup -q
-cp %{SOURCE1} .
-
-%build
-for ASM in %{Assemblies}; do
-%dotnet_build $ASM
-%dotnet_pack $ASM
-done
-
-%install
-for ASM in %{Assemblies}; do
-%dotnet_install $ASM
-done
-
-%files
-%manifest %{name}.manifest
-%license LICENSE
-%attr(644,root,root) %{dotnet_assembly_files}
diff --git a/src/Tizen.Account.AccountManager/Interop/Interop.Account.cs b/src/Tizen.Account.AccountManager/Interop/Interop.Account.cs
new file mode 100644 (file)
index 0000000..9789044
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Account.AccountManager;
+/// <summary>
+/// Interop for Account class APIs
+/// </summary>
+/// <since_tizen> 3 </since_tizen>
+internal static partial class Interop
+{
+    /// <summary>
+    /// Interop for Account class APIs
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    internal static partial class Account
+    {
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_create", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Create(out IntPtr handle);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_destroy", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Destroy(IntPtr handle);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_account_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountId(IntPtr data, out int accountId);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_user_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountUserName(IntPtr data, out string userName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_user_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountUserName(IntPtr handle, string userName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_display_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountDisplayName(IntPtr handle, out string displayName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_display_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountDisplayName(IntPtr handle, string displayName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_capability", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountCapability(IntPtr handle, string capabilityType, out int capabilityValue);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_capability", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountCapability(IntPtr handle, string capabilityType, int capabilityValue);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_icon_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountIconPath(IntPtr handle, out string iconPath);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_icon_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountIconPath(IntPtr handle, string iconPath);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_domain_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountDomainName(IntPtr handle, out string domainName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_domain_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountDomainName(IntPtr handle, string domainName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_email_address", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountEmail(IntPtr handle, out string email);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_email_address", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountEmail(IntPtr handle, string email);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_package_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountPackageName(IntPtr handle, out string name);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_package_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountPackageName(IntPtr handle, string name);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_access_token", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountAccessToken(IntPtr handle, out string accessToken);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_access_token", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountAccessToken(IntPtr handle, string accessToken);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_user_text", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountUserText(IntPtr handle, int index, out string userText);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_user_text", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountUserText(IntPtr handle, int index, string userText);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_user_int", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountUserInt(IntPtr handle, int index, out int value);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_user_int", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountUserInt(IntPtr handle, int index, int value);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_auth_type", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountAuthType(IntPtr handle, out int authType);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_auth_type", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountAuthType(IntPtr handle, int authType);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_secret", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountSercet(IntPtr handle, out int secretType);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_secret", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountSecret(IntPtr handle, int secretType);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_sync_support", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountSyncSupport(IntPtr handle, out int syncType);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_sync_support", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountSyncSupport(IntPtr handle, int syncType);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_source", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountSource(IntPtr handle, out string source);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_source", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountSource(IntPtr handle, string source);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_custom", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountCustomValue(IntPtr handle, string key, out string value);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_custom", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountCustomValue(IntPtr handle, string key, string value);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_update_sync_status_by_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int UpdateAccountSyncStatusById(int accountId, int status);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_capability_all")]
+        internal static extern int GetAllAccountCapabilities(IntPtr handle, AccountCapabilityCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_capability_by_account_id")]
+        internal static extern int QueryAccountCapabilityById(AccountCapabilityCallback callback, int accountId, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_custom_all")]
+        internal static extern int GetAllAccountCustomValues(IntPtr handle, AccountCustomCallback callback, IntPtr userData);
+
+        //Callbacks
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool AccountCapabilityCallback(string capabilityType, int capabilityState, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool AccountCustomCallback(string key, string value, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool AccountCallback(IntPtr data, IntPtr userData);
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Interop/Interop.AccountProvider.cs b/src/Tizen.Account.AccountManager/Interop/Interop.AccountProvider.cs
new file mode 100644 (file)
index 0000000..f201061
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Account.AccountManager;
+
+/// <summary>
+/// Interop for AccountProvider class APIs
+/// </summary>
+/// <since_tizen> 3 </since_tizen>
+internal static partial class Interop
+{
+    /// <summary>
+    /// Interop for AccountProvider class APIs
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    internal static partial class AccountProvider
+    {
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_create", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Create(out IntPtr handle);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_destroy", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Destroy(IntPtr handle);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_app_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAppId(IntPtr handle, out string appId);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_query_supported_feature", CallingConvention = CallingConvention.Cdecl)]
+       [return: MarshalAs(UnmanagedType.I1)]
+        internal static extern bool IsFeatureSupported(string appId, string capability);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_service_provider_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetServiceProviderId(IntPtr handle, out string providerId);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_icon_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountProviderIconPath(IntPtr handle, out string iconPath);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_small_icon_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountProviderSmallIconPath(IntPtr handle, out string iconPath);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_multiple_account_support", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetMultipleAccountSupport(IntPtr handle, out int suppport);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_label_by_locale", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetlabelbyLocale(IntPtr handle, string locale, out string label);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_query_app_id_exist", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAppIdExists(string appId);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_foreach_account_type_from_db", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAllAccountProviders(AccountProviderCallback callback, IntPtr data);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_query_provider_feature_by_app_id")]
+        internal static extern int GetAccountProviderFeaturesByAppId(AccountProviderFeatureCallback callback, string appId, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_provider_feature_all")]
+        internal static extern int GetAccountProviderFeatures(IntPtr handle, AccountProviderFeatureCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_label")]
+        internal static extern int GetAccountProviderLabels(IntPtr handle, LabelCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_query_label_by_app_id")]
+        internal static extern int GetLablesByAppId(LabelCallback callback, string appId, IntPtr userData);
+
+
+        //Callbacks
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool AccountProviderFeatureCallback(string appId, string key, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool AccountProviderCallback(IntPtr handle, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool LabelCallback(string appId, string label, string locale, IntPtr user_data);
+
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Interop/Interop.AccountService.cs b/src/Tizen.Account.AccountManager/Interop/Interop.AccountService.cs
new file mode 100644 (file)
index 0000000..7bb1275
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// Interop for Account class APIs
+/// </summary>
+/// <since_tizen> 3 </since_tizen>
+internal static partial class Interop
+{
+    /// <summary>
+    /// Interop for Account class APIs
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    internal static partial class AccountService
+    {
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_update_to_db_by_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int UpdateAccountToDBById(IntPtr handle, int id);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_update_to_db_by_user_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int UpdateAccountToDBByUserName(IntPtr handle, string userName, string packageName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_account_by_account_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int QueryAccountById(int accountId, out IntPtr handle);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_account_by_user_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int QueryAccountByUserName(Interop.Account.AccountCallback callback, string userName, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_account_by_package_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int QueryAccountByPackageName(Interop.Account.AccountCallback callback, string packageName, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_capability_by_account_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int QueryAccountCapabilityById(Interop.Account.AccountCapabilityCallback callback, int accoutId, IntPtr data);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_update_sync_status_by_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int UpdateAccountSyncStatusById(int accoutId, int status);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_insert_to_db", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int AddAccount(IntPtr handle, out int accountId);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_delete_from_db_by_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int DeleteAccountById(int accountId);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_delete_from_db_by_user_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int DeleteAccountByUser(string userName, string packageName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_delete_from_db_by_package_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int DeleteAccountByPackage(string packageName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_total_count_from_db", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountCount(out int count);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_foreach_account_from_db")]
+        internal static extern int AccountForeachAccountFromDb(Interop.Account.AccountCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_account_by_capability")]
+        internal static extern int GetAccountByCapability(Interop.Account.AccountCallback callback, string capabilityType, int value, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_account_by_capability_type")]
+        internal static extern int GetAccountByCapabilityType(Interop.Account.AccountCallback callback, string capabilityType, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_foreach_account_type_from_db")]
+        internal static extern int GetAllAccountproviders(Interop.AccountProvider.AccountProviderCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_query_by_provider_feature")]
+        internal static extern int GetAccountProviderByFeature(Interop.AccountProvider.AccountProviderCallback callback, string key, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_query_by_app_id")]
+        internal static extern int GetAccountProviderByAppId(string appId, out IntPtr handle);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_subscribe_create")]
+        internal static extern int CreateAccountSubscriber(out Interop.AccountService.SafeAccountSubscriberHandle handle);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_subscribe_notification")]
+        internal static extern int RegisterSubscriber(Interop.AccountService.SafeAccountSubscriberHandle handle, Interop.AccountService.SubscribeCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_unsubscribe_notification")]
+        internal static extern int UnregisterSubscriber(Interop.AccountService.SafeAccountSubscriberHandle handle);
+
+        //Callbacks
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool SubscribeCallback(string eventType, int accountId, IntPtr userData);
+
+        internal sealed class SafeAccountSubscriberHandle : SafeHandle
+        {
+            public SafeAccountSubscriberHandle()
+                : base(IntPtr.Zero, true)
+            {
+            }
+
+            public override bool IsInvalid
+            {
+                get { return this.handle == IntPtr.Zero; }
+            }
+
+            protected override bool ReleaseHandle()
+            {
+                this.SetHandle(IntPtr.Zero);
+                return true;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Interop/Interop.Libraries.cs b/src/Tizen.Account.AccountManager/Interop/Interop.Libraries.cs
new file mode 100644 (file)
index 0000000..f1530bd
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/// <summary>
+/// Interop for Library reference
+/// </summary>
+/// <since_tizen> 3 </since_tizen>
+internal static partial class Interop
+{
+    /// <summary>
+    /// Interop for Library reference
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    internal static partial class Libraries
+    {
+        public const string AccountSvc = "libaccounts-svc.so.0";
+        public const string Glib = "libglib-2.0.so.0";
+        public const string Libc = "libc.so.6";
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.csproj b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.csproj
new file mode 100644 (file)
index 0000000..d1b0495
--- /dev/null
@@ -0,0 +1,25 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <Version>1.0.7</Version>
+    <Authors>Samsung Electronics</Authors>
+    <Copyright>© Samsung Electronics Co., Ltd All Rights Reserved</Copyright>
+    <Description>Account Service APIs for Tizen.Account.AccountManager</Description>
+    <PackageProjectUrl>https://www.tizen.org/</PackageProjectUrl>
+    <PackageLicenseUrl>https://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
+    <PackageIconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</PackageIconUrl>
+  </PropertyGroup>
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.6</TargetFramework>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Account.AccountManager.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Tizen" Version="1.0.5" />
+  </ItemGroup>
+  
+</Project>
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.snk b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.snk
new file mode 100644 (file)
index 0000000..24dc971
Binary files /dev/null and b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.snk differ
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/Account.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/Account.cs
new file mode 100644 (file)
index 0000000..df10a15
--- /dev/null
@@ -0,0 +1,619 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Account.AccountManager
+{
+    /// <summary>
+    /// Represents the Account Information.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public class Account : IDisposable
+    {
+        private IntPtr _handle = IntPtr.Zero;
+        internal Account(IntPtr handle)
+        {
+            Handle = handle;
+        }
+
+        ~Account()
+        {
+            Dispose(false);
+        }
+        /// <summary>
+        /// Creates a new Account instance.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <returns>Account Instance.</returns>
+        public static Account CreateAccount()
+        {
+            IntPtr handle;
+            AccountError err = (AccountError)Interop.Account.Create(out handle);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to create new error.");
+            }
+
+            return new Account(handle);
+        }
+
+        /// <summary>
+        /// Id of the Account.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <remarks>Account Id shall be created only when account is added to the database.</remarks>
+        public int AccountId
+        {
+            get
+            {
+                int id = 0;
+                AccountError res = (AccountError)Interop.Account.GetAccountId(_handle, out id);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get Id for the Account");
+                }
+
+                return id;
+            }
+        }
+
+        /// <summary>
+        /// UserName of the Account.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>User Name of the Account.</value>
+        public string UserName
+        {
+            get
+            {
+                string name = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountUserName(_handle, out name);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get UserName for the Account");
+                }
+
+                return name;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountUserName(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set UserName for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Display Name of the Account.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>DisplayName of the  Account.</value>
+        public string DisplayName
+        {
+            get
+            {
+                string name = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountDisplayName(_handle, out name);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get DisplayName for the Account");
+                }
+
+                return name;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountDisplayName(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set DisplayName for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Icon path of the Account.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Icon path of the Account.</value>
+        public string IconPath
+        {
+            get
+            {
+                string path = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountIconPath(_handle, out path);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get IconPath for the Account");
+                }
+
+                return path;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountIconPath(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set IconPath for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Domain name of the Account.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Domain name of the Account.</value>
+        public string DomainName
+        {
+            get
+            {
+                string name = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountDomainName(_handle, out name);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get DomainName for the Account");
+                }
+
+                return name;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountDomainName(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set DomainName for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Email Id of the Account.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Email Id of the Account.</value>
+        public string EmailId
+        {
+            get
+            {
+                string email = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountEmail(_handle, out email);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get email for the Account");
+                }
+
+                return email;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountEmail(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set email for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Package Name of the Account.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Package Name.</value>
+        public string PackageName
+        {
+            get
+            {
+                string name = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountPackageName(_handle, out name);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get PacakageName for the Account");
+                }
+
+                return name;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountPackageName(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set PacakageName for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Access Token of the Account.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Access Token.</value>
+        public string AccessToken
+        {
+            get
+            {
+                string token = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountAccessToken(_handle, out token);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get token for the Account");
+                }
+
+                return token;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountAccessToken(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set token for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Authentication type of the Account.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Authentication type.</value>
+        public AccountAuthType AuthType
+        {
+            get
+            {
+                int user;
+                AccountError res = (AccountError)Interop.Account.GetAccountAuthType(_handle, out user);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get AuthType for the Account");
+                }
+
+                return (AccountAuthType)user;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountAuthType(_handle, (int)value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set AuthType for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Secrecy State of the Account.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Secrecy State.</value>
+        public AccountSecrecyState SecrecyState
+        {
+            get
+            {
+                int state;
+                AccountError res = (AccountError)Interop.Account.GetAccountSercet(_handle, out state);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get User Secret for the Account");
+                }
+
+                return (AccountSecrecyState)state;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountSecret(_handle, (int)value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set User Secret for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Sync State of the Account.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Sync State.</value>
+        public AccountSyncState SyncState
+        {
+            get
+            {
+                int supported;
+                AccountError res = (AccountError)Interop.Account.GetAccountSyncSupport(_handle, out supported);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get AuthType for the Account");
+                }
+
+                return (AccountSyncState)supported;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountSyncSupport(_handle, (int)value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set AuthType for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Source of the Account .
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Account Source.</value>
+        public string Source
+        {
+            get
+            {
+                string text = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountSource(_handle, out text);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get User Secret for the Account");
+                }
+
+                return text;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountSource(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set User Secret for Account");
+                }
+            }
+        }
+
+        internal IntPtr Handle
+        {
+            get
+            {
+                return _handle;
+            }
+
+            set
+            {
+                _handle = value;
+            }
+        }
+        /// <summary>
+        /// Sets the account capability.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="capabilityType"> The Account capability type</param>
+        /// <param name="state">The Account capability state</param>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        public void SetCapability(string capabilityType, CapabilityState state)
+        {
+            AccountError ret = (AccountError)Interop.Account.SetAccountCapability(_handle, capabilityType, (int)state);
+            if (ret != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(ret, "failed to set account capability");
+            }
+        }
+        /// <summary>
+        /// Gets all the capabilities of an account.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="capabilityType"> The capability type to get the capability value.</param>
+        /// <returns>The capability value (on/off) of the specified CapabilityState .</returns>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        public CapabilityState GetCapability(string capabilityType)
+        {
+            int type;
+            AccountError res = (AccountError)Interop.Account.GetAccountCapability(_handle, capabilityType, out type);
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to GetCapability for Account");
+            }
+
+            return (CapabilityState)type;
+        }
+
+        /// <summary>
+        /// Gets all the capabilities of an account.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <returns>List of Cpabailities as Dictionary</returns>
+        public Dictionary<string, CapabilityState> GetAllCapabilities()
+        {
+
+            AccountError res = AccountError.None;
+            Dictionary<string, CapabilityState> list = new Dictionary<string, CapabilityState>();
+            Interop.Account.AccountCapabilityCallback capabilityCallback = (string type, int state, IntPtr data) =>
+            {
+                list.Add(type, (CapabilityState)state);
+                return true;
+            };
+
+            res = (AccountError)Interop.Account.GetAllAccountCapabilities(_handle, capabilityCallback, IntPtr.Zero);
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to get account capabilities");
+            }
+
+            return list;
+        }
+
+        /// <summary>
+        /// Sets the Custom Value to the Account.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="key">key to be added to the Account.</param>
+        /// <param name="value">value to be updated for respective key for the Account.</param>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        public void SetCustomValue(string key, string value)
+        {
+            AccountError err = (AccountError)Interop.Account.SetAccountCustomValue(_handle, key, value);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to set the value for : " + key);
+            }
+        }
+
+        /// <summary>
+        /// Gets the user specific custom text of an account key.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="key">The key to retrieve custom text .</param>
+        /// <returns>The text of the given key</returns>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        /// <exception cref="InvalidOperationException">If there is no given capability type in the account </exception>
+        public string GetCustomValue(string key)
+        {
+            string result = "";
+            AccountError err = (AccountError)Interop.Account.GetAccountCustomValue(_handle, key, out result);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to get the value for : " + key);
+            }
+
+            return result;
+        }
+
+        /// <summary>
+        /// Gets All the custome values.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <returns>List of custom key, value pairs as Dictionary.</returns>
+        public Dictionary<string, string> GetAllCustomValues()
+        {
+            AccountError res = AccountError.None;
+            Dictionary<string, string> list = new Dictionary<string, string>();
+
+            Interop.Account.AccountCustomCallback customCallback = (string key, string value, IntPtr data) =>
+            {
+                list.Add(key, value);
+                return true;
+            };
+
+            res = (AccountError)Interop.Account.GetAllAccountCustomValues(_handle, customCallback, IntPtr.Zero);
+
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to get account capabilities");
+            }
+
+            return list;
+        }
+
+        /// <summary>
+        /// Sets the user text.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="index">The index of the user text (must be in range from 0 to 4) </param>
+        /// <param name="text">The text string to set as the user text</param>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        public void SetUserText(int index, string text)
+        {
+            AccountError err = (AccountError)Interop.Account.SetAccountUserText(_handle, index, text);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to get the value for : " + index);
+            }
+        }
+
+        /// <summary>
+        /// Gets the user text.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="index">The index of the user text (range: 0 ~ 4)</param>
+        /// <returns>The user text of the given key</returns>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        /// <exception cref="OutOfMemoryException">In case of out of memory</exception>
+        public string GetUserText(int index)
+        {
+            string result = "";
+            AccountError err = (AccountError)Interop.Account.GetAccountUserText(_handle, index, out result);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to get the value for : " + index);
+            }
+
+            return result;
+        }
+
+        /// <summary>
+        /// Gets the user int value.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="index">The index of the user int (range: 0 ~ 4)</param>
+        /// <returns>The user int of the given key</returns>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        public int GetUserInt(int index)
+        {
+            int result = -1;
+            AccountError err = (AccountError)Interop.Account.GetAccountUserInt(_handle, index, out result);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to get the value for : " + index);
+            }
+
+            return result;
+        }
+
+        /// <summary>
+        /// Sets the user integer value.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="index">The index of the user integer (must be in range from 0 to 4) </param>
+        /// <param name="value">The integer to set as the user integer</param>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        public void SetUserInt(int index, int value)
+        {
+            AccountError err = (AccountError)Interop.Account.SetAccountUserInt(_handle, index, value);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to get the value for : " + index);
+            }
+        }
+
+        /// <summary>
+        /// Overloaded Dispose API for destroying the Account Handle.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            if (!disposing)
+            {
+                if (_handle != IntPtr.Zero)
+                {
+                    _handle = IntPtr.Zero;
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountEnums.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountEnums.cs
new file mode 100644 (file)
index 0000000..b55a458
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Account.AccountManager
+{
+    /// <summary>
+    /// Enumeration for the state of capability
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum CapabilityState
+    {
+        /// <summary>
+        /// Account capability is invalid
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        InvalidState,
+
+        /// <summary>
+        /// Account capability is disabled
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        Disabled,
+
+        /// <summary>
+        /// Account capability is enabled
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        Enabled
+    }
+
+    /// <summary>
+    /// Enumeration for the state of account secrecy.
+    /// </summary>
+    public enum AccountSecrecyState
+    {
+        /// <summary>
+        /// Account secrecy is invalid
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        InvalidState,
+
+        /// <summary>
+        /// Account is not visible
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        Invisible,
+
+        /// <summary>
+        /// Account is visible
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        Visible
+    }
+
+    /// <summary>
+    /// Enumeration for the account sync status.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum AccountSyncState
+    {
+        /// <summary>
+        /// Account sync is invalid
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        InvalidState,
+
+        /// <summary>
+        /// Account sync not supported
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        NotSupported,
+
+        /// <summary>
+        /// Account sync supported but all synchronization functionalities are off
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        Off,
+
+        /// <summary>
+        /// Account sync support and sync status is idle
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        Idle,
+
+        /// <summary>
+        /// Account sync support and sync status is running
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        Running
+    }
+
+    /// <summary>
+    /// Enumeration for the account auth type.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum AccountAuthType
+    {
+        /// <summary>
+        /// Auth type is invalid
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        Invalid,
+
+        /// <summary>
+        /// XAuth type
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        XAuth,
+
+        /// <summary>
+        /// OAuth type
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        OAuth,
+
+        /// <summary>
+        /// Client-Login type
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        ClientLogin
+    }
+
+    /// <summary>
+    /// Account information change notification type
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    /// <remarks>
+    /// When the account database is changed, You can distinguish one event type from the other which are set for subscribing notification.
+    /// </remarks>
+    public enum AccountNotificationType
+    {
+        /// <summary>
+        /// The insert notification type.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        Insert,
+        /// <summary>
+        /// The delete notification type.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        Delete,
+        /// <summary>
+        /// The update notification type.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        Update,
+        /// <summary>
+        /// The sync update notification type.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        syncUpdate
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountErrorFactory.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountErrorFactory.cs
new file mode 100644 (file)
index 0000000..48f9164
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen;
+
+namespace Tizen.Account.AccountManager
+{
+    /// <summary>
+    /// Enum to give the type of error occured, if any.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum AccountError
+    {
+        //TIZEN_ERROR_ACCOUNT = -0x01000000
+        /// <summary>
+        /// Successful.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        None = Tizen.Internals.Errors.ErrorCode.None,
+        /// <summary>
+        /// Invalid parameter.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+        /// <summary>
+        /// Out of memory.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+        /// <summary>
+        /// Same user name exists in your application
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        Duplcated = -0x01000000 | 0x01,
+        /// <summary>
+        /// Empty Data
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        NoData = Tizen.Internals.Errors.ErrorCode.NoData,
+        /// <summary>
+        /// elated record does not exist
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        RecordNotFound = -0x01000000 | 0x03,
+        /// <summary>
+        /// Invalid Operation.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation,
+        /// <summary>
+        /// DB operation failed.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        DBFailed = -0x01000000 | 0x04,
+        /// <summary>
+        ///  DB is not connected.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        DBNotOpened = -0x01000000 | 0x05,
+        /// <summary>
+        /// DB query syntax error
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        QuerySyntaxError = -0x01000000 | 0x06,
+        /// <summary>
+        /// Iterator has reached the end
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        IteratorEnd = -0x01000000 | 0x07,
+        /// <summary>
+        /// Notification failed
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        NotificationFailed = -0x01000000 | 0x08,
+        /// <summary>
+        /// Permission denied.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
+        /// <summary>
+        /// XML parse failed
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        XMLParseFailed = -0x01000000 | 0x0a,
+        /// <summary>
+        /// XML File not found
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        XMLFileNotFound = -0x01000000 | 0x0b,
+        /// <summary>
+        /// Subscription failed
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        EventSubscriptionFailed = -0x01000000 | 0x0c,
+        /// <summary>
+        /// Account provider is not registered
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        ProviderNotRegistered = -0x01000000 | 0x0d,
+        /// <summary>
+        /// Multiple accounts are not supported.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        MultipleNotAllowed = -0x01000000 | 0x0e,
+        /// <summary>
+        /// SQLite busy handler expired
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        DBBusy = -0x01000000 | 0x10
+    };
+
+    internal class AccountErrorFactory
+    {
+        internal const string LogTag = "Tizen.Account.AccountManager";
+
+        internal static Exception CreateException(AccountError err, string msg)
+        {
+            Log.Info(LogTag, "Got Error " + err + " throwing Exception with msg " + msg);
+            Exception exp;
+            switch (err)
+            {
+                case AccountError.InvalidParameter:
+                    {
+                        exp = new ArgumentException(msg + " Invalid Parameters Provided");
+                        break;
+                    }
+
+                case AccountError.OutOfMemory:
+                    {
+                        exp = new OutOfMemoryException(msg + " Out Of Memory");
+                        break;
+                    }
+
+                case AccountError.InvalidOperation:
+                    {
+                        exp = new InvalidOperationException(msg + " Inavlid operation");
+                        break;
+                    }
+
+                case AccountError.NoData:
+                    {
+                        exp = new InvalidOperationException(msg + " Empty Data");
+                        break;
+                    }
+
+                case AccountError.PermissionDenied:
+                    {
+                        exp = new UnauthorizedAccessException(msg + " Permission Denied");
+                        break;
+                    }
+
+                case AccountError.DBFailed:
+                    {
+                        exp = new InvalidOperationException(msg + " DataBase Failed");
+                        break;
+                    }
+
+                case AccountError.DBBusy:
+                    {
+                        exp = new InvalidOperationException(msg + " DataBase Busy");
+                        break;
+                    }
+
+                case AccountError.QuerySyntaxError:
+                    {
+                        exp = new InvalidOperationException(msg + " Network Error");
+                        break;
+                    }
+                case AccountError.XMLFileNotFound:
+                    {
+                        exp = new System.IO.FileNotFoundException(msg + " XML File not found");
+                        break;
+                    }
+                case AccountError.XMLParseFailed:
+                    {
+                        exp = new System.IO.InvalidDataException(msg + " XML parse error");
+                        break;
+                    }
+
+                default:
+                    {
+                        exp = new InvalidOperationException(err + " " + msg);
+                        break;
+                    }
+            }
+
+            return exp;
+        }
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountProvider.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountProvider.cs
new file mode 100644 (file)
index 0000000..606a286
--- /dev/null
@@ -0,0 +1,366 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Account.AccountManager
+{
+    /// <summary>
+    ///  Account Id.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public class AccountProvider : IDisposable
+    {
+        internal IntPtr _handle;
+        internal AccountProvider(IntPtr handle)
+        {
+            Handle = handle;
+        }
+
+        ~AccountProvider()
+        {
+            Dispose(false);
+        }
+
+        internal IntPtr Handle
+        {
+            get
+            {
+                return _handle;
+            }
+
+            set
+            {
+                _handle = value;
+            }
+        }
+        /// <summary>
+        ///  Account Id.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public string AppId
+        {
+            get
+            {
+                string id = "";
+                AccountError res = (AccountError)Interop.AccountProvider.GetAppId(Handle, out id);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get AppId for the AccountProvider");
+                }
+
+                return id;
+            }
+        }
+
+        /// <summary>
+        ///  Serviceprovider Id of the account provider.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public string ServiceProviderId
+        {
+            get
+            {
+                string id = "";
+                AccountError res = (AccountError)Interop.AccountProvider.GetServiceProviderId(Handle, out id);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get ServiceProviderId for the AccountProvider");
+                }
+
+                return id;
+            }
+        }
+
+        /// <summary>
+        ///  Icon path of an account provider.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public string IconPath
+        {
+            get
+            {
+                string path = "";
+                AccountError res = (AccountError)Interop.AccountProvider.GetAccountProviderIconPath(Handle, out path);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get IconPath for the AccountProvider");
+                }
+
+                return path;
+            }
+        }
+
+        /// <summary>
+        ///  Small icon path of an account provider.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public string SmallIconPath
+        {
+            get
+            {
+                string path = "";
+                AccountError res = (AccountError)Interop.AccountProvider.GetAccountProviderSmallIconPath(Handle, out path);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get SmallIconPath for the AccountProvider");
+                }
+
+                return path;
+            }
+        }
+
+        /// <summary>
+        ///  Flag for account provider If supports multiple accounts.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public bool MultipleAccountSupport
+        {
+            get
+            {
+                int multiple = 0;
+                AccountError res = (AccountError)Interop.AccountProvider.GetMultipleAccountSupport(Handle, out multiple);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get SmallIconPath for the AccountProvider");
+                }
+
+                return (multiple == 0) ? false : true;
+            }
+        }
+
+        /// <summary>
+        /// Retrieves all the capability information of the account provider.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <returns>
+        /// list of capability information.
+        /// </returns>
+        /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public IEnumerable<string> GetAllCapabilities()
+        {
+            List<string> capabilities = new List<string>();
+            AccountError res;
+            Interop.AccountProvider.AccountProviderFeatureCallback callback = (string appId, string key, IntPtr data) =>
+            {
+                capabilities.Add(key);
+                return true;
+            };
+
+            res = (AccountError)Interop.AccountProvider.GetAccountProviderFeatures(Handle, callback, IntPtr.Zero);
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to GetAllCapabilities for AccountProvider");
+            }
+
+            return capabilities;
+        }
+
+        /// <summary>
+        /// Gets the specific label information detail of an account provider.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="locale">
+        /// The locale is specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code.
+        /// For example, "ko_KR" or "ko-kr" for Korean, "en_US" or "en-us" for American English.
+        /// </param>
+        /// <returns>The label text given for the locale</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given locale</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public string GetLabel(string locale)
+        {
+            string label;
+            AccountError res = (AccountError)Interop.AccountProvider.GetlabelbyLocale(Handle, locale, out label);
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to GetLabel for AccountProvider");
+            }
+
+            return label;
+        }
+
+        /// <summary>
+        /// Gets the specific label information detail of an account provider.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="appId">
+        /// The application ID to search
+        /// </param>
+        /// <returns> All the labels information for the given application Id.</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given appid</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static Dictionary<string, string> GetLabelsByAppId(string appId)
+        {
+
+            Dictionary<string, string> labels = new Dictionary<string, string>();
+            Interop.AccountProvider.LabelCallback callback = (string applicationId, string label, string locale, IntPtr userData) =>
+            {
+                labels.Add(locale, label);
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountProvider.GetLablesByAppId(callback, appId, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetLablesByAppId");
+            }
+
+            return labels;
+        }
+
+        /// <summary>
+        /// Gets the label information detail of an account provider.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <returns> All the labels information for the given account provider.</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public Dictionary<string, string> GetLabels()
+        {
+
+            Dictionary<string, string> labels = new Dictionary<string, string>();
+            Interop.AccountProvider.LabelCallback callback = (string applicationId, string label, string locale, IntPtr userData) =>
+            {
+                labels.Add(locale, label);
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountProvider.GetAccountProviderLabels(Handle, callback, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountProviderLabels");
+            }
+
+            return labels;
+        }
+
+        /// <summary>
+        /// Checks whether the given appId exists in the account provider DB.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="appId">The application ID to check.</param>
+        /// <returns>returns true If App is supported </returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given appid</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public bool IsAppSupported(string appId)
+        {
+            bool isSupported = false;
+            AccountError res = (AccountError)Interop.AccountProvider.GetAppIdExists(appId);
+
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to GetLabel for AccountProvider");
+            }
+            else
+            {
+                isSupported = true;
+            }
+
+            return isSupported;
+        }
+
+        /// <summary>
+        /// Checks whether the given application ID supports the capability.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="appId">The application Id</param>
+        /// <param name="capability">The capability information</param>
+        /// <returns>
+        /// TRUE if the application supports the given capability,
+        /// otherwise FALSE if the application does not support the given capability
+        /// </returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static bool IsFeatureSupportedByApp(string appId, string capability)
+        {
+            bool supported = Interop.AccountProvider.IsFeatureSupported(appId, capability);
+            if (!supported)
+            {
+                //Get last result and validate error code.
+                AccountError err = (AccountError)ErrorFacts.GetLastResult();
+                if ((err != AccountError.None) && (err != AccountError.RecordNotFound))
+                {
+                    throw AccountErrorFactory.CreateException(err, "Failed to get IsFeatureSupported");
+                }
+            }
+
+            return supported;
+        }
+
+        /// <summary>
+        ///     Retrieves capability information with application ID.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="appId">application Id</param>
+        /// <returns> Capability information list for the given appId.</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given appid</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static IEnumerable<string> GetFeaturesByAppId(string appId)
+        {
+
+            List<string> features = new List<string>();
+            Interop.AccountProvider.AccountProviderFeatureCallback callback = (string applicationId, string key, IntPtr userData) =>
+            {
+                features.Add(key);
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountProvider.GetAccountProviderFeaturesByAppId(callback, appId, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountProviderFeaturesByAppId");
+            }
+
+            return (IEnumerable<string>)features;
+        }
+
+        /// <summary>
+        /// Overloaded Dispose API for destroying the AccountProvider Handle.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            if (!disposing)
+            {
+                if (_handle != IntPtr.Zero)
+                {
+                    Interop.AccountProvider.Destroy(_handle);
+                    _handle = IntPtr.Zero;
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs
new file mode 100644 (file)
index 0000000..fc7cbd4
--- /dev/null
@@ -0,0 +1,606 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Account.AccountManager
+{
+    /// <summary>
+    /// The AccountManager APIs is separated into two major sections:
+    /// 1. Registering an account provider while an application is installed. This information will be used for the Add account screen.
+    /// 2. Adding an account information when an application signs in successfully to share the account information to the Tizen system. This information will be shown in the Tizen settings account menu.
+    ///
+    /// The APIs of both of the sections consist of the following functionality:
+    /// <list>
+    /// <item> Create an account or account provider </item>
+    /// <item> Update an account or account provider(Only available for the creator) </item>
+    /// <item> Delete an account or account provider(Only available for the creator) </item>
+    /// <item> Read an account or account provider with some filter </item>
+    /// </list>
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+
+    public static class AccountService
+    {
+        /// <summary>
+        /// This is contact capability string.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public static readonly string ContactCapability = "http://tizen.org/account/capability/contact";
+
+        /// <summary>
+        /// This is calendar capability string.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public static readonly string CalendarCapability = "http://tizen.org/account/capability/calendar";
+
+        /// <summary>
+        /// This is email capability string.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public static readonly string EmailCapability = "http://tizen.org/account/capability/email";
+
+        /// <summary>
+        /// This is photo capability string.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public static readonly string PhotoCapability = "http://tizen.org/account/capability/photo";
+
+        /// <summary>
+        /// This is video capability string.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public static readonly string VideoCapability = "http://tizen.org/account/capability/video";
+
+        /// <summary>
+        /// This is music capability string.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public static readonly string MusicCapability = "http://tizen.org/account/capability/music";
+
+        /// <summary>
+        /// This is document capability string.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public static readonly string DocumentCapability = "http://tizen.org/account/capability/document";
+
+        /// <summary>
+        /// This is message capability string.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public static readonly string MessageCapability = "http://tizen.org/account/capability/message";
+
+        /// <summary>
+        /// This is game capability string.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public static readonly string GameCapability = "http://tizen.org/account/capability/game";
+
+        /// <summary>
+        /// Retrieves all accounts details from the account database.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <returns>List of Accounts</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error. </exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static IEnumerable<Account> GetAccountsAsync()
+        {
+            List<Account> accounts = new List<Account>();
+            List<int> values = new List<int>();
+            Interop.Account.AccountCallback accountCallback = (IntPtr data, IntPtr userdata) =>
+            {
+                Account account = new Account(data);
+                values.Add(account.AccountId);
+                account.Dispose();
+                return true;
+            };
+
+            AccountError res = (AccountError)Interop.AccountService.AccountForeachAccountFromDb(accountCallback, IntPtr.Zero);
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to AccountForeachAccountFromDb");
+            }
+
+            foreach (int i in values)
+            {
+                Account account = AccountService.GetAccountById(i);
+                accounts.Add(account);
+            }
+
+            return accounts;
+        }
+
+        /// <summary>
+        /// Retrieve an account with the account ID.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="accountId"> The account Id to be searched.</param>
+        /// <returns>Account instance with reference to the given id.</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given account id</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static Account GetAccountById(int accountId)
+        {
+            Account account = Account.CreateAccount();
+            IntPtr handle = account.Handle;
+            AccountError res = (AccountError)Interop.AccountService.QueryAccountById(accountId, out handle);
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to get accounts from the database for account id: " + accountId);
+            }
+
+            account.Handle = handle;
+            return account;
+        }
+
+        /// <summary>
+        /// Retrieves all AccountProviders details from the account database.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <returns>List of AccountProviders</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static IEnumerable<AccountProvider> GetAccountProviders()
+        {
+            List<string> values = new List<string>();
+            List<AccountProvider> providers = new List<AccountProvider>();
+            Interop.AccountProvider.AccountProviderCallback accountCallback = (IntPtr handle, IntPtr data) =>
+            {
+                AccountProvider provider = new AccountProvider(handle);
+                values.Add(provider.AppId);
+                provider.Dispose();
+                return true;
+            };
+
+            AccountError res = (AccountError)Interop.AccountService.GetAllAccountproviders(accountCallback, IntPtr.Zero);
+            if (res != AccountError.None)
+            {
+                Log.Warn(AccountErrorFactory.LogTag, "Failed to get account providers from the database");
+                throw AccountErrorFactory.CreateException(res, "Failed to get account providers from the database");
+            }
+
+            foreach (string val in values)
+            {
+                AccountProvider provider = GetAccountProviderByAppId(val);
+                providers.Add(provider);
+            }
+
+            return providers;
+        }
+
+        /// <summary>
+        /// Retrieves the account provider information with application Id.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="appId">Application Id.</param>
+        /// <returns>The AccountProvider instance associated with the given application Id.</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given appid</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static AccountProvider GetAccountProviderByAppId(string appId)
+        {
+            IntPtr handle;
+            Interop.AccountProvider.Create(out handle);
+            AccountError err = (AccountError)Interop.AccountService.GetAccountProviderByAppId(appId, out handle);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountProviderByAppId");
+            }
+
+            AccountProvider provider = new AccountProvider(handle);
+            return provider;
+        }
+
+        /// <summary>
+        /// Retrieves all the account providers information with feature.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="feature">The capability value to search for account providers.</param>
+        /// <returns>Retrieves AccountProviders information with the capability name.</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given feature</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static IEnumerable<AccountProvider> GetAccountProvidersByFeature(string feature)
+        {
+            List<string> values = new List<string>();
+            List<AccountProvider> providers = new List<AccountProvider>();
+            Interop.AccountProvider.AccountProviderCallback providerCallback = (IntPtr handle, IntPtr data) =>
+            {
+                AccountProvider provider = new AccountProvider(handle);
+                values.Add(provider.AppId);
+                provider.Dispose();
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountService.GetAccountProviderByFeature(providerCallback, feature, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountProviderByFeature");
+            }
+
+            foreach (string val in values)
+            {
+                AccountProvider provider = GetAccountProviderByAppId(val);
+                providers.Add(provider);
+            }
+
+            return providers;
+        }
+
+        /// <summary>
+        /// Inserts into the Database with the new account Infomration.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="account">New Account instance to be added.</param>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <privilege>http://tizen.org/privilege/account.write </privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        /// <exception cref="OutOfMemoryException"> In case of OutOfMemory error.</exception>
+        public static int AddAccount(Account account)
+        {
+            if (account == null)
+            {
+                throw AccountErrorFactory.CreateException(AccountError.InvalidParameter, "Failed to AddAccount");
+            }
+
+            int id = -1;
+            AccountError err = (AccountError)Interop.AccountService.AddAccount(account.Handle, out id);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to AddAccount");
+            }
+
+            return id;
+        }
+
+        /// <summary>
+        /// Updates the account details to the account database.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="account">account instance to be updated.</param>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <privilege>http://tizen.org/privilege/account.write </privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error </exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        /// <exception cref="OutOfMemoryException"> In case of OutOfMemory error.</exception>
+        public static void UpdateAccount(Account account)
+        {
+            if (account == null)
+            {
+                throw AccountErrorFactory.CreateException(AccountError.InvalidParameter, "Failed to UpdateAccount");
+            }
+
+            AccountError err = (AccountError)Interop.AccountService.UpdateAccountToDBById(account.Handle, account.AccountId);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to UpdateAccount");
+            }
+        }
+
+        /// <summary>
+        /// Deletes the account information from the Database.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="account">Account instance to be deleted from the database.</param>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <privilege>http://tizen.org/privilege/account.write </privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error </exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static void DeleteAccount(Account account)
+        {
+            if (account == null)
+            {
+                throw AccountErrorFactory.CreateException(AccountError.InvalidParameter, "Failed to DeleteAccount");
+            }
+
+            AccountError err = (AccountError)Interop.AccountService.DeleteAccountById(account.AccountId);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to delete the account by Id: " + account.AccountId);
+            }
+        }
+
+        /// <summary>
+        /// Deletes an account from the account database by user name.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="userName">The user name of the account to delete.</param>
+        /// <param name="packageName">The package name of the account to delete.</param>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <privilege>http://tizen.org/privilege/account.write </privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static void DeleteAccount(string userName, string packageName)
+        {
+            AccountError err = (AccountError)Interop.AccountService.DeleteAccountByUser(userName, packageName);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to delete the account by userName: " + userName);
+            }
+        }
+
+        /// <summary>
+        /// Deletes an account from the account database by package name.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="packageName">The package name of the account to delete.</param>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <privilege>http://tizen.org/privilege/account.write </privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static void DeleteAccount(string packageName)
+        {
+            AccountError err = (AccountError)Interop.AccountService.DeleteAccountByPackage(packageName);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to delete the account by package name: " + packageName);
+            }
+
+        }
+
+        /// <summary>
+        /// Retrieves all accounts with the given user name.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="userName">The user name to search .</param>
+        /// <returns>Accounts list matched with the user name</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given username</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static IEnumerable<Account> GetAccountsByUserName(string userName)
+        {
+            List<Account> accounts = new List<Account>();
+            List<int> values = new List<int>();
+            Interop.Account.AccountCallback accountCallback = (IntPtr handle, IntPtr data) =>
+            {
+                Account account = new Account(handle);
+                values.Add(account.AccountId);
+                account.Dispose();
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountService.QueryAccountByUserName(accountCallback, userName, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountByUserName");
+            }
+
+            foreach (int i in values)
+            {
+                Account account = AccountService.GetAccountById(i);
+                accounts.Add(account);
+            }
+
+            return accounts;
+        }
+
+        /// <summary>
+        /// Retrieves all accounts with the given package name.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="packageName"> The package name to Search</param>
+        /// <returns>Accounts list matched with the package name</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given package name</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static IEnumerable<Account> GetAccountsByPackageName(string packageName)
+        {
+            List<Account> accounts = new List<Account>();
+            List<int> values = new List<int>();
+            Interop.Account.AccountCallback accountCallback = (IntPtr handle, IntPtr data) =>
+            {
+                Account account = new Account(handle);
+                values.Add(account.AccountId);
+                account.Dispose();
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountService.QueryAccountByPackageName(accountCallback, packageName, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountByPackageName");
+            }
+
+            foreach (int i in values)
+            {
+                Account account = AccountService.GetAccountById(i);
+                accounts.Add(account);
+            }
+
+            return accounts;
+        }
+
+        /// <summary>
+        /// Retrieves all accounts with the given cpability type.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="type"> Capability type</param>
+        /// <returns>Accounts list matched with the capability type</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given capability type</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static IEnumerable<Account> GetAccountsByCapabilityType(string type)
+        {
+            List<Account> accounts = new List<Account>();
+            List<int> values = new List<int>();
+            Interop.Account.AccountCallback accountCallback = (IntPtr handle, IntPtr data) =>
+            {
+                Account account = new Account(handle);
+                values.Add(account.AccountId);
+                account.Dispose();
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountService.GetAccountByCapabilityType(accountCallback, type, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountByCapabilityType");
+            }
+
+            foreach (int i in values)
+            {
+                Account account = AccountService.GetAccountById(i);
+                accounts.Add(account);
+            }
+
+            return accounts;
+        }
+
+        /// <summary>
+        /// Retrieves all capabilities with the given account
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="accountId">account instance</param>
+        /// <returns>Capabilities list as Dictionary of Capability type and State.</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given account id</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static Dictionary<string, CapabilityState> GetCapabilitiesById(int accountId)
+        {
+            Dictionary<string, CapabilityState> capabilities = new Dictionary<string, CapabilityState>();
+            Interop.Account.AccountCapabilityCallback capabilityCallback = (string type, int capabilityState, IntPtr data) =>
+            {
+                capabilities.Add(type, (CapabilityState)capabilityState);
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountService.QueryAccountCapabilityById(capabilityCallback, accountId, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAllCapabilitiesById");
+            }
+
+            return capabilities;
+        }
+
+        /// <summary>
+        /// Gets the count of accounts in the account database.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <returns>The number of accounts in the database</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error </exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static int GetAccountsCount()
+        {
+            int count = 0;
+            AccountError err = (AccountError)Interop.AccountService.GetAccountCount(out count);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountCount");
+            }
+
+            return count;
+        }
+
+        /// <summary>
+        /// Updates the sync status of the given account.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="account"> Account for which sync status needs to be updated</param>
+        /// <param name="status">Sync State</param>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <privilege>http://tizen.org/privilege/account.write</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error </exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static void UpdateSyncStatusById(Account account, AccountSyncState status)
+        {
+            AccountError err = (AccountError)Interop.AccountService.UpdateAccountSyncStatusById(account.AccountId, (int)status);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to UpdateSyncStatusById");
+            }
+        }
+
+        private static readonly Interop.AccountService.SubscribeCallback s_accountUpdatedCallback = (string eventType, int accountId, IntPtr userData) =>
+        {
+            AccountSubscriberEventArgs eventArgs = new AccountSubscriberEventArgs(eventType, accountId);
+            s_accountUpdated?.Invoke(null, eventArgs);
+            return true;
+        };
+
+        private static Interop.AccountService.SafeAccountSubscriberHandle s_subscriberHandle;
+
+        private static event EventHandler<AccountSubscriberEventArgs> s_accountUpdated;
+        /// <summary>
+        /// ContentUpdated event is triggered when the media item info from DB changes.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <remarks>
+        /// ContentUpdate event is triggered if the MediaInformaion updated/deleted or new Inforamtion is Inserted.
+        /// </remarks>
+        /// <param name="sender"></param>
+        /// <param name="e">A ContentUpdatedEventArgs object that contains information about the update operation.</param>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error </exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static event EventHandler<AccountSubscriberEventArgs> AccountUpdated
+        {
+            add
+            {
+                if (s_accountUpdated == null)
+                {
+                    if (s_subscriberHandle == null)
+                    {
+                        Interop.AccountService.CreateAccountSubscriber(out s_subscriberHandle);
+                    }
+
+                    AccountError ret = (AccountError)Interop.AccountService.RegisterSubscriber(s_subscriberHandle, s_accountUpdatedCallback, IntPtr.Zero);
+
+                    if (ret != AccountError.None)
+                    {
+                        throw AccountErrorFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+
+                s_accountUpdated += value;
+            }
+
+            remove
+            {
+                s_accountUpdated -= value;
+                if (s_accountUpdated == null)
+                {
+                    AccountError ret = (AccountError)Interop.AccountService.UnregisterSubscriber(s_subscriberHandle);
+                    if (ret != AccountError.None)
+                    {
+                        throw AccountErrorFactory.CreateException(ret, "Error in callback handling");
+                    }
+                    s_subscriberHandle = null;
+                }
+            }
+        }
+
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSubscriberEventArgs.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSubscriberEventArgs.cs
new file mode 100644 (file)
index 0000000..153c427
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Account.AccountManager
+{
+    /// <summary>
+    /// Event arguments passed when Event is triggered to notify that account is updated/removed from the account database.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public class AccountSubscriberEventArgs : EventArgs
+    {
+        private const string NotiInsert = "insert";
+        private const string NotiDelete = "delete";
+        private const string NotiUpdate = "update";
+        private const string NotiSyncUpdate = "sync_update";
+        internal AccountSubscriberEventArgs(string eventType, int accountId)
+        {
+            if (eventType.CompareTo(NotiInsert) == 0)
+            {
+                EventType = AccountNotificationType.Insert;
+            }
+            else if (eventType.CompareTo(NotiDelete) == 0)
+            {
+                EventType = AccountNotificationType.Delete;
+            }
+            else if (eventType.CompareTo(NotiUpdate) == 0)
+            {
+                EventType = AccountNotificationType.Update;
+            }
+            else if (eventType.CompareTo(NotiSyncUpdate) == 0)
+            {
+                EventType = AccountNotificationType.syncUpdate;
+            }
+
+            AccountId = accountId;
+        }
+
+        /// <summary>
+        /// The account event type
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public AccountNotificationType EventType
+        {
+            get;
+            internal set;
+        }
+
+        /// <summary>
+        /// The account ID to update
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public int AccountId
+        {
+            get;
+            internal set;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Alarm/Interop/Interop.Alarm.cs b/src/Tizen.Applications.Alarm/Interop/Interop.Alarm.cs
new file mode 100755 (executable)
index 0000000..bb4bbf9
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+using Tizen.Internals.Errors;
+using Tizen.Applications;
+using Tizen.Applications.Notifications;
+
+internal static partial class Interop
+{
+    internal static partial class Alarm
+    {
+        [StructLayout(LayoutKind.Sequential)]
+        internal struct DateTime
+        {
+            internal int sec;
+            internal int min;
+            internal int hour;
+            internal int mday; /* day of the month, range 1 to 31*/
+            internal int mon;
+            internal int year;
+            internal int wday; /* day of the week, range 0 to 6*/
+            internal int yday; /* day in the year, range 0 to 365*/
+            internal int isdst; /* daylight saving time*/
+            internal long tm_gmtoff;
+            internal IntPtr tm_zone;
+        };
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_after_delay")]
+        internal static extern int CreateAlarmAfterDelay(SafeAppControlHandle appControl, int delay, int period, out int alarmId);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_once_after_delay")]
+        internal static extern int CreateAlarmOnceAfterDelay(SafeAppControlHandle appControl, int delay, out int alarmId);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_once_at_date")]
+        internal static extern int CreateAlarmOnceAtDate(SafeAppControlHandle appControl, ref DateTime date, out int alarmId);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_with_recurrence_week_flag")]
+        internal static extern int CreateAlarmRecurWeek(SafeAppControlHandle appControl, ref DateTime date, int week, out int alarmId);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_get_scheduled_recurrence_week_flag")]
+        internal static extern int GetAlarmWeekFlag(int alarmId, out int weekFlag);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_cancel")]
+        internal static extern int CancelAlarm(int alarmId);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_cancel_all")]
+        internal static extern int CancelAllAlarms();
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_get_scheduled_date")]
+        internal static extern int GetAlarmScheduledDate(int alarmId, out DateTime date);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_get_current_time")]
+        internal static extern int GetCurrentTime(out DateTime date);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_get_app_control")]
+        internal static extern int GetAlarmAppControl(int alarmId, out SafeAppControlHandle control);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_get_scheduled_period")]
+        internal static extern int GetAlarmScheduledPeriod(int alarmId, out int period);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_set_global")]
+        internal static extern int SetAlarmGlobalFlag(int alarmId, bool global);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_get_global")]
+        internal static extern int GetAlarmGlobalFlag(int alarmId, out bool global);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_foreach_registered_alarm")]
+        internal static extern int GetAllRegisteredAlarms(RegisteredAlarmCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_noti_once_at_date")]
+        internal static extern AlarmError CreateAlarmNotiOnceAtDate(NotificationSafeHandle noti, ref DateTime date, out int alarmId);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_noti_after_delay")]
+        internal static extern AlarmError CreateAlarmNotiAfterDelay(NotificationSafeHandle noti, int delay, int period, out int alarmId);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_noti_once_after_delay")]
+        internal static extern AlarmError CreateAlarmNotiOnceAfterDelay(NotificationSafeHandle noti, int delay, out int alarmId);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_noti_with_recurrence_week_flag")]
+        internal static extern AlarmError CreateAlarmNotiRecurWeek(NotificationSafeHandle noti, ref DateTime date, int week, out int alarmId);
+
+        //callback
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool RegisteredAlarmCallback(int alarmId, IntPtr userData);
+    }
+}
diff --git a/src/Tizen.Applications.Alarm/Interop/Interop.Libraries.cs b/src/Tizen.Applications.Alarm/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..63f4a29
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string Alarm = "libcapi-appfw-alarm.so.0";
+    }
+}
diff --git a/src/Tizen.Applications.Alarm/Tizen.Applications.Alarm.csproj b/src/Tizen.Applications.Alarm/Tizen.Applications.Alarm.csproj
new file mode 100755 (executable)
index 0000000..9008ad0
--- /dev/null
@@ -0,0 +1,19 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <Import Project="../build/build.props" />
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.3</TargetFramework>
+    <Version>1.5.9</Version>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Applications.Alarm.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
+    <ProjectReference Include="..\Tizen.Applications.Notification\Tizen.Applications.Notification.csproj" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Applications.Alarm/Tizen.Applications.Alarm.snk b/src/Tizen.Applications.Alarm/Tizen.Applications.Alarm.snk
new file mode 100755 (executable)
index 0000000..7ac1b00
Binary files /dev/null and b/src/Tizen.Applications.Alarm/Tizen.Applications.Alarm.snk differ
diff --git a/src/Tizen.Applications.Alarm/Tizen.Applications/Alarm.cs b/src/Tizen.Applications.Alarm/Tizen.Applications/Alarm.cs
new file mode 100755 (executable)
index 0000000..af69b75
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// The Alarm API allows setting an "alarm clock" for the delivery of a notification at some point in the future.
+    /// </summary>
+    /// <example>
+    /// <code>
+    /// public class AlarmExample
+    /// {
+    ///     /// ...
+    ///     IEnumerable &lt; Alarm &gt; alarms = AlarmManager.GetAllScheduledAlarms();
+    ///     alarms[0].Cancel();
+    /// }
+    /// </code>
+    /// </example>
+    public class Alarm
+    {
+        private const string _logTag = "Tizen.Applications.Alarm";
+
+        /// <summary>
+        /// Constructor created with new AlarmId.
+        /// </summary>
+        /// <param name="id"></param>
+        internal Alarm(int id)
+        {
+            AlarmId = id;
+        }
+
+        /// <summary>
+        /// The alarm ID uniquely identifies an alarm.
+        /// </summary>
+        public int AlarmId
+        {
+            get; private set;
+        }
+
+        /// <summary>
+        /// Gets the recurrence days of the week.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/alarm.get</privilege>
+        /// <remarks>
+        /// week_flag may be a combination of days, like Tuesday | Friday
+        /// </remarks>
+        public AlarmWeekFlag WeekFlag
+        {
+            get
+            {
+                int week;
+                AlarmError ret = (AlarmError)Interop.Alarm.GetAlarmWeekFlag(AlarmId, out week);
+                if (ret != AlarmError.None)
+                {
+                    Log.Error(_logTag, "Failed to get WeekFlag");
+                }
+
+                return (AlarmWeekFlag)week;
+            }
+        }
+
+        /// <summary>
+        /// Gets the scheduled time.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/alarm.get</privilege>
+        public DateTime ScheduledDate
+        {
+            get
+            {
+                Interop.Alarm.DateTime value;
+                AlarmError ret = (AlarmError)Interop.Alarm.GetAlarmScheduledDate(AlarmId, out value);
+                if (ret != AlarmError.None)
+                {
+                    Log.Error(_logTag, "Failed to get WeekFlag");
+                }
+
+                DateTime time = AlarmManager.ConvertIntPtrToDateTime(value);
+                return time;
+            }
+        }
+
+        /// <summary>
+        /// Gets the period of time between the recurrent alarms.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/alarm.get</privilege>
+        public int Period
+        {
+            get
+            {
+                int period;
+                AlarmError ret = (AlarmError)Interop.Alarm.GetAlarmScheduledPeriod(AlarmId, out period);
+                if (ret != AlarmError.None)
+                {
+                    Log.Error(_logTag, "Failed to get WeekFlag");
+                }
+
+                return period;
+            }
+        }
+
+        /// <summary>
+        /// Gets the AppControl to be invoked when the the alarm is triggered.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/alarm.get</privilege>
+        public AppControl AlarmAppControl
+        {
+            get
+            {
+                SafeAppControlHandle handle;
+                AlarmError ret = (AlarmError)Interop.Alarm.GetAlarmAppControl(AlarmId, out handle);
+
+                if (ret != AlarmError.None)
+                {
+                    Log.Error(_logTag, "Failed to get WeekFlag");
+                }
+
+                return new AppControl(handle);
+            }
+        }
+
+        /// <summary>
+        /// Gets whether the alarm will launch global application or not.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+        /// <privilege>http://tizen.org/privilege/alarm.get</privilege>
+        public bool Global
+        {
+            get
+            {
+                bool global;
+                AlarmError ret = (AlarmError)Interop.Alarm.GetAlarmGlobalFlag(AlarmId, out global);
+                if (ret != AlarmError.None)
+                {
+                    Log.Error(_logTag, "Failed to get WeekFlag");
+                }
+
+                return global;
+            }
+
+            set
+            {
+                AlarmError ret = (AlarmError)Interop.Alarm.SetAlarmGlobalFlag(AlarmId, value);
+                if (ret != AlarmError.None)
+                {
+                    Log.Error(_logTag, "Failed to get WeekFlag");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Cancels the the specific alarm.
+        /// </summary>
+        /// <exception cref="ArgumentException">Thrown in case of Invalid parmaeter.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied due to insufficient previlleges.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+        public void Cancel()
+        {
+            AlarmError ret = (AlarmError)Interop.Alarm.CancelAlarm(AlarmId);
+            if (ret != AlarmError.None)
+            {
+                throw AlarmErrorFactory.GetException(ret, "Failed to Cancel alarm");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Alarm/Tizen.Applications/AlarmErrorFactory.cs b/src/Tizen.Applications.Alarm/Tizen.Applications/AlarmErrorFactory.cs
new file mode 100755 (executable)
index 0000000..4524882
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    internal enum AlarmError
+    {
+        None = Tizen.Internals.Errors.ErrorCode.None,
+        InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+        InvalidTime = -0x01100000 | 0x05,
+        InvalidDate = -0x01100000 | 0x06,
+        ConnectionFail = -0x01100000 | 0x07,
+        NotPermittedApp = -0x01100000 | 0x08,
+        OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+        PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied
+    }
+    internal static class AlarmErrorFactory
+    {
+        private const string _logTag = "Tizen.Applications.Alarm";
+
+        internal static Exception GetException(AlarmError ret, string msg)
+        {
+            switch (ret)
+            {
+                case AlarmError.InvalidParameter:
+                //fall through
+                case AlarmError.InvalidTime:
+                //fall through
+                case AlarmError.InvalidDate:
+                    Log.Error(_logTag, msg);
+                    return new ArgumentException(ret + " error occurred.");
+                case AlarmError.NotPermittedApp:
+                //fall through
+                case AlarmError.PermissionDenied:
+                    Log.Error(_logTag, msg);
+                    return new UnauthorizedAccessException(ret + "error occured.");
+                default:
+                    Log.Error(_logTag, msg);
+                    return new InvalidOperationException(ret + " error occurred.");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Alarm/Tizen.Applications/AlarmManager.cs b/src/Tizen.Applications.Alarm/Tizen.Applications/AlarmManager.cs
new file mode 100755 (executable)
index 0000000..60d2954
--- /dev/null
@@ -0,0 +1,412 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Runtime.InteropServices;
+    using Tizen.Applications.Notifications;
+
+    /// <summary>
+    /// Enumeration for Alarm Week Flag, the days of the week.
+    /// </summary>
+    [Flags]
+    public enum AlarmWeekFlag
+    {
+        /// <summary>
+        /// Identifier for Sunday.
+        /// </summary>
+        Sunday = 0x01,
+
+        /// <summary>
+        /// Identifier for Monday.
+        /// </summary>
+        Monday = 0x02,
+
+        /// <summary>
+        /// Identifier for Tuesday.
+        /// </summary>
+        Tuesday = 0x04,
+
+        /// <summary>
+        /// Identifier for Wednesday.
+        /// </summary>
+        Wednesday = 0x08,
+
+        /// <summary>
+        /// Identifier for Thursday.
+        /// </summary>
+        Thursday = 0x10,
+
+        /// <summary>
+        /// Identifier for Friday.
+        /// </summary>
+        Friday = 0x20,
+
+        /// <summary>
+        /// Identifier for Saturday.
+        /// </summary>
+        Saturday = 0x40,
+
+        /// <summary>
+        /// All Days of the Week.
+        /// </summary>
+        AllDays = Sunday |Monday|Tuesday|Wednesday|Thursday|Friday|Saturday,
+
+        /// <summary>
+        /// Only Weekdays
+        /// </summary>
+        WeekDays = Monday | Tuesday | Wednesday | Thursday | Friday
+    }
+
+    /// <summary>
+    /// Mobile devices typically give constant access to information from various sources.Some of this information is best delivered through alarms -
+    /// the most obvious case is a calendar scheduling application which lets you know when a meeting is about to start.Alarms are certainly better than actively waiting in a loop.
+    /// They are also better than putting an interface to sleep because they do not block your main UI thread.
+    /// Use of alarms helps build smooth user experiences and implements unattended data synchronization tasks.
+    /// If an application is installed after setting the alarm, your alarm is cancelled automatically.
+    /// </summary>
+    /// <example>
+    /// <code>
+    /// public class AlarmManagerExample
+    /// {
+    ///     /// ...
+    ///     Alarm alarm = AlarmManager.CreateAlarm(24000,1000,null);
+    ///     AlarmManager.CancelAll();
+    /// }
+    /// </code>
+    /// </example>
+
+    public static class AlarmManager
+    {
+        private const string LogTag = "Tizen.Applications.Alarm";
+
+        private static Interop.Alarm.DateTime ConvertDateTimeToStruct(DateTime value)
+        {
+            Interop.Alarm.DateTime time = new Interop.Alarm.DateTime();
+            time.sec = value.Second;
+            time.min = value.Minute;
+            time.hour = value.Hour;
+            time.mday = value.Day;
+            time.mon = value.Month - 1;
+            time.year = value.Year - 1900;
+            time.wday = (int)value.DayOfWeek;
+            time.yday = value.DayOfYear;
+            time.isdst = 0;
+            return time;
+        }
+
+        internal static DateTime ConvertIntPtrToDateTime(Interop.Alarm.DateTime time)
+        {
+            DateTime value = new DateTime(1900 + time.year, 1 + time.mon, time.mday, time.hour, time.min, time.sec, DateTimeKind.Utc);
+            return value;
+        }
+
+        /// <summary>
+        /// Sets an alarm to be triggered after a specific time.
+        /// The alarm will first go off delay seconds later and then will go off every certain amount of time defined using period seconds.
+        /// </summary>
+        /// <param name="delay">The amount of time before the first execution (in seconds).</param>
+        /// <param name="period"> The amount of time between subsequent alarms (in seconds). This value does not guarantee the accuracy.
+        /// The actual interval is calculated by the OS. The minimum value is 600sec</param>
+        /// <param name="appControl"> The destination AppControl to perform a specific task when the alarm is triggered </param>
+        /// <returns>Alarm Instance created with the set param values.</returns>
+        /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+        public static Alarm CreateAlarm(int delay, int period, AppControl appControl)
+        {
+            Alarm alarm = null;
+            int alarmId;
+            SafeAppControlHandle handle = (appControl == null) ? null : appControl.SafeAppControlHandle;
+            AlarmError ret = (AlarmError)Interop.Alarm.CreateAlarmAfterDelay(handle, delay, period, out alarmId);
+            alarm = new Alarm(alarmId);
+            if (ret != AlarmError.None)
+            {
+                throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
+            }
+
+            return alarm;
+        }
+
+        /// <summary>
+        /// Sets an alarm to be triggered after a specific time.
+        /// The alarm will go off delay seconds later.
+        /// </summary>
+        /// <param name="delay"> The amount of time before the execution (in seconds) </param>
+        /// <param name="appControl"> The destination AppControl to perform a specific task when the alarm is triggered </param>
+        /// <returns> Alarm Instance created with the set param values.</returns>
+        /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+        public static Alarm CreateAlarm(int delay, AppControl appControl)
+        {
+            Alarm alarm = null;
+            int alarmId;
+            AlarmError ret = (AlarmError)Interop.Alarm.CreateAlarmOnceAfterDelay(appControl.SafeAppControlHandle, delay, out alarmId);
+            alarm = new Alarm(alarmId);
+            if (ret != AlarmError.None)
+            {
+                throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
+            }
+
+            return alarm;
+        }
+
+        /// <summary>
+        /// Sets an alarm to be triggered at a specific time.
+        /// The date describes the time of the first occurrence.
+        /// </summary>
+        /// <param name="value"> The first active alarm time </param>
+        /// <param name="appControl"> The destination AppControl to perform specific work when the alarm is triggered </param>
+        /// <returns> Alarm Instance created with the set param values.</returns>
+        /// <remarks>This operation is permitted wit UI application appcontrol only.</remarks>
+        /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+        public static Alarm CreateAlarm(DateTime value, AppControl appControl)
+        {
+            Alarm alarm = null;
+            int alarmId;
+            Interop.Alarm.DateTime time = ConvertDateTimeToStruct(value);
+            AlarmError ret = (AlarmError)Interop.Alarm.CreateAlarmOnceAtDate(appControl.SafeAppControlHandle, ref time, out alarmId);
+            alarm = new Alarm(alarmId);
+            if (ret != AlarmError.None)
+            {
+                throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
+            }
+
+            return alarm;
+        }
+
+        /// <summary>
+        /// Sets an alarm to be triggered periodically, starting at a specific time.
+        /// The date describes the time of the first occurrence.
+        /// weekFlag is the repeat value of the days of the week.
+        /// If weekFlag is AlarmWeekFlag.Tuesday, the alarm will repeat every Tuesday at a specific time.
+        /// </summary>
+        /// <remarks>This operation is permitted wit UI application appcontrol only.</remarks>
+        /// <param name="value"> The first active alarm time </param>
+        /// <param name="weekFlag"> The day of the week, AlarmWeekFlag may be a combination of days, like AlarmWeekFlag.Sunday | AlarmWeekFlag.Monday</param>
+        /// <param name="appControl"> The destination AppControl to perform specific work when the alarm is triggered </param>
+        /// <returns> Alarm Instance created with the set param values.</returns>
+        /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+        public static Alarm CreateAlarm(DateTime value, AlarmWeekFlag weekFlag, AppControl appControl)
+        {
+            Alarm alarm = null;
+            int alarmId;
+            Interop.Alarm.DateTime time = ConvertDateTimeToStruct(value);
+            AlarmError ret = (AlarmError)Interop.Alarm.CreateAlarmRecurWeek(appControl.SafeAppControlHandle, ref time, (int)weekFlag, out alarmId);
+            alarm = new Alarm(alarmId);
+            if (ret != AlarmError.None)
+            {
+                throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
+            }
+
+            return alarm;
+        }
+
+        /// <summary>
+        /// Sets a notification alarm to be triggered at a specific time.
+        /// The date describes the time of the first occurrence.
+        /// </summary>
+        /// <param name="dateTime"> The first active alarm time </param>
+        /// <param name="notification"> The notification to be posted when the alarm is triggered </param>
+        /// <returns> Alarm Instance created with the set param values.</returns>
+        /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static Alarm CreateAlarm(DateTime dateTime, Notification notification)
+        {
+            Alarm alarm = null;
+            int alarmId;
+            NotificationSafeHandle safeHandle = NotificationManager.MakeNotificationSafeHandle(notification);
+            Interop.Alarm.DateTime time = ConvertDateTimeToStruct(dateTime);
+            AlarmError ret = Interop.Alarm.CreateAlarmNotiOnceAtDate(safeHandle, ref time, out alarmId);
+            if (ret != AlarmError.None)
+            {
+                throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
+            }
+
+            alarm = new Alarm(alarmId);
+
+            return alarm;
+        }
+
+        /// <summary>
+        /// Sets a notification alarm to be triggered after a specific time.
+        /// The alarm will first go off delay seconds later and then will go off every certain amount of time defined using period seconds.
+        /// </summary>
+        /// <param name="delay">The amount of time before the first execution (in seconds). </param>
+        /// <param name="period"> The amount of time between subsequent alarms (in seconds). This value does not guarantee the accuracy. </param>
+        /// <param name="notification"> The notification to be posted when the alarm is triggered </param>
+        /// <returns> Alarm Instance created with the set param values.</returns>
+        /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static Alarm CreateAlarm(int delay, int period, Notification notification)
+        {
+            Alarm alarm = null;
+            int alarmId;
+            NotificationSafeHandle safeHandle = NotificationManager.MakeNotificationSafeHandle(notification);
+            AlarmError ret = Interop.Alarm.CreateAlarmNotiAfterDelay(safeHandle, delay, period, out alarmId);
+            if (ret != AlarmError.None)
+            {
+                throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
+            }
+
+            alarm = new Alarm(alarmId);
+
+            return alarm;
+        }
+
+        /// <summary>
+        /// Sets a notification alarm to be triggered periodically, starting at a specific time.
+        /// The date describes the time of the first occurrence.
+        /// weekFlag is the repeat value of the days of the week.
+        /// If weekFlag is AlarmWeekFlag.Tuesday, the alarm will repeat every Tuesday at a specific time.
+        /// </summary>
+        /// <param name="dateTime"> The first active alarm time </param>
+        /// <param name="weekFlag"> The day of the week, AlarmWeekFlag may be a combination of days,
+        ///                         like AlarmWeekFlag.Sunday | AlarmWeekFlag.Monday</param>
+        /// <param name="notification"> The notification to be posted when the alarm is triggered </param>
+        /// <returns> Alarm Instance created with the set param values.</returns>
+        /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static Alarm CreateAlarm(DateTime dateTime, AlarmWeekFlag weekFlag, Notification notification)
+        {
+            Alarm alarm = null;
+            int alarmId;
+            NotificationSafeHandle safeHandle = NotificationManager.MakeNotificationSafeHandle(notification);
+            Interop.Alarm.DateTime time = ConvertDateTimeToStruct(dateTime);
+            AlarmError ret = Interop.Alarm.CreateAlarmNotiRecurWeek(safeHandle, ref time, (int)weekFlag, out alarmId);
+            if (ret != AlarmError.None)
+            {
+                throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
+            }
+
+            alarm = new Alarm(alarmId);
+
+            return alarm;
+        }
+
+        /// <summary>
+        /// Sets a notification alarm to be triggered after a specific time.
+        /// The alarm will go off delay seconds later.
+        /// </summary>
+        /// <param name="delay">The amount of time before the first execution (in seconds).</param>
+        /// <param name="notification"> The notification to be posted when the alarm is triggered </param>
+        /// <returns> Alarm Instance created with the set param values.</returns>
+        /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static Alarm CreateAlarm(int delay, Notification notification)
+        {
+            Alarm alarm = null;
+            int alarmId;
+            NotificationSafeHandle safeHandle = NotificationManager.MakeNotificationSafeHandle(notification);
+            AlarmError ret = Interop.Alarm.CreateAlarmNotiOnceAfterDelay(safeHandle, delay, out alarmId);
+            if (ret != AlarmError.None)
+            {
+                throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
+            }
+
+            alarm = new Alarm(alarmId);
+
+            return alarm;
+        }
+
+        /// <summary>
+        /// Cancels all scheduled alarms that are registered by the application that calls this API.
+        /// </summary>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+        public static void CancelAll()
+        {
+            AlarmError ret = (AlarmError)Interop.Alarm.CancelAllAlarms();
+            if (ret != AlarmError.None)
+            {
+                throw AlarmErrorFactory.GetException(ret, "Failed to cancel Alarms");
+            }
+        }
+
+        /// <summary>
+        /// Retrieves all registered alarms.
+        /// </summary>
+        /// <returns>List of all Alarm instances.</returns>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/alarm.get</privilege>
+        public static IEnumerable<Alarm> GetAllScheduledAlarms()
+        {
+            List<Alarm> alarms = new List<Alarm>();
+            Interop.Alarm.RegisteredAlarmCallback callback = (int alarmId, IntPtr userData) =>
+            {
+                alarms.Add(new Alarm(alarmId));
+                return true;
+            };
+
+            AlarmError ret = (AlarmError)Interop.Alarm.GetAllRegisteredAlarms(callback, IntPtr.Zero);
+            if (ret != AlarmError.None)
+            {
+                throw AlarmErrorFactory.GetException(ret, "Failed to get Alarms");
+            }
+
+            return alarms;
+        }
+
+        /// <summary>
+        /// Gets the current system time.
+        /// </summary>
+        /// <returns>The current system time</returns>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        public static DateTime GetCurrentTime()
+        {
+            DateTime time;
+            Interop.Alarm.DateTime value;
+            AlarmError ret = (AlarmError)Interop.Alarm.GetCurrentTime(out value);
+            if (ret != AlarmError.None)
+            {
+                throw AlarmErrorFactory.GetException(ret, "Failed to get Currenttime");
+            }
+            else
+            {
+
+                time = ConvertIntPtrToDateTime(value);
+            }
+
+            return time;
+        }
+
+    }
+}
diff --git a/src/Tizen.Applications.AttachPanel/Interop/Interop.AttachPanel.cs b/src/Tizen.Applications.AttachPanel/Interop/Interop.AttachPanel.cs
new file mode 100755 (executable)
index 0000000..3718191
--- /dev/null
@@ -0,0 +1,71 @@
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Applications;
+
+internal static partial class Interop
+{
+    internal static partial class AttachPanel
+    {
+        internal enum ErrorCode : int
+        {
+            None = Tizen.Internals.Errors.ErrorCode.None,
+            InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+            OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+            PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
+            AlreadyExists = -0x02850000 | 0x01,
+            NotInitialized = -0x02850000 | 0x02,
+            UnsupportedContentCategory = -0x02850000 | 0x03,
+            AlreadyDestroyed = -0x02850000 | 0x05,
+        }
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void AttachPanelEventCallback(IntPtr attachPanel, int eventType, IntPtr eventInfo, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void AttachPanelResultCallback(IntPtr attachPanel, int category, IntPtr result, int resultCode, IntPtr userData);
+
+        [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_create")]
+        internal static extern ErrorCode CreateAttachPanel(IntPtr conform, ref IntPtr attach_panel);
+
+        [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_destroy")]
+        internal static extern ErrorCode DestroyAttachPanel(IntPtr attach_panel);
+
+        [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_add_content_category")]
+        internal static extern ErrorCode AddCategory(IntPtr attach_panel, int content_category, IntPtr extraData);
+
+        [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_remove_content_category")]
+        internal static extern ErrorCode RemoveCategory(IntPtr attach_panel, int content_category);
+
+        [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_set_extra_data")]
+        internal static extern ErrorCode SetExtraData(IntPtr attach_panel, int content_category, IntPtr extraData);
+
+        [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_set_result_cb")]
+        internal static extern ErrorCode SetResultCb(IntPtr attach_panel, AttachPanelResultCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_unset_result_cb")]
+        internal static extern ErrorCode UnsetResultCb(IntPtr attach_panel);
+
+        [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_set_event_cb")]
+        internal static extern ErrorCode SetEventCb(IntPtr attach_panel, AttachPanelEventCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_unset_event_cb")]
+        internal static extern ErrorCode UnsetEventCb(IntPtr attach_panel);
+
+        [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_show")]
+        internal static extern ErrorCode Show(IntPtr attach_panel);
+
+        [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_show_without_animation")]
+        internal static extern ErrorCode ShowWithoutAnimation(IntPtr attach_panel);
+
+        [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_hide")]
+        internal static extern ErrorCode Hide(IntPtr attach_panel);
+
+        [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_hide_without_animation")]
+        internal static extern ErrorCode HideWithoutAnimation(IntPtr attach_panel);
+
+        [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_get_visibility")]
+        internal static extern ErrorCode GetVisibility(IntPtr attach_panel, out int visible);
+
+        [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_get_state")]
+        internal static extern ErrorCode GetState(IntPtr attach_panel, out int state);
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.AttachPanel/Interop/Interop.Libraries.cs b/src/Tizen.Applications.AttachPanel/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..4b4049b
--- /dev/null
@@ -0,0 +1,7 @@
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string AttachPanel = "libattach-panel.so.0.1.0";
+    }
+}
diff --git a/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel.csproj b/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel.csproj
new file mode 100755 (executable)
index 0000000..516b392
--- /dev/null
@@ -0,0 +1,26 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <Version>1.0.3</Version>
+    <Authors>Samsung Electronics</Authors>
+    <Copyright>© Samsung Electronics Co., Ltd All Rights Reserved</Copyright>
+    <Description>Provides the Attach Panel API for Tizen .NET</Description>
+    <PackageProjectUrl>https://www.tizen.org/</PackageProjectUrl>
+    <PackageLicenseUrl>https://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
+    <PackageIconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</PackageIconUrl>
+  </PropertyGroup>
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.6</TargetFramework>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Applications.AttachPanel.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Tizen" Version="1.0.5" />
+    <PackageReference Include="Tizen.Applications.Common" Version="1.5.8" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel.snk b/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel.snk
new file mode 100644 (file)
index 0000000..f03f8cb
Binary files /dev/null and b/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel.snk differ
diff --git a/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/AttachPanel.cs b/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/AttachPanel.cs
new file mode 100755 (executable)
index 0000000..bd403f0
--- /dev/null
@@ -0,0 +1,263 @@
+using System;
+
+namespace Tizen.Applications.AttachPanel
+{
+    /// <summary>
+    /// Represents immutable class for attach panel.
+    /// </summary>
+    public partial class AttachPanel
+    {
+        /// <summary>
+        /// Represents immutable class for attach panel.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="conformant">The caller's conformant</param>
+        /// <exception cref="OutOfMemoryException">Thrown when an attempt to allocate memory fails.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is already exist or the <paramref name="conformant"/> is not a conformant object</exception>
+        public AttachPanel(IntPtr conformant)
+        {
+            if (conformant == IntPtr.Zero)
+            {
+                throw new ArgumentNullException("Use the value property, not null value");
+            }
+            IntPtr candidateAttachPanel = new IntPtr();
+            Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.CreateAttachPanel(conformant, ref candidateAttachPanel);
+            checkException(err);
+
+            Tizen.Log.Debug("AttachPanelSharp", "Success to create an AttachPanel Instance");
+            isCreationSucceed = true;
+            _attachPanel = candidateAttachPanel;
+
+            if (_eventEventHandler == null)
+            {
+                StateEventListenStart();
+            }
+
+            if (_resultEventHandler == null)
+            {
+                ResultEventListenStart();
+            }
+        }
+
+        ~AttachPanel()
+        {
+            if (isCreationSucceed &&
+                _attachPanel != IntPtr.Zero)
+            {
+                Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.DestroyAttachPanel(_attachPanel);
+                checkException(err);
+                _attachPanel = IntPtr.Zero;
+            }
+        }
+
+        /// <summary>
+        /// Gets the state of the AttachPanel.
+        /// </summary>
+        /// <value>The AttachPanel window state</value>
+        public int State
+        {
+            get
+            {
+                int state;
+                Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.GetState(_attachPanel, out state);
+                checkException(err);
+                return state;
+            }
+        }
+
+        /// <summary>
+        /// Gets the value that indicates whether the AttachPanel is visible.
+        /// </summary>
+        /// <value>visible value of AttachPanel state</value>
+        public int Visible
+        {
+            get
+            {
+                int visible;
+                Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.GetVisibility(_attachPanel, out visible);
+                checkException(err);
+                return visible;
+            }
+        }
+
+        /// <summary>
+        /// Add a content category in the AttachPanel.
+        /// </summary>
+        /// <param name="category">The ContentCategory to be added in the AttachPanel</param>
+        /// <param name="extraData">The AttachPanel send some information using Bundle</param>
+        /// <privilege>http://tizen.org/privilege/mediastorage</privilege>
+        /// <privilege>http://tizen.org/privilege/camera</privilege>
+        /// <privilege>http://tizen.org/privilege/recorder</privilege>
+        /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+        /// <feature>http://tizen.org/feature/camera</feature>
+        /// <feature>http://tizen.org/feature/microphone</feature>
+        /// <remarks>
+        /// The caller app has to check the return value of this function.
+        /// Content categories will be shown as the sequence of using AddCategory
+        /// Some contents need time to load it all.
+        /// So, it is needed to use this before the mainloop of Show
+        /// Privileges,
+        /// http://tizen.org/privilege/mediastorage, for using Image or Camera
+        /// http://tizen.org/privilege/camera, for using Camera or TakePicture
+        /// http://tizen.org/privilege/recorder, for using Voice
+        /// http://tizen.org/privilege/appmanager.launch, for adding content categories on the More tab
+        /// http://tizen.org/feature/camera, for using Camera or TakePicture
+        /// http://tizen.org/feature/microphone, for using Voice
+        /// Deliver more information to the callee with a bundle if you need.
+        /// http://tizen.org/appcontrol/data/total_count
+        /// http://tizen.org/appcontrol/data/total_size
+        /// </remarks>
+        /// <exception cref="ArgumentOutOfRangeException">Thrown when the <paramref name="category"/> is not a valid category</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method</exception>
+        /// <exception cref="NotSupportedException">Thrown when the device does not supported the <paramref name="category"/> feature </exception>
+        /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is not created yet or already destroyed</exception>
+        public void AddCategory(ContentCategory category, Bundle extraData)
+        {
+            IntPtr bundle = IntPtr.Zero;
+            if (extraData != null)
+            {
+                bundle = extraData.SafeBundleHandle.DangerousGetHandle();
+            }
+            Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.AddCategory(_attachPanel, (int)category, bundle);
+            checkException(err);
+        }
+
+        /// <summary>
+        /// Removes the ContentCategory from the AttachPanel
+        /// </summary>
+        /// <param name="category">The ContentCategory adding in the AttachPanel</param>
+        ///  <exception cref="ArgumentOutOfRangeException">Thrown when the <paramref name="category"/> is not a valid category</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is not created yet or already destroyed</exception>
+        public void RemoveCategory(ContentCategory category)
+        {
+            Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.RemoveCategory(_attachPanel, (int)category);
+            checkException(err);
+        }
+
+        /// <summary>
+        /// Sets extraData to send to the ContentCategory using a Bundle
+        /// </summary>
+        /// <param name="category">The ContentCategory that some information to be set in the AttachPanel.</param>
+        /// <param name="extraData">The AttachPanel send some information using Bundle</param>
+        /// <exception cref="ArgumentOutOfRangeException">Thrown when the <paramref name="category"/> is not a valid category</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when an attempt to allocate memory fails.</exception>
+        public void SetExtraData(ContentCategory category, Bundle extraData)
+        {
+            if(extraData == null)
+            {
+                checkException(Interop.AttachPanel.ErrorCode.InvalidParameter);
+            }
+
+            IntPtr bundle = IntPtr.Zero;
+            if (extraData != null)
+            {
+                bundle = extraData.SafeBundleHandle.DangerousGetHandle();
+            }
+            Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.SetExtraData(_attachPanel, (int)category, bundle);
+            checkException(err);
+        }
+
+        /// <summary>
+        /// Shows the attach panel with animations
+        /// </summary>
+        /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed</exception>
+        public void Show()
+        {
+            Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Show(_attachPanel);
+            checkException(err);
+        }
+
+        /// <summary>
+        /// Shows the attach panel and selects whether or not to animate
+        /// </summary>
+        /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed</exception>
+        public void Show(bool animation)
+        {
+            if (animation)
+            {
+                Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Show(_attachPanel);
+                checkException(err);
+            }
+            else
+            {
+                Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.ShowWithoutAnimation(_attachPanel);
+                checkException(err);
+            }
+        }
+
+        /// <summary>
+        /// Hides the attach panel with animations
+        /// </summary>
+        /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed</exception>
+        public void Hide()
+        {
+            Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Hide(_attachPanel);
+            checkException(err);
+        }
+
+        /// <summary>
+        /// Hides the attach panel and selects whether or not to animate
+        /// </summary>
+        /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed</exception>
+        public void Hide(bool animation)
+        {
+            if (animation)
+            {
+                Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Hide(_attachPanel);
+                checkException(err);
+            }
+            else
+            {
+                Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.HideWithoutAnimation(_attachPanel);
+                checkException(err);
+            }
+        }
+
+        /// <summary>
+        /// Occurs when reserved events are published from the panel-side.
+        /// </summary>
+        public event EventHandler<StateEventArgs> EventChanged
+        {
+            add
+            {
+                if (_eventEventHandler == null)
+                {
+                    StateEventListenStart();
+                }
+                _eventEventHandler += value;
+            }
+            remove
+            {
+                _eventEventHandler -= value;
+                if (_eventEventHandler == null)
+                {
+                    StateEventListenStop();
+                }
+            }
+        }
+
+        /// <summary>
+        /// Occurs when an user selects and confirms something to attach in the AttachPanel
+        /// </summary>
+        public event EventHandler<ResultEventArgs> ResultCallback
+        {
+            add
+            {
+                if (_resultEventHandler == null)
+                {
+                    ResultEventListenStart();
+                }
+                _resultEventHandler += value;
+            }
+            remove
+            {
+                _resultEventHandler -= value;
+                if (_resultEventHandler == null)
+                {
+                    ResultEventListenStop();
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/AttachPanelInternal.cs b/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/AttachPanelInternal.cs
new file mode 100755 (executable)
index 0000000..e40af2d
--- /dev/null
@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Applications.AttachPanel
+{
+    public partial class AttachPanel
+    {
+        private static IntPtr _attachPanel;
+        private bool isCreationSucceed;
+
+        private static event EventHandler<StateEventArgs> _eventEventHandler;
+        private static event EventHandler<ResultEventArgs> _resultEventHandler;
+
+        private static Interop.AttachPanel.AttachPanelEventCallback SetEventListener;
+        private static Interop.AttachPanel.AttachPanelResultCallback SetResultListener;
+
+        private void StateEventListenStart()
+        {
+            Interop.AttachPanel.ErrorCode err = 0;
+
+            SetEventListener = (attachPanel, eventType, eventInfo, userData) =>
+            {
+                _eventEventHandler?.Invoke(null, new StateEventArgs(attachPanel, (EventType)eventType, eventInfo, userData));
+            };
+            err = Interop.AttachPanel.SetEventCb(_attachPanel, SetEventListener, IntPtr.Zero);
+            checkException(err);
+        }
+        private void StateEventListenStop()
+        {
+            Interop.AttachPanel.ErrorCode err = 0;
+            err =  Interop.AttachPanel.UnsetEventCb(_attachPanel);
+            checkException(err);
+        }
+
+        private void ResultEventListenStart()
+        {
+            Interop.AttachPanel.ErrorCode err = 0;
+            SetResultListener = (attachPanel, category, resulthandler, resultCode, userData) =>
+            {
+                SafeAppControlHandle handle = new SafeAppControlHandle(resulthandler, false);
+                AppControl result = new AppControl(handle);
+                _resultEventHandler?.Invoke(null, new ResultEventArgs(attachPanel, (ContentCategory)category, result, (AppControlReplyResult)resultCode, userData));
+            };
+            err = Interop.AttachPanel.SetResultCb(_attachPanel, SetResultListener, IntPtr.Zero);
+            checkException(err);
+        }
+
+        private void ResultEventListenStop()
+        {
+            Interop.AttachPanel.ErrorCode err = 0;
+            err = Interop.AttachPanel.UnsetResultCb(_attachPanel);
+            checkException(err);
+        }
+
+        internal static void checkException(Interop.AttachPanel.ErrorCode err)
+        {
+            switch (err)
+            {
+                case Interop.AttachPanel.ErrorCode.InvalidParameter:
+                    throw new ArgumentOutOfRangeException("Invalid parameter error at unmanaged code");
+                case Interop.AttachPanel.ErrorCode.OutOfMemory:
+                    throw new OutOfMemoryException("Out of Memory");
+                case Interop.AttachPanel.ErrorCode.PermissionDenied:
+                    throw new UnauthorizedAccessException();
+                case Interop.AttachPanel.ErrorCode.AlreadyExists:
+                    throw new InvalidOperationException("Already Exists");
+                case Interop.AttachPanel.ErrorCode.NotInitialized:
+                    throw new InvalidOperationException("Not initialized");
+                case Interop.AttachPanel.ErrorCode.UnsupportedContentCategory:
+                    throw new NotSupportedException("Unsupported Content Category");
+                case Interop.AttachPanel.ErrorCode.AlreadyDestroyed:
+                    throw new InvalidOperationException("Already Destroyed");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/ContentCategory.cs b/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/ContentCategory.cs
new file mode 100755 (executable)
index 0000000..e86b9ea
--- /dev/null
@@ -0,0 +1,57 @@
+namespace Tizen.Applications.AttachPanel
+{
+    /// <summary>
+    /// Enumeration for the attach panel content category.
+    /// </summary>
+    public enum ContentCategory
+    {
+        /// <summary>
+        /// Attaching images from the gallery
+        /// </summary>
+        Image = 1,
+        /// <summary>
+        /// Taking pictures to attach
+        /// </summary>
+        Camera,
+        /// <summary>
+        /// Taking a voice clip to attach
+        /// </summary>
+        Voice,
+        /// <summary>
+        /// Attaching video from the gallery
+        /// </summary>
+        Video,
+        /// <summary>
+        /// Attaching audio from my files
+        /// </summary>
+        Audio,
+        /// <summary>
+        /// Attaching calendar data from the calendar
+        /// </summary>
+        Calendar,
+        /// <summary>
+        /// Attaching contact data from the contacts
+        /// </summary>
+        Contact,
+        /// <summary>
+        /// Attaching files data from my files
+        /// </summary>
+        Myfiles,
+        /// <summary>
+        /// Taking a video clip to attach
+        /// </summary>
+        VideoRecorder,
+        /// <summary>
+        /// Attaching files from the document list
+        /// </summary>
+        Document,
+        /// <summary>
+        /// Launching apps to take pictures will be attached
+        /// </summary>
+        TakePicture,
+        /// <summary>
+        /// Attaching memo data from the memo
+        /// </summary>
+        Memo,
+    }
+}
diff --git a/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/EventType.cs b/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/EventType.cs
new file mode 100755 (executable)
index 0000000..dc460a1
--- /dev/null
@@ -0,0 +1,25 @@
+namespace Tizen.Applications.AttachPanel
+{
+    /// <summary>
+    /// Enumeration for the attach panel event.
+    /// </summary>
+    public enum EventType
+    {
+        /// <summary>
+        /// Attach panel starts the effect to show
+        /// </summary>
+        ShowStart = 1,
+        /// <summary>
+        /// Attach panel finishes the effect to show
+        /// </summary>
+        ShowFinish,
+        /// <summary>
+        /// Attach panel starts the effect to hide the panel
+        /// </summary>
+        HideStart,
+        /// <summary>
+        /// Attach panel finishes the effect to hide the panel
+        /// </summary>
+        HideFinish,
+    }
+}
diff --git a/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/ResultEventArgs.cs b/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/ResultEventArgs.cs
new file mode 100755 (executable)
index 0000000..6628b9d
--- /dev/null
@@ -0,0 +1,51 @@
+using System;
+
+namespace Tizen.Applications.AttachPanel
+{
+    /// <summary>
+    /// Class for event arguments of the result event
+    /// </summary>
+    public class ResultEventArgs : EventArgs
+    {
+        private readonly IntPtr _attachPanel;
+        private readonly ContentCategory _category;
+        private readonly AppControl _result;
+        private readonly AppControlReplyResult _resultCode;
+        private readonly IntPtr _userData;
+
+        internal ResultEventArgs(IntPtr attachPanel, ContentCategory category, AppControl result, AppControlReplyResult resultCode, IntPtr userData)
+        {
+            _attachPanel = attachPanel;
+            _category = category;
+            _result = result;
+            _resultCode = resultCode;
+            _userData = userData;
+        }
+
+        /// <summary>
+        ///  Property for attach panel object.
+        /// </summary>
+        public IntPtr AttachPanel { get { return _attachPanel; } }
+
+        /// <summary>
+        /// Results are from the content category.
+        /// </summary>
+        public ContentCategory Category { get { return _category; } }
+
+        /// <summary>
+        /// Property for result
+        /// The caller app has to use ExtraData property to get received data.
+        /// </summary>
+        public AppControl Result {  get { return _result; } }
+
+        /// <summary>
+        /// Property for result of AppControl
+        /// </summary>
+        public AppControlReplyResult ResultCode { get { return _resultCode; } }
+
+        /// <summary>
+        /// Property for user data
+        /// </summary>
+        public IntPtr UserData { get { return _userData; } }
+    }
+}
diff --git a/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/StateEventArgs.cs b/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/StateEventArgs.cs
new file mode 100755 (executable)
index 0000000..5354c5f
--- /dev/null
@@ -0,0 +1,44 @@
+using System;
+
+namespace Tizen.Applications.AttachPanel
+{
+    /// <summary>
+    /// Class for event arguments of the state event
+    /// </summary>
+    public class StateEventArgs : EventArgs
+    {
+        private readonly IntPtr _attachPanel;
+        private readonly EventType _eventType;
+        private readonly IntPtr _eventInfo;
+        private readonly IntPtr _userData;
+
+        internal StateEventArgs(IntPtr attachPanel, EventType eventType, IntPtr eventInfo, IntPtr userData)
+        {
+            _attachPanel = attachPanel;
+            _eventType = eventType;
+            _eventInfo = eventInfo;
+            _userData = userData;
+        }
+
+        /// <summary>
+        /// Property for attach panel object
+        /// </summary>
+        public IntPtr AttachPanel { get { return _attachPanel;  } }
+
+        /// <summary>
+        /// Property for event type.
+        /// </summary>
+        public EventType EventType { get { return _eventType;  } }
+
+        /// <summary>
+        /// Additional event information.
+        /// This can be NULL if there are no necessary information.
+        /// </summary>
+        public IntPtr EventInfo {  get { return _eventInfo;  } }
+
+        /// <summary>
+        /// Property for user data.
+        /// </summary>
+        public IntPtr UserData { get { return _userData; } }
+    }
+}
diff --git a/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/StateType.cs b/src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/StateType.cs
new file mode 100755 (executable)
index 0000000..a2474db
--- /dev/null
@@ -0,0 +1,21 @@
+namespace Tizen.Applications.AttachPanel
+{
+    /// <summary>
+    /// Enumeration for the attach panel's window state.
+    /// </summary>
+    public enum StateType
+    {
+        /// <summary>
+        /// Attach panel is not visible
+        /// </summary>
+        Hidden = 0,
+        /// <summary>
+        /// Attach panel is in partial window mode
+        /// </summary>
+        Partial,
+        /// <summary>
+        /// Attach panel is in full screen mode
+        /// </summary>
+        Full,
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Badge/GlobalSuppressions.cs b/src/Tizen.Applications.Badge/GlobalSuppressions.cs
new file mode 100755 (executable)
index 0000000..9d74253
Binary files /dev/null and b/src/Tizen.Applications.Badge/GlobalSuppressions.cs differ
diff --git a/src/Tizen.Applications.Badge/Interop/Interop.Badge.cs b/src/Tizen.Applications.Badge/Interop/Interop.Badge.cs
new file mode 100755 (executable)
index 0000000..53b1b1a
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Applications;
+
+internal static partial class Interop
+{
+    internal static partial class Badge
+    {
+        internal enum Action : uint
+        {
+            Create = 0,
+            Remove,
+            Update,
+            ChangedDisplay,
+            ServiceReady
+        }
+
+        internal delegate void ForeachCallback(string appId, uint count, IntPtr userData);
+
+        internal delegate void ChangedCallback(Action action, string appId, uint count, IntPtr userData);
+
+        [DllImport(Libraries.Badge, EntryPoint = "badge_add")]
+        internal static extern BadgeError Add(string appId);
+
+        [DllImport(Libraries.Badge, EntryPoint = "badge_remove")]
+        internal static extern BadgeError Remove(string appId);
+
+        [DllImport(Libraries.Badge, EntryPoint = "badge_set_count")]
+        internal static extern BadgeError SetCount(string appId, uint count);
+
+        [DllImport(Libraries.Badge, EntryPoint = "badge_get_count")]
+        internal static extern BadgeError GetCount(string appId, out uint count);
+
+        [DllImport(Libraries.Badge, EntryPoint = "badge_set_display")]
+        internal static extern BadgeError SetDisplay(string appId, uint isDisplay);
+
+        [DllImport(Libraries.Badge, EntryPoint = "badge_get_display")]
+        internal static extern BadgeError GetDisplay(string appId, out uint isDisplay);
+
+        [DllImport(Libraries.Badge, EntryPoint = "badge_foreach")]
+        internal static extern BadgeError Foreach(ForeachCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Badge, EntryPoint = "badge_register_changed_cb")]
+        internal static extern BadgeError SetChangedCallback(ChangedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Badge, EntryPoint = "badge_unregister_changed_cb")]
+        internal static extern BadgeError UnsetChangedCallback(ChangedCallback callback);
+    }
+}
diff --git a/src/Tizen.Applications.Badge/Interop/Interop.Libraries.cs b/src/Tizen.Applications.Badge/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..01ccffd
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string Badge = "libbadge.so.0";
+    }
+}
diff --git a/src/Tizen.Applications.Badge/Tizen.Applications.Badge.csproj b/src/Tizen.Applications.Badge/Tizen.Applications.Badge.csproj
new file mode 100755 (executable)
index 0000000..9d38bdc
--- /dev/null
@@ -0,0 +1,25 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <Version>1.0.6</Version>
+    <Authors>Samsung Electronics</Authors>
+    <Copyright>© Samsung Electronics Co., Ltd All Rights Reserved</Copyright>
+    <Description>Provides the Badge API for Tizen .NET</Description>
+    <PackageProjectUrl>https://www.tizen.org/</PackageProjectUrl>
+    <PackageLicenseUrl>https://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
+    <PackageIconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</PackageIconUrl>
+  </PropertyGroup>
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.6</TargetFramework>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Applications.Badge.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Tizen" Version="1.0.5" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Applications.Badge/Tizen.Applications.Badge.snk b/src/Tizen.Applications.Badge/Tizen.Applications.Badge.snk
new file mode 100755 (executable)
index 0000000..7ac1b00
Binary files /dev/null and b/src/Tizen.Applications.Badge/Tizen.Applications.Badge.snk differ
diff --git a/src/Tizen.Applications.Badge/Tizen.Applications/Badge.cs b/src/Tizen.Applications.Badge/Tizen.Applications/Badge.cs
new file mode 100755 (executable)
index 0000000..89b317a
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Immutable class for getting information of the badge.
+    /// </summary>
+    public class Badge
+    {
+        private readonly string _appId;
+        private readonly int _count;
+        private readonly bool _isDisplay;
+
+        internal Badge(string appid, int count, bool isDisplay)
+        {
+            _appId = appid;
+            _count = count;
+            _isDisplay = isDisplay;
+        }
+
+        /// <summary>
+        /// Property for the count value of the badge.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public int Count
+        {
+            get
+            {
+                return _count;
+            }
+        }
+
+        /// <summary>
+        /// Property for the application ID of the badge.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public string AppId
+        {
+            get
+            {
+                return _appId;
+            }
+        }
+
+        /// <summary>
+        /// Property for the flag of 'display'.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public bool IsDisplay
+        {
+            get
+            {
+                return _isDisplay;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Badge/Tizen.Applications/BadgeControl.cs b/src/Tizen.Applications.Badge/Tizen.Applications/BadgeControl.cs
new file mode 100755 (executable)
index 0000000..85e72a7
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    using System;
+    using System.Collections.Generic;
+    /// <summary>
+    /// The class for badge operation.
+    /// </summary>
+    public static class BadgeControl
+    {
+        private static event EventHandler<BadgeEventArgs> s_changed;
+        private static bool s_registered = false;
+        private static Interop.Badge.ChangedCallback s_callback;
+
+        /// <summary>
+        /// Event handler for receiving badge events.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static event EventHandler<BadgeEventArgs> Changed
+        {
+            add
+            {
+                if (s_changed == null && !s_registered)
+                {
+                    if (s_callback == null)
+                    {
+                        s_callback = new Interop.Badge.ChangedCallback(OnChangedEvent);
+                    }
+
+                    BadgeError err = Interop.Badge.SetChangedCallback(s_callback, IntPtr.Zero);
+                    if (err != BadgeError.None)
+                    {
+                        throw BadgeErrorFactory.GetException(err, "Failed to add event handler");
+                    }
+
+                    s_registered = true;
+                }
+
+                s_changed += value;
+            }
+            remove
+            {
+                s_changed -= value;
+                if (s_changed == null && s_registered)
+                {
+                    BadgeError err = Interop.Badge.UnsetChangedCallback(s_callback);
+                    if (err != BadgeError.None)
+                    {
+                        throw BadgeErrorFactory.GetException(err, "Failed to remove event handler");
+                    }
+
+                    s_callback = null;
+                    s_registered = false;
+                }
+            }
+        }
+
+        /// <summary>
+        /// Gets the badge information from the application ID.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="appId">Application ID.</param>
+        /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static Badge Find(string appId)
+        {
+            uint count;
+            uint display;
+
+            BadgeError err = Interop.Badge.GetCount(appId, out count);
+            if (err != BadgeError.None)
+            {
+                throw BadgeErrorFactory.GetException(err, "Failed to find badge count of " + appId);
+            }
+
+            err = Interop.Badge.GetDisplay(appId, out display);
+            if (err != BadgeError.None)
+            {
+                throw BadgeErrorFactory.GetException(err, "Failed to find badge display of " + appId);
+            }
+
+            return new Badge(appId, (int)count, display == 0 ? false : true);
+        }
+
+        /// <summary>
+        /// Removes the badge information.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="appId">Application ID.</param>
+        /// <exception cref="ArgumentException">Thrown when failed because of a an invalid argument.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static void Remove(string appId)
+        {
+            BadgeError err = Interop.Badge.Remove(appId);
+            if (err != BadgeError.None)
+            {
+                throw BadgeErrorFactory.GetException(err, "Failed to Remove badge of " + appId);
+            }
+        }
+
+        /// <summary>
+        /// Adds the badge information.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="appId">Application ID.</param>
+        /// <param name="count">Count value.</param>
+        /// <param name="isDisplay">True if it should be displayed.</param>
+        /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static void Add(string appId, int count = 1, bool isDisplay = true)
+        {
+            BadgeError err = Interop.Badge.Add(appId);
+            if (err != BadgeError.None)
+            {
+                throw BadgeErrorFactory.GetException(err, "Failed to add badge of " + appId);
+            }
+
+            try
+            {
+                Update(appId, count, isDisplay);
+            }
+            catch (Exception e)
+            {
+                Remove(appId);
+                throw e;
+            }
+        }
+
+        /// <summary>
+        /// Updates the badge information.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="appId">Application ID.</param>
+        /// <param name="count">Count value.</param>
+        /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static void Update(string appId, int count)
+        {
+            BadgeError err = Interop.Badge.SetCount(appId, (uint)count);
+            if (err != BadgeError.None)
+            {
+                throw BadgeErrorFactory.GetException(err, "Failed to update badge of " + appId);
+            }
+        }
+
+        /// <summary>
+        /// Updates the badge information.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="appId">Application ID.</param>
+        /// <param name="isDisplay">True if it should be displayed.</param>
+        /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static void Update(string appId, bool isDisplay)
+        {
+            BadgeError err = Interop.Badge.SetDisplay(appId, isDisplay ? 1U : 0U);
+            if (err != BadgeError.None)
+            {
+                throw BadgeErrorFactory.GetException(err, "Failed to update badge of " + appId);
+            }
+        }
+
+        /// <summary>
+        /// Updates the badge information.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="appId">Application ID.</param>
+        /// <param name="count">Count value.</param>
+        /// <param name="isDisplay">True if it should be displayed.</param>
+        /// <exception cref="ArgumentException">Thrown when failed because of invalid argument.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static void Update(string appId, int count, bool isDisplay)
+        {
+            Update(appId, count);
+            Update(appId, isDisplay);
+        }
+
+        /// <summary>
+        /// Gets all the badge information.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static IEnumerable<Badge> GetBadges()
+        {
+            IList<Badge> list = new List<Badge>();
+
+            BadgeError err = Interop.Badge.Foreach((appId, count, userData) =>
+            {
+                uint display = 0;
+                BadgeError errGetDisplay = Interop.Badge.GetDisplay(appId, out display);
+                if (errGetDisplay != BadgeError.None)
+                {
+                    throw BadgeErrorFactory.GetException(errGetDisplay, "Failed to get badges ");
+                }
+
+                list.Add(new Badge(appId, (int)count, display == 0 ? false : true));
+            }, IntPtr.Zero);
+
+            if (err != BadgeError.None)
+            {
+                throw BadgeErrorFactory.GetException(err, "Failed to get badges");
+            }
+
+            return list;
+        }
+
+        private static void OnChangedEvent(Interop.Badge.Action action, string appId, uint count, IntPtr userData)
+        {
+            uint display = 0;
+            uint countLocal = 0;
+
+            switch (action)
+            {
+                case Interop.Badge.Action.Create:
+                    s_changed?.Invoke(null, new BadgeEventArgs()
+                    {
+                        Reason = BadgeEventArgs.Action.Add,
+                        Badge = new Badge(appId, 0, false)
+                    });
+                    break;
+
+                case Interop.Badge.Action.Remove:
+                    s_changed?.Invoke(null, new BadgeEventArgs()
+                    {
+                        Reason = BadgeEventArgs.Action.Remove,
+                        Badge = new Badge(appId, 0, false)
+                    });
+                    break;
+
+                case Interop.Badge.Action.Update:
+                    Interop.Badge.GetDisplay(appId, out display);
+                    s_changed?.Invoke(null, new BadgeEventArgs()
+                    {
+                        Reason = BadgeEventArgs.Action.Update,
+                        Badge = new Badge(appId, (int)count, display == 0 ? false : true)
+                    });
+                    break;
+
+                case Interop.Badge.Action.ChangedDisplay:
+                    Interop.Badge.GetCount(appId, out countLocal);
+                    s_changed?.Invoke(null, new BadgeEventArgs()
+                    {
+                        Reason = BadgeEventArgs.Action.Update,
+                        Badge = new Badge(appId, (int)countLocal, count == 0 ? false : true)
+                    });
+                    break;
+
+                case Interop.Badge.Action.ServiceReady:
+                    // Ignore
+                    break;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Badge/Tizen.Applications/BadgeErrorFactory.cs b/src/Tizen.Applications.Badge/Tizen.Applications/BadgeErrorFactory.cs
new file mode 100755 (executable)
index 0000000..ff0d909
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    using System;
+    using System.Runtime.CompilerServices;
+
+    internal enum BadgeError
+    {
+        None = Tizen.Internals.Errors.ErrorCode.None,
+        InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+        OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+        PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
+        IoError = Tizen.Internals.Errors.ErrorCode.IoError,
+        DbError = -0x01120000 | 0x01,
+        AlreadyExists = -0x01120000 | 0x02,
+        DBusError = -0x01120000 | 0x03,
+        DoesnotExist = -0x01120000 | 0x04,
+        ServiceError = -0x01120000 | 0x05,
+        InvalidPackage = -0x01120000 | 0x06
+    }
+
+    /// <summary>
+    /// Immutable class for getting the badge information.
+    /// </summary>
+    internal static class BadgeErrorFactory
+    {
+        private static readonly string LogTag = "Tizen.Applications.Badge";
+
+        internal static Exception GetException(BadgeError ret, string msg, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0)
+        {
+            Log.Error(LogTag, memberName + " : " + lineNumber);
+
+            switch (ret)
+            {
+                case BadgeError.InvalidParameter:
+                    Log.Error(LogTag, msg);
+                    return new ArgumentException(ret + " error occurred.");
+                case BadgeError.PermissionDenied:
+                    throw new UnauthorizedAccessException("Permission denied (http://tizen.org/privilege/notification)");
+                default:
+                    Log.Error(LogTag, msg);
+                    return new InvalidOperationException(ret + " error occurred.");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Badge/Tizen.Applications/BadgeEventArgs.cs b/src/Tizen.Applications.Badge/Tizen.Applications/BadgeEventArgs.cs
new file mode 100755 (executable)
index 0000000..bfcc85f
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    using System;
+
+    /// <summary>
+    /// The class for event arguments of the badge event.
+    /// </summary>
+    public class BadgeEventArgs : EventArgs
+    {
+        internal BadgeEventArgs()
+        {
+        }
+
+        /// <summary>
+        /// Enumeration for the badge action.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public enum Action : int
+        {
+            /// <summary>
+            /// The badge was added.
+            /// </summary>
+            Add = 0,
+
+            /// <summary>
+            /// The badge was removed.
+            /// </summary>
+            Remove,
+
+            /// <summary>
+            /// The badge was updated.
+            /// </summary>
+            Update,
+        }
+
+        /// <summary>
+        /// The property for the badge object.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public Badge Badge { get; internal set; }
+
+        /// <summary>
+        /// The property for the action value.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public Action Reason { get; internal set; }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs b/src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs
new file mode 100755 (executable)
index 0000000..5ad41f5
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+using Tizen.Internals.Errors;
+using Tizen.Applications;
+
+internal static partial class Interop
+{
+    internal static partial class AppCommon
+    {
+       internal enum ResourceCategory : int
+        {
+            Image = 0,
+            Layout,
+            Sound,
+            Binary
+        }
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_id")]
+        internal static extern ErrorCode AppGetId(out string appId);
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_name")]
+        internal static extern ErrorCode AppGetName(out string name);
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_resource_path")]
+        internal static extern string AppGetResourcePath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_data_path")]
+        internal static extern string AppGetDataPath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_cache_path")]
+        internal static extern string AppGetCachePath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_shared_data_path")]
+        internal static extern string AppGetSharedDataPath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_shared_resource_path")]
+        internal static extern string AppGetSharedResourcePath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_shared_trusted_path")]
+        internal static extern string AppGetSharedTrustedPath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_tep_resource_path")]
+        internal static extern string AppGetTepResourcePath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_external_cache_path")]
+        internal static extern string AppGetExternalCachePath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_external_data_path")]
+        internal static extern string AppGetExternalDataPath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_external_shared_data_path")]
+        internal static extern string AppGetExternalSharedDataPath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_version")]
+        internal static extern ErrorCode AppGetVersion(out string version);
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_low_memory_status")]
+        internal static extern ErrorCode AppEventGetLowMemoryStatus(IntPtr handle, out LowMemoryStatus status);
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_low_battery_status")]
+        internal static extern ErrorCode AppEventGetLowBatteryStatus(IntPtr handle, out LowBatteryStatus status);
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_language")]
+        internal static extern ErrorCode AppEventGetLanguage(IntPtr handle, out string lang);
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_region_format")]
+        internal static extern ErrorCode AppEventGetRegionFormat(IntPtr handle, out string region);
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_resource_manager_get")]
+        internal static extern ErrorCode AppResourceManagerGet(ResourceCategory category, string id, out string path);
+
+        [DllImport(Libraries.Application, EntryPoint = "app_resource_manager_get")]
+        internal static extern ErrorCode LegacyAppResourceManagerGet(ResourceCategory category, string id, out string path);
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_device_orientation")]
+        internal static extern ErrorCode AppEventGetDeviceOrientation(IntPtr handle, out DeviceOrientation orientation);
+    }
+}
+
diff --git a/src/Tizen.Applications.Common/Interop/Interop.AppControl.cs b/src/Tizen.Applications.Common/Interop/Interop.AppControl.cs
new file mode 100755 (executable)
index 0000000..c379698
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+using Tizen.Applications;
+
+internal static partial class Interop
+{
+    internal static partial class AppControl
+    {
+        internal const int AppStartedStatus = 1;
+
+        internal delegate bool ExtraDataCallback(IntPtr handle, string key, IntPtr userData);
+        internal delegate bool AppMatchedCallback(IntPtr handle, string applicationId, IntPtr userData);
+        internal delegate void ReplyCallback(IntPtr request, IntPtr reply, int result, IntPtr userData);
+
+        internal enum ErrorCode
+        {
+            None = Tizen.Internals.Errors.ErrorCode.None,
+            InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+            OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+            AppNotFound = -0x01100000 | 0x21,
+            KeyNotFound = Tizen.Internals.Errors.ErrorCode.KeyNotAvailable,
+            KeyRejected = Tizen.Internals.Errors.ErrorCode.KeyRejected,
+            InvalidDataType = -0x01100000 | 0x22,
+            LaunchRejected = -0x01100000 | 0x23,
+            PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
+            LaunchFailed = -0x01100000 | 0x24,
+            IoError = Tizen.Internals.Errors.ErrorCode.IoError,
+            TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut,
+        }
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_create")]
+        internal static extern ErrorCode Create(out SafeAppControlHandle handle);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_clone")]
+        internal static extern ErrorCode DangerousClone(out SafeAppControlHandle clone, IntPtr handle);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_app_id")]
+        internal static extern ErrorCode GetAppId(IntPtr app_control, out IntPtr app_id);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_operation")]
+        internal static extern ErrorCode GetOperation(SafeAppControlHandle handle, out string operation);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_operation")]
+        internal static extern ErrorCode SetOperation(SafeAppControlHandle handle, string operation);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_uri")]
+        internal static extern ErrorCode GetUri(SafeAppControlHandle handle, out string uri);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_uri")]
+        internal static extern ErrorCode SetUri(SafeAppControlHandle handle, string uri);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_mime")]
+        internal static extern ErrorCode GetMime(SafeAppControlHandle handle, out string mime);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_mime")]
+        internal static extern ErrorCode SetMime(SafeAppControlHandle handle, string mime);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_category")]
+        internal static extern ErrorCode GetCategory(SafeAppControlHandle handle, out string category);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_category")]
+        internal static extern ErrorCode SetCategory(SafeAppControlHandle handle, string category);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_app_id")]
+        internal static extern ErrorCode GetAppId(SafeAppControlHandle handle, out string appId);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_app_id")]
+        internal static extern ErrorCode SetAppId(SafeAppControlHandle handle, string appId);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_launch_mode")]
+        internal static extern ErrorCode SetLaunchMode(SafeAppControlHandle handle, int mode);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_launch_mode")]
+        internal static extern ErrorCode GetLaunchMode(SafeAppControlHandle handle, out int mode);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_caller")]
+        internal static extern ErrorCode GetCaller(SafeAppControlHandle handle, out string caller);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_is_reply_requested")]
+        internal static extern ErrorCode IsReplyRequested(SafeAppControlHandle handle, out bool requested);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_add_extra_data")]
+        internal static extern ErrorCode AddExtraData(SafeAppControlHandle handle, string key, string value);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_remove_extra_data")]
+        internal static extern ErrorCode RemoveExtraData(SafeAppControlHandle handle, string key);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_extra_data")]
+        internal static extern ErrorCode GetExtraData(SafeAppControlHandle handle, string key, out string value);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_add_extra_data_array")]
+        internal static extern ErrorCode AddExtraDataArray(SafeAppControlHandle handle, string key, string[] value, int length);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_extra_data_array")]
+        internal static extern ErrorCode GetExtraDataArray(SafeAppControlHandle handle, string key, out IntPtr value, out int length);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_is_extra_data_array")]
+        internal static extern ErrorCode IsExtraDataArray(SafeAppControlHandle handle, string key, out bool array);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_destroy")]
+        internal static extern ErrorCode DangerousDestroy(IntPtr handle);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_foreach_extra_data")]
+        internal static extern ErrorCode ForeachExtraData(SafeAppControlHandle handle, ExtraDataCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_foreach_app_matched")]
+        internal static extern ErrorCode ForeachAppMatched(SafeAppControlHandle handle, AppMatchedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_send_launch_request")]
+        internal static extern ErrorCode SendLaunchRequest(SafeAppControlHandle handle, ReplyCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_send_terminate_request")]
+        internal static extern ErrorCode SendTerminateRequest(SafeAppControlHandle handle);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_reply_to_launch_request")]
+        internal static extern ErrorCode ReplyToLaunchRequest(SafeAppControlHandle reply, SafeAppControlHandle request, int result);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_enable_app_started_result_event")]
+        internal static extern ErrorCode EnableAppStartedResultEvent(SafeAppControlHandle handle);
+    }
+}
diff --git a/src/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs b/src/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs
new file mode 100644 (file)
index 0000000..0879a32
--- /dev/null
@@ -0,0 +1,356 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class ApplicationManager
+    {
+        internal enum ErrorCode
+        {
+            None = Tizen.Internals.Errors.ErrorCode.None,
+            InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+            OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+            IoError = Tizen.Internals.Errors.ErrorCode.IoError,
+            NoSuchApp = -0x01110000 | 0x01,
+            DbFailed = -0x01110000 | 0x03,
+            InvalidPackage = -0x01110000 | 0x04,
+            AppNoRunning = -0x01110000 | 0x05,
+            RequestFailed = -0x01110000 | 0x06,
+            PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied
+        }
+
+        internal enum AppContextEvent
+        {
+            Launched = 0,
+            Terminated = 1
+        }
+
+        internal enum AppManagerEventStatusType
+        {
+            All = 0x00,
+            Enable = 0x01,
+            Disable = 0x02
+        }
+
+        internal enum AppManagerEventType
+        {
+            Enable = 0,
+            Disable = 1
+        }
+
+        internal enum AppManagerEventState
+        {
+            Started = 0,
+            Completed = 1,
+            Failed = 2
+        }
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void AppManagerEventCallback(string appType, string appId, AppManagerEventType eventType, AppManagerEventState eventState, IntPtr eventHandle, IntPtr userData);
+        //void(* app_manager_event_cb)(const char *type, const char *app_id, app_manager_event_type_e event_type, app_manager_event_state_e event_state, app_manager_event_h handle, void *user_data)
+
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void AppManagerAppContextEventCallback(IntPtr handle, AppContextEvent state, IntPtr userData);
+        //void(* app_manager_app_context_event_cb)(app_context_h app_context, app_context_event_e event, void *user_data)
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool AppManagerAppInfoCallback(IntPtr handle, IntPtr userData);
+        //bool(* app_manager_app_info_cb )(app_info_h app_info, void *user_data)
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool AppManagerAppContextCallback(IntPtr handle, IntPtr userData);
+        //bool(* app_manager_app_context_cb)(app_context_h app_context, void *user_data)
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool AppInfoFilterCallback(IntPtr handle, IntPtr userData);
+        //bool(* app_info_filter_cb )(app_info_h app_info, void *user_data)
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool AppInfoMetadataCallback(string key, string value, IntPtr userData);
+        //bool(* app_info_metadata_cb )(const char *metadata_key, const char *metadata_value, void *user_data)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_set_app_context_event_cb")]
+        internal static extern ErrorCode AppManagerSetAppContextEvent(AppManagerAppContextEventCallback callback, IntPtr userData);
+        //int app_manager_set_app_context_event_cb( app_manager_app_context_event_cb callback, void * user_data)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_unset_app_context_event_cb")]
+        internal static extern void AppManagerUnSetAppContextEvent();
+        //void app_manager_unset_app_context_event_cb (void);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_foreach_running_app_context")]
+        internal static extern ErrorCode AppManagerForeachRunningAppContext(AppManagerAppContextCallback callback, IntPtr userData);
+        //int app_manager_foreach_running_app_context(app_manager_app_context_cb callback, void *user_data)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_foreach_app_context")]
+        internal static extern ErrorCode AppManagerForeachAppContext(AppManagerAppContextCallback callback, IntPtr userData);
+        //int app_manager_foreach_app_context(app_manager_app_context_cb callback, void *user_data)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_get_app_context")]
+        internal static extern ErrorCode AppManagerGetAppContext(string applicationId, out IntPtr handle);
+        //int app_manager_get_app_context(const char* app_id, app_context_h *app_context);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_get_app_id")]
+        internal static extern ErrorCode AppManagerGetAppId(int processId, out string applicationId);
+        //int app_manager_get_app_id (pid_t pid, char **appid);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_is_running")]
+        internal static extern ErrorCode AppManagerIsRunning(string applicationId, out bool running);
+        //int app_manager_is_running (const char *appid, bool *running);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_resume_app")]
+        internal static extern ErrorCode AppManagerResumeApp(IntPtr handle);
+        //int app_manager_resume_app (app_context_h handle);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_request_terminate_bg_app")]
+        internal static extern ErrorCode AppManagerRequestTerminateBgApp(IntPtr handle);
+        //int app_manager_request_terminate_bg_app (app_context_h handle);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_foreach_app_info")]
+        internal static extern ErrorCode AppManagerForeachAppInfo(AppManagerAppInfoCallback callback, IntPtr userData);
+        //int app_manager_foreach_app_info(app_manager_app_info_cb callback, void *user_data)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_get_app_info")]
+        internal static extern ErrorCode AppManagerGetAppInfo(string applicationId, out IntPtr handle);
+        //int app_manager_get_app_info(const char * app_id, app_info_h * app_info)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_get_shared_data_path")]
+        internal static extern ErrorCode AppManagerGetSharedDataPath(string applicationId, out string path);
+        //int app_manager_get_shared_data_path (const char *appid, char **path);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_get_shared_resource_path")]
+        internal static extern ErrorCode AppManagerGetSharedResourcePath(string applicationId, out string path);
+        //int app_manager_get_shared_resource_path (const char *appid, char **path);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_get_shared_trusted_path")]
+        internal static extern ErrorCode AppManagerGetSharedTrustedPath(string applicationId, out string path);
+        //int app_manager_get_shared_trusted_path (const char *appid, char **path);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_get_external_shared_data_path")]
+        internal static extern ErrorCode AppManagerGetExternalSharedDataPath(string applicationId, out string path);
+        //int app_manager_get_external_shared_data_path (const char *appid, char **path);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_event_create")]
+        internal static extern ErrorCode AppManagerEventCreate(out IntPtr handle);
+        //int app_manager_event_create (app_manager_event_h *handle);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_event_set_status")]
+        internal static extern ErrorCode AppManagerEventSetStatus(IntPtr handle, AppManagerEventStatusType statusType);
+        //int app_manager_event_set_status (app_manager_event_h handle, int status_type);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_set_event_cb")]
+        internal static extern ErrorCode AppManagerSetEventCallback(IntPtr handle, AppManagerEventCallback callback, IntPtr userData);
+        //int app_manager_set_event_cb (app_manager_event_h handle, app_manager_event_cb callback, void *user_data);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_unset_event_cb")]
+        internal static extern ErrorCode AppManagerUnSetEventCallback(IntPtr handle);
+        //int app_manager_unset_event_cb (app_manager_event_h handle);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_event_destroy")]
+        internal static extern ErrorCode AppManagerEventDestroy(IntPtr handle);
+        //int app_manager_event_destroy (app_manager_event_h handle);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_terminate_app")]
+        internal static extern ErrorCode AppManagerTerminateApp(IntPtr handle);
+        //int app_manager_terminate_app (app_context_h app_context);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_get_app_context_by_instance_id")]
+        internal static extern ErrorCode AppManagerGetAppContextByInstanceId(string applicationId, string instanceId, out IntPtr handle);
+        //int app_manager_get_app_context_by_instance_id (const char *app_id, const char *instance_id, app_context_h *app_context);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_context_destroy")]
+        internal static extern ErrorCode AppContextDestroy(IntPtr handle);
+        //int app_context_destroy(app_context_h app_context)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_context_get_app_id")]
+        internal static extern ErrorCode AppContextGetAppId(IntPtr handle, out string applicationId);
+        //int app_context_get_app_id(app_context_h app_context, char **app_id)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_context_get_package_id")]
+        internal static extern ErrorCode AppContextGetPackageId(IntPtr handle, out string packageId);
+        //int app_context_get_package_id(app_context_h app_context, char **package_id)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_context_get_pid")]
+        internal static extern ErrorCode AppContextGetPid(IntPtr handle, out int processId);
+        //int app_context_get_pid (app_context_h app_context, pid_t *pid)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_context_get_app_state")]
+        internal static extern ErrorCode AppContextGetAppState(IntPtr handle, out int state);
+        //int app_context_get_app_state (app_context_h app_context, app_state_e *state)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_context_is_terminated")]
+        internal static extern ErrorCode AppContextIsTerminated(IntPtr handle, out bool terminated);
+        //int app_context_is_terminated (app_context_h app_context, bool *terminated);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_context_is_equal")]
+        internal static extern ErrorCode AppContextIsEqual(IntPtr first, IntPtr second, out bool equal);
+        //int app_context_is_equal (app_context_h lhs, app_context_h rhs, bool *equal);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_context_is_sub_app")]
+        internal static extern ErrorCode AppContextIsSubApp(IntPtr handle, out bool is_sub_app);
+        //int app_context_is_sub_app (app_context_h app_context, bool *is_sub_app);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_context_clone")]
+        internal static extern ErrorCode AppContextClone(out IntPtr destination, IntPtr source);
+        //int app_context_clone (app_context_h *clone, app_context_h app_context);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_create")]
+        internal static extern ErrorCode AppInfoCreate(string applicationId, out IntPtr handle);
+        //int app_info_create (const char *app_id, app_info_h *app_info);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_destroy")]
+        internal static extern ErrorCode AppInfoDestroy(IntPtr handle);
+        //int app_info_destroy (app_info_h app_info);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_get_app_id")]
+        internal static extern ErrorCode AppInfoGetAppId(IntPtr handle, out string applicationId);
+        //int app_info_get_app_id (app_info_h app_info, char **app_id);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_get_exec")]
+        internal static extern ErrorCode AppInfoGetExec(IntPtr handle, out string exec);
+        //int app_info_get_exec (app_info_h app_info, char **exec);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_get_label")]
+        internal static extern ErrorCode AppInfoGetLabel(IntPtr handle, out string label);
+        //int app_info_get_label (app_info_h app_info, char **label);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_get_localed_label")]
+        internal static extern ErrorCode AppInfoGetLocaledLabel(string applicationId, string locale, out string label);
+        //int app_info_get_localed_label (const char *app_id, const char *locale, char **label);
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_get_icon")]
+        internal static extern ErrorCode AppInfoGetIcon(IntPtr handle, out string path);
+        //int app_info_get_icon (app_info_h app_info, char **path)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_get_package")]
+        internal static extern ErrorCode AppInfoGetPackage(IntPtr handle, out string package);
+        //int app_info_get_package (app_info_h app_info, char **package)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_get_type")]
+        internal static extern ErrorCode AppInfoGetType(IntPtr handle, out string type);
+        //int app_info_get_type (app_info_h app_info, char **type)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_foreach_metadata")]
+        internal static extern ErrorCode AppInfoForeachMetadata(IntPtr handle, AppInfoMetadataCallback callback, IntPtr userData);
+        //int app_info_foreach_metadata(app_info_h app_info, app_info_metadata_cb callback, void *user_data)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_is_nodisplay")]
+        internal static extern ErrorCode AppInfoIsNodisplay(IntPtr handle, out bool noDisplay);
+        //int app_info_is_nodisplay (app_info_h app_info, bool *nodisplay)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_is_equal")]
+        internal static extern ErrorCode AppInfoIsEqual(IntPtr first, IntPtr second, out bool equal);
+        //int app_info_is_equal (app_info_h lhs, app_info_h rhs, bool *equal)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_is_enabled")]
+        internal static extern ErrorCode AppInfoIsEnabled(IntPtr handle, out bool enabled);
+        //int app_info_is_enabled (app_info_h app_info, bool *enabled)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_is_onboot")]
+        internal static extern ErrorCode AppInfoIsOnBoot(IntPtr handle, out bool onBoot);
+        //int app_info_is_onboot (app_info_h app_info, bool *onboot)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_is_preload")]
+        internal static extern ErrorCode AppInfoIsPreLoad(IntPtr handle, out bool preLoaded);
+        //int app_info_is_preload (app_info_h app_info, bool *preload)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_clone")]
+        internal static extern ErrorCode AppInfoClone(out IntPtr destination, IntPtr source);
+        //int app_info_clone(app_info_h * clone, app_info_h app_info)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_filter_create")]
+        internal static extern ErrorCode AppInfoFilterCreate(out IntPtr handle);
+        //int app_info_filter_create(app_info_filter_h * handle)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_filter_destroy")]
+        internal static extern ErrorCode AppInfoFilterDestroy(IntPtr handle);
+        //int app_info_filter_destroy(app_info_filter_h handle)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_filter_add_bool")]
+        internal static extern ErrorCode AppInfoFilterAddBool(IntPtr handle, string property, bool value);
+        //int app_info_filter_add_bool(app_info_filter_h handle, const char *property, const bool value)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_filter_add_string")]
+        internal static extern ErrorCode AppInfoFilterAddString(IntPtr handle, string property, string value);
+        //int app_info_filter_add_string(app_info_filter_h handle, const char *property, const char *value)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_filter_count_appinfo")]
+        internal static extern ErrorCode AppInfoFilterCountAppinfo(IntPtr handle, out int count);
+        //int app_info_filter_count_appinfo(app_info_filter_h handle, int *count)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_filter_foreach_appinfo")]
+        internal static extern ErrorCode AppInfoFilterForeachAppinfo(IntPtr handle, AppInfoFilterCallback callback, IntPtr userData);
+        //int app_info_filter_foreach_appinfo(app_info_filter_h handle, app_info_filter_cb callback, void * user_data)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_metadata_filter_create")]
+        internal static extern ErrorCode AppInfoMetadataFilterCreate(out IntPtr handle);
+        //int app_info_metadata_filter_create (app_info_metadata_filter_h *handle)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_metadata_filter_destroy")]
+        internal static extern ErrorCode AppInfoMetadataFilterDestroy(IntPtr handle);
+        //int app_info_metadata_filter_destroy (app_info_metadata_filter_h handle)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_metadata_filter_add")]
+        internal static extern ErrorCode AppInfoMetadataFilterAdd(IntPtr handle, string key, string value);
+        //int app_info_metadata_filter_add (app_info_metadata_filter_h handle, const char *key, const char *value)
+
+        [DllImport(Libraries.AppManager, EntryPoint = "app_info_metadata_filter_foreach")]
+        internal static extern ErrorCode AppInfoMetadataFilterForeach(IntPtr handle, AppInfoFilterCallback callback, IntPtr userData);
+        //int app_info_metadata_filter_foreach (app_info_metadata_filter_h handle, app_info_filter_cb callback, void *user_data)
+
+        [StructLayout(LayoutKind.Sequential)]
+        internal struct RuaRec
+        {
+            internal int id;
+            internal IntPtr pkgName;
+            internal IntPtr appPath;
+            internal IntPtr arg;
+            internal IntPtr launchTime;
+            internal IntPtr instanceId;
+            internal IntPtr instanceName;
+            internal IntPtr icon;
+            internal IntPtr uri;
+            internal IntPtr image;
+        };
+
+        [DllImport(Libraries.Rua, EntryPoint = "rua_history_get_rec")]
+        internal static extern ErrorCode RuaHistoryGetRecord(out RuaRec record, IntPtr table, int nRows, int nCols, int row);
+        //int rua_history_get_rec(struct rua_rec *rec, char** table, int nrows, int ncols, int row);
+
+        [DllImport(Libraries.Rua, EntryPoint = "rua_history_load_db")]
+        internal static extern ErrorCode RuaHistoryLoadDb(out IntPtr table, out int nRows, out int nCols);
+        //int rua_history_load_db(char*** table, int *nrows, int *ncols);
+
+        [DllImport(Libraries.Rua, EntryPoint = "rua_history_unload_db")]
+        internal static extern ErrorCode RuaHistoryUnLoadDb(ref IntPtr table);
+        //int rua_history_unload_db(char*** table);
+
+        [DllImport(Libraries.Rua, EntryPoint = "rua_delete_history_with_pkgname")]
+        internal static extern ErrorCode RuaDeleteHistoryWithPkgname(string pkgName);
+        //int rua_delete_history_with_pkgname(char* pkg_name);
+
+        [DllImport(Libraries.Rua, EntryPoint = "rua_delete_history_with_apppath")]
+        internal static extern ErrorCode RuaDeleteHistoryWithApppath(string appPath);
+        //int rua_delete_history_with_apppath(char* app_path);
+
+        [DllImport(Libraries.Rua, EntryPoint = "rua_clear_history")]
+        internal static extern ErrorCode RuaClearHistory();
+        //int rua_clear_history(void);
+    }
+}
diff --git a/src/Tizen.Applications.Common/Interop/Interop.Bundle.cs b/src/Tizen.Applications.Common/Interop/Interop.Bundle.cs
new file mode 100755 (executable)
index 0000000..65c314a
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+using Tizen.Applications;
+
+internal static partial class Interop
+{
+    internal static partial class Bundle
+    {
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void Iterator(string key, int type, IntPtr keyval, IntPtr userData);
+
+        [DllImport(Libraries.Bundle, EntryPoint = "bundle_create")]
+        internal static extern SafeBundleHandle Create();
+
+        [DllImport(Libraries.Bundle, EntryPoint = "bundle_free")]
+        internal static extern int DangerousFree(IntPtr handle);
+
+        [DllImport(Libraries.Bundle, EntryPoint = "bundle_del")]
+        internal static extern int RemoveItem(SafeBundleHandle handle, string key);
+
+        [DllImport(Libraries.Bundle, EntryPoint = "bundle_add_str")]
+        internal static extern int AddString(SafeBundleHandle handle, string key, string value);
+
+        [DllImport(Libraries.Bundle, EntryPoint = "bundle_get_type")]
+        internal static extern int GetType(SafeBundleHandle handle, string key);
+
+        [DllImport(Libraries.Bundle, EntryPoint = "bundle_get_str")]
+        internal static extern int GetString(SafeBundleHandle handle, string key, out IntPtr value);
+
+        [DllImport(Libraries.Bundle, EntryPoint = "bundle_add_byte")]
+        internal static extern unsafe int AddByte(SafeBundleHandle handle, string key, byte* value, int size);
+
+        [DllImport(Libraries.Bundle, EntryPoint = "bundle_get_byte")]
+        internal static extern int GetByte(SafeBundleHandle handle, string key, out IntPtr value, out int size);
+
+        [DllImport(Libraries.Bundle, EntryPoint = "bundle_add_str_array")]
+        internal static extern int AddStringArray(SafeBundleHandle handle, string key, string[] value, int size);
+
+        [DllImport(Libraries.Bundle, EntryPoint = "bundle_get_str_array")]
+        internal static extern IntPtr GetStringArray(SafeBundleHandle handle, string key, out int size);
+
+        [DllImport(Libraries.Bundle, EntryPoint = "bundle_foreach")]
+        internal static extern void Foreach(SafeBundleHandle handle, Iterator iterator, IntPtr userData);
+
+        [DllImport(Libraries.Bundle, EntryPoint = "bundle_encode")]
+        internal static extern void BundleEncode(SafeBundleHandle handle, out string str, out int len);
+
+        [DllImport(Libraries.Bundle, EntryPoint = "bundle_decode")]
+        internal static extern SafeBundleHandle BundleDecode(string bundleRaw, int len);
+
+        [DllImport(Libraries.Bundle, EntryPoint = "bundle_dup")]
+        internal static extern SafeBundleHandle DangerousClone(IntPtr handle);
+
+        internal static class UnsafeCode
+        {
+            internal static unsafe int AddItem(SafeBundleHandle handle, string key, byte[] value, int offset, int count)
+            {
+                fixed (byte* pointer = value)
+                {
+                    return AddByte(handle, key, pointer + offset, count);
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Interop/Interop.Glib.cs b/src/Tizen.Applications.Common/Interop/Interop.Glib.cs
new file mode 100755 (executable)
index 0000000..576a6e2
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Glib
+    {
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool GSourceFunc(IntPtr userData);
+
+        [DllImport(Libraries.Glib, EntryPoint = "g_idle_add", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern uint IdleAdd(GSourceFunc d, IntPtr data);
+    }
+}
diff --git a/src/Tizen.Applications.Common/Interop/Interop.Libc.cs b/src/Tizen.Applications.Common/Interop/Interop.Libc.cs
new file mode 100755 (executable)
index 0000000..825599e
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Libc
+    {
+        [DllImport(Libraries.Libc, EntryPoint = "free", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Free(IntPtr ptr);
+    }
+}
diff --git a/src/Tizen.Applications.Common/Interop/Interop.Libraries.cs b/src/Tizen.Applications.Common/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..8a417c6
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string AppCommon = "libcapi-appfw-app-common.so.0";
+        public const string AppControl = "libcapi-appfw-app-control.so.0";
+        public const string AppEvent = "libcapi-appfw-event.so.0";
+        public const string AppManager = "libcapi-appfw-app-manager.so.0";
+        public const string Bundle = "libbundle.so.0";
+        public const string Rua = "librua.so.0";
+        public const string Glib = "libglib-2.0.so.0";
+        public const string Libc = "libc.so.6";
+        public const string Application = "libcapi-appfw-application.so.0";
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.Common.csproj b/src/Tizen.Applications.Common/Tizen.Applications.Common.csproj
new file mode 100755 (executable)
index 0000000..4a6e0ce
--- /dev/null
@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <Import Project="../build/build.props" />
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.3</TargetFramework>
+    <Version>1.5.10</Version>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Applications.Common.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Tizen" Version="$(TizenVersion)" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.Common.snk b/src/Tizen.Applications.Common/Tizen.Applications.Common.snk
new file mode 100755 (executable)
index 0000000..7ac1b00
Binary files /dev/null and b/src/Tizen.Applications.Common/Tizen.Applications.Common.snk differ
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/DefaultCoreBackend.cs b/src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/DefaultCoreBackend.cs
new file mode 100755 (executable)
index 0000000..aabbbeb
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+using Tizen.Internals.Errors;
+
+namespace Tizen.Applications.CoreBackend
+{
+    /// <summary>
+    /// Abstract class to provide default event handlers for apps.
+    /// </summary>
+    public abstract class DefaultCoreBackend : ICoreBackend
+    {
+        /// <summary>
+        /// Low level event types
+        /// </summary>
+        public enum AppEventType
+        {
+            LowMemory = 0,
+            LowBattery,
+            LanguageChanged,
+            DeviceOrientationChanged,
+            RegionFormatChanged,
+            SuspendedStateChanged
+        }
+
+        protected static readonly string LogTag = typeof(DefaultCoreBackend).Namespace;
+
+        protected IDictionary<EventType, object> Handlers = new Dictionary<EventType, object>();
+
+        public DefaultCoreBackend()
+        {
+        }
+
+        ~DefaultCoreBackend()
+        {
+            Dispose(false);
+        }
+
+        public void AddEventHandler(EventType evType, Action handler)
+        {
+            Handlers.Add(evType, handler);
+        }
+
+        public void AddEventHandler<TEventArgs>(EventType evType, Action<TEventArgs> handler) where TEventArgs : EventArgs
+        {
+            Handlers.Add(evType, handler);
+        }
+
+        public virtual void Run(string[] args)
+        {
+            TizenSynchronizationContext.Initialize();
+        }
+
+        public abstract void Exit();
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected abstract void Dispose(bool disposing);
+
+        protected virtual void OnLowMemoryNative(IntPtr infoHandle, IntPtr data)
+        {
+            LowMemoryStatus status = LowMemoryStatus.None;
+            ErrorCode err = Interop.AppCommon.AppEventGetLowMemoryStatus(infoHandle, out status);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to get memory status. Err = " + err);
+            }
+            if (Handlers.ContainsKey(EventType.LowMemory))
+            {
+                var handler = Handlers[EventType.LowMemory] as Action<LowMemoryEventArgs>;
+                handler?.Invoke(new LowMemoryEventArgs(status));
+            }
+        }
+
+        protected virtual void OnLowBatteryNative(IntPtr infoHandle, IntPtr data)
+        {
+            LowBatteryStatus status = LowBatteryStatus.None;
+            ErrorCode err = Interop.AppCommon.AppEventGetLowBatteryStatus(infoHandle, out status);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to get battery status. Err = " + err);
+            }
+            if (Handlers.ContainsKey(EventType.LowBattery))
+            {
+                var handler = Handlers[EventType.LowBattery] as Action<LowBatteryEventArgs>;
+                handler?.Invoke(new LowBatteryEventArgs(status));
+            }
+        }
+
+        protected virtual void OnLocaleChangedNative(IntPtr infoHandle, IntPtr data)
+        {
+            string lang;
+            ErrorCode err = Interop.AppCommon.AppEventGetLanguage(infoHandle, out lang);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to get changed language. Err = " + err);
+            }
+            if (Handlers.ContainsKey(EventType.LocaleChanged))
+            {
+                var handler = Handlers[EventType.LocaleChanged] as Action<LocaleChangedEventArgs>;
+                handler?.Invoke(new LocaleChangedEventArgs(lang));
+            }
+        }
+
+        protected virtual void OnRegionChangedNative(IntPtr infoHandle, IntPtr data)
+        {
+            string region;
+            ErrorCode err = Interop.AppCommon.AppEventGetRegionFormat(infoHandle, out region);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to get changed region format. Err = " + err);
+            }
+            if (Handlers.ContainsKey(EventType.RegionFormatChanged))
+            {
+                var handler = Handlers[EventType.RegionFormatChanged] as Action<RegionFormatChangedEventArgs>;
+                handler?.Invoke(new RegionFormatChangedEventArgs(region));
+            }
+        }
+
+        protected virtual void OnDeviceOrientationChangedNative(IntPtr infoHandle, IntPtr data)
+        {
+            DeviceOrientation orientation;
+            ErrorCode err = Interop.AppCommon.AppEventGetDeviceOrientation(infoHandle, out orientation);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to get deivce orientation. Err = " + err);
+            }
+            if (Handlers.ContainsKey(EventType.DeviceOrientationChanged))
+            {
+                var handler = Handlers[EventType.DeviceOrientationChanged] as Action<DeviceOrientationEventArgs>;
+                handler?.Invoke(new DeviceOrientationEventArgs(orientation));
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/EventType.cs b/src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/EventType.cs
new file mode 100755 (executable)
index 0000000..e24cddf
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+namespace Tizen.Applications.CoreBackend
+{
+    /// <summary>
+    /// Class that represents the type of event for backends. This class can be converted from string type.
+    /// </summary>
+    public class EventType
+    {
+        /// <summary>
+        /// Pre-defined event type. "PreCreated"
+        /// </summary>
+        public static readonly EventType PreCreated = "PreCreated";
+
+        /// <summary>
+        /// Pre-defined event type. "Created"
+        /// </summary>
+        public static readonly EventType Created = "Created";
+
+        /// <summary>
+        /// Pre-defined event type. "Terminated"
+        /// </summary>
+        public static readonly EventType Terminated = "Terminated";
+
+        /// <summary>
+        /// Pre-defined event type. "AppControlReceived"
+        /// </summary>
+        public static readonly EventType AppControlReceived = "AppControlReceived";
+
+        /// <summary>
+        /// Pre-defined event type. "Resumed"
+        /// </summary>
+        public static readonly EventType Resumed = "Resumed";
+
+        /// <summary>
+        /// Pre-defined event type. "Paused"
+        /// </summary>
+        public static readonly EventType Paused = "Paused";
+
+        /// <summary>
+        /// Pre-defined event type. "LowMemory"
+        /// </summary>
+        public static readonly EventType LowMemory = "LowMemory";
+
+        /// <summary>
+        /// Pre-defined event type. "LowBattery"
+        /// </summary>
+        public static readonly EventType LowBattery = "LowBattery";
+
+        /// <summary>
+        /// Pre-defined event type. "LocaleChanged"
+        /// </summary>
+        public static readonly EventType LocaleChanged = "LocaleChanged";
+
+        /// <summary>
+        /// Pre-defined event type. "RegionFormatChanged"
+        /// </summary>
+        public static readonly EventType RegionFormatChanged = "RegionFormatChanged";
+
+        /// <summary>
+        /// Pre-defined event type. "DeviceOrientationChanged"
+        /// </summary>
+        public static readonly EventType DeviceOrientationChanged = "DeviceOrientationChanged";
+
+        private string _typeName;
+
+        /// <summary>
+        /// Initializes the EventType class.
+        /// </summary>
+        /// <param name="name">The name of event type.</param>
+        public EventType(string name)
+        {
+            _typeName = name;
+        }
+
+        /// <summary>
+        /// Returns the name of event type.
+        /// </summary>
+        public override string ToString()
+        {
+            return _typeName;
+        }
+
+        /// <summary>
+        /// Returns the hash code for event type string.
+        /// </summary>
+        public override int GetHashCode()
+        {
+            if (_typeName == null) return 0;
+            return _typeName.GetHashCode();
+        }
+
+        /// <summary>
+        /// Determines whether this instance and a specified object.
+        /// </summary>
+        public override bool Equals(object obj)
+        {
+            EventType other = obj as EventType;
+            return other != null && other._typeName == this._typeName;
+        }
+
+        /// <summary>
+        /// Converts a string to EventType instance.
+        /// </summary>
+        public static implicit operator EventType(string value)
+        {
+            return new EventType(value);
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/ICoreBackend.cs b/src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/ICoreBackend.cs
new file mode 100755 (executable)
index 0000000..0ba8be5
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications.CoreBackend
+{
+    /// <summary>
+    /// Interface that represents the backend lifecycles.
+    /// </summary>
+    public interface ICoreBackend : IDisposable
+    {
+        /// <summary>
+        /// Adds an event handler.
+        /// </summary>
+        /// <param name="evType">The type of event.</param>
+        /// <param name="handler">The handler method without arguments.</param>
+        void AddEventHandler(EventType evType, Action handler);
+
+        /// <summary>
+        /// Adds an event handler.
+        /// </summary>
+        /// <typeparam name="TEventArgs">The EventArgs type used in arguments of the handler method.</typeparam>
+        /// <param name="evType">The type of event.</param>
+        /// <param name="handler">The handler method with a TEventArgs type argument.</param>
+        void AddEventHandler<TEventArgs>(EventType evType, Action<TEventArgs> handler) where TEventArgs : EventArgs;
+
+        /// <summary>
+        /// Runs the mainloop of backend.
+        /// </summary>
+        /// <param name="args"></param>
+        void Run(string[] args);
+
+        /// <summary>
+        /// Exits the mainloop of backend.
+        /// </summary>
+        void Exit();
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs
new file mode 100755 (executable)
index 0000000..1128f02
--- /dev/null
@@ -0,0 +1,1038 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Represents the control message to exchange between applications.
+    /// </summary>
+    /// <example>
+    /// <code>
+    /// public class AppControlExample : UIApplication
+    /// {
+    ///     /// ...
+    ///     protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
+    ///     {
+    ///         AppControl appControl = new AppControl();
+    ///         appControl.ApplicationId = "org.tizen.calculator";
+    ///         AppControl.SendLaunchRequest(appControl, (launchRequest, replyRequest, result) => {
+    ///             // ...
+    ///         });
+    ///     }
+    /// }
+    /// </code>
+    /// </example>
+    public class AppControl
+    {
+        private const string LogTag = "Tizen.Applications";
+
+        private static Dictionary<int, Interop.AppControl.ReplyCallback> s_replyNativeCallbackMaps = new Dictionary<int, Interop.AppControl.ReplyCallback>();
+        private static int s_replyNativeCallbackId = 0;
+
+        private readonly SafeAppControlHandle _handle;
+
+        private string _operation = null;
+        private string _mime = null;
+        private string _uri = null;
+        private string _category = null;
+        private string _applicationId = null;
+        private ExtraDataCollection _extraData = null;
+
+        /// <summary>
+        /// Initializes the instance of the AppControl class.
+        /// </summary>
+        /// <exception cref="InvalidOperationException">Thrown when failed to create AppControl handle.</exception>
+        public AppControl()
+        {
+            Interop.AppControl.ErrorCode err = Interop.AppControl.Create(out _handle);
+            if (err != Interop.AppControl.ErrorCode.None)
+            {
+                throw new InvalidOperationException("Failed to create the appcontrol handle. Err = " + err);
+            }
+        }
+
+        /// <summary>
+        /// Initializes the instance of the AppControl class with parameter.
+        /// </summary>
+        /// <param name="enableAppStartedResultEvent">The flag value to receive an additional launch result event on launch request.</param>
+        /// <exception cref="InvalidOperationException">Thrown when failed to create AppControl handle.</exception>
+        public AppControl(bool enableAppStartedResultEvent)
+        {
+            Interop.AppControl.ErrorCode err = Interop.AppControl.Create(out _handle);
+            if (err != Interop.AppControl.ErrorCode.None)
+            {
+                throw new InvalidOperationException("Failed to create the appcontrol handle. Err = " + err);
+            }
+
+            if (enableAppStartedResultEvent)
+            {
+                err = Interop.AppControl.EnableAppStartedResultEvent(_handle);
+                if (err != Interop.AppControl.ErrorCode.None)
+                {
+                    throw new InvalidOperationException("Failed to set EnableAppStartedResultEvent");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Initializes the instance of the AppControl class with the SafeAppControlHandle.
+        /// </summary>
+        /// <param name="handle"></param>
+        public AppControl(SafeAppControlHandle handle)
+        {
+            if (handle == null)
+            {
+                throw new ArgumentNullException("handle");
+            }
+
+            Interop.AppControl.ErrorCode err = Interop.AppControl.DangerousClone(out _handle, handle.DangerousGetHandle());
+            if (err != Interop.AppControl.ErrorCode.None)
+            {
+                throw new InvalidOperationException("Failed to clone the appcontrol handle. Err = " + err);
+            }
+        }
+
+        private AppControl(IntPtr handle)
+        {
+            Interop.AppControl.ErrorCode err = Interop.AppControl.DangerousClone(out _handle, handle);
+            if (err != Interop.AppControl.ErrorCode.None)
+            {
+                throw new InvalidOperationException("Failed to clone the appcontrol handle. Err = " + err);
+            }
+        }
+
+        #region Public Properties
+
+        /// <summary>
+        /// Gets the SafeAppControlHandle instance.
+        /// </summary>
+        public SafeAppControlHandle SafeAppControlHandle
+        {
+            get
+            {
+                return _handle;
+            }
+        }
+
+        /// <summary>
+        /// Gets and sets the operation to be performed.
+        /// </summary>
+        /// <value>
+        /// The operation is the mandatory information for the launch request. If the operation is not specified,
+        /// AppControlOperations.Default is used for the launch request. If the operation is AppControlOperations.Default,
+        /// the package information is mandatory to explicitly launch the application.
+        /// (if the operation is null for setter, it clears the previous value.)
+        /// </value>
+        /// <example>
+        /// <code>
+        /// AppControl appControl = new AppControl();
+        /// appControl.Operation = AppControlOperations.Default;
+        /// Log.Debug(LogTag, "Operation: " + appControl.Operation);
+        /// </code>
+        /// </example>
+        public string Operation
+        {
+            get
+            {
+                if (String.IsNullOrEmpty(_operation))
+                {
+                    Interop.AppControl.ErrorCode err = Interop.AppControl.GetOperation(_handle, out _operation);
+                    if (err != Interop.AppControl.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get the operation from the appcontrol. Err = " + err);
+                    }
+                }
+                return _operation;
+            }
+            set
+            {
+                Interop.AppControl.ErrorCode err = Interop.AppControl.SetOperation(_handle, value);
+                if (err == Interop.AppControl.ErrorCode.None)
+                {
+                    _operation = value;
+                }
+                else
+                {
+                    Log.Warn(LogTag, "Failed to set the operation to the appcontrol. Err = " + err);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Gets and sets the explicit MIME type of the data.
+        /// </summary>
+        /// <value>
+        /// (if the mime is null for setter, it clears the previous value.)
+        /// </value>
+        /// <example>
+        /// <code>
+        /// AppControl appControl = new AppControl();
+        /// appControl.Mime = "image/jpg";
+        /// Log.Debug(LogTag, "Mime: " + appControl.Mime);
+        /// </code>
+        /// </example>
+        public string Mime
+        {
+            get
+            {
+                if (String.IsNullOrEmpty(_mime))
+                {
+                    Interop.AppControl.ErrorCode err = Interop.AppControl.GetMime(_handle, out _mime);
+                    if (err != Interop.AppControl.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get the mime from the appcontrol. Err = " + err);
+                    }
+                }
+                return _mime;
+            }
+            set
+            {
+                Interop.AppControl.ErrorCode err = Interop.AppControl.SetMime(_handle, value);
+                if (err == Interop.AppControl.ErrorCode.None)
+                {
+                    _mime = value;
+                }
+                else
+                {
+                    Log.Warn(LogTag, "Failed to set the mime to the appcontrol. Err = " + err);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Gets and sets the URI of the data.
+        /// </summary>
+        /// <value>
+        /// Since Tizen 2.4, if the parameter 'uri' is started with 'file://' and
+        /// it is a regular file in this application's data path which can be obtained
+        /// by property DataPath in ApplicationInfo class,
+        /// it will be shared to the callee application.
+        /// Framework will grant a temporary permission to the callee application for this file and
+        /// revoke it when the callee application is terminated.
+        /// The callee application can just read it.
+        /// (if the uri is null for setter, it clears the previous value.)
+        /// </value>
+        /// <example>
+        /// <code>
+        /// public class AppControlExample : UIApplication
+        /// {
+        ///     ...
+        ///     protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
+        ///     {
+        ///         ...
+        ///         AppControl appControl = new AppControl();
+        ///         appContrl.Uri = this.ApplicationInfo.DataPath + "image.jpg";
+        ///         Log.Debug(LogTag, "Set Uri: " + appControl.Uri);
+        ///     }
+        /// }
+        /// </code>
+        /// </example>
+        public string Uri
+        {
+            get
+            {
+                if (String.IsNullOrEmpty(_uri))
+                {
+                    Interop.AppControl.ErrorCode err = Interop.AppControl.GetUri(_handle, out _uri);
+                    if (err != Interop.AppControl.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get the uri from the appcontrol. Err = " + err);
+                    }
+                }
+                return _uri;
+            }
+            set
+            {
+                Interop.AppControl.ErrorCode err = Interop.AppControl.SetUri(_handle, value);
+                if (err == Interop.AppControl.ErrorCode.None)
+                {
+                    _uri = value;
+                }
+                else
+                {
+                    Log.Warn(LogTag, "Failed to set the uri to the appcontrol. Err = " + err);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Gets and sets the explicit category.
+        /// </summary>
+        /// <value>
+        /// (if the category is null for setter, it clears the previous value.)
+        /// </value>
+        public string Category
+        {
+            get
+            {
+                if (String.IsNullOrEmpty(_category))
+                {
+                    Interop.AppControl.ErrorCode err = Interop.AppControl.GetCategory(_handle, out _category);
+                    if (err != Interop.AppControl.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get the category from the appcontrol. Err = " + err);
+                    }
+                }
+                return _category;
+            }
+            set
+            {
+                Interop.AppControl.ErrorCode err = Interop.AppControl.SetCategory(_handle, value);
+                if (err == Interop.AppControl.ErrorCode.None)
+                {
+                    _category = value;
+                }
+                else
+                {
+                    Log.Warn(LogTag, "Failed to set the category to the appcontrol. Err = " + err);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Gets and sets the application id to explicitly launch.
+        /// </summary>
+        /// <value>
+        /// (if the application id is null for setter, it clears the previous value.)
+        /// </value>
+        /// <example>
+        /// <code>
+        /// AppControl appControl = new AppControl();
+        /// appControl.ApplicationId = "org.tizen.calculator";
+        /// Log.Debug(LogTag, "ApplicationId: " + appControl.ApplicationId);
+        /// </code>
+        /// </example>
+        public string ApplicationId
+        {
+            get
+            {
+                if (String.IsNullOrEmpty(_applicationId))
+                {
+                    Interop.AppControl.ErrorCode err = Interop.AppControl.GetAppId(_handle, out _applicationId);
+                    if (err != Interop.AppControl.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get the application id from the AppControl. Err = " + err);
+                    }
+                }
+                return _applicationId;
+            }
+            set
+            {
+                Interop.AppControl.ErrorCode err = Interop.AppControl.SetAppId(_handle, value);
+                if (err == Interop.AppControl.ErrorCode.None)
+                {
+                    _applicationId = value;
+                }
+                else
+                {
+                    Log.Warn(LogTag, "Failed to set the application id to the AppControl. Err = " + err);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Gets and sets the launch mode of the application.
+        /// </summary>
+        /// <value>
+        /// Although LaunchMode were set as AppControlLaunchMode.Group,
+        /// callee application would be launched as single mode
+        /// if the manifest file of callee application defined the launch mode as "single".
+        /// This property can just set the preference of caller application to launch an application.
+        /// Sub-applications which were launched as group mode always have own process.
+        /// Since Tizen 3.0, if launch mode not set in the caller app control,
+        /// this property returns AppControlLaunchMode.Single launch mode.
+        /// </value>
+        /// <example>
+        /// <code>
+        /// AppControl appControl = new AppControl();
+        /// appControl.LaunchMode = AppControlLaunchMode.Group;
+        /// </code>
+        /// </example>
+        public AppControlLaunchMode LaunchMode
+        {
+            get
+            {
+                int value = 0;
+                Interop.AppControl.ErrorCode err = Interop.AppControl.GetLaunchMode(_handle, out value);
+                if (err != Interop.AppControl.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, "Failed to get the LaunchMode from the AppControl. Err = " + err);
+                }
+                return (AppControlLaunchMode)value;
+            }
+            set
+            {
+                Interop.AppControl.ErrorCode err = Interop.AppControl.SetLaunchMode(_handle, (int)value);
+                if (err != Interop.AppControl.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, "Failed to set the LaunchMode to the AppControl. Err = " + err);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Gets the collection of the extra data.
+        /// </summary>
+        /// <value>
+        /// Extra data for communication between AppControls.
+        /// </value>
+        /// <example>
+        /// <code>
+        /// AppControl appControl = new AppControl();
+        /// appControl.ExtraData.Add("key", "value");
+        /// ...
+        /// </code>
+        /// </example>
+        public ExtraDataCollection ExtraData
+        {
+            get
+            {
+                if (_extraData == null)
+                    _extraData = new ExtraDataCollection(_handle);
+                return _extraData;
+            }
+        }
+
+        #endregion // Public Properties
+
+        /// <summary>
+        /// Retrieves all applications that can be launched to handle the given app_control request.
+        /// </summary>
+        /// <param name="control">The AppControl</param>
+        /// <returns>ApplicationIds</returns>
+        /// <exception cref="InvalidOperationException">Thrown when failed because of invalid parameter</exception>
+        /// <example>
+        /// <code>
+        /// IEnumerable<string> applicationIds = AppControl.GetMatchedApplicationIds(control);
+        /// if (applicationIds != null)
+        /// {
+        ///     foreach (string id in applicationIds)
+        ///     {
+        ///         // ...
+        ///     }
+        /// }
+        /// </code>
+        /// </example>
+        public static IEnumerable<string> GetMatchedApplicationIds(AppControl control)
+        {
+            if (control == null)
+            {
+                throw new ArgumentNullException("control");
+            }
+
+            List<string> ids = new List<string>();
+            Interop.AppControl.AppMatchedCallback callback = (handle, applicationId, userData) =>
+            {
+                if (applicationId == null)
+                {
+                        return false;
+                }
+
+                ids.Add(applicationId);
+                return true;
+            };
+
+            Interop.AppControl.ErrorCode err = Interop.AppControl.ForeachAppMatched(control._handle, callback, IntPtr.Zero);
+            if (err != Interop.AppControl.ErrorCode.None)
+            {
+                    throw new InvalidOperationException("Failed to get matched application ids. err = " + err);
+            }
+
+            return ids;
+        }
+
+        /// <summary>
+        /// Sends the launch request.
+        /// </summary>
+        /// <remarks>
+        /// The operation is mandatory information for the launch request.
+        /// If the operation is not specified, AppControlOperations.Default is used by default.
+        /// If the operation is AppControlOperations.Default, the application ID is mandatory to explicitly launch the application. \n
+        /// Since Tizen 2.4, the launch request of the service application over out of packages is restricted by the platform.
+        /// Also, implicit launch requests are NOT delivered to service applications since 2.4.
+        /// To launch a service application, an explicit launch request with application ID given by property ApplicationId MUST be sent.
+        /// </remarks>
+        /// <param name="launchRequest">The AppControl</param>
+        /// <exception cref="ArgumentNullException">Thrown when failed because of a null arguament</exception>
+        /// <exception cref="InvalidOperationException">Thrown when failed because of invalid operation</exception>
+        /// <exception cref="TimeoutException">Thrown when failed because of timeout</exception>
+        /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+        /// <example>
+        /// <code>
+        /// AppControl appControl = new AppControl();
+        /// appControl.ApplicationId = "org.tizen.calculator";
+        /// AppControl.SendLaunchRequest(appControl);
+        /// </code>
+        /// </example>
+        public static void SendLaunchRequest(AppControl launchRequest)
+        {
+            SendLaunchRequest(launchRequest, null);
+        }
+
+        /// <summary>
+        /// Sends the launch request.
+        /// </summary>
+        /// <remarks>
+        /// The operation is mandatory information for the launch request.
+        /// If the operation is not specified, AppControlOperations.Default is used by default.
+        /// If the operation is AppControlOperations.Default, the application ID is mandatory to explicitly launch the application. \n
+        /// Since Tizen 2.4, the launch request of the service application over out of packages is restricted by the platform.
+        /// Also, implicit launch requests are NOT delivered to service applications since 2.4.
+        /// To launch a service application, an explicit launch request with application ID given by property ApplicationId MUST be sent.
+        /// </remarks>
+        /// <param name="launchRequest">The AppControl</param>
+        /// <param name="replyAfterLaunching">The callback function to be called when the reply is delivered</param>
+        /// <exception cref="ArgumentException">Thrown when failed because of arguament is invalid</exception>
+        /// <exception cref="InvalidOperationException">Thrown when failed because of invalid operation</exception>
+        /// <exception cref="TimeoutException">Thrown when failed because of timeout</exception>
+        /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+        /// <example>
+        /// <code>
+        /// AppControl appControl = new AppControl();
+        /// appControl.ApplicationId = "org.tizen.calculator";
+        /// AppControl.SendLaunchRequest(appControl, (launchRequest, replyRequest, result) => {
+        ///     // ...
+        /// });
+        /// </code>
+        /// </example>
+        public static void SendLaunchRequest(AppControl launchRequest, AppControlReplyCallback replyAfterLaunching)
+        {
+            if (launchRequest == null)
+            {
+                throw new ArgumentNullException("launchRequest");
+            }
+
+            Interop.AppControl.ErrorCode err;
+
+            if (replyAfterLaunching != null)
+            {
+                int id = 0;
+                lock (s_replyNativeCallbackMaps)
+                {
+                    id = s_replyNativeCallbackId++;
+                    s_replyNativeCallbackMaps[id] = (launchRequestHandle, replyRequestHandle, result, userData) =>
+                    {
+                        if (replyAfterLaunching != null)
+                        {
+                            Log.Debug(LogTag, "Reply Callback is launched");
+                            replyAfterLaunching(new AppControl(launchRequestHandle), new AppControl(replyRequestHandle), (AppControlReplyResult)result);
+                            if (result != Interop.AppControl.AppStartedStatus)
+                            {
+                                lock (s_replyNativeCallbackMaps)
+                                {
+                                    s_replyNativeCallbackMaps.Remove(id);
+                                }
+                            }
+                        }
+                    };
+                }
+                err = Interop.AppControl.SendLaunchRequest(launchRequest._handle, s_replyNativeCallbackMaps[id], IntPtr.Zero);
+            }
+            else
+            {
+                err = Interop.AppControl.SendLaunchRequest(launchRequest._handle, null, IntPtr.Zero);
+            }
+
+            if (err != Interop.AppControl.ErrorCode.None)
+            {
+                switch (err)
+                {
+                    case Interop.AppControl.ErrorCode.InvalidParameter:
+                        throw new ArgumentException("Invalid Arguments");
+                    case Interop.AppControl.ErrorCode.TimedOut:
+                        throw new TimeoutException("Timed out");
+                    default:
+                        throw new InvalidOperationException("Error = " + err);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Sends the terminate request to the application that is launched by AppControl.
+        /// </summary>
+        /// <remarks>
+        /// You are not allowed to terminate other general applications using this API.
+        /// This API can be used to terminate sub-applications which were launched as group mode by caller application.
+        /// Once callee application is being terminated by this API,
+        /// other applications which were launched by callee application as group mode will be terminated as well
+        /// </remarks>
+        /// <param name="terminateRequest">The AppControl</param>
+        /// <exception cref="ArgumentException">Thrown when failed because of arguament is invalid</exception>
+        /// <exception cref="InvalidOperationException">Thrown when failed because of invalid operation</exception>
+        /// <exception cref="TimeoutException">Thrown when failed because of timeout</exception>
+        /// <example>
+        /// <code>
+        /// AppControl terminateRequest = new AppControl();
+        /// terminateRequest.ApplicationId = "org.tizen.calculator";
+        /// AppControl.SendTerminateRequest(terminateRequest);
+        /// </code>
+        /// </example>
+        public static void SendTerminateRequest(AppControl terminateRequest)
+        {
+            if (terminateRequest == null)
+            {
+                throw new ArgumentNullException("terminateRequest");
+            }
+            Interop.AppControl.ErrorCode err;
+
+            err = Interop.AppControl.SendTerminateRequest(terminateRequest._handle);
+
+            if (err != Interop.AppControl.ErrorCode.None)
+            {
+                switch (err)
+                {
+                    case Interop.AppControl.ErrorCode.InvalidParameter:
+                        throw new ArgumentException("Invalid Arguments");
+                    case Interop.AppControl.ErrorCode.TimedOut:
+                        throw new TimeoutException("Timed out");
+                    default:
+                        throw new InvalidOperationException("Error = " + err);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Class for Extra Data
+        /// </summary>
+        public class ExtraDataCollection
+        {
+            private readonly SafeAppControlHandle _handle;
+
+            internal ExtraDataCollection(SafeAppControlHandle handle)
+            {
+                _handle = handle;
+            }
+
+            /// <summary>
+            /// Adds extra data.
+            /// </summary>
+            /// <remarks>
+            /// The function replaces any existing value for the given key.
+            /// </remarks>
+            /// <param name="key">The name of the extra data</param>
+            /// <param name="value">The value associated with the given key</param>
+            /// <exception cref="ArgumentNullException">Thrown when key or value is a zero-length string</exception>
+            /// <exception cref="ArgumentException">Thrown when the application tries to use the same key with system-defined key</exception>
+            /// <example>
+            /// <code>
+            /// AppControl appControl = new AppControl();
+            /// appControl.ExtraData.Add("myKey", "myValue");
+            /// </code>
+            /// </example>
+            public void Add(string key, string value)
+            {
+                if (string.IsNullOrEmpty(key))
+                {
+                    throw new ArgumentNullException("key");
+                }
+                if (string.IsNullOrEmpty(value))
+                {
+                    throw new ArgumentNullException("value");
+                }
+                Interop.AppControl.ErrorCode err = Interop.AppControl.AddExtraData(_handle, key, value);
+                if (err != Interop.AppControl.ErrorCode.None)
+                {
+                    switch (err)
+                    {
+                        case Interop.AppControl.ErrorCode.InvalidParameter:
+                            throw new ArgumentException("Invalid parameter: key or value is a zero-length string");
+                        case Interop.AppControl.ErrorCode.KeyRejected:
+                            throw new ArgumentException("Key is rejected: the key is system-defined key.");
+                        default:
+                            throw new InvalidOperationException("Error = " + err);
+                    }
+                }
+            }
+
+            /// <summary>
+            /// Adds extra data.
+            /// </summary>
+            /// <remarks>
+            /// The function replaces any existing value for the given key.
+            /// </remarks>
+            /// <param name="key">The name of the extra data</param>
+            /// <param name="value">The value associated with the given key</param>
+            /// <exception cref="ArgumentNullException">Thrown when key or value is a zero-length string</exception>
+            /// <exception cref="ArgumentException">Thrown when the application tries to use the same key with system-defined key</exception>
+            /// <example>
+            /// <code>
+            /// AppControl appControl = new AppControl();
+            /// string[] myValues = new string[] { "first", "second", "third" };
+            /// appControl.ExtraData.Add("myKey", myValues);
+            /// </code>
+            /// </example>
+            public void Add(string key, IEnumerable<string> value)
+            {
+                if (string.IsNullOrEmpty(key))
+                {
+                    throw new ArgumentNullException("key");
+                }
+                if (value == null)
+                {
+                    throw new ArgumentNullException("value");
+                }
+                string[] valueArray = value.ToArray();
+                Interop.AppControl.ErrorCode err = Interop.AppControl.AddExtraDataArray(_handle, key, valueArray, valueArray.Length);
+                if (err != Interop.AppControl.ErrorCode.None)
+                {
+                    switch (err)
+                    {
+                        case Interop.AppControl.ErrorCode.InvalidParameter:
+                            throw new ArgumentException("Invalid parameter: key or value is a zero-length string");
+                        case Interop.AppControl.ErrorCode.KeyRejected:
+                            throw new ArgumentException("Key is rejected: the key is system-defined key.");
+                        default:
+                            throw new InvalidOperationException("Error = " + err);
+                    }
+                }
+            }
+
+            /// <summary>
+            /// Gets the extra data.
+            /// </summary>
+            /// <typeparam name="T">Only string and IEnumerable&lt;string&gt;</typeparam>
+            /// <param name="key">The name of extra data</param>
+            /// <returns>The value associated with the given key</returns>
+            /// <exception cref="ArgumentNullException">Thrown when the key is invalid parameter</exception>
+            /// <exception cref="KeyNotFoundException">Thrown when the key is not found</exception>
+            /// <exception cref="ArgumentException">Thrown when the key is rejected</exception>
+            /// <example>
+            /// <code>
+            /// AppControl appControl = new AppControl();
+            /// string myValue = appControl.ExtraData.Get<string>("myKey");
+            /// </code>
+            /// </example>
+            public T Get<T>(string key)
+            {
+                object ret = Get(key);
+                return (T)ret;
+            }
+
+            /// <summary>
+            /// Gets the extra data.
+            /// </summary>
+            /// <param name="key">The name of extra data</param>
+            /// <returns>The value associated with the given key</returns>
+            /// <exception cref="ArgumentNullException">Thrown when the key is invalid parameter</exception>
+            /// <exception cref="KeyNotFoundException">Thrown when the key is not found</exception>
+            /// <exception cref="ArgumentException">Thrown when the key is rejected</exception>
+            /// <example>
+            /// <code>
+            /// AppControl appControl = new AppControl();
+            /// string myValue = appControl.ExtraData.Get("myKey") as string;
+            /// if (myValue != null)
+            /// {
+            ///     // ...
+            /// }
+            /// </code>
+            /// </example>
+            public object Get(string key)
+            {
+                if (IsCollection(key))
+                {
+                    return GetDataCollection(key);
+                }
+                else
+                {
+                    return GetData(key);
+                }
+            }
+
+            /// <summary>
+            /// Gets all keys in extra data.
+            /// </summary>
+            /// <returns>The keys in the AppControl</returns>
+            /// <exception cref="InvalidOperationException">Thrown when invalid parameter</exception>
+            /// <example>
+            /// <code>
+            /// AppControl appControl = new AppControl();
+            /// IEnumerable<string> keys = appControl.GetKeys();
+            /// if (keys != null)
+            /// {
+            ///     foreach (string key in keys)
+            ///     {
+            ///         // ...
+            ///     }
+            /// }
+            /// </code>
+            /// </example>
+            public IEnumerable<string> GetKeys()
+            {
+                List<string> keys = new List<string>();
+                Interop.AppControl.ExtraDataCallback callback = (handle, key, userData) =>
+                {
+                    if (key == null)
+                    {
+                        return false;
+                    }
+
+                    keys.Add(key);
+                    return true;
+                };
+
+                Interop.AppControl.ErrorCode err = Interop.AppControl.ForeachExtraData(_handle, callback, IntPtr.Zero);
+                if (err != Interop.AppControl.ErrorCode.None)
+                {
+                    throw new InvalidOperationException("Failed to get keys. err = " + err);
+                }
+
+                return keys;
+            }
+
+            /// <summary>
+            /// Tries getting the extra data.
+            /// </summary>
+            /// <param name="key">The name of extra data</param>
+            /// <param name="value">The value associated with the given key</param>
+            /// <returns>The result whether getting the value is done</returns>
+            /// <exception cref="ArgumentNullException">Thrown when the key is invalid parameter</exception>
+            /// <exception cref="KeyNotFoundException">Thrown when the key is not found</exception>
+            /// <exception cref="ArgumentException">Thrown when the key is rejected</exception>
+            /// <example>
+            /// <code>
+            /// AppControl appControl = new AppControl();
+            /// string myValue = string.Empty;
+            /// bool result = appControl.ExtraData.TryGet("myKey", out myValue);
+            /// if (result != null)
+            /// {
+            ///     // ...
+            /// }
+            /// </code>
+            /// </example>
+            public bool TryGet(string key, out string value)
+            {
+                if (string.IsNullOrEmpty(key))
+                {
+                    throw new ArgumentNullException("key");
+                }
+                Interop.AppControl.GetExtraData(_handle, key, out value);
+                if (value != null)
+                {
+                    return true;
+                }
+                else
+                {
+                    value = default(string);
+                    return false;
+                }
+            }
+
+            /// <summary>
+            /// Tries getting the extra data.
+            /// </summary>
+            /// <param name="key">The name of extra data</param>
+            /// <param name="value">The value associated with the given key</param>
+            /// <returns>The result whether getting the value is done</returns>
+            /// <exception cref="ArgumentNullException">Thrown when the key is invalid parameter</exception>
+            /// <exception cref="KeyNotFoundException">Thrown when the key is not found</exception>
+            /// <exception cref="ArgumentException">Thrown when the key is rejected</exception>
+            /// <example>
+            /// <code>
+            /// AppControl appControl = new AppControl();
+            /// IEnumerable<string> myValue = null;
+            /// bool result = appControl.ExtraData.TryGet("myKey", out myValue);
+            /// if (result)
+            /// {
+            ///     foreach (string value in myValue)
+            ///     {
+            ///         // ...
+            ///     }
+            /// }
+            /// </code>
+            /// </example>
+            public bool TryGet(string key, out IEnumerable<string> value)
+            {
+                if (string.IsNullOrEmpty(key))
+                {
+                    throw new ArgumentNullException("key");
+                }
+                IntPtr valuePtr = IntPtr.Zero;
+                int len = -1;
+                Interop.AppControl.ErrorCode err = Interop.AppControl.GetExtraDataArray(_handle, key, out valuePtr, out len);
+                if (err == Interop.AppControl.ErrorCode.None && valuePtr != IntPtr.Zero)
+                {
+                    List<string> stringList = new List<string>();
+                    for (int i = 0; i < len; ++i)
+                    {
+                        IntPtr charArr = Marshal.ReadIntPtr(valuePtr, IntPtr.Size * i);
+                        stringList.Add(Marshal.PtrToStringAnsi(charArr));
+                        Interop.Libc.Free(charArr);
+                    }
+                    Interop.Libc.Free(valuePtr);
+                    value = stringList;
+                    return true;
+                }
+                else
+                {
+                    value = default(IEnumerable<string>);
+                    return false;
+                }
+            }
+
+            /// <summary>
+            /// Removes the extra data.
+            /// </summary>
+            /// <param name="key">The name of the extra data</param>
+            /// <exception cref="ArgumentNullException">Thrown when the key is a zero-length string</exception>
+            /// <exception cref="KeyNotFoundException">Thrown when the key is not found</exception>
+            /// <exception cref="ArgumentException">Thrown when the key is rejected</exception>
+            /// <example>
+            /// <code>
+            /// AppControl appControl = new AppControl();
+            /// appControl.ExtraData.Remove("myKey");
+            /// </code>
+            /// </example>
+            public void Remove(string key)
+            {
+                if (string.IsNullOrEmpty(key))
+                {
+                    throw new ArgumentNullException("key");
+                }
+                Interop.AppControl.ErrorCode err = Interop.AppControl.RemoveExtraData(_handle, key);
+                if (err != Interop.AppControl.ErrorCode.None)
+                {
+                    switch (err)
+                    {
+                        case Interop.AppControl.ErrorCode.InvalidParameter:
+                            throw new ArgumentException("Invalid parameter: key is a zero-length string");
+                        case Interop.AppControl.ErrorCode.KeyNotFound:
+                            throw new KeyNotFoundException("Key is not found"); ;
+                        case Interop.AppControl.ErrorCode.KeyRejected:
+                            throw new ArgumentException("Key is rejected: the key is system-defined key.");
+                        default:
+                            throw new InvalidOperationException("Error = " + err);
+                    }
+                }
+            }
+
+            /// <summary>
+            /// Counts keys in the extra data.
+            /// </summary>
+            /// <returns>The number of counting keys</returns>
+            /// <exception cref="InvalidOperationException">Thrown when invalid parameter</exception>
+            /// <example>
+            /// <code>
+            /// AppControl appControl = new AppControl();
+            /// int numberOfKeys = appControl.ExtraData.Count();
+            /// </code>
+            /// </example>
+            public int Count()
+            {
+                return GetKeys().Count();
+            }
+
+            /// <summary>
+            /// Checks whether the extra data associated with the given key is of collection data type.
+            /// </summary>
+            /// <param name="key">The name of the extra data</param>
+            /// <returns>If true the extra data is of array data type, otherwise false</returns>
+            /// <exception cref="ArgumentNullException">Thrown when the key is a zero-length string</exception>
+            /// <exception cref="InvalidOperationException">Thrown when failed to check the key</exception>
+            /// <example>
+            /// <code>
+            /// AppControl appControl = new AppControl();
+            /// bool result = appControl.ExtraData.IsCollection("myKey");
+            /// </code>
+            /// </example>
+            public bool IsCollection(string key)
+            {
+                if (string.IsNullOrEmpty(key))
+                {
+                    throw new ArgumentNullException("key");
+                }
+                bool isArray = false;
+                Interop.AppControl.ErrorCode err = Interop.AppControl.IsExtraDataArray(_handle, key, out isArray);
+                if (err != Interop.AppControl.ErrorCode.None)
+                {
+                    throw new InvalidOperationException("Error = " + err);
+                }
+                return isArray;
+            }
+
+            private string GetData(string key)
+            {
+                if (string.IsNullOrEmpty(key))
+                {
+                    throw new ArgumentNullException("key");
+                }
+                string value = string.Empty;
+                Interop.AppControl.ErrorCode err = Interop.AppControl.GetExtraData(_handle, key, out value);
+                if (err != Interop.AppControl.ErrorCode.None)
+                {
+                    switch (err)
+                    {
+                        case Interop.AppControl.ErrorCode.InvalidParameter:
+                            throw new ArgumentException("Invalid parameter: key is a zero-length string");
+                        case Interop.AppControl.ErrorCode.KeyNotFound:
+                            throw new KeyNotFoundException("Key is not found"); ;
+                        case Interop.AppControl.ErrorCode.InvalidDataType:
+                            throw new ArgumentException("Invalid data type: value is data collection type");
+                        case Interop.AppControl.ErrorCode.KeyRejected:
+                            throw new ArgumentException("Key is rejected: the key is system-defined key.");
+                        default:
+                            throw new InvalidOperationException("Error = " + err);
+                    }
+                }
+                return value;
+            }
+
+            private IEnumerable<string> GetDataCollection(string key)
+            {
+                if (string.IsNullOrEmpty(key))
+                {
+                    throw new ArgumentNullException("key");
+                }
+                IntPtr valuePtr = IntPtr.Zero;
+                int len = -1;
+                Interop.AppControl.ErrorCode err = Interop.AppControl.GetExtraDataArray(_handle, key, out valuePtr, out len);
+                if (err != Interop.AppControl.ErrorCode.None)
+                {
+                    switch (err)
+                    {
+                        case Interop.AppControl.ErrorCode.InvalidParameter:
+                            throw new ArgumentException("Invalid parameter: key is a zero-length string");
+                        case Interop.AppControl.ErrorCode.KeyNotFound:
+                            throw new KeyNotFoundException("Key is not found"); ;
+                        case Interop.AppControl.ErrorCode.InvalidDataType:
+                            throw new ArgumentException("Invalid data type: value is data collection type");
+                        case Interop.AppControl.ErrorCode.KeyRejected:
+                            throw new ArgumentException("Key is rejected: the key is system-defined key.");
+                        default:
+                            throw new InvalidOperationException("Error = " + err);
+                    }
+                }
+
+                List<string> valueArray = new List<string>();
+                if (valuePtr != IntPtr.Zero)
+                {
+                    for (int i = 0; i < len; ++i)
+                    {
+                        IntPtr charArr = Marshal.ReadIntPtr(valuePtr, IntPtr.Size * i);
+                        valueArray.Add(Marshal.PtrToStringAnsi(charArr));
+                        Interop.Libc.Free(charArr);
+                    }
+                    Interop.Libc.Free(valuePtr);
+                }
+                return valueArray;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/AppControlData.cs b/src/Tizen.Applications.Common/Tizen.Applications/AppControlData.cs
new file mode 100755 (executable)
index 0000000..fddfd09
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Data of the AppControl.
+    /// </summary>
+    public static class AppControlData
+    {
+        /// <summary>
+        /// Subject
+        /// </summary>
+        public const string Subject = "http://tizen.org/appcontrol/data/subject";
+
+        /// <summary>
+        /// Recipients
+        /// </summary>
+        public const string To = "http://tizen.org/appcontrol/data/to";
+
+        /// <summary>
+        /// E-mail addresses that should be carbon copied
+        /// </summary>
+        public const string Cc = "http://tizen.org/appcontrol/data/cc";
+
+        /// <summary>
+        /// E-mail addresses that should be blind carbon copied
+        /// </summary>
+        public const string Bcc = "http://tizen.org/appcontrol/data/bcc";
+
+        /// <summary>
+        /// Text
+        /// </summary>
+        public const string Text = "http://tizen.org/appcontrol/data/text";
+
+        /// <summary>
+        /// Title
+        /// </summary>
+        public const string Title = "http://tizen.org/appcontrol/data/title";
+
+        /// <summary>
+        /// Selected items
+        /// </summary>
+        public const string Selected = "http://tizen.org/appcontrol/data/selected";
+
+        /// <summary>
+        /// Paths of items
+        /// </summary>
+        public const string Path = "http://tizen.org/appcontrol/data/path";
+
+        /// <summary>
+        /// Selection mode. ("single" or "multiple")
+        /// </summary>
+        public const string SectionMode = "http://tizen.org/appcontrol/data/selection_mode";
+
+        /// <summary>
+        /// All-day mode of event ("true" or "false")
+        /// </summary>
+        public const string AllDay = "http://tizen.org/appcontrol/data/calendar/all_day";
+
+        /// <summary>
+        /// Start time of event (format: YYYY-MM-DD HH:MM:SS)
+        /// </summary>
+        public const string StartTime = "http://tizen.org/appcontrol/data/calendar/start_time";
+
+        /// <summary>
+        /// End time of event (format: YYYY-MM-DD HH:MM:SS)
+        /// </summary>
+        public const string Endtime = "http://tizen.org/appcontrol/data/calendar/end_time";
+
+        /// <summary>
+        /// E-mail addressed
+        /// </summary>
+        public const string Email = "http://tizen.org/appcontrol/data/email";
+
+        /// <summary>
+        /// Phone numbers
+        /// </summary>
+        public const string Phone = "http://tizen.org/appcontrol/data/phone";
+
+        /// <summary>
+        /// URLs
+        /// </summary>
+        public const string Url = "http://tizen.org/appcontrol/data/url";
+
+        /// <summary>
+        /// IDs
+        /// </summary>
+        public const string Ids = "http://tizen.org/appcontrol/data/id";
+
+        /// <summary>
+        /// Type
+        /// </summary>
+        public const string Type = "http://tizen.org/appcontrol/data/type";
+
+        /// <summary>
+        /// Total count
+        /// </summary>
+        public const string TotalCount = "http://tizen.org/appcontrol/data/total_count";
+
+        /// <summary>
+        /// Total size (unit : bytes)
+        /// </summary>
+        public const string TotalSize = "http://tizen.org/appcontrol/data/total_size";
+
+        /// <summary>
+        /// Name
+        /// </summary>
+        public const string Name = "http://tizen.org/appcontrol/data/name";
+
+        /// <summary>
+        /// Location
+        /// </summary>
+        public const string Location = "http://tizen.org/appcontrol/data/location";
+
+        /// <summary>
+        /// Select the type of input method
+        /// </summary>
+        public const string InputType = "http://tizen.org/appcontrol/data/input_type";
+
+        /// <summary>
+        /// Send the pre inputted text such as "http://" in web
+        /// </summary>
+        public const string InputDefaultText = "http://tizen.org/appcontrol/data/input_default_text";
+
+        /// <summary>
+        /// Send guide text to show to user such as "Input user name"
+        /// </summary>
+        public const string InputGuideText = "http://tizen.org/appcontrol/data/input_guide_text";
+
+        /// <summary>
+        /// Send text to receive answer result from smart reply
+        /// </summary>
+        public const string InputPredictionHint = "http://tizen.org/appcontrol/data/input_prediction_hint";
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/AppControlLaunchMode.cs b/src/Tizen.Applications.Common/Tizen.Applications/AppControlLaunchMode.cs
new file mode 100755 (executable)
index 0000000..728612c
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for App Control Launch Mode.
+    /// </summary>
+    public enum AppControlLaunchMode
+    {
+        /// <summary>
+        /// Prefer to launch an application as single mode
+        /// </summary>
+        Single = 0,
+
+        /// <summary>
+        /// Prefer to launch an application as group mode
+        /// </summary>
+        Group,
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/AppControlOperations.cs b/src/Tizen.Applications.Common/Tizen.Applications/AppControlOperations.cs
new file mode 100755 (executable)
index 0000000..c045651
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Operations of the AppControl.
+    /// </summary>
+    public static class AppControlOperations
+    {
+        /// <summary>
+        /// An explicit launch for a homescreen application.
+        /// </summary>
+        public const string Main = "http://tizen.org/appcontrol/operation/main";
+
+        /// <summary>
+        /// An explicit launch for an application that excludes a homescreen application.
+        /// </summary>
+        public const string Default = "http://tizen.org/appcontrol/operation/default";
+
+        /// <summary>
+        /// Provides an editable access to the given data.
+        /// </summary>
+        public const string Edit = "http://tizen.org/appcontrol/operation/edit";
+
+        /// <summary>
+        /// Displays the data.
+        /// </summary>
+        public const string View = "http://tizen.org/appcontrol/operation/view";
+
+        /// <summary>
+        /// Picks items.
+        /// </summary>
+        public const string Pick = "http://tizen.org/appcontrol/operation/pick";
+
+        /// <summary>
+        /// Creates contents.
+        /// </summary>
+        public const string CreateContent = "http://tizen.org/appcontrol/operation/create_content";
+
+        /// <summary>
+        /// Performs a call to someone.
+        /// </summary>
+        public const string Call = "http://tizen.org/appcontrol/operation/call";
+
+        /// <summary>
+        /// Delivers some data to someone else.
+        /// </summary>
+        public const string Send = "http://tizen.org/appcontrol/operation/send";
+
+        /// <summary>
+        /// Delivers text data to someone else.
+        /// </summary>
+        public const string SendText = "http://tizen.org/appcontrol/operation/send_text";
+
+        /// <summary>
+        /// Shares an item with someone else.
+        /// </summary>
+        public const string Share = "http://tizen.org/appcontrol/operation/share";
+
+        /// <summary>
+        /// Shares multiple items with someone else.
+        /// </summary>
+        public const string MultiShare = "http://tizen.org/appcontrol/operation/multi_share";
+
+        /// <summary>
+        /// Shares text data with someone else.
+        /// </summary>
+        public const string ShareText = "http://tizen.org/appcontrol/operation/share_text";
+
+        /// <summary>
+        /// Dials a number. This shows a UI with the number to be dialed, allowing the user to explicitly initiate the call.
+        /// </summary>
+        public const string Dial = "http://tizen.org/appcontrol/operation/dial";
+
+        /// <summary>
+        /// Performs a search.
+        /// </summary>
+        public const string Search = "http://tizen.org/appcontrol/operation/search";
+
+        /// <summary>
+        /// Downloads items.
+        /// </summary>
+        public const string Download = "http://tizen.org/appcontrol/operation/download";
+
+        /// <summary>
+        /// Prints contents.
+        /// </summary>
+        public const string Print = "http://tizen.org/appcontrol/operation/print";
+
+        /// <summary>
+        /// Composes a message.
+        /// </summary>
+        public const string Compose = "http://tizen.org/appcontrol/operation/compose";
+
+        /// <summary>
+        /// Can be launched by interested System-Event.
+        /// </summary>
+        public const string LaunchOnEvent = "http://tizen.org/appcontrol/operation/launch_on_event";
+
+        /// <summary>
+        /// Adds an item.
+        /// </summary>
+        public const string Add = "http://tizen.org/appcontrol/operation/add";
+
+        /// <summary>
+        /// Captures images by camera applications.
+        /// </summary>
+        public const string ImageCapture = "http://tizen.org/appcontrol/operation/image_capture";
+
+        /// <summary>
+        /// Captures videos by camera applications.
+        /// </summary>
+        public const string VideoCapture = "http://tizen.org/appcontrol/operation/video_capture";
+
+        /// <summary>
+        /// Shows system settings.
+        /// </summary>
+        public const string Setting = "http://tizen.org/appcontrol/operation/setting";
+
+        /// <summary>
+        /// Shows settings to enable Bluetooth.
+        /// </summary>
+        public const string SettingBluetoothEnable = "http://tizen.org/appcontrol/operation/setting/bt_enable";
+
+        /// <summary>
+        /// Shows settings to configure Bluetooth visibility.
+        /// </summary>
+        public const string SettingBluetoothVisibility = "http://tizen.org/appcontrol/operation/setting/bt_visibility";
+
+        /// <summary>
+        /// Shows settings to allow configuration of current location sources.
+        /// </summary>
+        public const string SettingLocation = "http://tizen.org/appcontrol/operation/setting/location";
+
+        /// <summary>
+        /// Shows NFC settings.
+        /// </summary>
+        public const string SettingNfc = "http://tizen.org/appcontrol/operation/setting/nfc";
+
+        /// <summary>
+        /// Shows settings to allow configuration of Wi-Fi.
+        /// </summary>
+        public const string SettingWifi = "http://tizen.org/appcontrol/operation/setting/wifi";
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/AppControlReceivedEventArgs.cs b/src/Tizen.Applications.Common/Tizen.Applications/AppControlReceivedEventArgs.cs
new file mode 100755 (executable)
index 0000000..7318466
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Arguments for the event that raised when the application receives the AppControl.
+    /// </summary>
+    public class AppControlReceivedEventArgs : EventArgs
+    {
+        /// <summary>
+        /// Initializes AppControlReceivedEventArgs class.
+        /// </summary>
+        /// <param name="appControl"></param>
+        public AppControlReceivedEventArgs(ReceivedAppControl appControl)
+        {
+            ReceivedAppControl = appControl;
+        }
+
+        /// <summary>
+        /// The received AppControl.
+        /// </summary>
+        public ReceivedAppControl ReceivedAppControl { get; private set; }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/AppControlReplyCallback.cs b/src/Tizen.Applications.Common/Tizen.Applications/AppControlReplyCallback.cs
new file mode 100755 (executable)
index 0000000..1a9c6c9
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Reply callback for the launch request
+    /// </summary>
+    /// <param name="launchRequest">The AppControl of the launch request that has been sent</param>
+    /// <param name="replyRequest">The AppControl in which the results of the callee are contained</param>
+    /// <param name="result">The result of the launch request</param>
+    public delegate void AppControlReplyCallback(AppControl launchRequest, AppControl replyRequest, AppControlReplyResult result);
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/AppControlReplyResult.cs b/src/Tizen.Applications.Common/Tizen.Applications/AppControlReplyResult.cs
new file mode 100755 (executable)
index 0000000..7fed628
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for App Control Result.
+    /// </summary>
+    public enum AppControlReplyResult
+    {
+        /// <summary>
+        /// Callee application launched actually
+        /// </summary>
+        AppStarted = 1,
+
+        /// <summary>
+        /// Operation is succeeded
+        /// </summary>
+        Succeeded = 0,
+
+        /// <summary>
+        /// Operation is failed by the callee
+        /// </summary>
+        Failed = -1,
+
+        /// <summary>
+        /// Operation is canceled by the platform
+        /// </summary>
+        Canceled = -2,
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/Application.cs b/src/Tizen.Applications.Common/Tizen.Applications/Application.cs
new file mode 100755 (executable)
index 0000000..2049f57
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Class that represents a Tizen application.
+    /// </summary>
+    public abstract class Application : IDisposable
+    {
+        internal const string LogTag = "Tizen.Applications";
+
+        private static Application s_CurrentApplication = null;
+
+        private object _lock = new object();
+
+        private DirectoryInfo _directoryInfo;
+        private ApplicationInfo _applicationInfo;
+
+        /// <summary>
+        /// Gets the instance of current application.
+        /// </summary>
+        public static Application Current { get { return s_CurrentApplication; } }
+
+        /// <summary>
+        /// Gets the class representing directory information of current application.
+        /// </summary>
+        public DirectoryInfo DirectoryInfo
+        {
+            get
+            {
+                lock (_lock)
+                {
+                    if (_directoryInfo == null)
+                    {
+                        _directoryInfo = new DirectoryInfo();
+                    }
+                }
+                return _directoryInfo;
+            }
+        }
+
+        /// <summary>
+        /// Gets the class representing information of current application.
+        /// </summary>
+        public ApplicationInfo ApplicationInfo
+        {
+            get
+            {
+                lock (_lock)
+                {
+                    if (_applicationInfo == null)
+                    {
+                        string appId = string.Empty;
+                        Interop.AppCommon.AppGetId(out appId);
+                        if (!string.IsNullOrEmpty(appId))
+                        {
+                            _applicationInfo = new ApplicationInfo(appId);
+                        }
+                    }
+                }
+                return _applicationInfo;
+            }
+        }
+
+        /// <summary>
+        /// Runs the application's main loop.
+        /// </summary>
+        /// <param name="args">Arguments from commandline.</param>
+        public virtual void Run(string[] args)
+        {
+            if (args == null)
+            {
+                throw new ArgumentNullException("args");
+            }
+            s_CurrentApplication = this;
+        }
+
+        /// <summary>
+        /// Exits the main loop of application. 
+        /// </summary>
+        public abstract void Exit();
+
+        #region IDisposable Support
+        private bool _disposedValue = false; // To detect redundant calls
+
+        /// <summary>
+        /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
+        /// </summary>
+        /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!_disposedValue)
+            {
+                if (disposing)
+                {
+                    if (_applicationInfo != null)
+                    {
+                        _applicationInfo.Dispose();
+                    }
+                }
+
+                _disposedValue = true;
+            }
+        }
+
+        /// <summary>
+        /// Finalizer of the Application class.
+        /// </summary>
+        ~Application()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// Releases all resources used by the Application class.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+        #endregion
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationDisabledEventArgs.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationDisabledEventArgs.cs
new file mode 100644 (file)
index 0000000..5b185d3
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Arguments for the event that is raised when the application is disabled.
+    /// </summary>
+    public class ApplicationDisabledEventArgs : EventArgs
+    {
+        private readonly ApplicationEventState _eventState;
+        private readonly string _applicationId;
+
+        internal ApplicationDisabledEventArgs(string appId, ApplicationEventState eventState)
+        {
+            _applicationId = appId;
+            _eventState = eventState;
+        }
+
+        /// <summary>
+        /// The Id of the application
+        /// </summary>
+        public string ApplicationId { get { return _applicationId; } }
+
+        /// <summary>
+        /// The Event state of the application
+        /// </summary>
+        public ApplicationEventState EventState { get { return _eventState; } }
+    }
+}
+
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationEnabledEventArgs.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationEnabledEventArgs.cs
new file mode 100644 (file)
index 0000000..fa72e8a
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Arguments for the event that is raised when the application is enabled.
+    /// </summary>
+    public class ApplicationEnabledEventArgs : EventArgs
+    {
+        private readonly ApplicationEventState _eventState;
+        private readonly string _applicationId;
+
+        internal ApplicationEnabledEventArgs(string appId, ApplicationEventState eventState)
+        {
+            _applicationId = appId;
+            _eventState = eventState;
+        }
+
+        /// <summary>
+        /// The Id of the application
+        /// </summary>
+        public string ApplicationId { get { return _applicationId; } }
+
+        /// <summary>
+        /// The Event state of the application
+        /// </summary>
+        public ApplicationEventState EventState { get { return _eventState; } }
+    }
+}
+
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationEventState.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationEventState.cs
new file mode 100644 (file)
index 0000000..8ef9597
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration of the application event state
+    /// </summary>
+    public enum ApplicationEventState
+    {
+        /// <summary>
+        /// Processing Started.
+        /// </summary>
+        Started = Interop.ApplicationManager.AppManagerEventState.Started,
+        /// <summary>
+        /// Processing Completed.
+        /// </summary>
+        Completed = Interop.ApplicationManager.AppManagerEventState.Completed,
+        /// <summary>
+        /// Processing Failed.
+        /// </summary>
+        Failed = Interop.ApplicationManager.AppManagerEventState.Failed
+    }
+}
+
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationInfo.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationInfo.cs
new file mode 100755 (executable)
index 0000000..34d7b19
--- /dev/null
@@ -0,0 +1,406 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// This class provides methods and properties to get information of the application.
+    /// </summary>
+    public class ApplicationInfo : IDisposable
+    {
+        private const string LogTag = "Tizen.Applications";
+        private bool _disposed = false;
+        private IntPtr _infoHandle = IntPtr.Zero;
+        private string _applicationId = string.Empty;
+        private Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None;
+
+        internal ApplicationInfo(IntPtr infoHandle)
+        {
+            err = Interop.ApplicationManager.AppInfoGetAppId(infoHandle, out _applicationId);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                throw new ArgumentException("Invalid native handle.");
+            }
+            _infoHandle = infoHandle;
+        }
+
+        /// <summary>
+        /// A constructor of ApplicationInfo that takes the application id.
+        /// </summary>
+        /// <param name="applicationId">application id.</param>
+        public ApplicationInfo(string applicationId)
+        {
+            _applicationId = applicationId;
+        }
+
+        /// <summary>
+        /// Destructor of the class
+        /// </summary>
+        ~ApplicationInfo()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// Gets the application id.
+        /// </summary>
+        public string ApplicationId
+        {
+            get
+            {
+                if (!string.IsNullOrEmpty(_applicationId))
+                    return _applicationId;
+                IntPtr infoHandle = GetInfoHandle();
+                string appid = string.Empty;
+                if (infoHandle != IntPtr.Zero)
+                {
+                    err = Interop.ApplicationManager.AppInfoGetAppId(infoHandle, out appid);
+                    if (err != Interop.ApplicationManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get the application id. err = " + err);
+                    }
+                }
+                return appid;
+            }
+        }
+
+        /// <summary>
+        /// Gets the package id of the application.
+        /// </summary>
+        public string PackageId
+        {
+            get
+            {
+                IntPtr infoHandle = GetInfoHandle();
+                string packageid = string.Empty;
+                if (infoHandle != IntPtr.Zero)
+                {
+                    err = Interop.ApplicationManager.AppInfoGetPackage(infoHandle, out packageid);
+                    if (err != Interop.ApplicationManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get the package id of " + _applicationId + ". err = " + err);
+                    }
+                }
+                return packageid;
+            }
+        }
+
+        /// <summary>
+        /// Gets the label of the application.
+        /// </summary>
+        public string Label
+        {
+            get
+            {
+                IntPtr infoHandle = GetInfoHandle();
+                string label = string.Empty;
+                if (infoHandle != IntPtr.Zero)
+                {
+                    err = Interop.ApplicationManager.AppInfoGetLabel(infoHandle, out label);
+                    if (err != Interop.ApplicationManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get the app label of " + _applicationId + ". err = " + err);
+                    }
+                }
+                return label;
+            }
+        }
+
+        /// <summary>
+        /// Gets the executable path of the application.
+        /// </summary>
+        public string ExecutablePath
+        {
+            get
+            {
+                IntPtr infoHandle = GetInfoHandle();
+                string exec = string.Empty;
+                if (infoHandle != IntPtr.Zero)
+                {
+                    err = Interop.ApplicationManager.AppInfoGetExec(infoHandle, out exec);
+                    if (err != Interop.ApplicationManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get the executable file path of " + _applicationId + ". err = " + err);
+                    }
+                }
+                return exec;
+            }
+        }
+
+        /// <summary>
+        /// Gets the absolute path to the icon image.
+        /// </summary>
+        public string IconPath
+        {
+            get
+            {
+                IntPtr infoHandle = GetInfoHandle();
+                string path = string.Empty;
+                if (infoHandle != IntPtr.Zero)
+                {
+                    err = Interop.ApplicationManager.AppInfoGetIcon(infoHandle, out path);
+                    if (err != Interop.ApplicationManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get the app icon path of " + _applicationId + ". err = " + err);
+                    }
+                }
+                return path;
+            }
+        }
+
+        /// <summary>
+        /// Gets the application type name.
+        /// </summary>
+        public string ApplicationType
+        {
+            get
+            {
+                IntPtr infoHandle = GetInfoHandle();
+                string type = string.Empty;
+                if (infoHandle != IntPtr.Zero)
+                {
+                    err = Interop.ApplicationManager.AppInfoGetType(infoHandle, out type);
+                    if (err != Interop.ApplicationManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get the application type of " + _applicationId + ". err = " + err);
+                    }
+                }
+                return type;
+            }
+        }
+
+        /// <summary>
+        /// Gets the application's metadata.
+        /// </summary>
+        public IDictionary<String, String> Metadata
+        {
+            get
+            {
+                IDictionary<string, string> metadata = new Dictionary<String, String>();
+
+                Interop.ApplicationManager.AppInfoMetadataCallback cb = (string key, string value, IntPtr userData) =>
+                {
+                    if (key.Length != 0)
+                    {
+                        metadata.Add(key, value);
+                    }
+                    return true;
+                };
+
+                IntPtr infoHandle = GetInfoHandle();
+                if (infoHandle != IntPtr.Zero)
+                {
+                    err = Interop.ApplicationManager.AppInfoForeachMetadata(infoHandle, cb, IntPtr.Zero);
+                    if (err != Interop.ApplicationManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get application metadata of " + _applicationId + ". err = " + err);
+                    }
+                }
+                return metadata;
+            }
+        }
+
+        /// <summary>
+        /// Checks whether application information is nodisplay. If the application icon is not displayed on the menu screen, true; otherwise, false.
+        /// </summary>
+        public bool IsNoDisplay
+        {
+            get
+            {
+                IntPtr infoHandle = GetInfoHandle();
+                bool nodisplay = false;
+                if (infoHandle != IntPtr.Zero)
+                {
+                    err = Interop.ApplicationManager.AppInfoIsNodisplay(infoHandle, out nodisplay);
+                    if (err != Interop.ApplicationManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get the IsNoDisplay value of " + _applicationId + ". err = " + err);
+
+                    }
+                }
+                return nodisplay;
+            }
+        }
+
+        /// <summary>
+        /// Checks whether application is launched on booting time. If the application will be automatically start on boot, true; otherwise, false.
+        /// </summary>
+        public bool IsOnBoot
+        {
+            get
+            {
+                IntPtr infoHandle = GetInfoHandle();
+                bool onboot = false;
+                if (infoHandle != IntPtr.Zero)
+                {
+                    err = Interop.ApplicationManager.AppInfoIsOnBoot(infoHandle, out onboot);
+                    if (err != Interop.ApplicationManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get the IsOnBoot value of " + _applicationId + ". err = " + err);
+                    }
+                }
+                return onboot;
+            }
+        }
+
+        /// <summary>
+        /// Checks whether application is preloaded. If the application is preloaded, true; otherwise, false.
+        /// </summary>
+        public bool IsPreload
+        {
+            get
+            {
+                IntPtr infoHandle = GetInfoHandle();
+                bool preloaded = false;
+                if (infoHandle != IntPtr.Zero)
+                {
+                    err = Interop.ApplicationManager.AppInfoIsPreLoad(infoHandle, out preloaded);
+                    if (err != Interop.ApplicationManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get the IsPreload value of " + _applicationId + ". err = " + err);
+                    }
+                }
+                return preloaded;
+            }
+        }
+
+        /// <summary>
+        /// Gets the shared data path.
+        /// </summary>
+        public string SharedDataPath
+        {
+            get
+            {
+                string path = string.Empty;
+                err = Interop.ApplicationManager.AppManagerGetSharedDataPath(ApplicationId, out path);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, "Failed to get the SharedDataPath of " + _applicationId + ". err = " + err);
+                }
+                return path;
+            }
+        }
+
+        /// <summary>
+        /// Gets the shared resource path.
+        /// </summary>
+        public string SharedResourcePath
+        {
+            get
+            {
+                string path = string.Empty;
+                err = Interop.ApplicationManager.AppManagerGetSharedResourcePath(ApplicationId, out path);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, "Failed to get the SharedResourcePath of " + _applicationId + ". err = " + err);
+                }
+                return path;
+            }
+        }
+
+        /// <summary>
+        /// Gets the shared trust path.
+        /// </summary>
+        public string SharedTrustedPath
+        {
+            get
+            {
+                string path = string.Empty;
+                err = Interop.ApplicationManager.AppManagerGetSharedTrustedPath(ApplicationId, out path);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, "Failed to get the SharedTrustedPath of " + _applicationId + ". err = " + err);
+                }
+                return path;
+            }
+        }
+
+        /// <summary>
+        /// Gets the external shared data path.
+        /// </summary>
+        public string ExternalSharedDataPath
+        {
+            get
+            {
+                string path = string.Empty;
+                err = Interop.ApplicationManager.AppManagerGetExternalSharedDataPath(ApplicationId, out path);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, "Failed to get the ExternalSharedDataPath of " + _applicationId + ". err = " + err);
+                }
+                return path;
+            }
+        }
+
+        /// <summary>
+        /// Gets the localized label of application for the given locale.
+        /// </summary>
+        /// <param name="locale">locale.</param>
+        public string GetLocalizedLabel(string locale)
+        {
+            string label = string.Empty;
+            err = Interop.ApplicationManager.AppInfoGetLocaledLabel(ApplicationId, locale, out label);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, "Failed to get the GetLocalizedLabel of " + _applicationId + ". err = " + err);
+                label = Label;
+            }
+            return label;
+        }
+
+        private IntPtr GetInfoHandle()
+        {
+            if (_infoHandle == IntPtr.Zero)
+            {
+                IntPtr infoHandle = IntPtr.Zero;
+                err = Interop.ApplicationManager.AppManagerGetAppInfo(_applicationId, out infoHandle);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, "Failed to get the handle of the ApplicationInfo. err = " + err);
+                }
+                _infoHandle = infoHandle;
+            }
+            return _infoHandle;
+        }
+
+        /// <summary>
+        /// Releases all resources used by the ApplicationInfo class.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            if (_disposed)
+                return;
+            if (disposing)
+            {
+            }
+            if (_infoHandle != IntPtr.Zero)
+            {
+                Interop.ApplicationManager.AppInfoDestroy(_infoHandle);
+                _infoHandle = IntPtr.Zero;
+            }
+            _disposed = true;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationInfoFilter.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationInfoFilter.cs
new file mode 100755 (executable)
index 0000000..bba97b3
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// This class is a parameter of GetInstalledApplicationsAsync method.
+    /// </summary>
+    public class ApplicationInfoFilter
+    {
+        /// <summary>
+        ///
+        /// </summary>
+        public ApplicationInfoFilter()
+        {
+            Filter = new Dictionary<string, string>();
+        }
+
+        /// <summary>
+        /// This class is a possible key to use in the InstalledApplicationFilter.
+        /// </summary>
+        public static class Keys
+        {
+            /// <summary>
+            ///
+            /// </summary>
+            public const string Id = "PACKAGE_INFO_PROP_APP_ID";
+            /// <summary>
+            ///
+            /// </summary>
+            public const string Type = "PACKAGE_INFO_PROP_APP_TYPE";
+            /// <summary>
+            ///
+            /// </summary>
+            public const string Category = "PACKAGE_INFO_PROP_APP_CATEGORY";
+            /// <summary>
+            ///
+            /// </summary>
+            public const string NoDisplay = "PACKAGE_INFO_PROP_APP_NODISPLAY";
+            /// <summary>
+            ///
+            /// </summary>
+            public const string TaskManage = "PACKAGE_INFO_PROP_APP_TASKMANAGE";
+        }
+
+        /// <summary>
+        ///
+        /// </summary>
+        public IDictionary<string, string> Filter
+        {
+            get; private set;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationInfoMetadataFilter.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationInfoMetadataFilter.cs
new file mode 100755 (executable)
index 0000000..b4bc005
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// This class is a parameter of GetInstalledApplicationsAsync method.
+    /// </summary>
+    public class ApplicationInfoMetadataFilter : ApplicationInfoFilter
+    {
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationLaunchedEventArgs.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationLaunchedEventArgs.cs
new file mode 100755 (executable)
index 0000000..7f9c4b7
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Arguments for the event that is raised when the application is launched.
+    /// </summary>
+    public class ApplicationLaunchedEventArgs : EventArgs
+    {
+        /// <summary>
+        /// The information of the application.
+        /// </summary>
+        public ApplicationRunningContext ApplicationRunningContext { get; internal set; }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationManager.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationManager.cs
new file mode 100755 (executable)
index 0000000..adc70c3
--- /dev/null
@@ -0,0 +1,608 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// This class has the methods and events of the ApplicationManager.
+    /// </summary>
+    public static class ApplicationManager
+    {
+        private const string LogTag = "Tizen.Applications";
+        private static EventHandler<ApplicationLaunchedEventArgs> s_launchedHandler;
+        private static EventHandler<ApplicationTerminatedEventArgs> s_terminatedHandler;
+        private static Interop.ApplicationManager.AppManagerAppContextEventCallback s_applicationChangedEventCallback;
+        private static EventHandler<ApplicationEnabledEventArgs> _enabledHandler;
+        private static EventHandler<ApplicationDisabledEventArgs> _disabledHandler;
+        private static Interop.ApplicationManager.AppManagerEventCallback _eventCallback;
+        private static IntPtr _eventHandle = IntPtr.Zero;
+
+        /// <summary>
+        /// Occurs whenever the installed application is enabled.
+        /// </summary>
+        public static event EventHandler<ApplicationEnabledEventArgs> ApplicationEnabled
+        {
+            add
+            {
+                if (_enabledHandler == null && _disabledHandler == null)
+                {
+                    RegisterApplicationEvent();
+                }
+                _enabledHandler += value;
+            }
+            remove
+            {
+                _enabledHandler -= value;
+                if (_enabledHandler == null && _disabledHandler == null)
+                {
+                    UnRegisterApplicationEvent();
+                }
+            }
+        }
+
+        /// <summary>
+        /// Occurs whenever the installed application is disabled.
+        /// </summary>
+        public static event EventHandler<ApplicationDisabledEventArgs> ApplicationDisabled
+        {
+            add
+            {
+                if (_disabledHandler == null && _enabledHandler == null)
+                {
+                    RegisterApplicationEvent();
+                }
+                _disabledHandler += value;
+            }
+            remove
+            {
+                _disabledHandler -= value;
+                if (_disabledHandler == null && _enabledHandler == null)
+                {
+                    UnRegisterApplicationEvent();
+                }
+            }
+        }
+
+        /// <summary>
+        /// Occurs whenever the installed applications get launched.
+        /// </summary>
+        public static event EventHandler<ApplicationLaunchedEventArgs> ApplicationLaunched
+        {
+            add
+            {
+                if (s_launchedHandler == null && s_terminatedHandler == null)
+                {
+                    RegisterApplicationChangedEvent();
+                }
+                s_launchedHandler += value;
+            }
+            remove
+            {
+                s_launchedHandler -= value;
+                if (s_launchedHandler == null && s_terminatedHandler == null)
+                {
+                    UnRegisterApplicationChangedEvent();
+                }
+            }
+        }
+
+        /// <summary>
+        /// Occurs whenever the installed applications get terminated.
+        /// </summary>
+        public static event EventHandler<ApplicationTerminatedEventArgs> ApplicationTerminated
+        {
+            add
+            {
+                if (s_launchedHandler == null && s_terminatedHandler == null)
+                {
+                    RegisterApplicationChangedEvent();
+                }
+                s_terminatedHandler += value;
+            }
+            remove
+            {
+                s_terminatedHandler -= value;
+                if (s_launchedHandler == null && s_terminatedHandler == null)
+                {
+                    UnRegisterApplicationChangedEvent();
+                }
+            }
+        }
+
+        /// <summary>
+        /// Gets the information of the installed applications asynchronously.
+        /// </summary>
+        public static async Task<IEnumerable<ApplicationInfo>> GetInstalledApplicationsAsync()
+        {
+            return await Task.Run(() =>
+            {
+                Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None;
+                List<ApplicationInfo> result = new List<ApplicationInfo>();
+
+                Interop.ApplicationManager.AppManagerAppInfoCallback cb = (IntPtr infoHandle, IntPtr userData) =>
+                {
+                    if (infoHandle != IntPtr.Zero)
+                    {
+                        IntPtr clonedHandle = IntPtr.Zero;
+                        err = Interop.ApplicationManager.AppInfoClone(out clonedHandle, infoHandle);
+                        if (err != Interop.ApplicationManager.ErrorCode.None)
+                        {
+                            Log.Warn(LogTag, "Failed to clone the appinfo. err = " + err);
+                            return false;
+                        }
+                        ApplicationInfo app = new ApplicationInfo(clonedHandle);
+                        result.Add(app);
+                        return true;
+                    }
+                    return false;
+                };
+                err = Interop.ApplicationManager.AppManagerForeachAppInfo(cb, IntPtr.Zero);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    throw ApplicationManagerErrorFactory.GetException(err, "Failed to foreach the appinfo.");
+                }
+                return result;
+            });
+        }
+
+        /// <summary>
+        /// Gets the information of the installed applications with the ApplicationInfoFilter asynchronously.
+        /// </summary>
+        /// <param name="filter">Key-value pairs for filtering.</param>
+        public static async Task<IEnumerable<ApplicationInfo>> GetInstalledApplicationsAsync(ApplicationInfoFilter filter)
+        {
+            return await Task.Run(() =>
+            {
+                List<ApplicationInfo> result = new List<ApplicationInfo>();
+
+                Interop.ApplicationManager.AppInfoFilterCallback cb = (IntPtr infoHandle, IntPtr userData) =>
+                {
+                    if (infoHandle != IntPtr.Zero)
+                    {
+                        IntPtr clonedHandle = IntPtr.Zero;
+                        Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.AppInfoClone(out clonedHandle, infoHandle);
+                        if (err != Interop.ApplicationManager.ErrorCode.None)
+                        {
+                            Log.Warn(LogTag, "Failed to clone the appinfo. err = " + err);
+                            return false;
+                        }
+                        ApplicationInfo app = new ApplicationInfo(clonedHandle);
+                        result.Add(app);
+                        return true;
+                    }
+                    return false;
+                };
+                filter.Fetch(cb);
+                return result;
+            });
+        }
+
+        /// <summary>
+        /// Gets the information of the installed applications with the ApplicationInfoMetadataFilter asynchronously.
+        /// </summary>
+        /// <param name="filter">Key-value pairs for filtering.</param>
+        public static async Task<IEnumerable<ApplicationInfo>> GetInstalledApplicationsAsync(ApplicationInfoMetadataFilter filter)
+        {
+            return await Task.Run(() =>
+            {
+                List<ApplicationInfo> result = new List<ApplicationInfo>();
+
+                Interop.ApplicationManager.AppInfoFilterCallback cb = (IntPtr infoHandle, IntPtr userData) =>
+                {
+                    if (infoHandle != IntPtr.Zero)
+                    {
+                        IntPtr clonedHandle = IntPtr.Zero;
+                        Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.AppInfoClone(out clonedHandle, infoHandle);
+                        if (err != Interop.ApplicationManager.ErrorCode.None)
+                        {
+                            Log.Warn(LogTag, "Failed to clone the appinfo. err = " + err);
+                            return false;
+                        }
+                        ApplicationInfo app = new ApplicationInfo(clonedHandle);
+                        result.Add(app);
+                        return true;
+                    }
+                    return false;
+                };
+                filter.Fetch(cb);
+                return result;
+            });
+        }
+
+        /// <summary>
+        /// Gets the information of the running applications asynchronously.
+        /// </summary>
+        public static async Task<IEnumerable<ApplicationRunningContext>> GetRunningApplicationsAsync()
+        {
+            return await Task.Run(() =>
+            {
+                Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None;
+                List<ApplicationRunningContext> result = new List<ApplicationRunningContext>();
+
+                Interop.ApplicationManager.AppManagerAppContextCallback cb = (IntPtr contextHandle, IntPtr userData) =>
+                {
+                    if (contextHandle != IntPtr.Zero)
+                    {
+                        IntPtr clonedHandle = IntPtr.Zero;
+                        err = Interop.ApplicationManager.AppContextClone(out clonedHandle, contextHandle);
+                        if (err != Interop.ApplicationManager.ErrorCode.None)
+                        {
+                            Log.Warn(LogTag, "Failed to clone the app context. err = " + err);
+                            return false;
+                        }
+                        ApplicationRunningContext context = new ApplicationRunningContext(clonedHandle);
+                        result.Add(context);
+                        return true;
+                    }
+                    return false;
+                };
+
+                err = Interop.ApplicationManager.AppManagerForeachAppContext(cb, IntPtr.Zero);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    throw ApplicationManagerErrorFactory.GetException(err, "Failed to foreach appcontext.");
+                }
+                return result;
+            });
+        }
+
+        /// <summary>
+        /// Gets the information of the running applications including subapp asynchronously.
+        /// </summary>
+        public static async Task<IEnumerable<ApplicationRunningContext>> GetAllRunningApplicationsAsync()
+        {
+            return await Task.Run(() =>
+            {
+                Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None;
+                List<ApplicationRunningContext> result = new List<ApplicationRunningContext>();
+
+                Interop.ApplicationManager.AppManagerAppContextCallback cb = (IntPtr contextHandle, IntPtr userData) =>
+                {
+                    if (contextHandle != IntPtr.Zero)
+                    {
+                        IntPtr clonedHandle = IntPtr.Zero;
+                        err = Interop.ApplicationManager.AppContextClone(out clonedHandle, contextHandle);
+                        if (err != Interop.ApplicationManager.ErrorCode.None)
+                        {
+                            Log.Warn(LogTag, "Failed to clone the app context. err = " + err);
+                            return false;
+                        }
+                        ApplicationRunningContext context = new ApplicationRunningContext(clonedHandle);
+                        result.Add(context);
+                        return true;
+                    }
+                    return false;
+                };
+
+                err = Interop.ApplicationManager.AppManagerForeachRunningAppContext(cb, IntPtr.Zero);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    throw ApplicationManagerErrorFactory.GetException(err, "Failed to foreach appcontext.");
+                }
+                return result;
+            });
+        }
+
+        /// <summary>
+        /// Gets the information of the specified application with the application id.
+        /// </summary>
+        /// <param name="applicationId">Application id.</param>
+        public static ApplicationInfo GetInstalledApplication(string applicationId)
+        {
+            IntPtr infoHandle = IntPtr.Zero;
+            Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.AppManagerGetAppInfo(applicationId, out infoHandle);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                throw ApplicationManagerErrorFactory.GetException(err, "Failed to get the installed application information of " + applicationId + ".");
+            }
+            ApplicationInfo app = new ApplicationInfo(infoHandle);
+            return app;
+        }
+
+        /// <summary>
+        /// Returns if the specified application is running or not.
+        /// </summary>
+        /// <param name="applicationId">The application Id.</param>
+        /// <returns>Returns true if the given application is running, otherwise false.</returns>
+        /// <exception cref="ArgumentException">Thrown when the given parameter is invalid.</exception>
+        public static bool IsRunning(string applicationId)
+        {
+            bool isRunning = false;
+            Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.AppManagerIsRunning(applicationId, out isRunning);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                throw ApplicationManagerErrorFactory.GetException(Interop.ApplicationManager.ErrorCode.InvalidParameter, "Invalid parameter");
+            }
+            return isRunning;
+        }
+
+        private static void RegisterApplicationChangedEvent()
+        {
+            Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None;
+            s_applicationChangedEventCallback = (IntPtr contextHandle, Interop.ApplicationManager.AppContextEvent state, IntPtr userData) =>
+            {
+                if (contextHandle == IntPtr.Zero) return;
+
+                IntPtr clonedHandle = IntPtr.Zero;
+                err = Interop.ApplicationManager.AppContextClone(out clonedHandle, contextHandle);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    throw ApplicationManagerErrorFactory.GetException(err, "Failed to register the application context event.");
+                }
+                using (ApplicationRunningContext context = new ApplicationRunningContext(clonedHandle))
+                {
+                    if (state == Interop.ApplicationManager.AppContextEvent.Launched)
+                    {
+                        s_launchedHandler?.Invoke(null, new ApplicationLaunchedEventArgs { ApplicationRunningContext = context });
+                    }
+                    else if (state == Interop.ApplicationManager.AppContextEvent.Terminated)
+                    {
+                        s_terminatedHandler?.Invoke(null, new ApplicationTerminatedEventArgs { ApplicationRunningContext = context });
+                    }
+                }
+            };
+            err = Interop.ApplicationManager.AppManagerSetAppContextEvent(s_applicationChangedEventCallback, IntPtr.Zero);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                throw ApplicationManagerErrorFactory.GetException(err, "Failed to register the application context event.");
+            }
+        }
+
+        private static void UnRegisterApplicationChangedEvent()
+        {
+            Interop.ApplicationManager.AppManagerUnSetAppContextEvent();
+        }
+
+        private static void RegisterApplicationEvent()
+        {
+            Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None;
+            err = Interop.ApplicationManager.AppManagerEventCreate(out _eventHandle);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                throw ApplicationManagerErrorFactory.GetException(err, "Failed to create the application event handle");
+            }
+
+            err = Interop.ApplicationManager.AppManagerEventSetStatus(_eventHandle, Interop.ApplicationManager.AppManagerEventStatusType.All);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                Interop.ApplicationManager.AppManagerEventDestroy(_eventHandle);
+                _eventHandle = IntPtr.Zero;
+                throw ApplicationManagerErrorFactory.GetException(err, "Failed to set the application event");
+            }
+
+            _eventCallback = (string appType, string appId, Interop.ApplicationManager.AppManagerEventType eventType, Interop.ApplicationManager.AppManagerEventState eventState, IntPtr eventHandle, IntPtr UserData) =>
+            {
+                if (eventType == Interop.ApplicationManager.AppManagerEventType.Enable)
+                {
+                    _enabledHandler?.Invoke(null, new ApplicationEnabledEventArgs(appId, (ApplicationEventState)eventState));
+                }
+                else if (eventType == Interop.ApplicationManager.AppManagerEventType.Disable)
+                {
+                    _disabledHandler?.Invoke(null, new ApplicationDisabledEventArgs(appId, (ApplicationEventState)eventState));
+                }
+            };
+            err = Interop.ApplicationManager.AppManagerSetEventCallback(_eventHandle, _eventCallback, IntPtr.Zero);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                Interop.ApplicationManager.AppManagerEventDestroy(_eventHandle);
+                _eventHandle = IntPtr.Zero;
+                throw ApplicationManagerErrorFactory.GetException(err, "Failed to set the application event callback");
+            }
+        }
+
+        private static void UnRegisterApplicationEvent()
+        {
+            if (_eventHandle != IntPtr.Zero)
+            {
+                Interop.ApplicationManager.AppManagerUnSetEventCallback(_eventHandle);
+                Interop.ApplicationManager.AppManagerEventDestroy(_eventHandle);
+                _eventHandle = IntPtr.Zero;
+            }
+        }
+
+        /// <summary>
+        /// Gets the information of the recent applications.
+        /// </summary>
+        /// <returns>Returns a dictionary containing all recent application info.</returns>
+        /// <exception cref="InvalidOperationException">Thrown when failed because of invalid operation</exception>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static IEnumerable<RecentApplicationInfo> GetRecentApplications()
+        {
+            Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None;
+
+            List<RecentApplicationInfo> result = new List<RecentApplicationInfo>();
+            IntPtr table;
+            int nrows, ncols;
+
+            err = Interop.ApplicationManager.RuaHistoryLoadDb(out table, out nrows, out ncols);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                throw ApplicationManagerErrorFactory.GetException(err, "Failed to load a table for the recent application list.");
+            }
+
+            for (int row = 0; row < nrows; ++row)
+            {
+                Interop.ApplicationManager.RuaRec record;
+
+                err = Interop.ApplicationManager.RuaHistoryGetRecord(out record, table, nrows, ncols, row);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    throw ApplicationManagerErrorFactory.GetException(err, "Failed to get record.");
+                }
+
+                RecentApplicationInfo info = new RecentApplicationInfo(record);
+                result.Add(info);
+            }
+
+            err = Interop.ApplicationManager.RuaHistoryUnLoadDb(ref table);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                throw ApplicationManagerErrorFactory.GetException(err, "Failed to unload a table for the recent application list.");
+            }
+
+            return result;
+        }
+    }
+
+    internal static class FilterExtension
+    {
+        private const string LogTag = "Tizen.Applications";
+        internal static void Fetch(this ApplicationInfoFilter filter, Interop.ApplicationManager.AppInfoFilterCallback callback)
+        {
+            if (filter is ApplicationInfoMetadataFilter)
+            {
+                ApplicationInfoMetadataFilter metaFilter = (ApplicationInfoMetadataFilter)filter;
+                metaFilter.Fetch(callback);
+                return;
+            }
+
+            IntPtr nativeHandle = MakeNativeAppInfoFilter(filter.Filter);
+            if (nativeHandle == IntPtr.Zero)
+            {
+                throw ApplicationManagerErrorFactory.NativeFilterHandleIsInvalid();
+            }
+            try
+            {
+                Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.AppInfoFilterForeachAppinfo(nativeHandle, callback, IntPtr.Zero);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    throw ApplicationManagerErrorFactory.GetException(err, "Failed to get application information list with filter.");
+                }
+            }
+            finally
+            {
+                Interop.ApplicationManager.AppInfoFilterDestroy(nativeHandle);
+            }
+        }
+
+        internal static void Fetch(this ApplicationInfoMetadataFilter filter, Interop.ApplicationManager.AppInfoFilterCallback callback)
+        {
+            IntPtr nativeHandle = MakeNativeAppMetadataFilter(filter.Filter);
+            if (nativeHandle == IntPtr.Zero)
+            {
+                throw ApplicationManagerErrorFactory.NativeFilterHandleIsInvalid();
+            }
+            try
+            {
+                Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.AppInfoMetadataFilterForeach(nativeHandle, callback, IntPtr.Zero);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    throw ApplicationManagerErrorFactory.GetException(err, "Failed to get metadata list with filter.");
+                }
+            }
+            finally
+            {
+                Interop.ApplicationManager.AppInfoMetadataFilterDestroy(nativeHandle);
+            }
+        }
+
+        private static IntPtr MakeNativeAppInfoFilter(IDictionary<string, string> filter)
+        {
+            if (filter == null || filter.Count == 0)
+            {
+                throw ApplicationManagerErrorFactory.FilterIsInvalid();
+            }
+
+            IntPtr infoHandle = IntPtr.Zero;
+            Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.AppInfoFilterCreate(out infoHandle);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                throw ApplicationManagerErrorFactory.GetException(err, "Failed to create the filter handle.");
+            }
+
+            foreach (var item in filter)
+            {
+                if ((item.Key == ApplicationInfoFilter.Keys.Id) ||
+                    (item.Key == ApplicationInfoFilter.Keys.Type) ||
+                    (item.Key == ApplicationInfoFilter.Keys.Category))
+                {
+                    err = Interop.ApplicationManager.AppInfoFilterAddString(infoHandle, item.Key, item.Value);
+                }
+                else if ((item.Key == ApplicationInfoFilter.Keys.NoDisplay) ||
+                         (item.Key == ApplicationInfoFilter.Keys.TaskManage))
+                {
+                    err = Interop.ApplicationManager.AppInfoFilterAddBool(infoHandle, item.Key, Convert.ToBoolean(item.Value));
+                }
+                else
+                {
+                    Log.Warn(LogTag, string.Format("'{0}' is not supported key for the filter.", item.Key));
+                }
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    Interop.ApplicationManager.AppInfoFilterDestroy(infoHandle);
+                    throw ApplicationManagerErrorFactory.GetException(err, "Failed to add item to the filter.");
+                }
+            }
+            return infoHandle;
+        }
+
+        private static IntPtr MakeNativeAppMetadataFilter(IDictionary<string, string> filter)
+        {
+            if (filter == null || filter.Count == 0)
+            {
+                throw ApplicationManagerErrorFactory.FilterIsInvalid();
+            }
+
+            IntPtr infoHandle = IntPtr.Zero;
+            Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.AppInfoMetadataFilterCreate(out infoHandle);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                throw ApplicationManagerErrorFactory.GetException(err, "Failed to create the filter for searching with metadata.");
+            }
+            foreach (var item in filter)
+            {
+                err = Interop.ApplicationManager.AppInfoMetadataFilterAdd(infoHandle, item.Key, item.Value);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    Interop.ApplicationManager.AppInfoMetadataFilterDestroy(infoHandle);
+                    throw ApplicationManagerErrorFactory.GetException(err, "Failed to add the item to the filter.");
+                }
+            }
+            return infoHandle;
+        }
+    }
+
+    internal static class ApplicationManagerErrorFactory
+    {
+        internal static Exception NativeFilterHandleIsInvalid()
+        {
+            return new InvalidOperationException("The native handle for filtering is invalid.");
+        }
+
+        internal static Exception FilterIsInvalid()
+        {
+            return new ArgumentException("The filter is invalid.");
+        }
+
+        internal static Exception GetException(Interop.ApplicationManager.ErrorCode err, string message)
+        {
+            string errMessage = String.Format("{0} err = {1}", message, err);
+            switch (err)
+            {
+                case Interop.ApplicationManager.ErrorCode.InvalidParameter:
+                    return new ArgumentException(errMessage);
+                default:
+                    return new InvalidOperationException(errMessage);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationRunningContext.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationRunningContext.cs
new file mode 100644 (file)
index 0000000..0220424
--- /dev/null
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// This class provides methods and properties to get information of the application.
+    /// </summary>
+    public class ApplicationRunningContext : IDisposable
+    {
+        private const string LogTag = "Tizen.Applications";
+        private bool _disposed = false;
+        private IntPtr _contextHandle = IntPtr.Zero;
+        private Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None;
+
+        internal ApplicationRunningContext(IntPtr contextHandle)
+        {
+            _contextHandle = contextHandle;
+        }
+
+        /// <summary>
+        /// A constructor of ApplicationRunningContext that takes the application id.
+        /// </summary>
+        /// <param name="applicationId">application id.</param>
+        /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when failed because of application not exist error or system error.</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed because of out of memory.</exception>
+        public ApplicationRunningContext(string applicationId)
+        {
+            IntPtr contextHandle = IntPtr.Zero;
+            err = Interop.ApplicationManager.AppManagerGetAppContext(applicationId, out contextHandle);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, "Failed to get the handle of the ApplicationRunningContext. err = " + err);
+                switch (err)
+                {
+                    case Interop.ApplicationManager.ErrorCode.InvalidParameter:
+                        throw new ArgumentException("Invalid Parameter.");
+                    case Interop.ApplicationManager.ErrorCode.NoSuchApp:
+                        throw new InvalidOperationException("No such application.");
+                    case Interop.ApplicationManager.ErrorCode.OutOfMemory:
+                        throw new OutOfMemoryException("Out of memory");
+                    default:
+                        throw new InvalidOperationException("Invalid Operation.");
+                }
+            }
+            _contextHandle = contextHandle;
+        }
+
+        /// <summary>
+        /// A constructor of ApplicationRunningContext that takes the application id.
+        /// </summary>
+        /// <param name="applicationId">application id.</param>
+        /// <param name="instanceId">instance id.</param>
+        /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when failed because of application not exist error or system error.</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed because of out of memory.</exception>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public ApplicationRunningContext(string applicationId, string instanceId)
+        {
+            IntPtr contextHandle = IntPtr.Zero;
+            err = Interop.ApplicationManager.AppManagerGetAppContextByInstanceId(applicationId, instanceId, out contextHandle);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, "Failed to get the handle of the ApplicationRunningContext. err = " + err);
+                switch (err)
+                {
+                    case Interop.ApplicationManager.ErrorCode.InvalidParameter:
+                        throw new ArgumentException("Invalid Parameter.");
+                    case Interop.ApplicationManager.ErrorCode.NoSuchApp:
+                        throw new InvalidOperationException("No such application.");
+                    case Interop.ApplicationManager.ErrorCode.OutOfMemory:
+                        throw new OutOfMemoryException("Out of memory");
+                    default:
+                        throw new InvalidOperationException("Invalid Operation.");
+                }
+            }
+            _contextHandle = contextHandle;
+        }
+
+        /// <summary>
+        /// Destructor of the class
+        /// </summary>
+        ~ApplicationRunningContext()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// Enumeration for the Application State.
+        /// </summary>
+        public enum AppState
+        {
+            /// <summary>
+            /// The undefined state
+            /// </summary>
+            Undefined = 0,
+
+            /// <summary>
+            /// The UI application is running in the foreground.
+            /// </summary>
+            Foreground,
+
+            /// <summary>
+            /// The UI application is running in the background.
+            /// </summary>
+            Background,
+
+            /// <summary>
+            /// The Service application is running.
+            /// </summary>
+            Service,
+
+            /// <summary>
+            /// The application is terminated.
+            /// </summary>
+            Terminated,
+        }
+
+        /// <summary>
+        /// Gets the application id.
+        /// </summary>
+        public string ApplicationId
+        {
+            get
+            {
+                string appid = string.Empty;
+                err = Interop.ApplicationManager.AppContextGetAppId(_contextHandle, out appid);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, "Failed to get the application id. err = " + err);
+                }
+                return appid;
+            }
+        }
+
+        /// <summary>
+        /// Gets the package id of the application.
+        /// </summary>
+        public string PackageId
+        {
+            get
+            {
+                string packageid = string.Empty;
+                err = Interop.ApplicationManager.AppContextGetPackageId(_contextHandle, out packageid);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, "Failed to get the package id. err = " + err);
+                }
+                return packageid;
+            }
+        }
+
+        /// <summary>
+        /// Gets the application's process id.
+        /// </summary>
+        public int ProcessId
+        {
+            get
+            {
+                int pid = 0;
+                err = Interop.ApplicationManager.AppContextGetPid(_contextHandle, out pid);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, "Failed to get the process id. err = " + err);
+                }
+                return pid;
+            }
+        }
+
+        /// <summary>
+        /// Gets the state of the application.
+        /// </summary>
+        public AppState State
+        {
+            get
+            {
+                int state = 0;
+
+                err = Interop.ApplicationManager.AppContextGetAppState(_contextHandle, out state);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, "Failed to get the application state. err = " + err);
+                }
+                return (AppState)state;
+            }
+        }
+
+        /// <summary>
+        /// Gets whether the application is sub application of the application group.
+        /// </summary>
+        public bool IsSubApp
+        {
+            get
+            {
+                bool subapp = false;
+                err = Interop.ApplicationManager.AppContextIsSubApp(_contextHandle, out subapp);
+                if (err != Interop.ApplicationManager.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, "Failed to get the IsSubApp value. err = " + err);
+                }
+                return subapp;
+            }
+        }
+
+        /// <summary>
+        /// Terminates the application.
+        /// </summary>
+        /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when failed because of permission denied or system error.</exception>
+        /// <privilege>http://tizen.org/privilege/appmanager.kill</privilege>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void Terminate()
+        {
+            err = Interop.ApplicationManager.AppManagerTerminateApp(_contextHandle);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                switch (err)
+                {
+                    case Interop.ApplicationManager.ErrorCode.InvalidParameter:
+                        throw new ArgumentException("Invalid argument.");
+                    case Interop.ApplicationManager.ErrorCode.PermissionDenied:
+                        throw new InvalidOperationException("Permission denied.");
+                    default:
+                        throw new InvalidOperationException("Invalid Operation.");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Releases all resources used by the ApplicationRunningContext class.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            if (_disposed)
+                return;
+
+            if (_contextHandle != IntPtr.Zero)
+            {
+                Interop.ApplicationManager.AppContextDestroy(_contextHandle);
+                _contextHandle = IntPtr.Zero;
+            }
+            _disposed = true;
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationTerminatedEventArgs.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationTerminatedEventArgs.cs
new file mode 100755 (executable)
index 0000000..622dc91
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Arguments for the event that is raised when the application is terminated.
+    /// </summary>
+    public class ApplicationTerminatedEventArgs : EventArgs
+    {
+        /// <summary>
+        /// The information of the application.
+        /// </summary>
+        public ApplicationRunningContext ApplicationRunningContext { get; internal set; }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationType.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationType.cs
new file mode 100755 (executable)
index 0000000..857c3a7
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for applications type.
+    /// </summary>
+    public enum ApplicationType
+    {
+        /// <summary>
+        /// All applications.
+        /// </summary>
+        All = 0,
+        /// <summary>
+        /// UI applications.
+        /// </summary>
+        Ui = 1,
+        /// <summary>
+        /// Service applications.
+        /// </summary>
+        Service = 2
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/Bundle.cs b/src/Tizen.Applications.Common/Tizen.Applications/Bundle.cs
new file mode 100755 (executable)
index 0000000..1b56e8e
--- /dev/null
@@ -0,0 +1,714 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Reflection;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// A Bundle object represents a bundle.
+    /// A bundle holds items (key-value pairs) and can be used with other Tizen APIs.
+    /// Keys can be used to access values.
+    /// This class is accessed by using a constructor to create a new instance of this object.
+    /// A bundle instance is not guaranteed to be thread safe if the instance is modified by multiple threads.
+    /// </summary>
+    public class Bundle : IDisposable
+    {
+        private SafeBundleHandle _handle;
+        private bool _disposed = false;
+        private readonly HashSet<string> _keys;
+
+        /// <summary>
+        /// The Bundle constructor.
+        /// </summary>
+        /// <exception cref="System.InvalidOperationException">Thrown when out of memory</exception>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// </code>
+        public Bundle()
+        {
+            _handle = Interop.Bundle.Create();
+            BundleErrorFactory.CheckAndThrowException(ErrorFacts.GetLastResult(), _handle);
+            _keys = new HashSet<string>();
+        }
+
+        /// <summary>
+        /// The Bundle constructor.
+        /// </summary>
+        /// <param name="handle">The SafeBundleHandle instance.</param>
+        /// <exception cref="System.ArgumentNullException">Thrown when the handle is null or invalid.</exception>
+        public Bundle(SafeBundleHandle handle)
+        {
+            if (handle == null || handle.IsInvalid)
+            {
+                throw new ArgumentNullException("handle");
+            }
+
+            _handle = Interop.Bundle.DangerousClone(handle.DangerousGetHandle());
+            _keys = new HashSet<string>();
+            Interop.Bundle.Iterator iterator = (string key, int type, IntPtr keyval, IntPtr userData) =>
+            {
+                _keys.Add(key);
+            };
+
+            Interop.Bundle.Foreach(_handle, iterator, IntPtr.Zero);
+            if ((BundleErrorFactory.BundleError)ErrorFacts.GetLastResult() == BundleErrorFactory.BundleError.InvalidParameter)
+            {
+                throw new ArgumentException("Invalid parameter - cannot create bundle instance");
+            }
+        }
+
+        private enum BundleTypeProperty
+        {
+            Array = 0x0100,
+            Primitive = 0x0200,
+            Measurable = 0x0400
+        }
+
+        private enum BundleType
+        {
+            None = -1,
+            Any = 0,
+            String = 1 | BundleTypeProperty.Measurable,
+            StringArray = String | BundleTypeProperty.Array | BundleTypeProperty.Measurable,
+            Byte = 2,
+            ByteArray = Byte | BundleTypeProperty.Array
+        }
+
+        /// <summary>
+        /// The number of items in a Bundle object.
+        /// </summary>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// bundle.AddItem("string", "a_string");
+        /// Console.WriteLine("There are {0} items in the bundle", bundle.Count);
+        /// </code>
+        public int Count
+        {
+            get
+            {
+                return _keys.Count;
+            }
+        }
+
+        /// <summary>
+        /// The keys in a Bundle object.
+        /// </summary>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// bundle.AddItem("string1", "a_string1");
+        /// bundle.AddItem("string2", "a_string2");
+        /// bundle.AddItem("string3", "a_string3");
+        /// Console.WriteLine("The bundle contains the following keys:");
+        /// foreach(string key in bundle.Keys)
+        /// {
+        ///     Console.WriteLine(key);
+        /// }
+        /// </code>
+        public IEnumerable<string> Keys
+        {
+            get
+            {
+                return _keys;
+            }
+        }
+
+        /// <summary>
+        /// Gets the SafeBundleHandle instance.
+        /// </summary>
+        public SafeBundleHandle SafeBundleHandle
+        {
+            get { return _handle; }
+        }
+
+        /// <summary>
+        /// Releases any unmanaged resources used by this object.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        /// <summary>
+        /// Checks whether the bundle contains an item with a specified key.
+        /// </summary>
+        /// <param name="key">The key to check for.</param>
+        /// <returns>true if the bundle contains the key. false otherwise.</returns>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// bundle.AddItem("string", "a_string");
+        /// if (bundle.Contains("string"))
+        /// {
+        ///     string aValue = bundle.GetItem<string>("string");
+        ///     Console.WriteLine(aValue);
+        /// }
+        /// </code>
+        public bool Contains(string key)
+        {
+            return _keys.Contains(key);
+        }
+
+        /// <summary>
+        /// Adds an item into the bundle.
+        /// </summary>
+        /// <param name="key">The key to identify the item with. If an item with the key already exists in the Bundle, this method will not succeed.</param>
+        /// <param name="value">The value of the item.</param>
+        /// <exception cref="System.ArgumentException">Thrown when the key already exists or when there is an invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when out of memory or when the Bundle instance has been disposed.</exception>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// byte[] byteArray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+        /// bundle.AddItem("byte_array", byteArray);
+        /// </code>
+        public void AddItem(string key, byte[] value)
+        {
+            if (value == null)
+            {
+                throw new ArgumentNullException("value");
+            }
+            AddItem(key, value, 0, value.Length);
+        }
+
+        /// <summary>
+        /// Adds an item into the bundle.
+        /// </summary>
+        /// <param name="key">The key to identify the item with. If an item with the key already exists in the Bundle, this method will not succeed.</param>
+        /// <param name="value">The value of the item.</param>
+        /// <param name="offset">The zero-based byte offset in value from which to add to the bundle.</param>
+        /// <param name="count">The maximum number of bytes to add to the bundle starting with offset.</param>
+        /// <exception cref="System.ArgumentOutOfRangeException">Thrown when the offset or count is out of range.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when the key already exists or when there is an invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when out of memory or when the Bundle instance has been disposed.</exception>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// byte[] byteArray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+        /// bundle.AddItem("byte_array", byteArray, 2, 3);
+        /// </code>
+        public void AddItem(string key, byte[] value, int offset, int count)
+        {
+            if (!_keys.Contains(key))
+            {
+                if (value == null)
+                {
+                    throw new ArgumentNullException("value");
+                }
+                if (offset < 0)
+                {
+                    throw new ArgumentOutOfRangeException("offset", offset, "Cannot be less than 0");
+                }
+                if (offset > value.Length - 1)
+                {
+                    throw new ArgumentOutOfRangeException("offset", offset, "Greater than last index of array");
+                }
+                if (count < 1)
+                {
+                    throw new ArgumentOutOfRangeException("count", count, "Must be at least 1");
+                }
+                if (offset + count > value.Length)
+                {
+                    throw new ArgumentException("The count is too large for the specified offset");
+                }
+                // Code is in Interop file because it is unsafe
+                int ret = Interop.Bundle.UnsafeCode.AddItem(_handle, key, value, offset, count);
+                BundleErrorFactory.CheckAndThrowException(ret, _handle);
+                _keys.Add(key);
+            }
+            else
+            {
+                throw new ArgumentException("Key already exists", "key");
+            }
+        }
+
+        /// <summary>
+        /// Adds an item into the bundle.
+        /// </summary>
+        /// <param name="key">The key to identify the item with. If an item with the key already exists in the Bundle, this method will not succeed.</param>
+        /// <param name="value">The value of the item.</param>
+        /// <exception cref="System.ArgumentException">Thrown when the key already exists or when there is an invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when out of memory or when the Bundle instance has been disposed.</exception>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// bundle.AddItem("string", "a_string");
+        /// </code>
+        public void AddItem(string key, string value)
+        {
+            if (!_keys.Contains(key))
+            {
+                int ret = Interop.Bundle.AddString(_handle, key, value);
+                BundleErrorFactory.CheckAndThrowException(ret, _handle);
+                _keys.Add(key);
+            }
+            else
+            {
+                throw new ArgumentException("Key already exists", "key");
+            }
+        }
+
+        /// <summary>
+        /// Adds an item into the bundle.
+        /// </summary>
+        /// <param name="key">The key to identify the item with. If an item with the key already exists in the Bundle, this method will not succeed.</param>
+        /// <param name="value">The value of the item.</param>
+        /// <exception cref="System.ArgumentException">Thrown when the key already exists or when there is an invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when out of memory or when the Bundle instance has been disposed.</exception>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// string[] stringArray = { "a", "b", "c" };
+        /// bundle.AddItem("string_array", stringArray);
+        /// </code>
+        public void AddItem(string key, IEnumerable<string> value)
+        {
+            if (!_keys.Contains(key))
+            {
+                string[] valueArray = value.Select(v => v == null ? string.Empty : v).ToArray();
+                int ret = Interop.Bundle.AddStringArray(_handle, key, valueArray, valueArray.Count());
+                BundleErrorFactory.CheckAndThrowException(ret, _handle);
+                _keys.Add(key);
+            }
+            else
+            {
+                throw new ArgumentException("Key already exists", "key");
+            }
+        }
+
+        /// <summary>
+        /// Gets the value of a bundle item with a specified key.
+        /// </summary>
+        /// <param name="key">The key of the bundle item whose value is desired.</param>
+        /// <returns>The value of the bundle item.</returns>
+        /// <exception cref="System.ArgumentException">Thrown when the key does not exist or when there is an invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bundle instance has been disposed.</exception>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// bundle.AddItem("string", "a_string");
+        /// if (bundle.Contains("string"))
+        /// {
+        ///     object aValue = bundle.GetItem("string");
+        ///     if (bundle.Is<string>("string");)
+        ///     {
+        ///         string aString = (string)aValue;
+        ///         Console.WriteLine(aString);
+        ///     }
+        /// }
+        /// </code>
+        public object GetItem(string key)
+        {
+            if (_keys.Contains(key))
+            {
+                int type = Interop.Bundle.GetType(_handle, key);
+                BundleErrorFactory.CheckAndThrowException(ErrorFacts.GetLastResult(), _handle);
+                switch (type)
+                {
+                    case (int)BundleType.String:
+                        // get string
+                        IntPtr stringPtr;
+                        int retString = Interop.Bundle.GetString(_handle, key, out stringPtr);
+                        BundleErrorFactory.CheckAndThrowException(retString, _handle);
+                        string stringValue = Marshal.PtrToStringAnsi(stringPtr);
+                        if (stringValue == null)
+                            return string.Empty;
+                        return stringValue;
+
+                    case (int)BundleType.StringArray:
+                        // get string array
+                        int stringArraySize;
+                        IntPtr stringArrayPtr = Interop.Bundle.GetStringArray(_handle, key, out stringArraySize);
+                        BundleErrorFactory.CheckAndThrowException(ErrorFacts.GetLastResult(), _handle);
+                        string[] stringArray;
+                        IntPtrToStringArray(stringArrayPtr, stringArraySize, out stringArray);
+                        return stringArray;
+
+                    case (int)BundleType.Byte:
+                        // get byte array
+                        IntPtr byteArrayPtr;
+                        int byteArraySize;
+                        int retByte = Interop.Bundle.GetByte(_handle, key, out byteArrayPtr, out byteArraySize);
+                        BundleErrorFactory.CheckAndThrowException(retByte, _handle);
+                        byte[] byteArray = new byte[byteArraySize];
+                        Marshal.Copy(byteArrayPtr, byteArray, 0, byteArraySize);
+                        return byteArray;
+
+                    default:
+                        throw new ArgumentException("Key does not exist in the bundle", "key");
+                }
+            }
+            else
+            {
+                throw new ArgumentException("Key does not exist in the bundle (may be null or empty string)", "key");
+            }
+        }
+
+        /// <summary>
+        /// Gets the value of a bundle item with a specified key.
+        /// Note that this is a generic method.
+        /// </summary>
+        /// <typeparam name="T">The generic type to return.</typeparam>
+        /// <param name="key">The key of the bundle item whose value is desired.</param>
+        /// <returns>The value of the bundle item if it is of the specified generic type.</returns>
+        /// <exception cref="System.ArgumentException">Thrown when the key does not exist or when there is an invalid parameter.</exception>
+        /// <exception cref="System.InvalidCastException">Thrown when the value of the bundle item cannot be converted to the specified generic type.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bundle instance has been disposed.</exception>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// string[] stringArray = { "a", "b", "c" };
+        /// bundle.AddItem("string_array", stringArray);
+        /// if (bundle.Is<string>("string_array"))
+        /// {
+        ///     Console.WriteLine("It is a string");
+        ///     Console.WriteLine(bundle.GetItem<string>("string_array"));
+        /// }
+        /// else if (bundle.Is<string[]>("string_array"))
+        /// {
+        ///     Console.WriteLine("It is a string[]");
+        ///     string[] anArray = bundle.GetItem<string[]>("string_array");
+        ///     foreach (string value in anArray)
+        ///     {
+        ///         Console.WriteLine(value);
+        ///     }
+        /// }
+        /// </code>
+        public T GetItem<T>(string key)
+        {
+            return (T)GetItem(key);
+        }
+
+        /// <summary>
+        /// Gets the value of a bundle item with a specified key.
+        /// </summary>
+        /// <param name="key">The key of the bundle item whose value is desired.</param>
+        /// <param name="value">The value of the bundle item. If the key does not exist or the type of this parameter is incorrect, it is the default value for the value parameter type.</param>
+        /// <returns>true if an item with the key exists and if the value is the same type as the output value parameter. false otherwise.</returns>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bundle instance has been disposed.</exception>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// byte[] byteArray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+        /// bundle.AddItem("byte_array", byteArray);
+        /// byte[] aByteArray;
+        /// if (bundle.TryGetItem("byte_array", out aByteArray))
+        /// {
+        ///     Console.WriteLine("First item in the byte array: {0}", aByteArray[0]);
+        /// }
+        /// </code>
+        public bool TryGetItem(string key, out byte[] value)
+        {
+            if (_keys.Contains(key) && Interop.Bundle.GetType(_handle, key) == (int)BundleType.Byte)
+            {
+                value = GetItem<byte[]>(key);
+                return true;
+            }
+            else
+            {
+                if (_keys.Contains(key) && ErrorFacts.GetLastResult() == (int)BundleErrorFactory.BundleError.InvalidParameter)
+                {
+                    throw new InvalidOperationException("Invalid bundle instance (object may have been disposed or released)");
+                }
+                value = default(byte[]);
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// Gets the value of a bundle item with a specified key.
+        /// </summary>
+        /// <param name="key">The key of the bundle item whose value is desired.</param>
+        /// <param name="value">The value of the bundle item. If the key does not exist or the type of this parameter is incorrect, it is the default value for the value parameter type.</param>
+        /// <returns>true if an item with the key exists and if the value is the same type as the output value parameter. false otherwise.</returns>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bundle instance has been disposed.</exception>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// bundle.AddItem("string", "a_string");
+        /// string aString;
+        /// if (bundle.TryGetItem("string", out aString))
+        /// {
+        ///     Console.WriteLine(aString);
+        /// }
+        /// </code>
+        public bool TryGetItem(string key, out string value)
+        {
+            if (_keys.Contains(key) && Interop.Bundle.GetType(_handle, key) == (int)BundleType.String)
+            {
+                value = GetItem<string>(key);
+                return true;
+            }
+            else
+            {
+                if (_keys.Contains(key) && ErrorFacts.GetLastResult() == (int)BundleErrorFactory.BundleError.InvalidParameter)
+                {
+                    throw new InvalidOperationException("Invalid bundle instance (object may have been disposed or released)");
+                }
+                value = default(string);
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// Gets the value of a bundle item with a specified key.
+        /// </summary>
+        /// <param name="key">The key of the bundle item whose value is desired.</param>
+        /// <param name="value">The value of the bundle item. If the key does not exist or the type of this parameter is incorrect, it is the default value for the value parameter type.</param>
+        /// <returns>true if an item with the key exists and if the value is the same type as the output value parameter. false otherwise.</returns>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bundle instance has been disposed.</exception>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// string[] stringArray = { "a", "b", "c" };
+        /// bundle.AddItem("string_array", stringArray);
+        /// System.Collections.Generic.IEnumerable<string> aStringEnumerable;
+        /// if (bundle.TryGetItem("string", out aStringEnumerable))
+        /// {
+        ///     foreach (string value in aStringEnumerable)
+        ///     {
+        ///         Console.WriteLine(value);
+        ///     }
+        /// }
+        /// </code>
+        public bool TryGetItem(string key, out IEnumerable<string> value)
+        {
+            if (_keys.Contains(key) && Interop.Bundle.GetType(_handle, key) == (int)BundleType.StringArray)
+            {
+                value = GetItem<IEnumerable<string>>(key);
+                return true;
+            }
+            else
+            {
+                if (_keys.Contains(key) && ErrorFacts.GetLastResult() == (int)BundleErrorFactory.BundleError.InvalidParameter)
+                {
+                    throw new InvalidOperationException("Invalid bundle instance (object may have been disposed or released)");
+                }
+                value = default(IEnumerable<string>);
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// Checks whether an item is of a specific type.
+        /// </summary>
+        /// <typeparam name="T">The generic type to check for.</typeparam>
+        /// <param name="key">The key whose type wants to be checked.</param>
+        /// <returns>true if the item is of the specified type. false otherwise.</returns>
+        /// <exception cref="System.ArgumentException">Thrown when the key does not exist or when there is an invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bundle instance has been disposed.</exception>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// string[] stringArray = { "a", "b", "c" };
+        /// bundle.AddItem("string_array", stringArray);
+        /// if (bundle.Is<string[]>("string_array"))
+        /// {
+        ///     Console.WriteLine("It is a string[]");
+        ///     string[] anArray = bundle.GetItem<string[]>("string_array");
+        ///     foreach (string value in anArray)
+        ///     {
+        ///         Console.WriteLine(value);
+        ///     }
+        /// }
+        /// </code>
+        public bool Is<T>(string key)
+        {
+            if (_keys.Contains(key))
+            {
+                int type = Interop.Bundle.GetType(_handle, key);
+                switch (type)
+                {
+                    case (int)BundleType.String:
+                        return typeof(string) == typeof(T);
+
+                    case (int)BundleType.StringArray:
+                        return typeof(T).GetTypeInfo().IsAssignableFrom(typeof(string[]).GetTypeInfo());
+
+                    case (int)BundleType.Byte:
+                        return typeof(byte[]) == typeof(T);
+
+                    default:
+                        throw new ArgumentException("Key does not exist in the bundle", "key");
+                }
+            }
+            else
+            {
+                throw new ArgumentException("Key does not exist in the bundle (may be null or empty string)", "key");
+            }
+        }
+
+        /// <summary>
+        /// Removes a a bundle item with a specific key from a Bundle.
+        /// </summary>
+        /// <param name="key">The key of the item to delete.</param>
+        /// <returns>true if the item is successfully found and removed. false otherwise (even if the item is not found).</returns>
+        /// <exception cref="System.ArgumentException">Thrown when there is an invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bundle instance has been disposed.</exception>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// bundle.AddItem("string", "a_string");
+        /// if (bundle.Contains("string"))
+        /// {
+        ///     if (bundle.RemoveItem("string"))
+        ///     {
+        ///         Console.WriteLine("Removed");
+        ///     }
+        /// }
+        /// </code>
+        public bool RemoveItem(string key)
+        {
+            if (_keys.Contains(key))
+            {
+                int ret = Interop.Bundle.RemoveItem(_handle, key);
+                if (ret == (int)BundleErrorFactory.BundleError.KeyNotAvailable)
+                {
+                    return false;
+                }
+                BundleErrorFactory.CheckAndThrowException(ret, _handle);
+                _keys.Remove(key);
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// Decodes an encoded bundle data.
+        /// </summary>
+        /// <param name="bundleRaw">The encoded bundle data. bundleRaw should be return value of Tizen.Applications.Bundle.Encode, otherwise this method will not succeed</param>
+        /// <returns>Decoded Bundle object.</returns>
+        /// <exception cref="System.ArgumentException">Thrown when there is an invalid parameter.</exception>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// string bundleRaw = bundle.Encode();
+        /// Bundle data = bundle.Decode(bundleRaw);
+        /// </code>
+        public static Bundle Decode(string bundleRaw)
+        {
+            SafeBundleHandle handle;
+
+            handle = Interop.Bundle.BundleDecode(bundleRaw, bundleRaw.Length);
+            if (ErrorFacts.GetLastResult() == (int)BundleErrorFactory.BundleError.InvalidParameter)
+            {
+                throw new ArgumentException("Invalid bundle raw");
+            }
+
+            return new Bundle(handle);
+        }
+
+        /// <summary>
+        /// Encodes bundle to string.
+        /// </summary>
+        /// <returns>Encoded Bundle data in string.</returns>
+        /// <exception cref="System.InvalidOperationException">Thrown when out of memory or when the Bundle instance has been disposed.</exception>
+        /// <code>
+        /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
+        /// string bundleRaw = bundle.Encode();
+        /// </code>
+        public string Encode()
+        {
+            string bundleRaw;
+            int len;
+
+            Interop.Bundle.BundleEncode(_handle, out bundleRaw, out len);
+            if (ErrorFacts.GetLastResult() == (int)BundleErrorFactory.BundleError.InvalidParameter)
+            {
+                throw new InvalidOperationException("Invalid bundle");
+            }
+
+            return bundleRaw;
+        }
+
+        /// <summary>
+        /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
+        /// </summary>
+        /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!_disposed)
+            {
+                if (disposing)
+                {
+                    if (_handle != null && !_handle.IsInvalid)
+                        _handle.Dispose();
+                }
+
+                _disposed = true;
+            }
+        }
+
+        /// <summary>
+        /// Destructor of the Bundle class.
+        /// </summary>
+        ~Bundle()
+        {
+            Dispose(false);
+        }
+
+        static private void IntPtrToStringArray(IntPtr unmanagedArray, int size, out string[] managedArray)
+        {
+            managedArray = new string[size];
+            IntPtr[] IntPtrArray = new IntPtr[size];
+
+            Marshal.Copy(unmanagedArray, IntPtrArray, 0, size);
+
+            for (int iterator = 0; iterator < size; iterator++)
+            {
+                managedArray[iterator] = Marshal.PtrToStringAnsi(IntPtrArray[iterator]);
+            }
+        }
+    }
+
+    internal static class BundleErrorFactory
+    {
+        internal enum BundleError
+        {
+            None = ErrorCode.None,
+            OutOfMemory = ErrorCode.OutOfMemory,
+            InvalidParameter = ErrorCode.InvalidParameter,
+            KeyNotAvailable = ErrorCode.KeyNotAvailable,
+            KeyExists = -0x01180000 | 0x01
+        }
+
+        static internal void CheckAndThrowException(int error, SafeBundleHandle handle)
+        {
+            if ((BundleError)error == BundleError.None)
+            {
+                return;
+            }
+            else if ((BundleError)error == BundleError.OutOfMemory)
+            {
+                throw new InvalidOperationException("Out of memory");
+            }
+            else if ((BundleError)error == BundleError.InvalidParameter)
+            {
+                if (handle.IsInvalid)
+                {
+                    throw new InvalidOperationException("Invalid bundle instance (object may have been disposed or released)");
+                }
+                throw new ArgumentException("Invalid parameter");
+            }
+            else if ((BundleError)error == BundleError.KeyNotAvailable)
+            {
+                throw new ArgumentException("Key does not exist in the bundle");
+            }
+            else if ((BundleError)error == BundleError.KeyExists)
+            {
+                throw new ArgumentException("Key already exists");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs b/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs
new file mode 100755 (executable)
index 0000000..5bf6e39
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+using Tizen.Applications.CoreBackend;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Class that represents an application controlled lifecycles by the backend system.
+    /// </summary>
+    public class CoreApplication : Application
+    {
+        private readonly ICoreBackend _backend;
+        private bool _disposedValue = false;
+
+        /// <summary>
+        /// Initializes the CoreApplication class.
+        /// </summary>
+        /// <param name="backend">The backend instance implementing ICoreBacked interface.</param>
+        public CoreApplication(ICoreBackend backend)
+        {
+            _backend = backend;
+        }
+
+        /// <summary>
+        /// Occurs when the application is launched.
+        /// </summary>
+        public event EventHandler Created;
+
+        /// <summary>
+        /// Occurs when the application is about to shutdown.
+        /// </summary>
+        public event EventHandler Terminated;
+
+        /// <summary>
+        /// Occurs whenever the application receives the appcontrol message.
+        /// </summary>
+        public event EventHandler<AppControlReceivedEventArgs> AppControlReceived;
+
+        /// <summary>
+        /// Occurs when the system memory is low.
+        /// </summary>
+        public event EventHandler<LowMemoryEventArgs> LowMemory;
+
+        /// <summary>
+        /// Occurs when the system battery is low.
+        /// </summary>
+        public event EventHandler<LowBatteryEventArgs> LowBattery;
+
+        /// <summary>
+        /// Occurs when the system language is chagned.
+        /// </summary>
+        public event EventHandler<LocaleChangedEventArgs> LocaleChanged;
+
+        /// <summary>
+        /// Occurs when the region format is changed.
+        /// </summary>
+        public event EventHandler<RegionFormatChangedEventArgs> RegionFormatChanged;
+
+        /// <summary>
+        /// Occurs when the device orientation is changed.
+        /// </summary>
+        public event EventHandler<DeviceOrientationEventArgs> DeviceOrientationChanged;
+
+        /// <summary>
+        /// The backend instance.
+        /// </summary>
+        protected ICoreBackend Backend { get { return _backend; } }
+
+        /// <summary>
+        /// Runs the application's main loop.
+        /// </summary>
+        /// <param name="args">Arguments from commandline.</param>
+        public override void Run(string[] args)
+        {
+            base.Run(args);
+
+            _backend.AddEventHandler(EventType.Created, OnCreate);
+            _backend.AddEventHandler(EventType.Terminated, OnTerminate);
+            _backend.AddEventHandler<AppControlReceivedEventArgs>(EventType.AppControlReceived, OnAppControlReceived);
+            _backend.AddEventHandler<LowMemoryEventArgs>(EventType.LowMemory, OnLowMemory);
+            _backend.AddEventHandler<LowBatteryEventArgs>(EventType.LowBattery, OnLowBattery);
+            _backend.AddEventHandler<LocaleChangedEventArgs>(EventType.LocaleChanged, OnLocaleChanged);
+            _backend.AddEventHandler<RegionFormatChangedEventArgs>(EventType.RegionFormatChanged, OnRegionFormatChanged);
+            _backend.AddEventHandler<DeviceOrientationEventArgs>(EventType.DeviceOrientationChanged, OnDeviceOrientationChanged);
+
+            string[] argsClone = null;
+
+            if (args == null)
+            {
+                argsClone = new string[1];
+            }
+            else
+            {
+                argsClone = new string[args.Length + 1];
+                args.CopyTo(argsClone, 1);
+            }
+            argsClone[0] = string.Empty;
+            _backend.Run(argsClone);
+        }
+
+        /// <summary>
+        /// Exits the main loop of the application.
+        /// </summary>
+        public override void Exit()
+        {
+            _backend.Exit();
+        }
+
+        /// <summary>
+        /// Overrides this method if want to handle behavior when the application is launched.
+        /// If base.OnCreated() is not called, the event 'Created' will not be emitted.
+        /// </summary>
+        protected virtual void OnCreate()
+        {
+            Created?.Invoke(this, EventArgs.Empty);
+        }
+
+        /// <summary>
+        /// Overrides this method if want to handle behavior when the application is terminated.
+        /// If base.OnTerminate() is not called, the event 'Terminated' will not be emitted.
+        /// </summary>
+        protected virtual void OnTerminate()
+        {
+            Terminated?.Invoke(this, EventArgs.Empty);
+        }
+
+        /// <summary>
+        /// Overrides this method if want to handle behavior when the application receives the appcontrol message.
+        /// If base.OnAppControlReceived() is not called, the event 'AppControlReceived' will not be emitted.
+        /// </summary>
+        /// <param name="e"></param>
+        protected virtual void OnAppControlReceived(AppControlReceivedEventArgs e)
+        {
+            AppControlReceived?.Invoke(this, e);
+        }
+
+        /// <summary>
+        /// Overrides this method if want to handle behavior when the system memory is low.
+        /// If base.OnLowMemory() is not called, the event 'LowMemory' will not be emitted.
+        /// </summary>
+        protected virtual void OnLowMemory(LowMemoryEventArgs e)
+        {
+            LowMemory?.Invoke(this, e);
+            System.GC.Collect();
+        }
+
+        /// <summary>
+        /// Overrides this method if want to handle behavior when the system battery is low.
+        /// If base.OnLowBattery() is not called, the event 'LowBattery' will not be emitted.
+        /// </summary>
+        protected virtual void OnLowBattery(LowBatteryEventArgs e)
+        {
+            LowBattery?.Invoke(this, e);
+        }
+
+        /// <summary>
+        /// Overrides this method if want to handle behavior when the system language is changed.
+        /// If base.OnLocaleChanged() is not called, the event 'LocaleChanged' will not be emitted.
+        /// </summary>
+        protected virtual void OnLocaleChanged(LocaleChangedEventArgs e)
+        {
+            LocaleChanged?.Invoke(this, e);
+        }
+
+        /// <summary>
+        /// Overrides this method if want to handle behavior when the region format is changed.
+        /// If base.OnRegionFormatChanged() is not called, the event 'RegionFormatChanged' will not be emitted.
+        /// </summary>
+        protected virtual void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
+        {
+            RegionFormatChanged?.Invoke(this, e);
+        }
+
+        /// <summary>
+        /// Overrides this method if want to handle behavior when the device orientation is changed.
+        /// If base.OnRegionFormatChanged() is not called, the event 'RegionFormatChanged' will not be emitted.
+        /// </summary>
+        protected virtual void OnDeviceOrientationChanged(DeviceOrientationEventArgs e)
+        {
+            DeviceOrientationChanged?.Invoke(this, e);
+        }
+
+        /// <summary>
+        /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
+        /// </summary>
+        /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (!_disposedValue)
+            {
+                if (disposing)
+                {
+                    _backend.Dispose();
+                }
+
+                _disposedValue = true;
+            }
+            base.Dispose(disposing);
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/DeviceOrientation.cs b/src/Tizen.Applications.Common/Tizen.Applications/DeviceOrientation.cs
new file mode 100755 (executable)
index 0000000..5b41aea
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for device orientation.
+    /// </summary>
+    public enum DeviceOrientation
+    {
+        /// <summary>
+        /// The device orientation is 0
+        /// </summary>
+        Orientation_0 = 0,
+
+        /// <summary>
+        /// The device orientation is 90
+        /// </summary>
+        Orientation_90 = 90,
+
+        /// <summary>
+        /// The device orientation is 180
+        /// </summary>
+        Orientation_180 = 180,
+
+        /// <summary>
+        /// The device orientation is 270
+        /// </summary>
+        Orientation_270 = 270,
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/DeviceOrientationEventArgs.cs b/src/Tizen.Applications.Common/Tizen.Applications/DeviceOrientationEventArgs.cs
new file mode 100755 (executable)
index 0000000..750e316
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// The class for the argument of the DeviceOrientationChanged EventHandler
+    /// </summary>
+    public class DeviceOrientationEventArgs : EventArgs
+    {
+        /// <summary>
+        ///  Initializes DeviceOrientationEventArgs class
+        /// </summary>
+        /// <param name="orientation">The information of the DeviceOrientation</param>
+        public DeviceOrientationEventArgs(DeviceOrientation orientation)
+        {
+            DeviceOrientation = orientation;
+        }
+
+        /// <summary>
+        /// The property to get the intformation of the DeviceOrientation
+        /// </summary>
+        public DeviceOrientation DeviceOrientation { get; private set; }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/DirectoryInfo.cs b/src/Tizen.Applications.Common/Tizen.Applications/DirectoryInfo.cs
new file mode 100755 (executable)
index 0000000..4b7f06b
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Represents directory information of the application.
+    /// </summary>
+    public class DirectoryInfo
+    {
+        private string _dataPath;
+        private string _cachePath;
+        private string _resourcePath;
+
+        private string _sharedDataPath;
+        private string _sharedResourcePath;
+        private string _sharedTrustedPath;
+
+        private string _externalDataPath;
+        private string _externalCachePath;
+        private string _externalSharedDataPath;
+
+        private string _expansionPackageResourcePath;
+
+        internal DirectoryInfo()
+        {
+        }
+
+        /// <summary>
+        /// Gets the absolute path to the application's data directory which is used to store private data of the application.
+        /// </summary>
+        public string Data
+        {
+            get
+            {
+                if (_dataPath == null)
+                    _dataPath = Interop.AppCommon.AppGetDataPath();
+                return _dataPath;
+            }
+        }
+
+        /// <summary>
+        /// Gets the absolute path to the application's cache directory which is used to store temporary data of the application.
+        /// </summary>
+        public string Cache
+        {
+            get
+            {
+                if (_cachePath == null)
+                    _cachePath = Interop.AppCommon.AppGetCachePath();
+                return _cachePath;
+            }
+        }
+
+        /// <summary>
+        /// Gets the absolute path to the application resource directory. The resource files are delivered with the application package.
+        /// </summary>
+        public string Resource
+        {
+            get
+            {
+                if (_resourcePath == null)
+                    _resourcePath = Interop.AppCommon.AppGetResourcePath();
+                return _resourcePath;
+            }
+        }
+
+        /// <summary>
+        /// Gets the absolute path to the application's shared data directory which is used to share data with other applications.
+        /// </summary>
+        public string SharedData
+        {
+            get
+            {
+                if (_sharedDataPath == null)
+                    _sharedDataPath = Interop.AppCommon.AppGetSharedDataPath();
+                return _sharedDataPath;
+            }
+        }
+
+        /// <summary>
+        /// Gets the absolute path to the application's shared resource directory which is used to share resources with other applications.
+        /// </summary>
+        public string SharedResource
+        {
+            get
+            {
+                if (_sharedResourcePath == null)
+                    _sharedResourcePath = Interop.AppCommon.AppGetSharedResourcePath();
+                return _sharedResourcePath;
+            }
+        }
+
+
+        /// <summary>
+        /// Gets the absolute path to the application's shared trusted directory which is used to share data with a family of trusted applications.
+        /// </summary>
+        public string SharedTrusted
+        {
+            get
+            {
+                if (_sharedTrustedPath == null)
+                    _sharedTrustedPath = Interop.AppCommon.AppGetSharedTrustedPath();
+                return _sharedTrustedPath;
+            }
+        }
+
+        /// <summary>
+        /// Gets the absolute path to the application's external data directory which is used to store data of the application.
+        /// </summary>
+        public string ExternalData
+        {
+            get
+            {
+                if (_externalDataPath == null)
+                    _externalDataPath = Interop.AppCommon.AppGetExternalDataPath();
+                return _externalDataPath;
+            }
+        }
+
+        /// <summary>
+        /// Gets the absolute path to the application's external cache directory which is used to store temporary data of the application.
+        /// </summary>
+        public string ExternalCache
+        {
+            get
+            {
+                if (_externalCachePath == null)
+                    _externalCachePath = Interop.AppCommon.AppGetExternalCachePath();
+                return _externalCachePath;
+            }
+        }
+
+        /// <summary>
+        /// Gets the absolute path to the application's external shared data directory which is used to share data with other applications.
+        /// </summary>
+        public string ExternalSharedData
+        {
+            get
+            {
+                if (_externalSharedDataPath == null)
+                    _externalSharedDataPath = Interop.AppCommon.AppGetExternalSharedDataPath();
+                return _externalSharedDataPath;
+            }
+        }
+
+        /// <summary>
+        /// Gets the absolute path to the application's TEP(Tizen Expansion Package) directory. The resource files are delivered with the expansion package.
+        /// </summary>
+        public string ExpansionPackageResource
+        {
+            get
+            {
+                if (_expansionPackageResourcePath == null)
+                    _expansionPackageResourcePath = Interop.AppCommon.AppGetTepResourcePath();
+                return _expansionPackageResourcePath;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/LocaleChangedEventArgs.cs b/src/Tizen.Applications.Common/Tizen.Applications/LocaleChangedEventArgs.cs
new file mode 100755 (executable)
index 0000000..a1e99ba
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// The class for the argument of the LocaleChanged EventHandler
+    /// </summary>
+    public class LocaleChangedEventArgs : EventArgs
+    {
+
+        /// <summary>
+        /// Initializes LocaleChangedEventArgs class
+        /// </summary>
+        /// <param name="locale">The information of the Locale</param>
+        public LocaleChangedEventArgs(string locale)
+        {
+            Locale = locale;
+        }
+
+        /// <summary>
+        /// The property to get the intformation of the Locale
+        /// </summary>
+        public string Locale { get; private set; }
+
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/LowBatteryEventArgs.cs b/src/Tizen.Applications.Common/Tizen.Applications/LowBatteryEventArgs.cs
new file mode 100755 (executable)
index 0000000..bf0c49a
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// The class for the argument of the LowBattery EventHandler
+    /// </summary>
+    public class LowBatteryEventArgs : EventArgs
+    {
+        /// <summary>
+        /// Initializes LowBatteryEventArgs class
+        /// </summary>
+        /// <param name="status">The information of the LowBatteryEventArgs</param>
+        public LowBatteryEventArgs(LowBatteryStatus status)
+        {
+            LowBatteryStatus = status;
+        }
+
+        /// <summary>
+        /// The property to get the intformation of the LowBatteryStatus
+        /// </summary>
+        public LowBatteryStatus LowBatteryStatus { get; private set; }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/LowBatteryStatus.cs b/src/Tizen.Applications.Common/Tizen.Applications/LowBatteryStatus.cs
new file mode 100755 (executable)
index 0000000..a835521
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for low battery status.
+    /// </summary>
+    public enum LowBatteryStatus
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        None = 0,
+
+        /// <summary>
+        /// The battery status is under 1%
+        /// </summary>
+        PowerOff = 1,
+
+        /// <summary>
+        /// The battery status is under 5%
+        /// </summary>
+        CriticalLow
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/LowMemoryEventArgs.cs b/src/Tizen.Applications.Common/Tizen.Applications/LowMemoryEventArgs.cs
new file mode 100755 (executable)
index 0000000..e42fedc
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// The class for the argument of the LowMemory EventHandler
+    /// </summary>
+    public class LowMemoryEventArgs : EventArgs
+    {
+        /// <summary>
+        /// Initializes LowMemoryEventArgs class
+        /// </summary>
+        /// <param name="status">The information of the LowMemoryStatus</param>
+        public LowMemoryEventArgs(LowMemoryStatus status)
+        {
+            LowMemoryStatus = status;
+        }
+
+        /// <summary>
+        /// The property to get the intformation of the LowMemoryStatus
+        /// </summary>
+        public LowMemoryStatus LowMemoryStatus { get; private set; }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/LowMemoryStatus.cs b/src/Tizen.Applications.Common/Tizen.Applications/LowMemoryStatus.cs
new file mode 100755 (executable)
index 0000000..e704de3
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for low memory status.
+    /// </summary>
+    public enum LowMemoryStatus
+    {
+        /// <summary>
+        /// Not initialized status
+        /// </summary>
+        None = 0x00,
+
+        /// <summary>
+        /// Normal status
+        /// </summary>
+        Normal = 0x01,
+
+        /// <summary>
+        /// Soft warning status
+        /// </summary>
+        SoftWarning = 0x02,
+
+        /// <summary>
+        /// Hard warning status
+        /// </summary>
+        HardWarning = 0x04,
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ReceivedAppControl.cs b/src/Tizen.Applications.Common/Tizen.Applications/ReceivedAppControl.cs
new file mode 100755 (executable)
index 0000000..638ee7a
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Represents the received AppControl.
+    /// </summary>
+    /// <example>
+    /// <code>
+    /// public class ReceivedAppControlExample : UIApplication
+    /// {
+    ///     // ...
+    ///     protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
+    ///     {
+    ///         ReceivedAppControl control = e.ReceivedAppControl;
+    ///         if (control.Operation == AppControlOperations.Pick)
+    ///         {
+    ///             Log.Debug(LogTag, "Received AppControl is Pick");
+    ///         }
+    ///         if (control.IsReplyRequest)
+    ///         {
+    ///             AppControl replyRequest = new AppControl();
+    ///             replyRequest.ExtraData.Add("myKey", "I'm replying");
+    ///             control.ReplyToLaunchRequest(replyRequest, AppControlReplyResult.Succeeded);
+    ///         }
+    ///     }
+    /// }
+    /// </code>
+    /// </example>
+    public class ReceivedAppControl : AppControl
+    {
+        private const string LogTag = "Tizen.Applications";
+
+        /// <summary>
+        /// Initializes a ReceivedAppControl class.
+        /// </summary>
+        public ReceivedAppControl(SafeAppControlHandle handle) : base(handle)
+        {
+        }
+
+        /// <summary>
+        /// Gets the application ID of the caller from the launch request.
+        /// </summary>
+        /// <value>
+        /// The application ID of the caller
+        /// </value>
+        /// <example>
+        /// <code>
+        ///     protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
+        ///     {
+        ///         ReceivedAppControl control = e.ReceivedAppControl;
+        ///         string caller = control.CallerApplicationId;
+        ///     }
+        /// </code>
+        /// </example>
+        public string CallerApplicationId
+        {
+            get
+            {
+                string value = String.Empty;
+                Interop.AppControl.ErrorCode err = Interop.AppControl.GetCaller(SafeAppControlHandle, out value);
+                if (err != Interop.AppControl.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, "Failed to get the caller application id from the AppControl. Err = " + err);
+                }
+                return value;
+            }
+        }
+
+        /// <summary>
+        /// Checks whether the caller is requesting a reply from the launch request.
+        /// </summary>
+        /// <value>
+        /// If true this ReceivedAppControl is requested by the caller, otherwise false
+        /// </value>
+        /// <example>
+        /// <code>
+        ///     protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
+        ///     {
+        ///         ReceivedAppControl control = e.ReceivedAppControl;
+        ///         bool isReply = control.IsReplyRequest;
+        ///     }
+        /// </code>
+        /// </example>
+        public bool IsReplyRequest
+        {
+            get
+            {
+                bool value = false;
+                Interop.AppControl.ErrorCode err = Interop.AppControl.IsReplyRequested(SafeAppControlHandle, out value);
+                if (err != Interop.AppControl.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, "Failed to check the reply  of the AppControl is requested. Err = " + err);
+                }
+                return value;
+            }
+        }
+
+        /// <summary>
+        /// Replies to the launch request sent by the caller.
+        /// If the caller application sent the launch request to receive the result, the callee application can return the result back to the caller.
+        /// </summary>
+        /// <param name="replyRequest">The AppControl in which the results of the callee are contained</param>
+        /// <param name="result">The result code of the launch request</param>
+        /// <example>
+        /// <code>
+        ///     protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
+        ///     {
+        ///         ReceivedAppControl control = e.ReceivedAppControl;
+        ///         if (control.IsReplyRequest)
+        ///         {
+        ///             AppControl replyRequest = new AppControl();
+        ///             replyRequest.ExtraData.Add("myKey", "I'm replying");
+        ///             control.ReplyToLaunchRequest(replyRequest, AppControlReplyResult.Succeeded);
+        ///         }
+        ///     }
+        /// </code>
+        /// </example>
+        public void ReplyToLaunchRequest(AppControl replyRequest, AppControlReplyResult result)
+        {
+            if (replyRequest == null)
+            {
+                throw new ArgumentNullException("replyRequest");
+            }
+            Interop.AppControl.ErrorCode err = Interop.AppControl.ReplyToLaunchRequest(replyRequest.SafeAppControlHandle, this.SafeAppControlHandle, (int)result);
+            if (err != Interop.AppControl.ErrorCode.None)
+                throw new InvalidOperationException("Failed to reply. Err = " + err);
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/RecentApplicationControl.cs b/src/Tizen.Applications.Common/Tizen.Applications/RecentApplicationControl.cs
new file mode 100755 (executable)
index 0000000..5bc84fe
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// This class provides methods and properties to get information of recent application.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class RecentApplicationControl
+    {
+        private const string LogTag = "Tizen.Applications";
+
+        private readonly string _pkgId;
+
+        internal RecentApplicationControl(String pkgId)
+        {
+            _pkgId = pkgId;
+        }
+
+        /// <summary>
+        /// Deletes the application from recent application list.
+        /// </summary>
+        /// <privlevel>platform</privlevel>
+        public void Delete()
+        {
+            Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None;
+            err = Interop.ApplicationManager.RuaDeleteHistoryWithPkgname(_pkgId);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                throw ApplicationManagerErrorFactory.GetException(err, "Failed to delete application from recent application list.");
+            }
+        }
+
+        /// <summary>
+        /// Delete all recent applicationsfrom recent application list.
+        /// </summary>
+        /// <privlevel>platform</privlevel>
+        public static void DeleteAll()
+        {
+            Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None;
+            err = Interop.ApplicationManager.RuaClearHistory();
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                throw ApplicationManagerErrorFactory.GetException(err, "Failed to clear the recent application list.");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/RecentApplicationInfo.cs b/src/Tizen.Applications.Common/Tizen.Applications/RecentApplicationInfo.cs
new file mode 100755 (executable)
index 0000000..613e7d6
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// This class provides methods and properties to get information of recent application.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class RecentApplicationInfo : ApplicationInfo
+    {
+        private const string LogTag = "Tizen.Applications";
+
+        /// <summary>
+        /// Gets the instance id.
+        /// </summary>
+        public string InstanceId { get; private set; }
+
+        /// <summary>
+        /// Gets the instance Name.
+        /// </summary>
+        public string InstanceName { get; private set; }
+
+        /// <summary>
+        /// Gets the arguements.
+        /// </summary>
+        public string Arg { get; private set; }
+
+        /// <summary>
+        /// Gets the uri.
+        /// </summary>
+        public string Uri { get; private set; }
+
+        /// <summary>
+        /// Gets the launchTime.
+        /// </summary>
+        public DateTime LaunchTime { get; private set; }
+
+        /// <summary>
+        /// Gets the recent application controller.
+        /// </summary>
+        public RecentApplicationControl Controller { get; private set; }
+
+        internal RecentApplicationInfo(Interop.ApplicationManager.RuaRec record) : base(Marshal.PtrToStringAnsi(record.pkgName))
+        {
+            InstanceId = Marshal.PtrToStringAnsi(record.instanceId);
+            InstanceName = Marshal.PtrToStringAnsi(record.instanceName);
+            Arg = Marshal.PtrToStringAnsi(record.arg);
+            Uri = Marshal.PtrToStringAnsi(record.uri);
+            long seconds = record.launchTime.ToInt64();
+            LaunchTime = new DateTime(1970, 1, 1).AddSeconds(seconds);
+            Controller = new RecentApplicationControl(Marshal.PtrToStringAnsi(record.pkgName));
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/RegionFormatChangedEventArgs.cs b/src/Tizen.Applications.Common/Tizen.Applications/RegionFormatChangedEventArgs.cs
new file mode 100755 (executable)
index 0000000..a481093
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// The class for the argument of the RegionFormatChanged EventHandler
+    /// </summary>
+    public class RegionFormatChangedEventArgs : EventArgs
+    {
+
+        /// <summary>
+        /// Initializes RegionFormatChangedEventArgs class
+        /// </summary>
+        /// <param name="region">The information of the Region</param>
+        public RegionFormatChangedEventArgs(string region)
+        {
+            Region = region;
+        }
+
+        /// <summary>
+        /// The property to get the intformation of the Region
+        /// </summary>
+        public string Region { get; private set; }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ResourceManager.cs b/src/Tizen.Applications.Common/Tizen.Applications/ResourceManager.cs
new file mode 100755 (executable)
index 0000000..c20840a
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Class for getting resource path.
+    /// </summary>
+    public static class ResourceManager
+    {
+        /// <summary>
+        /// Enumeration for Resource category.
+        /// </summary>
+        public enum Category : int
+        {
+            /// <summary>
+            /// Image format.
+            /// </summary>
+            Image = 0,
+
+            /// <summary>
+            /// Layout format.
+            /// </summary>
+            Layout,
+
+            /// <summary>
+            /// Sound format.
+            /// </summary>
+            Sound,
+
+            /// <summary>
+            /// Binary format.
+            /// </summary>
+            Binary
+        }
+
+        private static ErrorCode AppResourceManagerGet(Category category, string id, out string path)
+        {
+            ErrorCode err;
+
+            try
+            {
+                err = Interop.AppCommon.AppResourceManagerGet(
+                             (Interop.AppCommon.ResourceCategory)category, id, out path);
+            }
+            catch (System.TypeLoadException)
+            {
+                err = Interop.AppCommon.LegacyAppResourceManagerGet(
+                             (Interop.AppCommon.ResourceCategory)category, id, out path);
+            }
+
+            return err;
+        }
+
+        /// <summary>
+        /// Converts resource ID to path name.
+        /// </summary>
+        /// <param name="category">Category to search</param>
+        /// <param name="id">ID to search</param>
+        /// <returns>Found resource path</returns>
+        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
+        public static string GetPath(Category category, string id)
+        {
+            string path;
+            ErrorCode err = AppResourceManagerGet(category, id, out path);
+
+            switch (err)
+            {
+                case ErrorCode.InvalidParameter:
+                throw new InvalidOperationException("Invalid parameter");
+
+                case ErrorCode.OutOfMemory:
+                throw new InvalidOperationException("Out-of-memory at unmanaged code");
+
+                case ErrorCode.IoError:
+                throw new InvalidOperationException("IO error at unmanaged code");
+            }
+
+            return path;
+        }
+
+        /// <summary>
+        /// Converts resource ID to path name.
+        /// </summary>
+        /// <param name="category">Category to search</param>
+        /// <param name="id">ID to search</param>
+        /// <returns>Found resource path or null when the resource doesn't exist</returns>
+        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
+        public static string TryGetPath(Category category, string id)
+        {
+            string path;
+            ErrorCode err = AppResourceManagerGet(category, id, out path);
+
+            switch (err)
+            {
+                case ErrorCode.InvalidParameter:
+                throw new InvalidOperationException("Invalid parameter");
+
+                case ErrorCode.OutOfMemory:
+                throw new InvalidOperationException("Out-of-memory at unmanaged code");
+
+                case ErrorCode.IoError:
+                return null;
+            }
+
+            return path;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/SafeAppControlHandle.cs b/src/Tizen.Applications.Common/Tizen.Applications/SafeAppControlHandle.cs
new file mode 100755 (executable)
index 0000000..5bbdf60
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Represents a wrapper class for a unmanaged AppControl handle.
+    /// </summary>
+    public sealed class SafeAppControlHandle : SafeHandle
+    {
+        /// <summary>
+        /// Initializes a new instance of the SafeAppControlHandle class.
+        /// </summary>
+        public SafeAppControlHandle() : base(IntPtr.Zero, true)
+        {
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the SafeAppControlHandle class.
+        /// </summary>
+        /// <param name="existingHandle">An IntPtr object that represents the pre-existing handle to use.</param>
+        /// <param name="ownsHandle">true to reliably release the handle during the finalization phase; false to prevent reliable release.</param>
+        public SafeAppControlHandle(IntPtr existingHandle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle)
+        {
+            SetHandle(existingHandle);
+        }
+
+        /// <summary>
+        /// Gets a value that indicates whether the handle is invalid.
+        /// </summary>
+        public override bool IsInvalid
+        {
+            get { return this.handle == IntPtr.Zero; }
+        }
+
+        /// <summary>
+        /// When overridden in a derived class, executes the code required to free the handle.
+        /// </summary>
+        /// <returns>true if the handle is released successfully</returns>
+        protected override bool ReleaseHandle()
+        {
+            Interop.AppControl.DangerousDestroy(this.handle);
+            this.SetHandle(IntPtr.Zero);
+            return true;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/SafeBundleHandle.cs b/src/Tizen.Applications.Common/Tizen.Applications/SafeBundleHandle.cs
new file mode 100755 (executable)
index 0000000..c3bab4b
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Represents a wrapper class for a unmanaged Bundle handle.
+    /// </summary>
+    public sealed class SafeBundleHandle : SafeHandle
+    {
+        /// <summary>
+        /// Initializes a new instance of the SafeBundleHandle class.
+        /// </summary>
+        public SafeBundleHandle() : base(IntPtr.Zero, true)
+        {
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the SafeBundleHandle class.
+        /// </summary>
+        /// <param name="existingHandle">An IntPtr object that represents the pre-existing handle to use.</param>
+        /// <param name="ownsHandle">true to reliably release the handle during the finalization phase; false to prevent reliable release.</param>
+        public SafeBundleHandle(IntPtr existingHandle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle)
+        {
+            SetHandle(existingHandle);
+        }
+
+        /// <summary>
+        /// Gets a value that indicates whether the handle is invalid.
+        /// </summary>
+        public override bool IsInvalid
+        {
+            get { return this.handle == IntPtr.Zero; }
+        }
+
+        /// <summary>
+        /// When overridden in a derived class, executes the code required to free the handle.
+        /// </summary>
+        /// <returns>true if the handle is released successfully</returns>
+        protected override bool ReleaseHandle()
+        {
+            Interop.Bundle.DangerousFree(this.handle);
+            this.SetHandle(IntPtr.Zero);
+            return true;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/TizenSynchronizationContext.cs b/src/Tizen.Applications.Common/Tizen.Applications/TizenSynchronizationContext.cs
new file mode 100644 (file)
index 0000000..dcfb4c8
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Concurrent;
+using System.Threading;
+
+namespace Tizen.Applications
+{
+
+    /// <summary>
+    /// Provides a synchronization context for the Tizen application model.
+    /// </summary>
+    public class TizenSynchronizationContext : SynchronizationContext
+    {
+        private readonly Interop.Glib.GSourceFunc _wrapperHandler;
+        private readonly Object _transactionLock = new Object();
+        private readonly ConcurrentDictionary<int, Action> _handlerMap = new ConcurrentDictionary<int, Action>();
+        private int _transactionId = 0;
+
+        /// <summary>
+        /// Initializes a new instance of the TizenSynchronizationContext class.
+        /// </summary>
+        public TizenSynchronizationContext()
+        {
+            _wrapperHandler = new Interop.Glib.GSourceFunc(Handler);
+        }
+
+        /// <summary>
+        /// Initilizes a new TizenSynchronizationContext and install into current thread
+        /// </summary>
+        /// <remarks>
+        /// It is equivalent
+        /// <code>
+        /// SetSynchronizationContext(new TizenSynchronizationContext());
+        /// </code>
+        /// </remarks>
+        public static void Initialize()
+        {
+            SetSynchronizationContext(new TizenSynchronizationContext());
+        }
+
+
+        /// <summary>
+        /// Dispatches an asynchronous message to a Tizen main loop.
+        /// </summary>
+        /// <param name="d"><see cref="System.Threading.SendOrPostCallback"/>The SendOrPostCallback delegate to call.</param>
+        /// <param name="state"><see cref="System.Object"/>The object passed to the delegate.</param>
+        /// <remarks>
+        /// The Post method starts an asynchronous request to post a message.</remarks>
+        public override void Post(SendOrPostCallback d, object state)
+        {
+            Post(() =>
+            {
+                d(state);
+            });
+        }
+
+        /// <summary>
+        /// Dispatches a synchronous message to a Tizen main loop
+        /// </summary>
+        /// <param name="d"><see cref="System.Threading.SendOrPostCallback"/>The SendOrPostCallback delegate to call.</param>
+        /// <param name="state"><see cref="System.Object"/>The object passed to the delegate.</param>
+        /// <remarks>
+        /// The Send method starts a synchronous request to send a message.</remarks>
+        public override void Send(SendOrPostCallback d, object state)
+        {
+            var mre = new ManualResetEvent(false);
+            Exception err = null;
+            Post(() =>
+            {
+                try
+                {
+                    d(state);
+                }
+                catch (Exception ex)
+                {
+                    err = ex;
+                }
+                finally
+                {
+                    mre.Set();
+                }
+            });
+            mre.WaitOne();
+            if (err != null)
+            {
+                throw err;
+            }
+        }
+
+        private void Post(Action action)
+        {
+            int id = 0;
+            lock (_transactionLock)
+            {
+                id = _transactionId++;
+            }
+            _handlerMap.TryAdd(id, action);
+            Interop.Glib.IdleAdd(_wrapperHandler, (IntPtr)id);
+        }
+
+        private bool Handler(IntPtr userData)
+        {
+            int key = (int)userData;
+            if (_handlerMap.ContainsKey(key))
+            {
+                Action action;
+                _handlerMap.TryRemove(key, out action);
+                action?.Invoke();
+            }
+            return false;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.DataControl/Tizen.Applications.DataControl.sln b/src/Tizen.Applications.DataControl/Tizen.Applications.DataControl.sln
deleted file mode 100755 (executable)
index b68ed82..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26430.4
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.DataControl", "Tizen.Applications.DataControl.csproj", "{2EC826C0-E07A-4A53-8FC6-322BD2F1228F}"
-EndProject
-Global
-       GlobalSection(SolutionConfigurationPlatforms) = preSolution
-               Debug|Any CPU = Debug|Any CPU
-               Release|Any CPU = Release|Any CPU
-       EndGlobalSection
-       GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {2EC826C0-E07A-4A53-8FC6-322BD2F1228F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-               {2EC826C0-E07A-4A53-8FC6-322BD2F1228F}.Debug|Any CPU.Build.0 = Debug|Any CPU
-               {2EC826C0-E07A-4A53-8FC6-322BD2F1228F}.Release|Any CPU.ActiveCfg = Release|Any CPU
-               {2EC826C0-E07A-4A53-8FC6-322BD2F1228F}.Release|Any CPU.Build.0 = Release|Any CPU
-       EndGlobalSection
-       GlobalSection(SolutionProperties) = preSolution
-               HideSolutionNode = FALSE
-       EndGlobalSection
-EndGlobal
diff --git a/src/Tizen.Applications.MessagePort/Interop/Interop.Libraries.cs b/src/Tizen.Applications.MessagePort/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..2b7e4da
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string MessagePort = "libmessage-port.so.1";
+    }
+}
diff --git a/src/Tizen.Applications.MessagePort/Interop/Interop.MessagePort.cs b/src/Tizen.Applications.MessagePort/Interop/Interop.MessagePort.cs
new file mode 100755 (executable)
index 0000000..bcbbc63
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+using Tizen.Applications;
+
+internal static partial class Interop
+{
+    internal static partial class MessagePort
+    {
+        [DllImport(Libraries.MessagePort, EntryPoint = "message_port_register_local_port", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int RegisterPort(string local_port, message_port_message_cb callback, IntPtr userData);
+
+        [DllImport(Libraries.MessagePort, EntryPoint = "message_port_register_trusted_local_port", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int RegisterTrustedPort(string trusted_local_port, message_port_message_cb callback, IntPtr userData);
+
+        [DllImport(Libraries.MessagePort, EntryPoint = "message_port_unregister_local_port", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int UnregisterPort(int local_port_id);
+
+        [DllImport(Libraries.MessagePort, EntryPoint = "message_port_unregister_trusted_local_port", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int UnregisterTrustedPort(int trusted_local_port_id);
+
+        [DllImport(Libraries.MessagePort, EntryPoint = "message_port_send_message_with_local_port", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SendMessageWithLocalPort(string remote_app_id, string remote_port, SafeBundleHandle message, int local_port_id);
+
+        [DllImport(Libraries.MessagePort, EntryPoint = "message_port_send_trusted_message_with_local_port", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SendTrustedMessageWithLocalPort(string remote_app_id, string remote_port, SafeBundleHandle message, int local_port_id);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void message_port_message_cb(int local_port_id, string remote_app_id, string remote_port, bool trusted_remote_port, IntPtr message, IntPtr userData);
+    }
+}
diff --git a/src/Tizen.Applications.MessagePort/Tizen.Applications.MessagePort.csproj b/src/Tizen.Applications.MessagePort/Tizen.Applications.MessagePort.csproj
new file mode 100755 (executable)
index 0000000..fb42a2b
--- /dev/null
@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <Import Project="../build/build.props" />
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.3</TargetFramework>
+    <Version>1.5.8</Version>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Applications.MessagePort.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Applications.MessagePort/Tizen.Applications.MessagePort.snk b/src/Tizen.Applications.MessagePort/Tizen.Applications.MessagePort.snk
new file mode 100755 (executable)
index 0000000..7ac1b00
Binary files /dev/null and b/src/Tizen.Applications.MessagePort/Tizen.Applications.MessagePort.snk differ
diff --git a/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/MessagePort.cs b/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/MessagePort.cs
new file mode 100755 (executable)
index 0000000..26632e4
--- /dev/null
@@ -0,0 +1,306 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using Tizen.Applications;
+
+namespace Tizen.Applications.Messages
+{
+    /// <summary>
+    /// The Message Port API provides functions to send and receive messages between applications.
+    /// </summary>
+    /// <remarks>
+    /// The Message Port API provides functions for passing messages between applications. An application should register its own local port to receive messages from remote applications.
+    /// If a remote application sends a message, the registered callback function of the local port is called.
+    /// The trusted message-port API allows communications between applications that are signed by the same developer(author) certificate.
+    /// </remarks>
+    public class MessagePort : IDisposable
+    {
+        private static readonly object s_lock = new object();
+        private static readonly HashSet<string> s_portMap = new HashSet<string>();
+
+        // The name of the local message port
+        private readonly string _portName = null;
+
+        // If true the message port is a trusted port, otherwise false it is not
+        private readonly bool _trusted = false;
+
+        // The local message port ID
+        private int _portId = 0;
+
+        // If true the message port is listening, otherwise false it is not
+        private bool _listening = false;
+
+        private Interop.MessagePort.message_port_message_cb _messageCallBack;
+
+        /// <summary>
+        /// Initializes the instance of the MessagePort class.
+        /// </summary>
+        /// <param name="portName">The name of the local message port</param>
+        /// <param name="trusted">If true is the trusted message port of application, otherwise false</param>
+        /// <exception cref="System.InvalidOperationException">Thrown when portName is null or empty</exception>
+        /// <code>
+        /// MessagePort messagePort = new MessagePort("SenderPort", true);
+        /// </code>
+        public MessagePort(string portName, bool trusted)
+        {
+            if (String.IsNullOrEmpty(portName))
+            {
+                MessagePortErrorFactory.ThrowException((int)MessagePortError.InvalidParameter, "Invalid PortName", "PortName");
+            }
+            _portName = portName;
+            _trusted = trusted;
+        }
+
+        /// <summary>
+        /// Destructor of the MessagePort class.
+        /// </summary>
+        ~MessagePort()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// Called when a message is received.
+        /// </summary>
+        /// <code>
+        /// MessagePort messagePort = new MessagePort("SenderPort", true);
+        /// messagePort.MessageReceived += MessageReceivedCallback;
+        /// static void MessageReceivedCallback(object sender, MessageReceivedEventArgs e)
+        /// {
+        ///     Console.WriteLine("Message Received ");
+        ///     if (e.Remote.AppId != null) {
+        ///         Console.WriteLine("from :"+e.Remote.AppId);
+        ///     }
+        /// }
+        /// </code>
+        public event EventHandler<MessageReceivedEventArgs> MessageReceived;
+
+        /// <summary>
+        /// The name of the local message port
+        /// </summary>
+        public string PortName
+        {
+            get
+            {
+                return _portName;
+            }
+        }
+        /// <summary>
+        /// If true the message port is a trusted port, otherwise false it is not
+        /// </summary>
+        public bool Trusted
+        {
+            get
+            {
+                return _trusted;
+            }
+        }
+
+        /// <summary>
+        /// If true the message port is listening, otherwise false it is not
+        /// </summary>
+        public bool Listening
+        {
+            get
+            {
+                return _listening;
+            }
+        }
+
+        /// <summary>
+        /// Register the local message port.
+        /// </summary>
+        /// <exception cref="System.InvalidOperationException">Thrown when portName is already used, when there is an invalid parameter, when out of memory, when there is an I/O error</exception>
+        /// <code>
+        /// MessagePort messagePort = new MessagePort("SenderPort", true);
+        /// messagePort.MessageReceived += MessageReceivedCallback;
+        /// messagePort.Listen();
+        /// </code>
+        public void Listen()
+        {
+            lock (s_lock)
+            {
+                if (s_portMap.Contains(_portName))
+                {
+                    throw new InvalidOperationException(_portName + " is already used");
+                }
+                _messageCallBack = (int localPortId, string remoteAppId, string remotePortName, bool trusted, IntPtr message, IntPtr userData) =>
+                {
+                    MessageReceivedEventArgs args = new MessageReceivedEventArgs()
+                    {
+                        Message = new Bundle(new SafeBundleHandle(message, false))
+                    };
+
+                    if (!String.IsNullOrEmpty(remotePortName) && !String.IsNullOrEmpty(remoteAppId))
+                    {
+                        args.Remote = new RemoteValues()
+                        {
+                            AppId = remoteAppId,
+                            PortName = remotePortName,
+                            Trusted = trusted
+                        };
+                    }
+                    MessageReceived?.Invoke(this, args);
+                };
+
+                _portId = _trusted ?
+                            Interop.MessagePort.RegisterTrustedPort(_portName, _messageCallBack, IntPtr.Zero) :
+                            Interop.MessagePort.RegisterPort(_portName, _messageCallBack, IntPtr.Zero);
+
+                if (_portId <= 0)
+                    throw new InvalidOperationException("Can't Listening with " + _portName);
+
+                s_portMap.Add(_portName);
+                _listening = true;
+            }
+        }
+
+        /// <summary>
+        /// Unregisters the local message port.
+        /// </summary>
+        /// <exception cref="System.InvalidOperationException">Thrown when messageport is already stopped, when there is an invalid parameter, when the port is not found, when out of memory, when there is an I/O error</exception>
+        /// <code>
+        /// MessagePort messagePort = new MessagePort("SenderPort", true);
+        /// messagePort.MessageReceived += MessageReceivedCallback;
+        /// messagePort.Listen();
+        /// using (var message = new Tizen.Application.Bundle())
+        /// {
+        ///     message.AddItem("message", "a_string");
+        ///     messagePort.Send(message, "ReceiverAppID", "ReceiverPort");
+        /// }
+        /// messageProt.StopListening();
+        /// </code>
+        public void StopListening()
+        {
+            if (!_listening)
+            {
+                throw new InvalidOperationException("Already stopped");
+            }
+
+            int ret = _trusted ?
+                        Interop.MessagePort.UnregisterTrustedPort(_portId) :
+                        Interop.MessagePort.UnregisterPort(_portId);
+
+            if (ret != (int)MessagePortError.None)
+            {
+                MessagePortErrorFactory.ThrowException(ret);
+            }
+
+            lock (s_lock)
+            {
+                s_portMap.Remove(_portName);
+            }
+            _portId = 0;
+            _listening = false;
+        }
+
+        /// <summary>
+        /// Sends a untrusted message to the message port of a remote application.
+        /// </summary>
+        /// <param name="message">The message to be passed to the remote application, the recommended message size is under 4KB</param>
+        /// <param name="remoteAppId">The ID of the remote application</param>
+        /// <param name="remotePortName">The name of the remote message port</param>
+        /// <exception cref="System.InvalidOperationException">Thrown when there is an invalid parameter, when the port is not found, when out of memory, when there is an I/O error</exception>
+        /// <exception cref="System.ArgumentOutOfRangeException">Thrown when message has exceeded the maximum limit(4KB)</exception>
+        /// <code>
+        /// MessagePort messagePort = new MessagePort("SenderPort", true);
+        /// messagePort.MessageReceived += MessageReceivedCallback;
+        /// messagePort.Listen();
+        /// using (var message = new Tizen.Application.Bundle())
+        /// {
+        ///     message.AddItem("message", "a_string");
+        ///     messagePort.Send(message, "ReceiverAppID", "ReceiverPort");
+        /// }
+        /// </code>
+        public void Send(Bundle message, string remoteAppId, string remotePortName)
+        {
+            Send(message, remoteAppId, remotePortName, false);
+        }
+
+        /// <summary>
+        /// Sends a message to the message port of a remote application.
+        /// </summary>
+        /// <param name="message">The message to be passed to the remote application, the recommended message size is under 4KB</param>
+        /// <param name="remoteAppId">The ID of the remote application</param>
+        /// <param name="remotePortName">The name of the remote message port</param>
+        /// <param name="trusted">If true the trusted message port of remote application otherwise false</param>
+        /// <exception cref="System.InvalidOperationException">Thrown when there is an invalid parameter, when the port is not found, when out of memory, when there is an I/O error</exception>
+        /// <exception cref="System.ArgumentOutOfRangeException">Thrown when message has exceeded the maximum limit(4KB)</exception>
+        /// <code>
+        /// MessagePort messagePort = new MessagePort("SenderPort", true);
+        /// messagePort.MessageReceived += MessageReceivedCallback;
+        /// messagePort.Listen();
+        /// using (var message = new Tizen.Application.Bundle())
+        /// {
+        ///     message.AddItem("message", "a_string");
+        ///     messagePort.Send(message, "ReceiverAppID", "ReceiverPort", true);
+        /// }
+        /// </code>
+        public void Send(Bundle message, string remoteAppId, string remotePortName, bool trusted)
+        {
+            if (!_listening)
+            {
+                throw new InvalidOperationException("Should start listen before send");
+            }
+            if (message == null)
+            {
+                throw new ArgumentNullException("message");
+            }
+            int ret = trusted ?
+                        Interop.MessagePort.SendTrustedMessageWithLocalPort(remoteAppId, remotePortName, message.SafeBundleHandle, _portId) :
+                        Interop.MessagePort.SendMessageWithLocalPort(remoteAppId, remotePortName, message.SafeBundleHandle, _portId);
+
+            if (ret != (int)MessagePortError.None)
+            {
+                if (ret == (int)MessagePortError.MaxExceeded)
+                {
+                    MessagePortErrorFactory.ThrowException(ret, "Message has exceeded the maximum limit(4KB)", "Message");
+                }
+                MessagePortErrorFactory.ThrowException(ret, "Can't send message");
+            }
+        }
+
+        /// <summary>
+        /// Releases the unmanaged resourced used by the MessagePort class specifying whether to perform a normal dispose operation.
+        /// </summary>
+        /// <param name="disposing">true for a normal dispose operation; false to finalize the handle.</param>
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_listening)
+            {
+                try
+                {
+                    StopListening();
+                }
+                catch (Exception e)
+                {
+                    Log.Warn(GetType().Namespace, "Exception in Dispose :" + e.Message);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Releases all resources used by the MessagePort class.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+    }
+}
diff --git a/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/MessagePortErrorFactory.cs b/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/MessagePortErrorFactory.cs
new file mode 100755 (executable)
index 0000000..949d067
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Applications.Messages
+{
+    internal enum MessagePortError
+    {
+        None = ErrorCode.None,
+        IOError = ErrorCode.IoError,
+        OutOfMemory = ErrorCode.OutOfMemory,
+        InvalidParameter = ErrorCode.InvalidParameter,
+        InvalidOperation = ErrorCode.InvalidOperation,
+        PortNotFound = -0x01130000 | 0x01,
+        CertificateNotMatch = -0x01130000 | 0x02,
+        MaxExceeded = -0x01130000 | 0x03,
+        ResourceUnavailable = -0x01130000 | 0x04
+    }
+
+    internal static class MessagePortErrorFactory
+    {
+        internal static void ThrowException(int errorCode, string errorMessage = null, string paramName = null)
+        {
+            MessagePortError err = (MessagePortError)errorCode;
+            if (String.IsNullOrEmpty(errorMessage))
+            {
+                errorMessage = err.ToString();
+            }
+            switch ((MessagePortError)errorCode)
+            {
+                case MessagePortError.IOError:
+                case MessagePortError.OutOfMemory:
+                case MessagePortError.InvalidOperation:
+                case MessagePortError.PortNotFound:
+                case MessagePortError.ResourceUnavailable: throw new InvalidOperationException(errorMessage);
+                case MessagePortError.InvalidParameter:
+                case MessagePortError.CertificateNotMatch: throw new ArgumentException(errorMessage, paramName);
+                case MessagePortError.MaxExceeded: throw new ArgumentOutOfRangeException(paramName, errorMessage);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/MessageReceivedEventArgs.cs b/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/MessageReceivedEventArgs.cs
new file mode 100755 (executable)
index 0000000..cfe1762
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+
+namespace Tizen.Applications.Messages
+{
+    /// <summary>
+    /// An extended EventArgs class which contains remote message port information and message
+    /// </summary>
+    public class MessageReceivedEventArgs : EventArgs
+    {
+        /// <summary>
+        /// Contains AppId, Port Name, Trusted
+        /// </summary>
+        public RemoteValues Remote { get; internal set; }
+
+        /// <summary>
+        /// The message passed from the remote application
+        /// </summary>
+        public Bundle Message { get; internal set; }
+    }
+}
diff --git a/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/RemoteValues.cs b/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/RemoteValues.cs
new file mode 100755 (executable)
index 0000000..db853d3
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Messages
+{
+    /// <summary>
+    /// Contains AppId, Port Name, Trusted
+    /// </summary>
+    public class RemoteValues
+    {
+        /// <summary>
+        /// The ID of the remote application that sent this message
+        /// </summary>
+        public string AppId { get; set; }
+
+        /// <summary>
+        /// The name of the remote message port
+        /// </summary>
+        public string PortName { get; set; }
+
+        /// <summary>
+        /// If true the remote port is a trusted port, otherwise if false it is not
+        /// </summary>
+        public bool Trusted { get; set; }
+    }
+}
diff --git a/src/Tizen.Applications.Notification/Interop/Interop.Libraries.cs b/src/Tizen.Applications.Notification/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..d5edebd
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string Notification = "libnotification.so.0";
+    }
+}
diff --git a/src/Tizen.Applications.Notification/Interop/Interop.Notification.cs b/src/Tizen.Applications.Notification/Interop/Interop.Notification.cs
new file mode 100755 (executable)
index 0000000..e865ab1
--- /dev/null
@@ -0,0 +1,311 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Applications;
+using Tizen.Applications.Notifications;
+
+internal static partial class Interop
+{
+    internal static class Notification
+    {
+        [DllImport(Libraries.Notification, EntryPoint = "notification_create")]
+        internal static extern IntPtr Create(NotificationType type);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_free")]
+        internal static extern NotificationError Destroy(IntPtr handle);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_text")]
+        internal static extern NotificationError GetTextReferenceType(NotificationSafeHandle handle, NotificationText type, out IntPtr text);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_text")]
+        internal static extern NotificationError SetText(NotificationSafeHandle handle, NotificationText type, string text, string key, int args);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_image")]
+        internal static extern NotificationError GetImageReferenceType(NotificationSafeHandle handle, NotificationImage type, out IntPtr path);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_image")]
+        internal static extern NotificationError SetImage(NotificationSafeHandle handle, NotificationImage type, string path);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_time")]
+        internal static extern NotificationError GetTime(NotificationSafeHandle handle, out int time);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_time")]
+        internal static extern NotificationError SetTime(NotificationSafeHandle handle, int time);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_insert_time")]
+        internal static extern NotificationError GetInsertTime(NotificationSafeHandle handle, out long time);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_sound")]
+        internal static extern NotificationError GetSoundReferenceType(NotificationSafeHandle handle, out AccessoryOption type, out IntPtr path);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_sound")]
+        internal static extern NotificationError SetSound(NotificationSafeHandle handle, AccessoryOption type, string path);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_vibration")]
+        internal static extern NotificationError GetVibrationReferenceType(NotificationSafeHandle handle, out AccessoryOption type, out IntPtr path);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_vibration")]
+        internal static extern NotificationError SetVibration(NotificationSafeHandle handle, AccessoryOption type, string path);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_led")]
+        internal static extern NotificationError GetLed(NotificationSafeHandle handle, out AccessoryOption type, out int color);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_led")]
+        internal static extern NotificationError SetLed(NotificationSafeHandle handle, AccessoryOption type, int color);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_led_time_period")]
+        internal static extern NotificationError GetLedTimePeriod(NotificationSafeHandle handle, out int onMillisecond, out int offMillisecond);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_led_time_period")]
+        internal static extern NotificationError SetLedTimePeriod(NotificationSafeHandle handle, int onMillisecond, int offMillisecond);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_launch_option")]
+        internal static extern NotificationError GetAppControl(NotificationSafeHandle handle, LaunchOption type, out SafeAppControlHandle apphandle);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_launch_option")]
+        internal static extern NotificationError SetAppControl(NotificationSafeHandle handle, LaunchOption type, SafeAppControlHandle appHandle);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_event_handler")]
+        internal static extern NotificationError GetEventHandler(NotificationSafeHandle handle, int type, out SafeAppControlHandle appHandle);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_event_handler")]
+        internal static extern NotificationError SetEventHandler(NotificationSafeHandle handle, int type, SafeAppControlHandle appHandle);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_property")]
+        internal static extern NotificationError GetProperties(NotificationSafeHandle handle, out int flags);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_property")]
+        internal static extern NotificationError SetProperties(NotificationSafeHandle handle, int flags);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_display_applist")]
+        internal static extern NotificationError GetApplist(NotificationSafeHandle handle, out int flags);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_display_applist")]
+        internal static extern NotificationError SetApplist(NotificationSafeHandle handle, int flags);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_size")]
+        internal static extern NotificationError GetProgressSize(NotificationSafeHandle handle, out double size);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_size")]
+        internal static extern NotificationError SetProgressSize(NotificationSafeHandle handle, double size);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_progress")]
+        internal static extern NotificationError GetProgress(NotificationSafeHandle handle, out double progress);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_progress")]
+        internal static extern NotificationError SetProgress(NotificationSafeHandle handle, double progress);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_layout")]
+        internal static extern NotificationError GetLayout(NotificationSafeHandle handle, out NotificationLayout layout);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_layout")]
+        internal static extern NotificationError SetLayout(NotificationSafeHandle handle, NotificationLayout layout);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_type")]
+        internal static extern NotificationError GetType(NotificationSafeHandle handle, out NotificationType type);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_update")]
+        internal static extern NotificationError Update(NotificationSafeHandle handle);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_delete")]
+        internal static extern NotificationError Delete(NotificationSafeHandle handle);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_delete_all")]
+        internal static extern NotificationError DeleteAll(int type);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_post")]
+        internal static extern NotificationError Post(NotificationSafeHandle handle);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_pkgname")]
+        internal static extern NotificationError GetPackageName(NotificationSafeHandle handle, out IntPtr name);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_event_handler")]
+        internal static extern NotificationError AddButtonAction(NotificationSafeHandle handle, ButtonIndex type, SafeAppControlHandle appcontrol);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_remove_button")]
+        internal static extern NotificationError RemoveButton(NotificationSafeHandle handle, ButtonIndex index);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_tag")]
+        internal static extern NotificationError SetTag(NotificationSafeHandle handle, string tag);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_tag")]
+        internal static extern NotificationError GetTagReferenceType(NotificationSafeHandle handle, out IntPtr tag);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_load_by_tag")]
+        internal static extern IntPtr Load(string text);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_id")]
+        internal static extern NotificationError GetID(NotificationSafeHandle handle, out int groupID, out int privID);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_priv_id")]
+        internal static extern NotificationError SetID(NotificationSafeHandle handle, int privID);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_save_as_template")]
+        internal static extern NotificationError SaveTemplate(NotificationSafeHandle handle, string name);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_create_from_template")]
+        internal static extern IntPtr LoadTemplate(string name);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_noti_block_state")]
+        internal static extern NotificationError GetBlockState(out NotificationBlockState status);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_auto_remove")]
+        internal static extern NotificationError SetAutoRemove(NotificationSafeHandle handle, bool autoRemove);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_auto_remove")]
+        internal static extern NotificationError GetAutoRemove(NotificationSafeHandle handle, out bool autoRemove);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_ongoing_value_type")]
+        internal static extern NotificationError SetProgressType(NotificationSafeHandle handle, ProgressCategory category);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_ongoing_value_type")]
+        internal static extern NotificationError GetProgressType(NotificationSafeHandle handle, out ProgressCategory category);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_ongoing_flag")]
+        internal static extern NotificationError SetOngoingFlag(NotificationSafeHandle handle, bool flag);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_ongoing_flag")]
+        internal static extern NotificationError GetProgressFlag(NotificationSafeHandle handle, bool flag);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_ongoing_flag")]
+        internal static extern NotificationError GetProgressFlag(NotificationSafeHandle handle, out bool flag);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_text_input")]
+        internal static extern NotificationError SetPlaceHolderLength(NotificationSafeHandle handle, int length);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_text_input_max_length")]
+        internal static extern NotificationError GetPlaceHolderLength(NotificationSafeHandle handle, out int length);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_hide_timeout")]
+        internal static extern NotificationError GetHideTime(NotificationSafeHandle handle, out int timeout);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_hide_timeout")]
+        internal static extern NotificationError SetHideTime(NotificationSafeHandle handle, int timeout);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_delete_timeout")]
+        internal static extern NotificationError GetDeleteTime(NotificationSafeHandle handle, out int timeout);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_delete_timeout")]
+        internal static extern NotificationError SetDeleteTime(NotificationSafeHandle handle, int timeout);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_extention_data")]
+        internal static extern NotificationError SetExtentionData(NotificationSafeHandle handle, string key, SafeBundleHandle bundleHandle);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_extention_data")]
+        internal static extern NotificationError GetExtentionData(NotificationSafeHandle handle, string key, out SafeBundleHandle bundleHandle);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_args")]
+        internal static extern NotificationError GetExtentionBundle(NotificationSafeHandle handle, out IntPtr args, out IntPtr group_args);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_default_button")]
+        internal static extern NotificationError GetDefaultButton(NotificationSafeHandle handle, out int index);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_default_button")]
+        internal static extern NotificationError SetDefaultButton(NotificationSafeHandle handle, int index);
+
+        internal static NotificationError GetText(NotificationSafeHandle handle, NotificationText type, out string text)
+        {
+            NotificationError ret;
+            IntPtr ptr;
+            ret = GetTextReferenceType(handle, type, out ptr);
+
+            if (ptr == IntPtr.Zero)
+            {
+                text = null;
+            }
+            else
+            {
+                text = Marshal.PtrToStringAnsi(ptr);
+            }
+
+            return ret;
+        }
+
+        internal static NotificationError GetImage(NotificationSafeHandle handle, NotificationImage type, out string path)
+        {
+            NotificationError ret;
+            IntPtr ptr;
+            ret = GetImageReferenceType(handle, type, out ptr);
+
+            if (ptr == IntPtr.Zero)
+            {
+                path = null;
+            }
+            else
+            {
+                path = Marshal.PtrToStringAnsi(ptr);
+            }
+
+            return ret;
+        }
+
+        internal static NotificationError GetSound(NotificationSafeHandle handle, out AccessoryOption type, out string path)
+        {
+            NotificationError ret;
+            IntPtr ptr;
+            ret = GetSoundReferenceType(handle, out type, out ptr);
+
+            if (ptr == IntPtr.Zero)
+            {
+                path = null;
+            }
+            else
+            {
+                path = Marshal.PtrToStringAnsi(ptr);
+            }
+
+            return ret;
+        }
+
+        internal static NotificationError GetVibration(NotificationSafeHandle handle, out AccessoryOption type, out string path)
+        {
+            NotificationError ret;
+            IntPtr ptr;
+            ret = GetVibrationReferenceType(handle, out type, out ptr);
+
+            if (ptr == IntPtr.Zero)
+            {
+                path = null;
+            }
+            else
+            {
+                path = Marshal.PtrToStringAnsi(ptr);
+            }
+
+            return ret;
+        }
+
+        internal static NotificationError GetTag(NotificationSafeHandle handle, out string tag)
+        {
+            NotificationError ret;
+            IntPtr ptr;
+            ret = GetTagReferenceType(handle, out ptr);
+
+            if (ptr == IntPtr.Zero)
+            {
+                tag = null;
+            }
+            else
+            {
+                tag = Marshal.PtrToStringAnsi(ptr);
+            }
+
+            return ret;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notification.csproj b/src/Tizen.Applications.Notification/Tizen.Applications.Notification.csproj
new file mode 100755 (executable)
index 0000000..06a99e5
--- /dev/null
@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <Import Project="../build/build.props" />
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.3</TargetFramework>
+    <Version>1.5.9</Version>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Applications.Notification.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notification.snk b/src/Tizen.Applications.Notification/Tizen.Applications.Notification.snk
new file mode 100755 (executable)
index 0000000..7ac1b00
Binary files /dev/null and b/src/Tizen.Applications.Notification/Tizen.Applications.Notification.snk differ
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/Notification.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/Notification.cs
new file mode 100755 (executable)
index 0000000..ec7202a
--- /dev/null
@@ -0,0 +1,505 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel;
+
+    /// <summary>
+    /// Class containing common properties and methods of Notifications
+    /// </summary>
+    /// <remarks>
+    /// A notification is a message that is displayed on the notification area.
+    /// It is created to notify information to the user through the application.
+    /// This class helps you to provide method and property for creating notification object.
+    /// </remarks>
+    public sealed partial class Notification : IDisposable
+    {
+        internal static readonly string LogTag = "Tizen.Applications.Notification";
+
+        private NotificationSafeHandle safeHandle;
+        private bool disposed = false;
+
+        private IDictionary<string, StyleBase> styleDictionary;
+        private IDictionary<string, Bundle> extenderDictionary;
+        private int count = 0;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="Notification"/> class.
+        /// </summary>
+        public Notification()
+        {
+            styleDictionary = new Dictionary<string, StyleBase>();
+            extenderDictionary = new Dictionary<string, Bundle>();
+        }
+
+        /// <summary>
+        /// Gets or sets Tag of Notification.
+        /// </summary>
+        public string Tag { get; set; } = string.Empty;
+
+        /// <summary>
+        /// Gets or sets Title of Notification.
+        /// </summary>
+        public string Title { get; set; } = string.Empty;
+
+        /// <summary>
+        /// Gets or sets icon of Notification.
+        /// </summary>
+        public string Icon { get; set; } = string.Empty;
+
+        /// <summary>
+        /// Gets or sets sub icon of Notification.
+        /// This SubIcon is displayed in Icon you set.
+        /// </summary>
+        public string SubIcon { get; set; } = string.Empty;
+
+        /// <summary>
+        /// Gets or sets content of Notification.
+        /// </summary>
+        public string Content { get; set; } = string.Empty;
+
+        /// <summary>
+        /// Gets or sets a value indicating whether TimeStamp of Notification is Visible or not.
+        /// Default to true.
+        /// </summary>
+        public bool IsTimeStampVisible { get; set; } = true;
+
+        /// <summary>
+        /// Gets or sets TimeStamp of Notification.
+        /// </summary>
+        /// <remarks>
+        /// If you don't set TimeStamp, It will be set value that time when the notification is posted.
+        /// TimeStamp requires NotificationManager.Post() to be called.
+        /// If you set IsVisibleTimeStamp property is false, TimeStamp is not Visible in Notification.
+        /// </remarks>
+        public DateTime TimeStamp { get; set; }
+
+        /// <summary>
+        /// Gets or sets Action which is invoked when notification is clicked
+        /// </summary>
+        /// <remarks>
+        /// If you set it to null, the already set AppControl will be removed and nothing will happen when you click on notification.
+        /// </remarks>
+        /// <seealso cref="Tizen.Applications.AppControl"></seealso>
+        public AppControl Action { get; set; }
+
+        /// <summary>
+        /// Gets or sets Count which is displayed at the right side of notification.
+        /// </summary>
+        /// <remarks>
+        /// You must set only positive number.
+        /// If you set count to negative number, This property throw exception.
+        /// </remarks>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        public int Count
+        {
+            get
+            {
+                return count;
+            }
+
+            set
+            {
+                if (value < 0)
+                {
+                    Log.Error(LogTag, "Count value is negative");
+                    throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "The Count must be a positive integer.");
+                }
+
+                count = value;
+            }
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool IsOngoing { get; set; } = false;
+
+        /// <summary>
+        /// Gets or sets property
+        /// </summary>
+        /// <seealso cref="Tizen.Applications.Notifications.NotificationProperty"></seealso>
+        public NotificationProperty Property { get; set; } = NotificationProperty.None;
+
+        /// <summary>
+        /// Gets or sets <see cref="Notification.ProgressType"/> object for display at notification
+        /// </summary>
+        /// <seealso cref="Tizen.Applications.Notifications.Notification.ProgressType"></seealso>
+        public ProgressType Progress { get; set; }
+
+        /// <summary>
+        /// Gets or sets <see cref="Notification.AccessorySet"/> which is included vibration, led and sound option to be applied at Notification.
+        /// </summary>
+        /// <remarks>
+        /// If you set it to null, the already set AccessorySet will be initialized.
+        /// </remarks>
+        /// <example>
+        /// <code>
+        /// Notification notification = new Notification
+        /// {
+        ///     Title = "Notification",
+        ///     Content = "Hello Tizen",
+        ///     Icon = "Icon path",
+        ///     Count = 3
+        /// };
+        ///
+        /// Notification.AccessorySet accessory = new Notification.AccessorySet
+        /// {
+        ///     SoundOption = AccessoryOption.Custom,
+        ///     SoundPath = "Sound File Path",
+        ///     IsVibration = true,
+        ///     LedOption = AccessoryOption.Custom,
+        ///     LedOnMs = 100;
+        ///     LedOffMs = 50;
+        ///     LedColor = Color.Lime
+        /// };
+        ///
+        /// notification.Accessory = accessory;
+        ///
+        /// NotificationManager.Post(notification);
+        /// </code>
+        /// </example>
+        public AccessorySet Accessory { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether notification is displayed on default viewer.
+        /// If you set false and add style, you can see only style notification.
+        /// </summary>
+        public bool IsDisplay { get; set; } = true;
+
+        /// <summary>
+        /// Gets or sets NotificationSafeHandle
+        /// </summary>
+        internal NotificationSafeHandle Handle
+        {
+            get
+            {
+                return safeHandle;
+            }
+
+            set
+            {
+                if (value == null)
+                {
+                    Log.Error(LogTag, "Invalid argument NotificationSafeHandle");
+                    throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid argument to set NotificationSafeHandle");
+                }
+
+                safeHandle = value;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets Private ID
+        /// </summary>
+        internal int PrivID { get; set; } = -1;
+
+        /// <summary>
+        /// Method to add various style to be applied to notification.
+        /// </summary>
+        /// <remarks>
+        /// The user always see about valid notification style. If you add style which is not supported in platform,
+        /// this method has no effect.
+        /// </remarks>
+        /// <param name="style">The style to be applied to notification</param>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        /// <example>
+        /// <code>
+        /// Notification notification = new Notification
+        /// {
+        ///     Title = "Notification",
+        ///     Content = "Hello Tizen",
+        ///     Icon = "Icon path",
+        ///     Count = 3
+        /// };
+        ///
+        /// Notification.LockStyle lockStyle = new Notification.LockStyle
+        /// {
+        ///     IconPath = "Icon path",
+        ///     ThumbnailPath = "Thumbnail Path"
+        /// };
+        ///
+        /// notification.AddStyle(lockStyle);
+        ///
+        /// NotificationManager.Post(notification);
+        /// </code>
+        /// </example>
+        public void AddStyle(StyleBase style)
+        {
+            if (style == null)
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered");
+            }
+
+            if (styleDictionary.ContainsKey(style.Key) == true)
+            {
+                Log.Info(LogTag, "The Style is existed, so extender data is replaced");
+                styleDictionary.Remove(style.Key);
+                styleDictionary.Add(style.Key, style);
+            }
+            else
+            {
+                styleDictionary.Add(style.Key, style);
+            }
+        }
+
+        /// <summary>
+        /// Method to remove style you already added.
+        /// </summary>
+        /// <typeparam name="T">Type of notification style to be queried</typeparam>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        public void RemoveStyle<T>() where T : Notification.StyleBase, new()
+        {
+            T type = new T();
+
+            if (styleDictionary.ContainsKey(type.Key))
+            {
+                styleDictionary.Remove(type.Key);
+            }
+            else
+            {
+                Log.Error(LogTag, "Sytle Can't be removed, there is no style matched input key");
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered");
+            }
+        }
+
+        /// <summary>
+        /// Method to get style you already added.
+        /// </summary>
+        /// <typeparam name="T">Type of notification style to be queried</typeparam>
+        /// <returns>
+        /// The Notification.Style object associated with the given style
+        /// </returns>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        public T GetStyle<T>() where T : Notification.StyleBase, new()
+        {
+            T type = new T();
+            StyleBase style = null;
+
+            styleDictionary.TryGetValue(type.Key, out style);
+
+            if (style == null)
+            {
+                Log.Error(LogTag, "Invalid Style");
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered");
+            }
+            else
+            {
+                return style as T;
+            }
+        }
+
+        /// <summary>
+        /// Method to set extender data to add extra data
+        /// </summary>
+        /// <remarks>
+        /// The type of extra data is Bundle.
+        /// </remarks>
+        /// <param name="key">The key of the extra data you want to add.</param>
+        /// <param name="value">The value you want to add.</param>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        /// <example>
+        /// <code>
+        /// Notification notification = new Notification
+        /// {
+        ///     Title = "Notification",
+        ///     Content = "Hello Tizen",
+        ///     Icon = "Icon path",
+        /// };
+        ///
+        /// Bundle bundle = new Bundle();
+        /// bundle.AddItem("key", "value");
+        ///
+        /// notification.SetExtender("firstKey", bundle);
+        /// </code>
+        /// </example>
+        public void SetExtender(string key, Bundle value)
+        {
+            if (value == null || value.SafeBundleHandle.IsInvalid || string.IsNullOrEmpty(key))
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered");
+            }
+
+            if (extenderDictionary.ContainsKey(key) == true)
+            {
+                Log.Info(LogTag, "The key is existed, so extender data is replaced");
+                extenderDictionary.Remove(key);
+                extenderDictionary.Add(key, value);
+            }
+            else
+            {
+                extenderDictionary.Add(key, value);
+            }
+        }
+
+        /// <summary>
+        /// Method to remove extender you already added.
+        /// </summary>
+        /// <remarks>
+        /// The type of extra data is Bundle.
+        /// </remarks>
+        /// <param name="key">The key of the extra data to add.</param>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        public void RemoveExtender(string key)
+        {
+            if (string.IsNullOrEmpty(key))
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered");
+            }
+
+            if (extenderDictionary.ContainsKey(key))
+            {
+                extenderDictionary.Remove(key);
+            }
+            else
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered");
+            }
+        }
+
+        /// <summary>
+        /// Method to get extender data you already set
+        /// </summary>
+        /// <param name="key">The key of the extra data to get.</param>
+        /// <returns>Bundle Object that include extender data</returns>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        public Bundle GetExtender(string key)
+        {
+            if (string.IsNullOrEmpty(key))
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered");
+            }
+
+            Bundle bundle;
+            if (extenderDictionary.TryGetValue(key, out bundle) == false)
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered : " + key);
+            }
+
+            return bundle;
+        }
+
+        /// <summary>
+        /// Releases any unmanaged resources used by this object.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        internal void Dispose(bool disposing)
+        {
+            if (disposed)
+            {
+                return;
+            }
+
+            if (disposing)
+            {
+                Handle.Dispose();
+            }
+
+            disposed = true;
+        }
+
+        internal IDictionary<string, StyleBase> GetStyleDictionary()
+        {
+            return styleDictionary;
+        }
+
+        internal IDictionary<string, Bundle> GetExtenderDictionary()
+        {
+            return extenderDictionary;
+        }
+
+        internal StyleBase GetStyle(string key)
+        {
+            if (string.IsNullOrEmpty(key))
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "Key is null or empty");
+            }
+
+            StyleBase style = null;
+            bool ret = styleDictionary.TryGetValue(key, out style);
+            if (ret == false)
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "The Style object matched input key is not existed");
+            }
+
+            return style;
+        }
+
+        internal void Make()
+        {
+            NotificationBinder.BindObject(this);
+
+            foreach (string key in GetExtenderDictionary().Keys)
+            {
+                Log.Info(LogTag, "Start to bind Notification.ExtenderData to SafeHandle");
+                Interop.Notification.SetExtentionData(Handle, key, extenderDictionary[key].SafeBundleHandle);
+            }
+
+            foreach (Notification.StyleBase style in styleDictionary.Values)
+            {
+                Log.Info(LogTag, "Start to bind Notification.Style to SafeHandle [" + style.Key + "]");
+                style.Make(this);
+            }
+
+            if (Accessory != null)
+            {
+                Log.Info(LogTag, "Start to bind Notification.AccessetSet to SafeHandle");
+                Accessory.Make(this);
+            }
+
+            if (Progress != null)
+            {
+                Log.Info(LogTag, "Start to bind Notification.Progress to SafeHandle");
+                Progress.Make(this);
+            }
+        }
+
+        internal Notification Build()
+        {
+            IntPtr extention = IntPtr.Zero;
+            IntPtr extentionBundlePtr = IntPtr.Zero;
+
+            NotificationBinder.BindSafeHandle(this);
+
+            Interop.Notification.GetExtentionBundle(Handle, out extention, out extentionBundlePtr);
+
+            if (extention != IntPtr.Zero)
+            {
+                Bundle bundle = new Bundle(new SafeBundleHandle(extention, false));
+                foreach (string key in bundle.Keys)
+                {
+                    SafeBundleHandle sbh;
+                    Interop.Notification.GetExtentionData(Handle, key, out sbh);
+                    extenderDictionary.Add(key, new Bundle(sbh));
+                }
+            }
+
+            ProgressBinder.BindSafeHandle(this);
+            AccessorySetBinder.BindSafeHandle(this);
+            IndicatorBinder.BindSafeHandle(this);
+            ActiveBinder.BindSafeHandle(this);
+            LockBinder.BindSafehandle(this);
+
+            return this;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationAccessorySet.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationAccessorySet.cs
new file mode 100755 (executable)
index 0000000..ec7958d
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    using Tizen.Common;
+
+    /// <summary>
+    /// Class containing common properties and methods of Notifications
+    /// </summary>
+    /// <remarks>
+    /// A notification is a message that is displayed on the notification area.
+    /// It is created to notify information to the user through the application.
+    /// This class helps you to provide method and property for creating notification object.
+    /// </remarks>
+    public sealed partial class Notification
+    {
+        /// <summary>
+        ///  Class for Notification AccessorySet which is included vibration, led, sound option
+        /// </summary>
+        public sealed class AccessorySet : MakerBase
+        {
+            /// <summary>
+            /// Gets or sets the sound option. Default to AccessoryOption.Off.
+            /// </summary>
+            /// <remarks>
+            /// If you set AccessoryOption.Custom and not set SoundPath, then turn on the default sound.
+            /// </remarks>
+            public AccessoryOption SoundOption { get; set; } = AccessoryOption.Off;
+
+            /// <summary>
+            /// Gets or sets the sound path, It will play on the sound file you set.
+            /// </summary>
+            public string SoundPath { get; set; }
+
+            /// <summary>
+            /// Gets or sets a value indicating whether vibration is operated. Default to false.
+            /// </summary>
+            public bool CanVibrate { get; set; } = false;
+
+            /// <summary>
+            /// Gets or sets the led option. Default to AccessoryOption.Off.
+            /// </summary>
+            /// <remarks>
+            /// If you set AccessoryOption.Custom and not set LedColor, then turn on the LED with default color.
+            /// </remarks>
+            public AccessoryOption LedOption { get; set; } = AccessoryOption.Off;
+
+            /// <summary>
+            /// Gets or sets the led on time period that you would like the LED on the device to blink. as well as the rate
+            /// </summary>
+            /// <remarks>
+            /// Default value of LedOnMillisecond is 0.
+            /// The rate is specified in terms of the number of Milliseconds to be on.
+            /// You should always set LedOnMillisecond with LedOffMillisecond. Otherwise, it may not operate normally.
+            /// </remarks>
+            public int LedOnMillisecond { get; set; }
+
+            /// <summary>
+            /// Gets or sets the led on time period that you would like the LED on the device to blink. as well as the rate.
+            /// </summary>
+            /// <remarks>
+            /// The rate is specified in terms of the number of Milliseconds to be off.
+            /// You should always set LedOffMillisecond with LedOnMillisecond. Otherwise, it may not operate normally.
+            /// </remarks>
+            public int LedOffMillisecond { get; set; }
+
+            /// <summary>
+            /// Gets or sets the led color that you would like the LED on the device to blink.
+            /// </summary>
+            /// <remarks>
+            /// If you want to set LedColor, you should always set LedOption is AccessoryOption.Custom. Otherwise, it may operate default led color.
+            /// </remarks>
+            public Color LedColor { get; set; }
+
+            internal override void Make(Notification notification)
+            {
+                AccessorySetBinder.BindObject(notification);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationAccessorySetBinder.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationAccessorySetBinder.cs
new file mode 100755 (executable)
index 0000000..91e2282
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    using Tizen.Common;
+
+    internal static class AccessorySetBinder
+    {
+        internal static void BindObject(Notification notification)
+        {
+            BindLedToHandle(notification);
+            BindSoundToHandle(notification);
+            BindVibrationToHandle(notification);
+        }
+
+        internal static void BindSafeHandle(Notification notification)
+        {
+            Notification.AccessorySet accessory = new Notification.AccessorySet();
+            BindHandleToLed(notification, accessory);
+            BindHandleToSound(notification, accessory);
+            BindHandleToVibration(notification, accessory);
+            notification.Accessory = accessory;
+        }
+
+        private static void BindLedToHandle(Notification notification)
+        {
+            NotificationError ret = NotificationError.None;
+            Notification.AccessorySet accessory = notification.Accessory;
+
+            ret = Interop.Notification.SetLed(notification.Handle, accessory.LedOption, 0);
+            if (ret != NotificationError.None)
+            {
+                throw NotificationErrorFactory.GetException(ret, "unable to set led");
+            }
+
+            ret = Interop.Notification.SetLedTimePeriod(notification.Handle, accessory.LedOnMillisecond, accessory.LedOffMillisecond);
+            if (ret != NotificationError.None)
+            {
+                throw NotificationErrorFactory.GetException(ret, "unable to set led period");
+            }
+
+            if (notification.Accessory.LedOption == AccessoryOption.Custom)
+            {
+                Color color = accessory.LedColor;
+                ret = Interop.Notification.SetLed(notification.Handle, AccessoryOption.Custom, color.GetArgb());
+                if (ret != NotificationError.None)
+                {
+                    throw NotificationErrorFactory.GetException(ret, "unable to set led color");
+                }
+            }
+        }
+
+        private static void BindVibrationToHandle(Notification notification)
+        {
+            Notification.AccessorySet accessory = notification.Accessory;
+            if (accessory.CanVibrate == false)
+            {
+                Interop.Notification.SetVibration(notification.Handle, AccessoryOption.Off, null);
+            }
+            else
+            {
+                Interop.Notification.SetVibration(notification.Handle, AccessoryOption.On, null);
+            }
+        }
+
+        private static void BindSoundToHandle(Notification notification)
+        {
+            Notification.AccessorySet accessory = notification.Accessory;
+
+            if (accessory.SoundOption == AccessoryOption.Custom && string.IsNullOrEmpty(accessory.SoundPath))
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "If the option is set to Custom, the path must also be set.");
+            }
+
+            NotificationError ret = Interop.Notification.SetSound(notification.Handle, accessory.SoundOption, accessory.SoundPath);
+            if (ret != NotificationError.None)
+            {
+                throw NotificationErrorFactory.GetException(ret, "unable to set sound");
+            }
+        }
+
+        private static void BindHandleToLed(Notification notification, Notification.AccessorySet accessory)
+        {
+            AccessoryOption type;
+            int argb;
+            Interop.Notification.GetLed(notification.Handle, out type, out argb);
+
+            accessory.LedOption = type;
+            if (type == AccessoryOption.Custom)
+            {
+                accessory.LedColor = new Color(argb >> 16 & 255, argb >> 8 & 255, argb >> 0 & 255, argb >> 24 & 255);
+            }
+
+            int onMillisecond, offMillisecond;
+            Interop.Notification.GetLedTimePeriod(notification.Handle, out onMillisecond, out offMillisecond);
+            accessory.LedOnMillisecond = onMillisecond;
+            accessory.LedOffMillisecond = offMillisecond;
+        }
+
+        private static void BindHandleToSound(Notification notification, Notification.AccessorySet accessory)
+        {
+            AccessoryOption type;
+            string path;
+
+            Interop.Notification.GetSound(notification.Handle, out type, out path);
+
+            accessory.SoundOption = type;
+            if (type == AccessoryOption.Custom)
+            {
+                accessory.SoundPath = path;
+            }
+        }
+
+        private static void BindHandleToVibration(Notification notification, Notification.AccessorySet accessory)
+        {
+            AccessoryOption type;
+            string path;
+
+            Interop.Notification.GetVibration(notification.Handle, out type, out path);
+            if (type == AccessoryOption.Off)
+            {
+                accessory.CanVibrate = false;
+            }
+            else
+            {
+                accessory.CanVibrate = true;
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationActiveStyle.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationActiveStyle.cs
new file mode 100755 (executable)
index 0000000..d7b9d7f
--- /dev/null
@@ -0,0 +1,264 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Class containing common properties and methods of Notifications
+    /// </summary>
+    /// <remarks>
+    /// A notification is a message that is displayed on the notification area.
+    /// It is created to notify information to the user through the application.
+    /// This class helps you to provide method and property for creating notification object.
+    /// </remarks>
+    public sealed partial class Notification
+    {
+        /// <summary>
+        ///  Class for generating Active style notification
+        /// </summary>
+        public sealed class ActiveStyle : StyleBase
+        {
+            private IDictionary<ButtonIndex, ButtonAction> buttonDictionary;
+            private int hideTimeout = 0;
+            private int deleteTimeout = 0;
+
+            /// <summary>
+            /// Initializes a new instance of the <see cref="ActiveStyle"/> class.
+            /// </summary>
+            public ActiveStyle()
+            {
+                buttonDictionary = new Dictionary<ButtonIndex, ButtonAction>();
+            }
+
+            /// <summary>
+            /// Gets or sets an absolute path for an image file to display on the background of active notification
+            /// </summary>
+            public string BackgroundImage { get; set; }
+
+            /// <summary>
+            /// Gets or sets a value indicating whether the active notification is removed automatically. Default value is true.
+            /// </summary>
+            /// <remarks>
+            /// IsAutoRemove option lets the active notification be removed several seconds after it shows.
+            /// When 'IsAutoRemove' is set as false, the active notification will not be removed as long as the user removes
+            /// the active notification or the app which posted the active notification removes the active notification.
+            /// </remarks>>
+            public bool IsAutoRemove { get; set; } = true;
+
+            /// <summary>
+            /// Gets or sets the default button to display highlight on the active notification
+            /// </summary>
+            /// <remarks>
+            /// The default button for display highlight is only reflected on Tizen TV.
+            /// If you use this Property on other profile, this value have no effect
+            /// </remarks>
+            public ButtonIndex DefaultButton { get; set; } = ButtonIndex.None;
+
+            /// <summary>
+            /// Gets or sets a ReplyAction to this active notification style.
+            /// </summary>
+            /// <remarks>
+            /// When you add a ReplyAction to the ActiveStyle, the notification UI will show a ReplyAction with button.
+            /// If you set null parameter, ReplyAction is disappeared.
+            /// </remarks>
+            /// <example>
+            /// <code>
+            ///
+            /// ButtonAction button = new ButtonAction
+            /// {
+            ///     Index = ButtonIndex.First,
+            ///     Text = "Yes"
+            ///     Action = new AppControl{ ApplicationId = "org.tizen.app" };
+            /// };
+            ///
+            /// ReplyAction reply = new ReplyAction
+            /// {
+            ///     ParentIndex = ButtonIndex.First;
+            ///     PlaceHolderText = "Please write your reply."
+            ///     ReplyMax = 160,
+            ///     Button = new ButtonAction
+            ///     {
+            ///         Text = "Yes",
+            ///         ImagePath = "image path"
+            ///         Action = new AppControl{ ApplicationId = "org.tizen.app" };
+            ///     };
+            /// };
+            ///
+            /// ActiveStyle active = new ActiveStyle
+            /// {
+            ///     AutoRemove = true,
+            ///     BackgroundImage = "image path",
+            ///     ReplyAction = reply
+            /// };
+            ///
+            /// active.AddButtonAction(button);
+            /// </code>
+            /// </example>
+            public ReplyAction ReplyAction { get; set; }
+
+            /// <summary>
+            /// Gets the key of ActiveStyle
+            /// </summary>
+            internal override string Key
+            {
+                get
+                {
+                    return "Active";
+                }
+            }
+
+            /// <summary>
+            /// Method to set times to hide or delete notification.
+            /// </summary>
+            /// <remarks>
+            /// The time settings for hiding and deleting are only reflected on Tizen TV.
+            /// If you use this API on other profile, this time settings have no effect
+            /// </remarks>
+            /// <param name="hideTime">The value in second when the notification can be hidden from the notification viewer after notification is posted</param>
+            /// <param name="deleteTime">The value in second when the notification can be deleted from the notification list in setting application after notification is posted</param>
+            /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+            public void SetRemoveTime(int hideTime, int deleteTime)
+            {
+                if (hideTime < 0 || deleteTime < 0)
+                {
+                    throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid argument");
+                }
+
+                hideTimeout = hideTime;
+                deleteTimeout = deleteTime;
+            }
+
+            /// <summary>
+            /// Method to get times to hide or delete notification.
+            /// </summary>
+            /// <param name="hideTime">The value in second when the notification can be hidden from the notification viewer after notification is posted</param>
+            /// <param name="deleteTime">The value in second when the notification can be deleted from the notification list in setting application after notification is posted</param>
+            public void GetRemoveTime(out int hideTime, out int deleteTime)
+            {
+                hideTime = hideTimeout;
+                deleteTime = deleteTimeout;
+            }
+
+            /// <summary>
+            /// Method to add a button to the active notification style.
+            /// Buttons are displayed on the notification.
+            /// </summary>
+            /// <remarks>
+            /// If you add button that has same index, the button is replaced to latest adding button.
+            /// If you don't set an index on ButtonAction, the index is set sequentially from zero.
+            /// </remarks>
+            /// <param name="button">An ButtonAction for appear to the notification</param>
+            /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+            /// <example>
+            /// <code>
+            ///
+            /// ButtonAction button = new ButtonAction
+            /// {
+            ///     Index = 0,
+            ///     Text = "Yes"
+            ///     Action = new AppControl{ ApplicationId = "org.tizen.app" };
+            /// };
+            ///
+            /// ActiveStyle active = new ActiveStyle
+            /// {
+            ///     IsAutoRemove = true,
+            ///     BackgroundImage = "image path",
+            /// };
+            ///
+            /// active.AddButtonAction(button);
+            ///
+            /// </code>
+            /// </example>
+            public void AddButtonAction(ButtonAction button)
+            {
+                if (button == null)
+                {
+                    throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid ButtonAction object");
+                }
+
+                if (button.Index == ButtonIndex.None)
+                {
+                    button.Index = (ButtonIndex)buttonDictionary.Count;
+                    buttonDictionary.Add(button.Index, button);
+                }
+                else if (button.Index >= ButtonIndex.First)
+                {
+                    if (buttonDictionary.ContainsKey(button.Index))
+                    {
+                        buttonDictionary.Remove(button.Index);
+                    }
+
+                    buttonDictionary.Add(button.Index, button);
+                }
+            }
+
+            /// <summary>
+            /// Remove the ButtonAction you already add.
+            /// </summary>
+            /// <param name="index">The index to remove a button</param>
+            /// <returns>true if the element is successfully found and removed; otherwise, false</returns>
+            public bool RemoveButtonAction(ButtonIndex index)
+            {
+                bool ret = buttonDictionary.Remove(index);
+
+                if (ret == false)
+                {
+                    Log.Debug(Notification.LogTag, "Invalid key, there is no button matched input index");
+                }
+                else
+                {
+                    Log.Debug(Notification.LogTag, "The button was removed.");
+                }
+
+                return ret;
+            }
+
+            /// <summary>
+            /// Gets the ButtonAction of the active notification.
+            /// </summary>
+            /// <param name="index">The index to get a button you already add</param>
+            /// <returns>The ButtonAction object which is you already add</returns>
+            /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+            public ButtonAction GetButtonAction(ButtonIndex index)
+            {
+                ButtonAction button = null;
+
+                if (buttonDictionary.ContainsKey(index) == true)
+                {
+                    buttonDictionary.TryGetValue(index, out button);
+                }
+                else
+                {
+                    throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "The value is not existed.");
+                }
+
+                return button;
+            }
+
+            internal ICollection<ButtonAction> GetButtonAction()
+            {
+                return buttonDictionary.Values;
+            }
+
+            internal override void Make(Notification notification)
+            {
+                ActiveBinder.BindObject(notification);
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationBinder.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationBinder.cs
new file mode 100755 (executable)
index 0000000..2d7eb4b
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    using System;
+
+    internal static class NotificationBinder
+    {
+        private static readonly int DoNotShowTimeStamp = -1;
+
+        internal static void BindObject(Notification notification)
+        {
+            BindNotificationSafeHandle(notification);
+            BindNotificationText(notification);
+            BindNotificationTime(notification);
+
+            Interop.Notification.SetID(notification.Handle, notification.PrivID);
+
+            if (notification.IsDisplay)
+            {
+                Interop.Notification.SetApplist(notification.Handle, (int)NotificationDisplayApplist.Tray);
+            }
+            else
+            {
+                Interop.Notification.SetApplist(notification.Handle, 0);
+            }
+
+            if (notification.IsOngoing == true)
+            {
+                Log.Info(Notification.LogTag, "Start to set IsOngoing to SafeHandle");
+                Interop.Notification.SetLayout(notification.Handle, NotificationLayout.Ongoing);
+                Interop.Notification.SetOngoingFlag(notification.Handle, true);
+            }
+
+            if (string.IsNullOrEmpty(notification.Tag) != true)
+            {
+                Interop.Notification.SetTag(notification.Handle, notification.Tag);
+            }
+
+            if (notification.Action != null && notification.Action.SafeAppControlHandle.IsInvalid == false)
+            {
+                Interop.Notification.SetAppControl(notification.Handle, LaunchOption.AppControl, notification.Action.SafeAppControlHandle);
+            }
+
+            Interop.Notification.SetProperties(notification.Handle, (int)notification.Property);
+        }
+
+        internal static void BindSafeHandle(Notification notification)
+        {
+            int privID, groupID;
+            Interop.Notification.GetID(notification.Handle, out groupID, out privID);
+            notification.PrivID = privID;
+
+            NotificationLayout layout;
+            Interop.Notification.GetLayout(notification.Handle, out layout);
+            NotificationType type;
+            Interop.Notification.GetType(notification.Handle, out type);
+            if (layout == NotificationLayout.Ongoing && type == NotificationType.Ongoing)
+            {
+                notification.IsOngoing = true;
+            }
+
+            int appList;
+            Interop.Notification.GetApplist(notification.Handle, out appList);
+            if ((appList & (int)NotificationDisplayApplist.Tray) == 0)
+            {
+                notification.IsDisplay = false;
+            }
+
+            BindSafeHandleText(notification);
+            BindSafeHandleTime(notification);
+            BindSafeHandleTag(notification);
+            BindSafeHandleAction(notification);
+        }
+
+        private static void BindNotificationSafeHandle(Notification notification)
+        {
+            IntPtr ptr;
+            NotificationError ret;
+
+            if (notification.Handle != null && notification.Handle.IsInvalid == false)
+            {
+                notification.Handle.Dispose();
+            }
+
+            if (notification.IsOngoing == true || notification.Progress != null)
+            {
+                ptr = Interop.Notification.Create(NotificationType.Ongoing);
+            }
+            else
+            {
+                ptr = Interop.Notification.Create(NotificationType.Basic);
+            }
+
+            if (ptr == IntPtr.Zero)
+            {
+                ret = (NotificationError)Tizen.Internals.Errors.ErrorFacts.GetLastResult();
+                throw NotificationErrorFactory.GetException(ret, "Unable to create IntPtr Notification");
+            }
+
+            notification.Handle = new NotificationSafeHandle(ptr, true);
+        }
+
+        private static void BindNotificationText(Notification notification)
+        {
+            Interop.Notification.SetText(notification.Handle, NotificationText.Title, notification.Title, null, -1);
+            Interop.Notification.SetText(notification.Handle, NotificationText.Content, notification.Content, null, -1);
+            Interop.Notification.SetImage(notification.Handle, NotificationImage.Icon, notification.Icon);
+            Interop.Notification.SetImage(notification.Handle, NotificationImage.SubIcon, notification.SubIcon);
+            Interop.Notification.SetText(notification.Handle, NotificationText.EventCount, notification.Count.ToString(), null, -1);
+        }
+
+        private static void BindNotificationTime(Notification notification)
+        {
+            if (notification.IsTimeStampVisible == true)
+            {
+                if (notification.TimeStamp != DateTime.MinValue)
+                {
+                    TimeSpan datatime = notification.TimeStamp.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+                    Interop.Notification.SetTime(notification.Handle, (int)datatime.TotalSeconds);
+                }
+            }
+            else
+            {
+                Interop.Notification.SetTime(notification.Handle, DoNotShowTimeStamp);
+            }
+        }
+
+        private static void BindSafeHandleText(Notification notification)
+        {
+            string text;
+            Interop.Notification.GetText(notification.Handle, NotificationText.Title, out text);
+            if (string.IsNullOrEmpty(text) == false)
+            {
+                notification.Title = text;
+            }
+
+            Interop.Notification.GetText(notification.Handle, NotificationText.Content, out text);
+            if (string.IsNullOrEmpty(text) == false)
+            {
+                notification.Content = text;
+            }
+
+            string path;
+            Interop.Notification.GetImage(notification.Handle, NotificationImage.Icon, out path);
+            if (string.IsNullOrEmpty(path) == false)
+            {
+                notification.Icon = path;
+            }
+
+            Interop.Notification.GetImage(notification.Handle, NotificationImage.SubIcon, out path);
+            if (string.IsNullOrEmpty(path) == false)
+            {
+                notification.SubIcon = path;
+            }
+
+            Interop.Notification.GetText(notification.Handle, NotificationText.EventCount, out text);
+            if (string.IsNullOrEmpty(text) == false)
+            {
+                try
+                {
+                    notification.Count = int.Parse(text);
+                }
+                catch (Exception ex)
+                {
+                    Log.Error(Notification.LogTag, ex.ToString());
+                }
+            }
+        }
+
+        private static void BindSafeHandleTime(Notification notification)
+        {
+            int time;
+
+            Interop.Notification.GetTime(notification.Handle, out time);
+
+            if (time == DoNotShowTimeStamp)
+            {
+                notification.IsTimeStampVisible = false;
+            }
+            else
+            {
+                notification.IsTimeStampVisible = true;
+
+                if (time != 0)
+                {
+                    notification.TimeStamp = (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local)).AddSeconds(time).ToLocalTime();
+                }
+            }
+        }
+
+        private static void BindSafeHandleTag(Notification notification)
+        {
+            string text;
+            Interop.Notification.GetTag(notification.Handle, out text);
+            if (string.IsNullOrEmpty(text) != true)
+            {
+                notification.Tag = text;
+            }
+        }
+
+        private static void BindSafeHandleProperty(Notification notification)
+        {
+            int property;
+            Interop.Notification.GetProperties(notification.Handle, out property);
+            notification.Property = (NotificationProperty)property;
+        }
+
+        private static void BindSafeHandleAction(Notification notification)
+        {
+            SafeAppControlHandle appcontrol = null;
+            Interop.Notification.GetAppControl(notification.Handle, LaunchOption.AppControl, out appcontrol);
+            if (appcontrol != null && appcontrol.IsInvalid == false)
+            {
+                notification.Action = new AppControl(appcontrol);
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationButtonAction.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationButtonAction.cs
new file mode 100755 (executable)
index 0000000..c4c2ed5
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    /// <summary>
+    /// Class containing common properties and methods of Notifications
+    /// </summary>
+    /// <remarks>
+    /// A notification is a message that is displayed on the notification area.
+    /// It is created to notify information to the user through the application.
+    /// This class helps you to provide method and property for creating notification object.
+    /// </remarks>
+    public sealed partial class Notification
+    {
+        /// <summary>
+        ///  Class to help you set button on Active style of Notification
+        /// </summary>
+        /// <remarks>
+        /// It must include a Text, an Index, an ImagePath, and an Action to be invoked when user select the button.
+        /// </remarks>>
+        public sealed class ButtonAction : MakerBase
+        {
+            /// <summary>
+            /// Gets or sets the index of Button which is appeared at Notification.
+            /// </summary>
+            public ButtonIndex Index { get; set; } = ButtonIndex.None;
+
+            /// <summary>
+            /// Gets or sets the text describing the button
+            /// </summary>
+            public string Text { get; set; }
+
+            /// <summary>
+            /// Gets or sets the image path that represent the button
+            /// </summary>
+            public string ImagePath { get; set; }
+
+            /// <summary>
+            /// Gets or sets the action which is invoked when button is clicked
+            /// </summary>
+            /// <value>
+            /// If you don't set Action, nothing happens when button is clicked.
+            /// </value>
+            /// <example>
+            /// <code>
+            /// ButtonAction button = new ButtonAction
+            /// {
+            ///     Index = ButtonIndex.First,
+            ///     text = "Yes",
+            ///     ImagePath = "image path",
+            ///     Action = new AppControl{ ApplicationId = "org.tizen.app" };
+            /// };
+            /// </code>
+            /// </example>
+            /// <seealso cref="Tizen.Applications.AppControl"></seealso>
+            public AppControl Action { get; set; }
+
+            internal override void Make(Notification notification)
+            {
+                int enumIndex = (int)NotificationText.FirstButton + (int)Index;
+
+                Interop.Notification.SetText(notification.Handle, (NotificationText)enumIndex, Text, null, -1);
+                enumIndex = (int)NotificationImage.FirstButton + (int)Index;
+                Interop.Notification.SetImage(notification.Handle, (NotificationImage)enumIndex, ImagePath);
+                if (Action != null && Action.SafeAppControlHandle.IsInvalid == false)
+                {
+                    Interop.Notification.SetEventHandler(notification.Handle, (int)Index, Action.SafeAppControlHandle);
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationEnumerations.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationEnumerations.cs
new file mode 100755 (executable)
index 0000000..7cb41d9
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    using System;
+
+    /// <summary>
+    /// Enumeration for Progress category
+    /// </summary>
+    public enum ProgressCategory
+    {
+        /// <summary>
+        /// Value for percent type
+        /// </summary>
+        Percent,
+
+        /// <summary>
+        /// Value for time type
+        /// </summary>
+        Time,
+
+        /// <summary>
+        /// Value for pending type which is not updated progress current value
+        /// </summary>
+        PendingBar
+    }
+
+    /// <summary>
+    /// Enumeration for Accessory option
+    /// </summary>
+    public enum AccessoryOption
+    {
+        /// <summary>
+        /// Value for off accessory option
+        /// </summary>
+        Off = -1,
+
+        /// <summary>
+        /// Value for on accessory option
+        /// </summary>
+        On,
+
+        /// <summary>
+        /// Value for custom accessory option
+        /// </summary>
+        Custom
+    }
+
+    /// <summary>
+    /// Enumeration for Button Index
+    /// </summary>
+    public enum ButtonIndex
+    {
+        /// <summary>
+        /// Value for default button index
+        /// </summary>
+        None = -1,
+
+        /// <summary>
+        /// Value for first button index
+        /// </summary>
+        First,
+
+        /// <summary>
+        /// Value for second button index
+        /// </summary>
+        Second,
+
+        /// <summary>
+        /// Value for third button index
+        /// </summary>
+        Third
+    }
+
+    /// <summary>
+    /// Enumeration for notification particular property
+    /// </summary>
+    [Flags]
+    public enum NotificationProperty
+    {
+        /// <summary>
+        /// Value for adjust nothing
+        /// </summary>
+        None = 0x00,
+
+        /// <summary>
+        /// Value for display only SIM card inserted
+        /// </summary>
+        DisplayOnlySimmode = 0x01,
+
+        /// <summary>
+        /// Value for disable application launch when it selected
+        /// </summary>
+        DisableAppLaunch = 0x02,
+
+        /// <summary>
+        /// Value for disable auto delete when it selected
+        /// </summary>
+        DisableAutoDelete = 0x04,
+
+        /// <summary>
+        /// Value for deleted when device is rebooted even though notification is not set Ongoing
+        /// </summary>
+        VolatileDisplay = 0x100
+    }
+
+    /// <summary>
+    /// Enumeration for block state
+    /// </summary>
+    public enum NotificationBlockState
+    {
+        /// <summary>
+        /// Value to check the app is allowed to post notification
+        /// </summary>
+        Allowed = 0,
+
+        /// <summary>
+        /// Value to check the app is not allowed to post any notification
+        /// </summary>
+        Blocked,
+
+        /// <summary>
+        /// Value to check do not disturb mode which is user set
+        /// </summary>
+        DoNotDisturb
+    }
+
+    internal enum NotificationType
+    {
+        None = -1,
+        Basic = 0,
+        Ongoing,
+    }
+
+    internal enum NotificationEventType
+    {
+        FirstButton = 0,
+        SecondButton,
+        ThirdButton,
+        ClickOnIcon = 6,
+        ClockOnThumbnail = 7,
+        ClickOnTextInputButton = 8
+    }
+
+    internal enum NotificationLayout
+    {
+        None = 0,
+        SingleEvent = 1,
+        Thumbnail = 3,
+        Ongoing = 4,
+        Progress = 5,
+        Extension = 6
+    }
+
+    internal enum NotificationText
+    {
+        Title = 0,
+        Content,
+        EventCount = 3,
+        FirstMainText,
+        FirstSubText,
+        SecondMainText,
+        SecondSubText,
+        FirstButton = 13,
+        SeceondButton = 14,
+        ThirdButton = 15,
+        PlaceHolder = 19,
+        InputButton = 20,
+    }
+
+    internal enum NotificationImage
+    {
+        Icon = 0,
+        IconForIndicator,
+        IconForLock,
+        Thumbnail,
+        ThumbnailForLock,
+        SubIcon,
+        Background,
+        FirstButton = 12,
+        SecondButton,
+        ThirdButton,
+        TextInputButton = 18,
+    }
+
+    internal enum LaunchOption
+    {
+        AppControl = 1
+    }
+
+    [Flags]
+    internal enum NotificationDisplayApplist
+    {
+        Tray = 0x00000001,
+        Ticker = 0x00000002,
+        Lock = 0x00000004,
+        Indicator = 0x00000008,
+        Active = 0x00000010,
+        All = 0x0000000f,
+    }
+}
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationErrorFactory.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationErrorFactory.cs
new file mode 100755 (executable)
index 0000000..12f92f3
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    using System;
+    using System.Runtime.CompilerServices;
+
+    internal enum NotificationError
+    {
+        None = Tizen.Internals.Errors.ErrorCode.None,
+        InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+        OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+        IoError = Tizen.Internals.Errors.ErrorCode.IoError,
+        DbError = -0x01140000 | 0x01,
+        AlreadyExists = -0x01140000 | 0x02,
+        DBusError = -0x01140000 | 0x03,
+        DoesnotExist = -0x01140000 | 0x04,
+        ServiceError = -0x01140000 | 0x05,
+        PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
+        InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation
+    }
+
+    internal static class NotificationErrorFactory
+    {
+        internal static Exception GetException(NotificationError ret, string msg, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0)
+        {
+            Log.Error(Notification.LogTag, memberName + " : " + lineNumber);
+
+            switch (ret)
+            {
+                case NotificationError.InvalidParameter:
+                    Log.Error(Notification.LogTag, msg);
+                    return new ArgumentException(ret + " error occurred.");
+                case NotificationError.PermissionDenied:
+                    throw new UnauthorizedAccessException("Permission denied (http://tizen.org/privilege/notification)");
+                default:
+                    Log.Error(Notification.LogTag, msg);
+                    return new InvalidOperationException(ret + " error occurred.");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationIndicatorStyle.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationIndicatorStyle.cs
new file mode 100755 (executable)
index 0000000..7e87c84
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    /// <summary>
+    /// Class containing common properties and methods of Notifications
+    /// </summary>
+    /// <remarks>
+    /// A notification is a message that is displayed on the notification area.
+    /// It is created to notify information to the user through the application.
+    /// This class helps you to provide method and property for creating notification object.
+    /// </remarks>
+    public sealed partial class Notification
+    {
+        /// <summary>
+        ///  Class for generating Indicator style notification
+        /// </summary>
+        public sealed class IndicatorStyle : StyleBase
+        {
+            /// <summary>
+            /// Gets or sets an absolute path for an image file.
+            /// If you set IconPath, you can see the icon on the right side of indicator.
+            /// </summary>
+            public string IconPath { get; set; }
+
+            /// <summary>
+            /// Gets or sets a sub text for displaying Indicator style
+            /// </summary>
+            public string SubText { get; set; }
+
+            /// <summary>
+            /// Gets the key of IndicatorStyle
+            /// </summary>
+            internal override string Key
+            {
+                get
+                {
+                    return "Indicator";
+                }
+            }
+
+            internal override void Make(Notification notification)
+            {
+                IndicatorBinder.BindObject(notification);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationLockStyle.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationLockStyle.cs
new file mode 100755 (executable)
index 0000000..78029a7
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    /// <summary>
+    /// Class containing common properties and methods of Notifications
+    /// </summary>
+    /// <remarks>
+    /// A notification is a message that is displayed on the notification area.
+    /// It is created to notify information to the user through the application.
+    /// This class helps you to provide method and property for creating notification object.
+    /// </remarks>
+    public sealed partial class Notification
+    {
+        /// <summary>
+        ///  Class for generating Lock style notification
+        /// </summary>
+        public sealed class LockStyle : StyleBase
+        {
+            /// <summary>
+            /// Gets or sets an absolute path for an image file to display on the icon of Lock style
+            /// </summary>
+            public string IconPath { get; set; }
+
+            /// <summary>
+            /// Gets or sets an absolute path for a thumbnail image file to display on Lock style
+            /// </summary>
+            public string ThumbnailPath { get; set; }
+
+            /// <summary>
+            /// Gets the key of LockStyle
+            /// </summary>
+            internal override string Key
+            {
+                get
+                {
+                    return "Lock";
+                }
+            }
+
+            internal override void Make(Notification notification)
+            {
+                LockBinder.BindObject(notification);
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationMakerBase.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationMakerBase.cs
new file mode 100755 (executable)
index 0000000..859a81f
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    using System.ComponentModel;
+
+    /// <summary>
+    /// Class containing common properties and methods of Notifications
+    /// </summary>
+    /// <remarks>
+    /// A notification is a message that is displayed on the notification area.
+    /// It is created to notify information to the user through the application.
+    /// This class helps you to provide method and property for creating notification object.
+    /// </remarks>
+    public sealed partial class Notification
+    {
+        /// <summary>
+        /// An object that help notification make to SafeHandle.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public abstract class MakerBase
+        {
+            internal abstract void Make(Notification notification);
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationManager.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationManager.cs
new file mode 100755 (executable)
index 0000000..1a890f3
--- /dev/null
@@ -0,0 +1,480 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    using System;
+    using System.ComponentModel;
+
+    /// <summary>
+    /// NotificationManager class to post, update, delete and get Notification.
+    /// </summary>
+    public static class NotificationManager
+    {
+        /// <summary>
+        /// Posts a new Notification.
+        /// </summary>
+        /// <param name="notification">Notification to post</param>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <example>
+        /// <code>
+        /// Notification notification = new Notification
+        /// {
+        ///     Title = "title",
+        ///     Content = "content",
+        ///     Icon = "absolute icon path",
+        ///     Tag = "first notification"
+        /// };
+        ///
+        /// Notification.AccessorySet accessory = new Notification.AccessorySet
+        /// {
+        ///     SoundOption = AccessoryOption.On,
+        ///     CanVibrate = true
+        /// };
+        /// notification.Accessory = accessory;
+        ///
+        ///     // do something
+        ///
+        /// NotificationManager.Post(notification);
+        /// </code>
+        /// </example>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static void Post(Notification notification)
+        {
+            if (notification == null)
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid argument to post method");
+            }
+
+            notification.Make();
+
+            NotificationError ret = Interop.Notification.Post(notification.Handle);
+            if (ret != NotificationError.None)
+            {
+                throw NotificationErrorFactory.GetException(ret, "post notification failed");
+            }
+
+            int priv_id, group_id;
+            Interop.Notification.GetID(notification.Handle, out group_id, out priv_id);
+            notification.PrivID = priv_id;
+        }
+
+        /// <summary>
+        /// Updates a posted Notification.
+        /// </summary>
+        /// <param name="notification">Notification to update</param>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <example>
+        /// <code>
+        /// string tag = "first tag";
+        ///
+        /// Notification notification = new Notification
+        /// {
+        ///     Title = "title",
+        ///     Content = "content",
+        ///     Icon = "absolute icon path",
+        ///     Tag = tag
+        /// };
+        ///
+        /// Notification.AccessorySet accessory = new Notification.AccessorySet
+        /// {
+        ///     LedOption = AccessoryOption.On,
+        ///     VibrationOption = AccessoryOption.Custom,
+        ///     VibrationPath = "vibration absolute path"
+        /// }
+        /// notification.Accessory = accessory;
+        ///
+        /// NotificationManager.Post(notification);
+        ///
+        ///     // do something
+        ///
+        /// Notification loadNotification = NotificationManager.Load(tag);
+        ///
+        /// loadNotification.Progress = new ProgressType(ProgressCategory.Percent, 0.0. 100.0);
+        ///
+        /// Thread thread = new Thread(new ParameterizedThreadStart(UpdateProgress));
+        /// thread.IsBackground = true;
+        /// thread.Start(notification);
+        ///
+        ///   ...
+        ///
+        /// static void UpdateProgress(Object obj)
+        /// {
+        ///     Notification notification = (Notification)obj;
+        ///
+        ///     for (double current = 1.0; current &lt;= 100.0; current = current + 1.0)
+        ///     {
+        ///         notification.Progress.ProgressCurrent = current;
+        ///         NotificationManager.Update(notification);
+        ///         Thread.Sleep(300);
+        ///     }
+        /// }
+        /// </code>
+        /// </example>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        /// <pre>
+        /// Post method should be called on the Notification object.
+        /// </pre>
+        public static void Update(Notification notification)
+        {
+            if (notification == null || notification.Handle == null || notification.Handle.IsInvalid)
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid argument to post method");
+            }
+
+            notification.Make();
+            NotificationError ret = Interop.Notification.Update(notification.Handle);
+            if (ret != NotificationError.None)
+            {
+                throw NotificationErrorFactory.GetException(ret, "update notification failed");
+            }
+        }
+
+        /// <summary>
+        /// Deletes a posted Notification.
+        /// </summary>
+        /// <param name="notification">Notification to remove</param>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <example>
+        /// <code>
+        /// Notification notification = new Notification
+        /// {
+        ///     Title = "title",
+        ///     Content = "content",
+        ///     Icon = "absolute icon path",
+        ///     Tag = "first notification"
+        /// };
+        /// NotificationManager.Post(notification);
+        ///
+        ///     // do something
+        ///
+        /// NotificationManager.Delete(notification);
+        /// </code>
+        /// </example>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        /// <pre>
+        /// Post method should be called on the Notification object.
+        /// </pre>
+        public static void Delete(Notification notification)
+        {
+            if (notification == null || notification.Handle == null || notification.Handle.IsInvalid)
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid argument to post method");
+            }
+
+            NotificationError ret = Interop.Notification.Delete(notification.Handle);
+            if (ret != NotificationError.None)
+            {
+                throw NotificationErrorFactory.GetException(ret, "delete notification failed");
+            }
+        }
+
+        /// <summary>
+        /// Removes all posted Notification of calling application.
+        /// </summary>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <example>
+        /// <code>
+        /// Notification firstNotification = new Notification
+        /// {
+        ///     Title = "title",
+        ///     Content = "content",
+        ///     Icon = "absolute icon path",
+        ///     Tag = "first notification"
+        /// };
+        /// NotificationManager.Post(firstNotification);
+        ///
+        /// Notification secondNotification = new Notification
+        /// {
+        ///     Title = "title",
+        ///     Content = "content",
+        ///     Icon = "absolute icon path",
+        ///     Tag = "second notification"
+        /// };
+        /// NotificationManager.Post(secondNotification);
+        /// NotificationManager.DeleteAll();
+        /// </code>
+        /// </example>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static void DeleteAll()
+        {
+            NotificationError ret;
+
+            ret = Interop.Notification.DeleteAll((int)NotificationType.Basic);
+            if (ret != NotificationError.None)
+            {
+                throw NotificationErrorFactory.GetException(ret, "delete all notifications failed of Noti type");
+            }
+
+            ret = Interop.Notification.DeleteAll((int)NotificationType.Ongoing);
+            if (ret != NotificationError.None)
+            {
+                throw NotificationErrorFactory.GetException(ret, "delete all notifications failed of Ongoing type");
+            }
+        }
+
+        /// <summary>
+        /// Searches for a posted notification which has the inputted tag and isn't deleted not yet.
+        /// </summary>
+        /// <remarks>
+        /// Load method should be called only for notifications which have been posted using NotificationManager.Post method.
+        /// If two or more notifications share the same tag, the notification posted most recently is returned.
+        /// </remarks>
+        /// <param name="tag">Tag used to query</param>
+        /// <returns>Notification Object with inputted tag</returns>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid or when the tag does not exist</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <example>
+        /// <code>
+        /// Notification notification = new Notification
+        /// {
+        ///     Title = "title",
+        ///     Content = "content",
+        ///     Icon = "absolute icon path",
+        ///     Tag = "first notification"
+        /// };
+        /// NotificationManager.Post(notification);
+        ///
+        ///     // do someting
+        ///
+        /// Notification loadNotification = NotificationManager.Load("first notification");
+        /// </code>
+        /// </example>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static Notification Load(string tag)
+        {
+            IntPtr ptr = IntPtr.Zero;
+
+            if (string.IsNullOrEmpty(tag))
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered");
+            }
+
+            ptr = Interop.Notification.Load(tag);
+
+            if (ptr == IntPtr.Zero)
+            {
+                NotificationError ret = (NotificationError)Tizen.Internals.Errors.ErrorFacts.GetLastResult();
+                Log.Error(Notification.LogTag, "unable to load Notification : " + ret.ToString());
+                if (ret == NotificationError.DbError)
+                {
+                    throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "the tag does not exist");
+                }
+                else
+                {
+                    throw NotificationErrorFactory.GetException(ret, "unable to load Notification");
+                }
+            }
+
+            Notification notification = new Notification
+            {
+                Handle = new NotificationSafeHandle(ptr, true)
+            }.Build();
+
+            return notification;
+        }
+
+        /// <summary>
+        /// Saves a notification template to the notification database
+        /// </summary>
+        /// <param name="notification">Notification to save as template</param>
+        /// <param name="name">Template name</param>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when can't save as template</exception>
+        /// <example>
+        /// <code>
+        /// Notification notification = new Notification
+        /// {
+        ///     Title = "title",
+        ///     Content = "content",
+        ///     Icon = "absolute icon path",
+        ///     Tag = "first notification"
+        /// };
+        ///
+        /// Notification.Accessory accessory = new Notification.Accessory
+        /// {
+        ///     LedOption = AccessoryOption.On,
+        ///     VibrationOption = AccessoryOption.Custom,
+        ///     VibrationPath = "vibration absolute path"
+        /// }
+        /// notification.setAccessory(accessory);
+        ///
+        ///     // do something
+        ///
+        /// NotificationManager.Post(notification);
+        ///
+        /// Notification.LockStyle style = new Notification.LockStyle
+        /// {
+        ///     IconPath = "icon path",
+        ///     ThumbnailPath = "Thumbnail path"
+        /// }
+        /// notification.AddStyle(style);
+        /// NotificationManager.SaveTemplate(notification, "firstTemplate");
+        /// </code>
+        /// </example>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static void SaveTemplate(Notification notification, string name)
+        {
+            if (notification == null || string.IsNullOrEmpty(name))
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid argument to save template");
+            }
+
+            notification.Make();
+
+            NotificationError ret = Interop.Notification.SaveTemplate(notification.Handle, name);
+            if (ret != NotificationError.None)
+            {
+                throw NotificationErrorFactory.GetException(ret, "save as template failed");
+            }
+        }
+
+        /// <summary>
+        /// Loads a notification template from the notification database
+        /// </summary>
+        /// <param name="name">Template name</param>
+        /// <returns>Notification Object with inputted template name</returns>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid or when no template with input name exists</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <example>
+        /// <code>
+        /// Notification notification = new Notification
+        /// {
+        ///     Title = "title",
+        ///     Content = "content",
+        ///     Icon = "absolute icon path",
+        ///     Tag = "first notification"
+        /// };
+        ///
+        /// Notification.Accessory accessory = new Notification.Accessory
+        /// {
+        ///     LedOption = AccessoryOption.On,
+        ///     VibrationOption = AccessoryOption.Custom,
+        ///     VibrationPath = "vibration absolute path"
+        /// }
+        /// notification.setAccessory(accessory);
+        ///
+        ///     // do something
+        ///
+        /// NotificationManager.Post(notification);
+        ///
+        /// Notification.LockStyle style = new Notification.LockStyle
+        /// {
+        ///     IconPath = "icon path",
+        ///     ThumbnailPath = "Thumbnail path"
+        /// }
+        /// notification.AddStyle(style);
+        /// NotificationManager.SaveTemplate(notification, "firstTemplate");
+        /// Notification notificationTemplate = NotificationManager.LoadTemplate("firstTemplate");
+        /// </code>
+        /// </example>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static Notification LoadTemplate(string name)
+        {
+            IntPtr handle = IntPtr.Zero;
+
+            if (string.IsNullOrEmpty(name))
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid argument to load template");
+            }
+
+            handle = Interop.Notification.LoadTemplate(name);
+            if (handle == IntPtr.Zero)
+            {
+                NotificationError ret = (NotificationError)Tizen.Internals.Errors.ErrorFacts.GetLastResult();
+                if (ret == NotificationError.DbError)
+                {
+                    throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "the name does not exist");
+                }
+                else
+                {
+                    throw NotificationErrorFactory.GetException(ret, "unable to create Notification from template");
+                }
+            }
+
+            Notification notification = new Notification
+            {
+                Handle = new NotificationSafeHandle(handle, true)
+            }.Build();
+
+            return notification;
+        }
+
+        /// <summary>
+        /// Gets notification block state.
+        /// </summary>
+        /// <remarks>
+        /// The user can set the notification block state in settings.
+        /// The block state indicates whether or not notifications can be posted.
+        /// Additionally only notifications to the notification panel are allowed in "Do not disturb mode".
+        /// Sound, Vibrate and Active notifications are blocked.
+        /// </remarks>
+        /// <returns>NotificationBlockState is state if notification is posted</returns>
+        /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static NotificationBlockState GetBlockState()
+        {
+            NotificationBlockState state;
+            NotificationError ret;
+
+            ret = Interop.Notification.GetBlockState(out state);
+            if (ret != NotificationError.None)
+            {
+                throw NotificationErrorFactory.GetException(ret, "GetBlockState failed");
+            }
+
+            Log.Info(Notification.LogTag, "Current block state is " + state.ToString());
+            return state;
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static NotificationSafeHandle MakeNotificationSafeHandle(Notification notification)
+        {
+            if (notification == null)
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid notification object");
+            }
+
+            notification.Make();
+
+            return notification.Handle;
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static Notification MakeNotification(NotificationSafeHandle handle)
+        {
+            if (handle == null || handle.IsInvalid == true)
+            {
+                throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "handle is invalid or null");
+            }
+
+            Notification notification = new Notification { Handle = handle }.Build();
+
+            return notification;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationProgress.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationProgress.cs
new file mode 100755 (executable)
index 0000000..3630755
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    /// <summary>
+    /// Class containing common properties and methods of Notifications
+    /// </summary>
+    /// <remarks>
+    /// A notification is a message that is displayed on the notification area.
+    /// It is created to notify information to the user through the application.
+    /// This class helps you to provide method and property for creating notification object.
+    /// </remarks>
+    public sealed partial class Notification
+    {
+        /// <summary>
+        ///  Class for displaying progress notification
+        ///  You must initialize progress category, current, max value when you create object.
+        /// </summary>
+        public sealed class ProgressType : MakerBase
+        {
+            private double progressCurrent;
+            private double progressMax;
+
+            /// <summary>
+            /// Initializes a new instance of the <see cref="ProgressType"/> class.
+            /// You must initialize category, current, max value of progress.
+            /// </summary>
+            /// <param name="category">The category of progress that appeared on Notification</param>
+            /// <param name="current">The current value of the progress</param>
+            /// <param name="max">The max value of the progress</param>
+            /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+            public ProgressType(ProgressCategory category, double current, double max)
+            {
+                if (IsNegativeNumber(current))
+                {
+                    throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "The current must be a positive integer.");
+                }
+
+                if (IsNegativeNumber(max))
+                {
+                    throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "The max must be a positive integer.");
+                }
+
+                Category = category;
+                ProgressCurrent = current;
+                ProgressMax = max;
+            }
+
+            /// <summary>
+            /// Gets or sets category of ProgressType.
+            /// </summary>
+            /// <seealso cref="Tizen.Applications.Notifications.ProgressCategory"></seealso>
+            public ProgressCategory Category { get; set; }
+
+            /// <summary>
+            /// Gets or sets current value of ProgressType
+            /// </summary>
+            /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+            public double ProgressCurrent
+            {
+                get
+                {
+                    return progressCurrent;
+                }
+
+                set
+                {
+                    if (IsNegativeNumber(value))
+                    {
+                        throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "The value must be a positive integer.");
+                    }
+
+                    progressCurrent = value;
+                }
+            }
+
+            /// <summary>
+            /// Gets or sets max value of ProgressType
+            /// </summary>
+            /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+            public double ProgressMax
+            {
+                get
+                {
+                    return progressMax;
+                }
+
+                set
+                {
+                    if (IsNegativeNumber(value))
+                    {
+                        throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "The value must be a positive integer.");
+                    }
+
+                    progressMax = value;
+                }
+            }
+
+            internal override void Make(Notification notification)
+            {
+                ProgressBinder.BindObject(notification);
+            }
+
+            private bool IsNegativeNumber(double number)
+            {
+                return number < 0;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationProgressBinder.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationProgressBinder.cs
new file mode 100755 (executable)
index 0000000..6afd5c5
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    internal static class ProgressBinder
+    {
+        internal static void BindObject(Notification notification)
+        {
+            double current, max;
+
+            Notification.ProgressType progress = notification.Progress;
+
+            if (progress.Category == ProgressCategory.PendingBar)
+            {
+                Interop.Notification.SetProgressType(notification.Handle, ProgressCategory.Percent);
+                current = 0;
+                max = 0;
+            }
+            else if (progress.Category == ProgressCategory.Percent)
+            {
+                Interop.Notification.SetProgressType(notification.Handle, progress.Category);
+                current = progress.ProgressCurrent / 100;
+                max = progress.ProgressMax;
+            }
+            else
+            {
+                Interop.Notification.SetProgressType(notification.Handle, progress.Category);
+                current = progress.ProgressCurrent;
+                max = progress.ProgressMax;
+            }
+
+            Interop.Notification.SetProgress(notification.Handle, current);
+            Interop.Notification.SetProgressSize(notification.Handle, max);
+            Interop.Notification.SetLayout(notification.Handle, NotificationLayout.Progress);
+            Interop.Notification.SetOngoingFlag(notification.Handle, true);
+        }
+
+        internal static void BindSafeHandle(Notification notification)
+        {
+            NotificationLayout layout;
+            Interop.Notification.GetLayout(notification.Handle, out layout);
+
+            if (layout == NotificationLayout.Progress)
+            {
+                ProgressCategory category;
+                double current, max;
+
+                Interop.Notification.GetProgressType(notification.Handle, out category);
+                Interop.Notification.GetProgress(notification.Handle, out current);
+                Interop.Notification.GetProgressSize(notification.Handle, out max);
+
+                if (category == ProgressCategory.Percent)
+                {
+                    current *= 100;
+                }
+
+                notification.Progress = new Notification.ProgressType(category, current, max);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationReplyAction.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationReplyAction.cs
new file mode 100755 (executable)
index 0000000..f3bc10a
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    /// <summary>
+    /// Class containing common properties and methods of Notifications
+    /// </summary>
+    /// <remarks>
+    /// A notification is a message that is displayed on the notification area.
+    /// It is created to notify information to the user through the application.
+    /// This class helps you to provide method and property for creating notification object.
+    /// </remarks>
+    public sealed partial class Notification
+    {
+        /// <summary>
+        ///  Class for displaying direct-reply at notification.
+        ///  You must set a ReplyMax and Button. Otherwise user can't send written text to application which is set by AppControl.
+        /// </summary>
+        public sealed class ReplyAction : MakerBase
+        {
+            /// <summary>
+            /// Gets or sets the Index of Button which is appeared at Notification.
+            /// If you set ParentIndex, ReplyAction is displayed when button matched with ParentIndex click by the user.
+            /// If you don't set ParentIndex, appeared to notification directly.
+            /// </summary>
+            public ButtonIndex ParentIndex { get; set; } = ButtonIndex.None;
+
+            /// <summary>
+            /// Gets or sets the PlaceHolderText of ReplyAction which is appeared at Notification.
+            /// If you set PlaceHolderText, it is displayed to placeholder in notification.
+            /// </summary>
+            public string PlaceHolderText { get; set; }
+
+            /// <summary>
+            /// Gets or sets the ReplyMax of ReplyAction which is appeared at Notification.
+            /// You must set a ReplyMax. Otherwise user don't write text to placeholder in notification.
+            /// </summary>
+            /// <value>
+            /// Default value is 160.
+            /// </value>
+            public int ReplyMax { get; set; } = 160;
+
+            /// <summary>
+            /// Gets or sets the Button which is appeared to ReplyAction in Notification.
+            /// You must set a Button. Otherwise user can't send written text to application which is set by AppControl.
+            /// </summary>
+            /// <remarks>
+            /// If you set it to null, the already set ButtonAction will be removed.
+            /// </remarks>
+            /// <example>
+            /// <code>
+            /// ReplyAction button = new ReplyAction
+            /// {
+            ///     ParentIndex = ButtonIndex.Second;
+            ///     PlaceHolderText = "Please write your reply."
+            ///     ReplyMax = 160,
+            ///     Button = new ButtonAction
+            ///     {
+            ///         text = "Yes",
+            ///         ImagePath = "image path",
+            ///         Action = new AppControl{ ApplicationId = "org.tizen.app" };
+            ///     };
+            /// };
+            /// </code>
+            /// </example>
+            public ButtonAction Button { get; set; }
+
+            internal override void Make(Notification notification)
+            {
+                string replyKey = "__PARENT_INDEX__";
+
+                if (Button != null)
+                {
+                    Interop.Notification.SetText(notification.Handle, NotificationText.InputButton, Button.Text, null, -1);
+                    Interop.Notification.SetImage(notification.Handle, NotificationImage.TextInputButton, Button.ImagePath);
+
+                    if (this.Button.Action != null && this.Button.Action.SafeAppControlHandle.IsInvalid == false)
+                    {
+                        Interop.Notification.SetEventHandler(notification.Handle, (int)NotificationEventType.ClickOnTextInputButton, this.Button.Action.SafeAppControlHandle);
+
+                        if (this.ParentIndex != ButtonIndex.None)
+                        {
+                            Interop.Notification.SetEventHandler(notification.Handle, (int)this.ParentIndex, this.Button.Action.SafeAppControlHandle);
+                        }
+                    }
+                }
+
+                Bundle bundle = new Bundle();
+                bundle.AddItem(replyKey, ((int)this.ParentIndex).ToString());
+                Interop.Notification.SetExtentionData(notification.Handle, replyKey, bundle.SafeBundleHandle);
+
+                Interop.Notification.SetPlaceHolderLength(notification.Handle, this.ReplyMax);
+                Interop.Notification.SetText(notification.Handle, NotificationText.PlaceHolder, PlaceHolderText, null, -1);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationSafeHandle.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationSafeHandle.cs
new file mode 100755 (executable)
index 0000000..28ce60a
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    using System;
+    using System.ComponentModel;
+    using System.Runtime.InteropServices;
+
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public sealed class NotificationSafeHandle : SafeHandle
+    {
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public NotificationSafeHandle()
+            : base(IntPtr.Zero, true)
+        {
+        }
+
+        internal NotificationSafeHandle(IntPtr existingHandle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle)
+        {
+            SetHandle(existingHandle);
+        }
+
+        /// <summary>
+        /// Gets a value that indicates whether the handle is invalid.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public override bool IsInvalid
+        {
+            get { return this.DangerousGetHandle() == IntPtr.Zero; }
+        }
+
+        protected override bool ReleaseHandle()
+        {
+            Interop.Notification.Destroy(this.handle);
+            this.SetHandle(IntPtr.Zero);
+            return true;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationStyle.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationStyle.cs
new file mode 100755 (executable)
index 0000000..84ec3a7
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    /// <summary>
+    /// Class containing common properties and methods of Notifications
+    /// </summary>
+    /// <remarks>
+    /// A notification is a message that is displayed on the notification area.
+    /// It is created to notify information to the user through the application.
+    /// This class helps you to provide method and property for creating notification object.
+    /// </remarks>
+    public sealed partial class Notification
+    {
+        /// <summary>
+        /// An object that can apply a rich notification style to a Notification object.
+        /// If the platform does not provide rich notification styles in this class have no effect.
+        /// </summary>
+        public abstract class StyleBase : MakerBase
+        {
+            internal abstract string Key { get; }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationStyleBinder.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationStyleBinder.cs
new file mode 100755 (executable)
index 0000000..587c6ef
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Notifications
+{
+    using System;
+
+    internal static class IndicatorBinder
+    {
+        internal static void BindObject(Notification notification)
+        {
+            int flag;
+            NotificationError ret = NotificationError.None;
+            Notification.IndicatorStyle style = (Notification.IndicatorStyle)notification.GetStyle("Indicator");
+            Interop.Notification.GetApplist(notification.Handle, out flag);
+
+            if (string.IsNullOrEmpty(style.SubText) == false)
+            {
+                ret = Interop.Notification.SetText(notification.Handle, NotificationText.FirstMainText, style.SubText, null, -1);
+                if (ret != NotificationError.None)
+                {
+                    throw NotificationErrorFactory.GetException(ret, "unable to set indicator text");
+                }
+                flag |= (int)NotificationDisplayApplist.Ticker;
+            }
+
+            if (string.IsNullOrEmpty(style.IconPath) == false)
+            {
+                ret = Interop.Notification.SetImage(notification.Handle, NotificationImage.IconForIndicator, style.IconPath);
+                if (ret != NotificationError.None)
+                {
+                    throw NotificationErrorFactory.GetException(ret, "unable to set indicator image");
+                }
+                flag |= (int)NotificationDisplayApplist.Indicator;
+            }
+            Interop.Notification.SetApplist(notification.Handle, flag);
+        }
+
+        internal static void BindSafeHandle(Notification notification)
+        {
+            int appList;
+            Interop.Notification.GetApplist(notification.Handle, out appList);
+            if ((appList & (int)NotificationDisplayApplist.Ticker) != 0 || (appList & (int)NotificationDisplayApplist.Indicator) != 0)
+            {
+                string path, text;
+                Notification.IndicatorStyle indicator = new Notification.IndicatorStyle();
+                Interop.Notification.GetImage(notification.Handle, NotificationImage.IconForIndicator, out path);
+                indicator.IconPath = path;
+                Interop.Notification.GetText(notification.Handle, NotificationText.FirstMainText, out text);
+                indicator.SubText = text;
+
+                notification.AddStyle(indicator);
+            }
+        }
+    }
+
+    internal static class ActiveBinder
+    {
+        internal static void BindObject(Notification notification)
+        {
+            int flag;
+            NotificationError ret = NotificationError.None;
+            Notification.ActiveStyle style = (Notification.ActiveStyle)notification.GetStyle("Active");
+
+            Interop.Notification.SetAutoRemove(notification.Handle, style.IsAutoRemove);
+            if (style.IsAutoRemove == true)
+            {
+                int hidetime;
+                int deletetime;
+                style.GetRemoveTime(out hidetime, out deletetime);
+
+                Interop.Notification.SetHideTime(notification.Handle, hidetime);
+                try
+                {
+                    Interop.Notification.SetDeleteTime(notification.Handle, deletetime);
+                }
+                catch (TypeLoadException)
+                {
+                    // To support in API version 3.0
+                    style.SetRemoveTime(hidetime, 60);
+                }
+            }
+
+            ret = Interop.Notification.SetImage(notification.Handle, NotificationImage.Background, style?.BackgroundImage);
+            if (ret != NotificationError.None)
+            {
+                throw NotificationErrorFactory.GetException(ret, "unable to set background Image");
+            }
+
+            if (style.DefaultButton != ButtonIndex.None)
+            {
+                Interop.Notification.SetDefaultButton(notification.Handle, (int)style.DefaultButton + 1);
+            }
+
+            Interop.Notification.GetApplist(notification.Handle, out flag);
+            Interop.Notification.SetApplist(notification.Handle, flag | (int)NotificationDisplayApplist.Active);
+
+            foreach (Notification.ButtonAction button in style.GetButtonAction())
+            {
+                button.Make(notification);
+            }
+
+            if (style.ReplyAction != null)
+            {
+                style.ReplyAction.Make(notification);
+            }
+        }
+
+        internal static void BindSafeHandle(Notification notification)
+        {
+            int appList;
+            Interop.Notification.GetApplist(notification.Handle, out appList);
+
+            if ((appList & (int)NotificationDisplayApplist.Active) != 0)
+            {
+                Notification.ActiveStyle active = new Notification.ActiveStyle();
+                bool isExisted = false;
+                bool autoRemove;
+                string path, text;
+                SafeAppControlHandle appcontrol = null;
+                string replyKey = "__PARENT_INDEX__";
+
+                for (int i = (int)ButtonIndex.First; i <= (int)ButtonIndex.Third; i++)
+                {
+                    appcontrol = null;
+
+                    Interop.Notification.GetImage(notification.Handle, NotificationImage.FirstButton + i, out path);
+                    Interop.Notification.GetText(notification.Handle, NotificationText.FirstButton + i, out text);
+                    Interop.Notification.GetEventHandler(notification.Handle, i, out appcontrol);
+
+                    if (string.IsNullOrEmpty(path) == false || string.IsNullOrEmpty(text) == false
+                        || (appcontrol != null && appcontrol.IsInvalid == false))
+                    {
+                        Notification.ButtonAction button = new Notification.ButtonAction();
+                        if (appcontrol != null && appcontrol.IsInvalid == false)
+                        {
+                            button.Action = new AppControl(appcontrol);
+                        }
+
+                        button.ImagePath = path;
+                        button.Text = text;
+                        button.Index = (ButtonIndex)i;
+                        active.AddButtonAction(button);
+                        isExisted = true;
+                    }
+                }
+
+                Interop.Notification.GetAutoRemove(notification.Handle, out autoRemove);
+                active.IsAutoRemove = autoRemove;
+                if (autoRemove)
+                {
+                    int hidetime, deletetime;
+                    Interop.Notification.GetHideTime(notification.Handle, out hidetime);
+                    try
+                    {
+                        Interop.Notification.GetDeleteTime(notification.Handle, out deletetime);
+                    }
+                    catch (TypeLoadException)
+                    {
+                        // To support in API version 3.0
+                        deletetime = 60;
+                    }
+
+                    active.SetRemoveTime(hidetime, deletetime);
+                }
+
+                Interop.Notification.GetImage(notification.Handle, NotificationImage.Background, out path);
+                if (string.IsNullOrEmpty(path) == false)
+                {
+                    isExisted = true;
+                    active.BackgroundImage = path;
+                }
+
+                int defaultIndex;
+                Interop.Notification.GetDefaultButton(notification.Handle, out defaultIndex);
+                active.DefaultButton = (ButtonIndex)(defaultIndex - 1);
+
+                appcontrol = null;
+                Interop.Notification.GetImage(notification.Handle, NotificationImage.TextInputButton, out path);
+                Interop.Notification.GetText(notification.Handle, NotificationText.InputButton, out text);
+                Interop.Notification.GetEventHandler(notification.Handle, (int)NotificationEventType.ClickOnTextInputButton, out appcontrol);
+
+                if (string.IsNullOrEmpty(path) == false || string.IsNullOrEmpty(text) == false
+                    || (appcontrol != null && appcontrol.IsInvalid == false))
+                {
+                    Notification.ReplyAction reply = new Notification.ReplyAction();
+                    Notification.ButtonAction button = new Notification.ButtonAction();
+                    if (appcontrol != null && appcontrol.IsInvalid == false)
+                    {
+                        button.Action = new AppControl(appcontrol);
+                    }
+
+                    button.ImagePath = path;
+                    button.Text = text;
+                    reply.Button = button;
+
+                    Interop.Notification.GetText(notification.Handle, NotificationText.PlaceHolder, out text);
+                    reply.PlaceHolderText = text;
+
+                    int holderLength;
+                    Interop.Notification.GetPlaceHolderLength(notification.Handle, out holderLength);
+                    reply.ReplyMax = holderLength;
+
+                    isExisted = true;
+
+                    try
+                    {
+                        SafeBundleHandle bundleHandle;
+                        Interop.Notification.GetExtentionData(notification.Handle, replyKey, out bundleHandle);
+                        Bundle bundle = new Bundle(bundleHandle);
+                        reply.ParentIndex = (ButtonIndex)int.Parse(bundle.GetItem(replyKey).ToString());
+                    }
+                    catch (Exception ex)
+                    {
+                        Log.Error(Notification.LogTag, ex.ToString());
+                    }
+
+                    active.ReplyAction = reply;
+                }
+
+                if (isExisted)
+                {
+                    notification.AddStyle(active);
+                }
+            }
+        }
+    }
+
+    internal static class LockBinder
+    {
+        internal static void BindObject(Notification notification)
+        {
+            int flag;
+            NotificationError ret = NotificationError.None;
+            Notification.LockStyle style = (Notification.LockStyle)notification.GetStyle("Lock");
+
+            ret = Interop.Notification.SetImage(notification.Handle, NotificationImage.IconForLock, style.IconPath);
+            if (ret != NotificationError.None)
+            {
+                throw NotificationErrorFactory.GetException(ret, "unable to set lock icon");
+            }
+
+            ret = Interop.Notification.SetImage(notification.Handle, NotificationImage.ThumbnailForLock, style.ThumbnailPath);
+            if (ret != NotificationError.None)
+            {
+                throw NotificationErrorFactory.GetException(ret, "unable to set lock thumbnail");
+            }
+
+            Interop.Notification.GetApplist(notification.Handle, out flag);
+            Interop.Notification.SetApplist(notification.Handle, flag | (int)NotificationDisplayApplist.Lock);
+        }
+
+        internal static void BindSafehandle(Notification notification)
+        {
+            int applist;
+            Interop.Notification.GetApplist(notification.Handle, out applist);
+
+            if ((applist & (int)NotificationDisplayApplist.Lock) != 0)
+            {
+                string path;
+                Notification.LockStyle lockStyle = new Notification.LockStyle();
+
+                Interop.Notification.GetImage(notification.Handle, NotificationImage.IconForLock, out path);
+                lockStyle.IconPath = path;
+
+                Interop.Notification.GetImage(notification.Handle, NotificationImage.ThumbnailForLock, out path);
+                lockStyle.ThumbnailPath = path;
+
+                notification.AddStyle(lockStyle);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Interop/Interop.Libraries.cs b/src/Tizen.Applications.NotificationEventListener/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..75347d4
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string NotificationEventListener = "libnotification.so.0";
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Interop/Interop.NotificationEventListener.cs b/src/Tizen.Applications.NotificationEventListener/Interop/Interop.NotificationEventListener.cs
new file mode 100755 (executable)
index 0000000..1e8b413
--- /dev/null
@@ -0,0 +1,298 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+using Tizen.Applications;
+using Tizen.Applications.NotificationEventListener;
+
+internal static partial class Interop
+{
+    internal static class NotificationEventListener
+    {
+        internal delegate void ChangedCallback(IntPtr userData, NotificationType type, IntPtr operationList, int num);
+
+        internal enum ErrorCode
+        {
+            None = Tizen.Internals.Errors.ErrorCode.None,
+            InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+            OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+            IoError = Tizen.Internals.Errors.ErrorCode.IoError,
+            DbError = -0x01140000 | 0x01,
+            AlreadyExists = -0x01140000 | 0x02,
+            DBusError = -0x01140000 | 0x03,
+            DoesnotExist = -0x01140000 | 0x04,
+            ServiceError = -0x01140000 | 0x05,
+            PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
+            InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation
+        }
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_free")]
+        internal static extern ErrorCode Destroy(IntPtr handle);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_id")]
+        internal static extern ErrorCode GetID(NotificationSafeHandle handle, out int groupId, out int privateId);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_pkgname")]
+        internal static extern ErrorCode GetAppIdReferenceType(NotificationSafeHandle handle, out IntPtr appid);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_text")]
+        internal static extern ErrorCode GetTextReferenceType(NotificationSafeHandle handle, NotificationText type, out IntPtr text);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_image")]
+        internal static extern ErrorCode GetImageReferenceType(NotificationSafeHandle handle, NotificationImage type, out IntPtr text);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_insert_time")]
+        internal static extern ErrorCode GetInsertTime(NotificationSafeHandle handle, out int time);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_time")]
+        internal static extern ErrorCode GetTime(NotificationSafeHandle handle, out int time);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_sound")]
+        internal static extern ErrorCode GetSoundReferenceType(NotificationSafeHandle handle, out AccessoryOption type, out IntPtr path);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_vibration")]
+        internal static extern ErrorCode GetVibrationReferenceType(NotificationSafeHandle handle, out AccessoryOption type, out IntPtr path);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_led")]
+        internal static extern ErrorCode GetLed(NotificationSafeHandle handle, out AccessoryOption type, out int color);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_led_time_period")]
+        internal static extern ErrorCode GetLedTime(NotificationSafeHandle handle, out int onMilliSeconds, out int offMilliSeconds);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_tag")]
+        internal static extern ErrorCode GetTagReferenceType(NotificationSafeHandle handle, out IntPtr tag);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_display_applist")]
+        internal static extern ErrorCode GetStyleList(NotificationSafeHandle handle, out int styleList);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_auto_remove")]
+        internal static extern ErrorCode GetAutoRemove(NotificationSafeHandle handle, out bool autoRemove);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_text_input_max_length")]
+        internal static extern ErrorCode GetPlaceHolderLength(NotificationSafeHandle handle, out int max);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_launch_option")]
+        internal static extern ErrorCode GetAppControl(NotificationSafeHandle handle, LaunchOption type, out SafeAppControlHandle appControlHandle);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_event_handler")]
+        internal static extern ErrorCode GetEventHandler(NotificationSafeHandle handle, int type, out SafeAppControlHandle appControlHandle);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_register_detailed_changed_cb")]
+        internal static extern ErrorCode SetChangedCallback(ChangedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_unregister_detailed_changed_cb")]
+        internal static extern ErrorCode UnsetChangedCallback(ChangedCallback callback);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_op_get_data")]
+        internal static extern ErrorCode GetOperationData(IntPtr operationList, NotificationOperationDataType type, out IntPtr userData);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_list_get_data")]
+        internal static extern IntPtr GetData(IntPtr notificationList);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_list_get_next")]
+        internal static extern IntPtr GetNext(IntPtr notificationList);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_delete_by_priv_id")]
+        internal static extern ErrorCode Delete(string appId, NotificationType type, int uniqueNumber);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_clear")]
+        internal static extern ErrorCode DeleteAll(int type);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_list")]
+        internal static extern ErrorCode GetList(NotificationType type, int count, out IntPtr notification);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_send_event_by_priv_id")]
+        internal static extern ErrorCode SendEvent(int uniqueNumber, int evnetType);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_layout")]
+        internal static extern ErrorCode GetLayout(NotificationSafeHandle handle, out NotificationLayout type);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_type")]
+        internal static extern ErrorCode GetType(NotificationSafeHandle handle, out NotificationType type);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_ongoing_value_type")]
+        internal static extern ErrorCode GetOngoingType(NotificationSafeHandle handle, out ProgressCategory category);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_size")]
+        internal static extern ErrorCode GetProgressSize(NotificationSafeHandle handle, out double value);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_progress")]
+        internal static extern ErrorCode GetProgress(NotificationSafeHandle handle, out double value);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_property")]
+        internal static extern ErrorCode GetProperties(NotificationSafeHandle handle, out int flags);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_extention_data")]
+        internal static extern ErrorCode GetExtender(NotificationSafeHandle handle, string key, out SafeBundleHandle value);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_clone")]
+        internal static extern ErrorCode GetClone(IntPtr handle, out IntPtr value);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_free_list")]
+        internal static extern ErrorCode NotificationListFree(IntPtr list);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_args")]
+        internal static extern ErrorCode GetExtentionBundle(NotificationSafeHandle handle, out IntPtr args, out IntPtr groupArgs);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_hide_timeout")]
+        internal static extern ErrorCode GetHideTimeout(NotificationSafeHandle handle, out int timeout);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_delete_timeout")]
+        internal static extern ErrorCode GetDeleteTimeout(NotificationSafeHandle handle, out int timeout);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_event_flag")]
+        internal static extern ErrorCode GetEventFlag(NotificationSafeHandle handle, out bool eventFlag);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_default_button")]
+        internal static extern ErrorCode GetDefaultButton(NotificationSafeHandle handle, out int index);
+
+        internal static ErrorCode GetAppId(NotificationSafeHandle handle, out string appid)
+        {
+            ErrorCode err;
+            IntPtr ptr;
+            err = GetAppIdReferenceType(handle, out ptr);
+
+            if (ptr == IntPtr.Zero)
+            {
+                appid = null;
+            }
+            else
+            {
+                appid = Marshal.PtrToStringAnsi(ptr);
+            }
+
+            return err;
+        }
+
+        internal static ErrorCode GetText(NotificationSafeHandle handle, NotificationText type, out string text)
+        {
+            ErrorCode err;
+            IntPtr ptr;
+            err = GetTextReferenceType(handle, type, out ptr);
+
+            if (ptr == IntPtr.Zero)
+            {
+                text = null;
+            }
+            else
+            {
+                text = Marshal.PtrToStringAnsi(ptr);
+            }
+
+            return err;
+        }
+
+        internal static ErrorCode GetImage(NotificationSafeHandle handle, NotificationImage type, out string text)
+        {
+            ErrorCode err;
+            IntPtr ptr;
+            err = GetImageReferenceType(handle, type, out ptr);
+
+            if (ptr == IntPtr.Zero)
+            {
+                text = null;
+            }
+            else
+            {
+                text = Marshal.PtrToStringAnsi(ptr);
+            }
+
+            return err;
+        }
+
+        internal static ErrorCode GetSound(NotificationSafeHandle handle, out AccessoryOption type, out string path)
+        {
+            ErrorCode err;
+            IntPtr ptr;
+            err = GetSoundReferenceType(handle, out type, out ptr);
+
+            if (ptr == IntPtr.Zero)
+            {
+                path = null;
+            }
+            else
+            {
+                path = Marshal.PtrToStringAnsi(ptr);
+            }
+
+            return err;
+        }
+
+        internal static ErrorCode GetVibration(NotificationSafeHandle handle, out AccessoryOption type, out string path)
+        {
+            ErrorCode err;
+            IntPtr ptr;
+            err = GetVibrationReferenceType(handle, out type, out ptr);
+
+            if (ptr == IntPtr.Zero)
+            {
+                path = null;
+            }
+            else
+            {
+                path = Marshal.PtrToStringAnsi(ptr);
+            }
+
+            return err;
+        }
+
+        internal static ErrorCode GetTag(NotificationSafeHandle handle, out string tag)
+        {
+            ErrorCode err;
+            IntPtr ptr;
+            err = GetTagReferenceType(handle, out ptr);
+
+            if (ptr == IntPtr.Zero)
+            {
+                tag = null;
+            }
+            else
+            {
+                tag = Marshal.PtrToStringAnsi(ptr);
+            }
+
+            return err;
+        }
+
+        internal sealed class NotificationSafeHandle : SafeHandle
+        {
+            public NotificationSafeHandle()
+                : base(IntPtr.Zero, true)
+            {
+            }
+
+            internal NotificationSafeHandle(IntPtr existingHandle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle)
+            {
+                SetHandle(existingHandle);
+            }
+
+            public override bool IsInvalid
+            {
+                get { return this.handle == IntPtr.Zero; }
+            }
+
+            protected override bool ReleaseHandle()
+            {
+                NotificationEventListener.Destroy(this.handle);
+                this.SetHandle(IntPtr.Zero);
+                return true;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener.csproj b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener.csproj
new file mode 100755 (executable)
index 0000000..475c4f8
--- /dev/null
@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <Import Project="../build/build.props" />
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.3</TargetFramework>
+    <Version>1.5.9</Version>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Applications.NotificationEventListener.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener.snk b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener.snk
new file mode 100644 (file)
index 0000000..5a8de8a
Binary files /dev/null and b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener.snk differ
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationAccessoryArgsBinder.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationAccessoryArgsBinder.cs
new file mode 100755 (executable)
index 0000000..30dd573
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    internal static class NotificationAccessoryAgsBinder
+    {
+        internal static void BindObject(NotificationEventArgs eventargs)
+        {
+            AccessoryOption type;
+            int color;
+            string path;
+
+            NotificationEventArgs.AccessoryArgs accessory = new NotificationEventArgs.AccessoryArgs();
+
+            Interop.NotificationEventListener.GetLed(eventargs.Handle, out type, out color);
+            accessory.LedOption = type;
+            if (type != AccessoryOption.Off)
+            {
+                int on, off;
+
+                Interop.NotificationEventListener.GetLedTime(eventargs.Handle, out on, out off);
+                accessory.LedOnMillisecond = on;
+                accessory.LedOffMillisecond = off;
+
+                if (type == AccessoryOption.Custom)
+                {
+                    accessory.LedColor = new Common.Color(color >> 16 & 255, color >> 8 & 255, color >> 0 & 255, color >> 24 & 255);
+                }
+            }
+
+            Interop.NotificationEventListener.GetSound(eventargs.Handle, out type, out path);
+            accessory.SoundOption = type;
+            if (type == AccessoryOption.Custom)
+            {
+                accessory.SoundPath = path;
+            }
+
+            Interop.NotificationEventListener.GetVibration(eventargs.Handle, out type, out path);
+            if (type == AccessoryOption.Off)
+            {
+                accessory.CanVibrate = false;
+            }
+            else
+            {
+                accessory.CanVibrate = true;
+            }
+
+            eventargs.Accessory = accessory;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationButtonActionArgsBinder.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationButtonActionArgsBinder.cs
new file mode 100755 (executable)
index 0000000..e252015
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    internal static class NotificationButtonActionArgBinder
+    {
+        internal static void BindObject(NotificationEventArgs eventargs, int index)
+        {
+            string text;
+            bool isExisted = false;
+            SafeAppControlHandle appcontrol = null;
+            NotificationEventArgs.ButtonActionArgs button = new NotificationEventArgs.ButtonActionArgs();
+
+            button.Index = (ButtonIndex)index;
+
+            Interop.NotificationEventListener.GetImage(eventargs.Handle, NotificationImage.Button_1 + index, out text);
+            if (string.IsNullOrEmpty(text) == false)
+            {
+                isExisted = true;
+                button.ImagePath = text;
+            }
+
+            Interop.NotificationEventListener.GetText(eventargs.Handle, NotificationText.FirstButton + index, out text);
+            if (string.IsNullOrEmpty(text) == false)
+            {
+                isExisted = true;
+                button.Text = text;
+            }
+
+            Interop.NotificationEventListener.GetEventHandler(eventargs.Handle, index, out appcontrol);
+
+            if (appcontrol != null && appcontrol.IsInvalid == false)
+            {
+                button.Action = new AppControl(appcontrol);
+                isExisted = true;
+            }
+
+            if (isExisted)
+            {
+                (eventargs.Style["Active"] as NotificationEventArgs.ActiveStyleArgs).Button.Add(button);
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationDeleteEventArgs.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationDeleteEventArgs.cs
new file mode 100755 (executable)
index 0000000..5d05883
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    using System;
+    /// <summary>
+    /// This class provides the property to get information about the deleted notification.
+    /// </summary>
+    public class NotificationDeleteEventArgs : EventArgs
+    {
+        /// <summary>
+        /// Gets the unique number of the Notification.
+        /// </summary>
+        public int UniqueNumber { get; internal set; }
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationDeleteEventArgsBinder.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationDeleteEventArgsBinder.cs
new file mode 100755 (executable)
index 0000000..35108cd
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    internal static class NotificationDeleteEventArgsBinder
+    {
+        internal static NotificationDeleteEventArgs BindObject(int uniqueNumber)
+        {
+            NotificationDeleteEventArgs deleteargs = new NotificationDeleteEventArgs();
+
+            deleteargs.UniqueNumber = uniqueNumber;
+
+            return deleteargs;
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgs.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgs.cs
new file mode 100755 (executable)
index 0000000..9f348f6
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel;
+
+    /// <summary>
+    /// This class provides the methods and properties to get information about the posted or updated notification.
+    /// </summary>
+    public partial class NotificationEventArgs : EventArgs
+    {
+        private const string LogTag = "Tizen.Applications.NotificationEventListener";
+
+        internal IDictionary<string, StyleArgs> Style;
+        internal IDictionary<string, Bundle> Extender;
+        internal Interop.NotificationEventListener.NotificationSafeHandle Handle;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="NotificationEventArgs"/> class.
+        /// </summary>
+        public NotificationEventArgs()
+        {
+            Style = new Dictionary<string, StyleArgs>();
+            Extender = new Dictionary<string, Bundle>();
+        }
+
+        /// <summary>
+        /// Gets the unique id of Notification.
+        /// </summary>
+        public int UniqueNumber { get; internal set; }
+
+        /// <summary>
+        /// Gets the appId of Notification.
+        /// </summary>
+        public string AppID { get; internal set; }
+
+        /// <summary>
+        /// Gets the title of Notification.
+        /// </summary>
+        public string Title { get; internal set; }
+
+        /// <summary>
+        /// Gets the content text of Notification.
+        /// </summary>
+        public string Content { get; internal set; }
+
+        /// <summary>
+        /// Gets the icon's path of Notification.
+        /// </summary>
+        public string Icon { get; internal set; }
+
+        /// <summary>
+        /// Gets the sub icon path of Notification.
+        /// </summary>
+        public string SubIcon { get; internal set; }
+
+        /// <summary>
+        /// Gets the Timestamp of notification is visible or not.
+        /// </summary>
+        public bool IsTimeStampVisible { get; internal set; }
+
+        /// <summary>
+        /// Gets TimeStamp of Notification.
+        /// </summary>
+        /// <remarks>
+        /// If IsTimeStampVisible property is set false, this TimeStamp property is meanless.
+        /// </remarks>
+        public DateTime TimeStamp { get; internal set; }
+
+        /// <summary>
+        /// Gets the count which is displayed at the right side of notification.
+        /// </summary>
+        public int Count { get; internal set; }
+
+        /// <summary>
+        /// Gets the Tag of notification.
+        /// </summary>
+        public string Tag { get; internal set; }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool IsOngoing { get; internal set; } = false;
+
+        /// <summary>
+        /// Gets a value that determines whether notification is displayed on the default viewer.
+        /// If IsDisplay property set false and add style, you can see only style notification.
+        /// </summary>
+        public bool IsDisplay { get; internal set; } = true;
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool HasEventFlag { get; internal set; } = false;
+
+        /// <summary>
+        /// Gets the AppControl which is invoked when notification is clicked.
+        /// </summary>
+        public AppControl Action { get; internal set; }
+
+        /// <summary>
+        /// Gets the object of the progress notification.
+        /// </summary>
+        public ProgressArgs Progress { get; internal set; }
+
+        /// <summary>
+        /// Gets the AccessoryArgs which has option of Sound, Vibration, LED.
+        /// </summary>
+        public AccessoryArgs Accessory { get; internal set; }
+
+        /// <summary>
+        /// Gets the key for extender.
+        /// </summary>
+        public ICollection<string> ExtenderKey
+        {
+            get
+            {
+                return Extender.Keys;
+            }
+        }
+
+        /// <summary>
+        /// Gets the property.
+        /// </summary>
+        public NotificationProperty Property { get; internal set; }
+
+        /// <summary>
+        /// Gets the styleArgs of active, lock, indicator, bigpicture.
+        /// </summary>
+        /// <typeparam name="T">Type of notification style to be queried</typeparam>
+        /// <returns>The NotificationEventListener.StyleArgs object associated with the given style</returns>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        public T GetStyle<T>() where T : StyleArgs, new()
+        {
+            T type = new T();
+            StyleArgs style = null;
+
+            Style.TryGetValue(type.Key, out style);
+
+            if (style == null)
+            {
+                Log.Error(LogTag, "Invalid Style");
+                throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
+            }
+            else
+            {
+                return style as T;
+            }
+        }
+
+        /// <summary>
+        /// Gets the ExtenderArgs.
+        /// </summary>
+        /// <param name="key">The key that specifies which extender</param>
+        /// <returns>Returns the bundle for key</returns>
+        public Bundle GetExtender(string key)
+        {
+            Bundle bundle;
+
+            if (string.IsNullOrEmpty(key))
+            {
+                throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
+            }
+
+            if (Extender.TryGetValue(key, out bundle) == false)
+            {
+                throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered : " + key);
+            }
+
+            return bundle;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsAccessory.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsAccessory.cs
new file mode 100755 (executable)
index 0000000..b09398c
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    using Tizen.Common;
+
+    /// <summary>
+    /// This class provides the methods and properties to get information about the posted or updated notification.
+    /// </summary>
+    public partial class NotificationEventArgs
+    {
+        /// <summary>
+        /// Class to get infomation about Notification accessory.
+        /// </summary>
+        public class AccessoryArgs
+        {
+            /// <summary>
+            /// Gets the sound option.
+            /// </summary>
+            public AccessoryOption SoundOption { get; internal set; }
+
+            /// <summary>
+            /// Gets the sound path.
+            /// </summary>
+            public string SoundPath { get; internal set; }
+
+            /// <summary>
+            /// Gets the vibration option.
+            /// </summary>
+            public bool CanVibrate { get; internal set; }
+
+            /// <summary>
+            /// Gets the led option.
+            /// </summary>
+            public AccessoryOption LedOption { get; internal set; }
+
+            /// <summary>
+            /// Gets led on time period that you would like the LED on the device to blink. as well as the rate.
+            /// </summary>
+            /// <value>
+            /// Default value of LedOnMilliseconds is 0.
+            /// The rate is specified in terms of the number of milliseconds to be on.
+            /// </value>
+            public int LedOnMillisecond { get; internal set; }
+
+            /// <summary>
+            /// Gets led on time period that you would like the LED on the device to blink. as well as the rate.
+            /// </summary>
+            /// <value>
+            /// Default value of LedOffMillisecond is 0.
+            /// The rate is specified in terms of the number of millisecond to be off.
+            /// </value>
+            public int LedOffMillisecond { get; internal set; }
+
+            /// <summary>
+            /// Gets led color that you would like the LED on the device to blink.
+            /// </summary>
+            public Color LedColor { get; internal set; }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsActiveStyle.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsActiveStyle.cs
new file mode 100755 (executable)
index 0000000..7495ffc
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// This class provides the methods and properties to get information about the posted or updated notification.
+    /// </summary>
+    public partial class NotificationEventArgs
+    {
+        /// <summary>
+        /// Class to get infomation about Notification Active style.
+        /// </summary>
+        public class ActiveStyleArgs : StyleArgs
+        {
+            /// <summary>
+            /// Initializes a new instance of the <see cref="ActiveStyleArgs"/> class.
+            /// </summary>
+            public ActiveStyleArgs()
+            {
+                Button = new List<ButtonActionArgs>();
+            }
+
+            /// <summary>
+            /// Gets the IsAutoRemove option of the active notification.
+            /// IsAutoRemove option lets the active notification be removed several seconds after it shows.
+            /// </summary>
+            /// <value>
+            /// When 'IsAutoRemove' is set as false, the active notification will not be removed as long as the user removes
+            /// the active notification or the app which posted the active notification removes the active notification.
+            /// </value>
+            public bool IsAutoRemove { get; internal set; }
+
+            /// <summary>
+            /// Gets an absolute path for an image file to display on the background of active notification.
+            /// </summary>
+            public string BackgroundImage { get; internal set; }
+
+            /// <summary>
+            /// Gets the default button to display highlight on the active notification
+            /// </summary>
+            public ButtonIndex DefaultButton { get; internal set; }
+
+            /// <summary>
+            /// Gets timeout value in second when the notification can be hidden from the viewer.
+            /// </summary>
+            public int HideTimeout { get; internal set; }
+
+            /// <summary>
+            /// Gets timeout value in second when the notification can be deleted from the viewer.
+            /// </summary>
+            public int DeleteTimeout { get; internal set; }
+
+            /// <summary>
+            /// Gets a button to this active notification style.
+            /// Buttons are displayed in the notification content.
+            /// </summary>
+            public IList<ButtonActionArgs> Button { get; internal set; }
+
+            /// <summary>
+            /// Gets a ReplyAction to this active notification style.
+            /// </summary>
+            public ReplyActionArgs Reply { get; internal set; }
+
+            internal override string Key
+            {
+                get
+                {
+                    return "Active";
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsBinder.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsBinder.cs
new file mode 100755 (executable)
index 0000000..e38f331
--- /dev/null
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    using System;
+
+    internal static class NotificationEventArgsBinder
+    {
+        private const string LogTag = "Tizen.Applications.NotificationEventListener";
+
+        internal static NotificationEventArgs BindObject(IntPtr notification, bool data)
+        {
+            Interop.NotificationEventListener.ErrorCode err;
+            int time;
+            int uniqueNumber = -1;
+            int groupNumber = -1;
+            int property;
+            int doNotShowTimeStamp = -1;
+            int displayList;
+            bool eventFlag = false;
+            NotificationLayout layout;
+            NotificationType type;
+            string text;
+            IntPtr extention = IntPtr.Zero;
+            IntPtr dummy = IntPtr.Zero;
+            SafeAppControlHandle appcontrol = null;
+
+            NotificationEventArgs eventargs = new NotificationEventArgs();
+
+            eventargs.Handle = new Interop.NotificationEventListener.NotificationSafeHandle(notification, data);
+
+            err = Interop.NotificationEventListener.GetID(eventargs.Handle, out groupNumber, out uniqueNumber);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                Log.Error(LogTag, "unable to get UniqueNumber");
+            }
+
+            eventargs.UniqueNumber = uniqueNumber;
+
+            Interop.NotificationEventListener.GetAppId(eventargs.Handle, out text);
+            if (string.IsNullOrEmpty(text) == false)
+            {
+                eventargs.AppID = text;
+            }
+
+            Interop.NotificationEventListener.GetText(eventargs.Handle, NotificationText.Title, out text);
+            if (string.IsNullOrEmpty(text) == false)
+            {
+                eventargs.Title = text;
+            }
+
+            Interop.NotificationEventListener.GetText(eventargs.Handle, NotificationText.Content, out text);
+            if (string.IsNullOrEmpty(text) == false)
+            {
+                eventargs.Content = text;
+            }
+
+            Interop.NotificationEventListener.GetImage(eventargs.Handle, NotificationImage.Icon, out text);
+            if (string.IsNullOrEmpty(text) == false)
+            {
+                eventargs.Icon = text;
+            }
+
+            Interop.NotificationEventListener.GetImage(eventargs.Handle, NotificationImage.SubIcon, out text);
+            if (string.IsNullOrEmpty(text) == false)
+            {
+                eventargs.SubIcon = text;
+            }
+
+            err = Interop.NotificationEventListener.GetTime(eventargs.Handle, out time);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                Log.Info(LogTag, "unable to get TimeStamp");
+            }
+
+            if (time == doNotShowTimeStamp)
+            {
+                eventargs.IsTimeStampVisible = false;
+            }
+            else
+            {
+                eventargs.IsTimeStampVisible = true;
+
+                if (time == 0)
+                {
+                    err = Interop.NotificationEventListener.GetInsertTime(eventargs.Handle, out time);
+                    if (err != Interop.NotificationEventListener.ErrorCode.None)
+                    {
+                        Log.Info(LogTag, "unable to get InsertTime");
+                    }
+                }
+
+                eventargs.TimeStamp = (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddSeconds(time).ToLocalTime();
+            }
+
+            err = Interop.NotificationEventListener.GetText(eventargs.Handle, NotificationText.EventCount, out text);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                Log.Info(LogTag, "unable to get Event Count");
+            }
+
+            if (string.IsNullOrEmpty(text) == false)
+            {
+                try
+                {
+                    eventargs.Count = int.Parse(text);
+                }
+                catch (Exception ex)
+                {
+                    Log.Error(LogTag, ex.ToString());
+                }
+            }
+
+            err = Interop.NotificationEventListener.GetAppControl(eventargs.Handle, LaunchOption.AppControl, out appcontrol);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                Log.Info(LogTag, "unable to get Action");
+            }
+
+            if (appcontrol != null && appcontrol.IsInvalid == false)
+            {
+                eventargs.Action = new AppControl(appcontrol);
+            }
+
+            Interop.NotificationEventListener.GetTag(eventargs.Handle, out text);
+            if (string.IsNullOrEmpty(text) == false)
+            {
+                eventargs.Tag = text;
+            }
+
+            err = Interop.NotificationEventListener.GetProperties(eventargs.Handle, out property);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                Log.Info(LogTag, "unable to get Property");
+            }
+            else
+            {
+                eventargs.Property = (NotificationProperty)property;
+            }
+
+            Interop.NotificationEventListener.GetStyleList(eventargs.Handle, out displayList);
+            if ((displayList & (int)NotificationDisplayApplist.Tray) == 0)
+            {
+                eventargs.IsDisplay = false;
+            }
+
+            err = Interop.NotificationEventListener.GetExtentionBundle(eventargs.Handle, out extention, out dummy);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                Log.Info(LogTag, "unable to get Extender");
+            }
+
+            if (extention != IntPtr.Zero)
+            {
+                Bundle bundle = new Bundle(new SafeBundleHandle(extention, false));
+                foreach (string key in bundle.Keys)
+                {
+                    SafeBundleHandle sbh;
+                    Interop.NotificationEventListener.GetExtender(eventargs.Handle, key, out sbh);
+                    eventargs.Extender.Add(key, new Bundle(sbh));
+                }
+            }
+
+            err = Interop.NotificationEventListener.GetLayout(eventargs.Handle, out layout);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                Log.Info(LogTag, "unable to get layout");
+            }
+
+            err = Interop.NotificationEventListener.GetType(eventargs.Handle, out type);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                Log.Info(LogTag, "unable to get type");
+            }
+
+            if (layout == NotificationLayout.OngoingEvent && type == NotificationType.Ongoing)
+            {
+                eventargs.IsOngoing = true;
+            }
+
+            err = Interop.NotificationEventListener.GetEventFlag(eventargs.Handle, out eventFlag);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                Log.Info(LogTag, "unable to get event flag");
+            }
+
+            eventargs.HasEventFlag = eventFlag;
+
+            NotificationAccessoryAgsBinder.BindObject(eventargs);
+            NotificationStyleArgBinder.BindObject(eventargs);
+            NotificationProgressArgBinder.BindObject(eventargs);
+
+            return eventargs;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsButtonAction.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsButtonAction.cs
new file mode 100755 (executable)
index 0000000..2e39158
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    /// <summary>
+    /// This class provides the methods and properties to get information about the posted or updated notification.
+    /// </summary>
+    public partial class NotificationEventArgs
+    {
+        /// <summary>
+        ///  Class to get infomation about Notification ButtonAction.
+        /// </summary>
+        public class ButtonActionArgs
+        {
+            /// <summary>
+            /// Gets the Index of the Button which is appeared at Notification.
+            /// </summary>
+            public ButtonIndex Index { get; internal set; }
+
+            /// <summary>
+            /// Gets the text that describes the button.
+            /// </summary>
+            public string Text { get; internal set; }
+
+            /// <summary>
+            /// Gets the image's path that represent the button.
+            /// </summary>
+            public string ImagePath { get; internal set; }
+
+            /// <summary>
+            /// Gets the AppControl that is invoked when the button is clicked.
+            /// </summary>
+            public AppControl Action { get; internal set; }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsEnumerations.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsEnumerations.cs
new file mode 100755 (executable)
index 0000000..348a016
--- /dev/null
@@ -0,0 +1,488 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    using System;
+    using System.ComponentModel;
+
+    /// <summary>
+    /// Enumeration for Progress category
+    /// </summary>
+    public enum ProgressCategory
+    {
+        /// <summary>
+        /// Value for percent type
+        /// </summary>
+        Percent,
+
+        /// <summary>
+        /// Value for time type
+        /// </summary>
+        Time,
+
+        /// <summary>
+        /// Value for pending type which is not updated progress current value
+        /// </summary>
+        PendingBar
+    }
+
+    /// <summary>
+    /// Enumeration for Accessory option
+    /// </summary>
+    public enum AccessoryOption
+    {
+        /// <summary>
+        /// Value for off accessory option
+        /// </summary>
+        Off = -1,
+
+        /// <summary>
+        /// Value for on accessory option
+        /// </summary>
+        On,
+
+        /// <summary>
+        /// Value for custom accessory option
+        /// </summary>
+        Custom
+    }
+
+    /// <summary>
+    /// Enumeration for Button Index
+    /// </summary>
+    public enum ButtonIndex
+    {
+        /// <summary>
+        /// Value for default button index
+        /// </summary>
+        None = -1,
+
+        /// <summary>
+        /// Value for first button index
+        /// </summary>
+        First,
+
+        /// <summary>
+        /// Value for second button index
+        /// </summary>
+        Second,
+
+        /// <summary>
+        /// Value for third button index
+        /// </summary>
+        Third
+    }
+
+    /// <summary>
+    /// Enumeration for notification particular property
+    /// </summary>
+    [Flags]
+    public enum NotificationProperty
+    {
+        /// <summary>
+        /// Value for adjust nothing
+        /// </summary>
+        None = 0x00,
+
+        /// <summary>
+        /// Value for display only SIM card inserted
+        /// </summary>
+        DisplayOnlySimMode = 0x01,
+
+        /// <summary>
+        /// Value for disable application launch when it selected
+        /// </summary>
+        DisableAppLaunch = 0x02,
+
+        /// <summary>
+        /// Value for disable auto delete when it selected
+        /// </summary>
+        DisableAutoDelete = 0x04,
+
+        /// <summary>
+        /// Value for deleted when device is rebooted even though notification is not set OngoingType
+        /// </summary>
+        VolatileDisplay = 0x100,
+    }
+
+    /// <summary>
+    /// Enumeration for event type on notification.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public enum UserEventType
+    {
+        /// <summary>
+        /// Event type : Click on button 1
+        /// </summary>
+        ClickOnButton1 = 0,
+
+        /// <summary>
+        /// Event type : Click on button 2
+        /// </summary>
+        ClickOnButton2,
+
+        /// <summary>
+        /// Event type : Click on button 3
+        /// </summary>
+        ClickOnButton3,
+
+        /// <summary>
+        /// Event type : Click on text_input button
+        /// </summary>
+        ClickOnReplyButton = 8,
+
+        /// <summary>
+        /// Event type : Hidden by user
+        /// </summary>
+        HiddenByUser = 100,
+
+        /// <summary>
+        /// Event type : Deleted by timer
+        /// </summary>
+        HiddenByTimeout = 101,
+
+        /// <summary>
+        /// Event type : Clicked by user
+        /// </summary>
+        ClickOnNotification = 200,
+
+        /// <summary>
+        /// Event type : Deleted by user
+        /// </summary>
+        DeleteNotification = 201,
+    }
+
+    /// <summary>
+    /// Enumeration for notification type.
+    /// </summary>
+    internal enum NotificationType
+    {
+        /// <summary>
+        /// Notification type
+        /// </summary>
+        Notification = 0,
+
+        /// <summary>
+        /// Ongoing type
+        /// </summary>
+        Ongoing,
+    }
+
+    /// <summary>
+    /// Enumeration for notification text type.
+    /// </summary>
+    internal enum NotificationText
+    {
+        /// <summary>
+        /// Title
+        /// </summary>
+        Title = 0,
+
+        /// <summary>
+        /// Content
+        /// </summary>
+        Content,
+
+        /// <summary>
+        /// Text to display event count
+        /// </summary>
+        EventCount = 3,
+
+        /// <summary>
+        /// Box contents 1
+        /// </summary>
+        FirstMainText,
+
+        /// <summary>
+        /// Box contents 1-1
+        /// </summary>
+        FirstSubText,
+
+        /// <summary>
+        /// Box contents 2
+        /// </summary>
+        SecondMainText,
+
+        /// <summary>
+        /// Box contents 2-1
+        /// </summary>
+        SecondSubText,
+
+        /// <summary>
+        /// Text on button 1
+        /// </summary>
+        FirstButton = 13,
+
+        /// <summary>
+        /// Text on button 2
+        /// </summary>
+        SecondButton,
+
+        /// <summary>
+        /// Text on button 3
+        /// </summary>
+        ThirdButton,
+
+        /// <summary>
+        /// Guide text on the message reply box
+        /// </summary>
+        PlaceHolder = 19,
+
+        /// <summary>
+        /// Text on button the on message reply box
+        /// </summary>
+        InputButton = 20,
+    }
+
+    /// <summary>
+    /// Enumeration for image type.
+    /// </summary>
+    internal enum NotificationImage
+    {
+        /// <summary>
+        /// Icon
+        /// </summary>
+        Icon = 0,
+
+        /// <summary>
+        /// Indicator icon
+        /// </summary>
+        Indicator,
+
+        /// <summary>
+        ///  Lock screen icon
+        /// </summary>
+        Lockscreen,
+
+        /// <summary>
+        /// Thumbnail
+        /// </summary>
+        Thumbnail,
+
+        /// <summary>
+        /// Lock screen thumbnail
+        /// </summary>
+        ThumbnailLockscreen,
+
+        /// <summary>
+        /// Icon
+        /// </summary>
+        SubIcon,
+
+        /// <summary>
+        /// image displayed on background
+        /// </summary>
+        Background,
+
+        /// <summary>
+        /// Image for button 1
+        /// </summary>
+        Button_1 = 12,
+
+        /// <summary>
+        /// Image for button 2
+        /// </summary>
+        Button_2,
+
+        /// <summary>
+        /// Image for button 3
+        /// </summary>
+        Button_3,
+
+        /// <summary>
+        /// Image for message reply
+        /// </summary>
+        TextInputButton = 18,
+    }
+
+    /// <summary>
+    /// Enumeration for notification layout type.
+    /// </summary>
+    internal enum NotificationLayout
+    {
+        /// <summary>
+        /// Default
+        /// </summary>
+        None = 0,
+
+        /// <summary>
+        /// Layout for notification. Used to inform single event
+        /// </summary>
+        SingleEvent = 1,
+
+        /// <summary>
+        /// Layout for notification. Used to display images
+        /// </summary>
+        Thumbnail = 3,
+
+        /// <summary>
+        /// Layout for ongoing notification. Used to display text message
+        /// </summary>
+        OngoingEvent = 4,
+
+        /// <summary>
+        /// Layout for ongoing notification. Used to display progress
+        /// </summary>
+        OngoingProgress = 5,
+    }
+
+    /// <summary>
+    /// Enumeration for notification launch option type.
+    /// </summary>
+    internal enum LaunchOption
+    {
+        /// <summary>
+        /// Launching with app control
+        /// </summary>
+        AppControl = 1
+    }
+
+    /// <summary>
+    /// Enumeration for notification operation data code.
+    /// </summary>
+    internal enum NotificationOperationDataType
+    {
+        /// <summary>
+        /// Default
+        /// </summary>
+        Min = 0,
+
+        /// <summary>
+        /// Operation type
+        /// </summary>
+        Type,
+
+        /// <summary>
+        /// Private ID
+        /// </summary>
+        UniqueNumber,
+
+        /// <summary>
+        /// Notification handler
+        /// </summary>
+        Notification,
+
+        /// <summary>
+        /// Reserved
+        /// </summary>
+        ExtraInformation1,
+
+        /// <summary>
+        /// Reserved
+        /// </summary>
+        ExtraInformation2,
+    }
+
+    /// <summary>
+    /// Enumeration for notification operation code.
+    /// </summary>
+    internal enum NotificationOperationType
+    {
+        /// <summary>
+        /// Default
+        /// </summary>
+        None = 0,
+
+        /// <summary>
+        /// Notification inserted
+        /// </summary>
+        Insert,
+
+        /// <summary>
+        /// Notification updated
+        /// </summary>
+        Update,
+
+        /// <summary>
+        /// Notification deleted
+        /// </summary>
+        Delete,
+    }
+
+    /// <summary>
+    /// Enumeration for event type on notification.
+    /// </summary>
+    internal enum ClickEventType
+    {
+        /// <summary>
+        /// Event type : Click on button 1
+        /// </summary>
+        FirstButton = 0,
+
+        /// <summary>
+        /// Event type : Click on button 2
+        /// </summary>
+        SecondButton = 1,
+
+        /// <summary>
+        /// Event type : Click on button 3
+        /// </summary>
+        ThirdButton = 2,
+
+        /// <summary>
+        /// Event type : Click on icon
+        /// </summary>
+        Icon = 6,
+
+        /// <summary>
+        /// Event type : Click on thumbnail
+        /// </summary>
+        Thumbnail = 7,
+
+        /// <summary>
+        /// Event type : Click on text_input button
+        /// </summary>
+        InputButton = 8,
+    }
+
+    /// <summary>
+    /// Enumeration for display application list.
+    /// </summary>
+    [Flags]
+    internal enum NotificationDisplayApplist
+    {
+        /// <summary>
+        /// Notification Tray(Quickpanel)
+        /// </summary>
+        Tray = 0x00000001,
+
+        /// <summary>
+        /// Ticker notification
+        /// </summary>
+        Ticker = 0x00000002,
+
+        /// <summary>
+        /// Lock screen
+        /// </summary>
+        Lock = 0x00000004,
+
+        /// <summary>
+        /// Indicator
+        /// </summary>
+        Indicator = 0x00000008,
+
+        /// <summary>
+        /// Active notification
+        /// </summary>
+        Active = 0x00000010,
+
+        /// <summary>
+        /// All display application except active notification
+        /// </summary>
+        All = 0x0000000f,
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsIndicatorStyle.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsIndicatorStyle.cs
new file mode 100755 (executable)
index 0000000..bc04cf1
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    /// <summary>
+    /// This class provides the methods and properties to get information about the posted or updated notification.
+    /// </summary>
+    public partial class NotificationEventArgs
+    {
+        /// <summary>
+        ///  Class to generate the Indicator style notification.
+        /// </summary>
+        public class IndicatorStyleArgs : StyleArgs
+        {
+            /// <summary>
+            /// Gets the path of the image file to display on the icon of Indicator style.
+            /// </summary>
+            public string IconPath { get; internal set; }
+
+            /// <summary>
+            /// Gets the sub text to display Indicator style.
+            /// </summary>
+            public string SubText { get; internal set; }
+
+            internal override string Key
+            {
+                get
+                {
+                    return "Indicator";
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsLockStyle.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsLockStyle.cs
new file mode 100755 (executable)
index 0000000..62ca496
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    /// <summary>
+    /// This class provides the methods and properties to get information about the posted or updated notification.
+    /// </summary>
+    public partial class NotificationEventArgs
+    {
+        /// <summary>
+        ///  Class to get infomation about Notification Lock style.
+        /// </summary>
+        public class LockStyleArgs : StyleArgs
+        {
+            /// <summary>
+            /// Gets the path of the image file to display on the icon of Lock style.
+            /// </summary>
+            public string IconPath { get; internal set; }
+
+            /// <summary>
+            /// Gets the path of the thumbnail image file to display on the icon of Lock style.
+            /// </summary>
+            public string Thumbnail { get; internal set; }
+
+            internal override string Key
+            {
+                get
+                {
+                    return "Lock";
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsProgress.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsProgress.cs
new file mode 100755 (executable)
index 0000000..ed01380
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    /// <summary>
+    /// This class provides the methods and properties to get information about the posted or updated notification.
+    /// </summary>
+    public partial class NotificationEventArgs
+    {
+        /// <summary>
+        ///  Class to get infomation about Progress Notification.
+        /// </summary>
+        public class ProgressArgs
+        {
+            /// <summary>
+            /// Gets category of ProgressType.
+            /// </summary>
+            public ProgressCategory Category { get; internal set; }
+
+            /// <summary>
+            /// Gets current value of ProgressType.
+            /// </summary>
+            public double Current { get; internal set; }
+
+            /// <summary>
+            /// Gets max value of ProgressType.
+            /// </summary>
+            public double Max { get; internal set; }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsReplyAction.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsReplyAction.cs
new file mode 100755 (executable)
index 0000000..d96ebf0
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    /// <summary>
+    /// This class provides the methods and properties to get information about the posted or updated notification.
+    /// </summary>
+    public partial class NotificationEventArgs
+    {
+        /// <summary>
+        ///  Class to get infomation about Notification ReplyAction.
+        /// </summary>
+        public class ReplyActionArgs
+        {
+            /// <summary>
+            /// Gets Index of Button which is appeared at Notification.
+            /// If there is no ParentIndex, the ReplyAction should be displayed directly on the active notification.
+            /// </summary>
+            public ButtonIndex ParentIndex { get; internal set; } = ButtonIndex.None;
+
+            /// <summary>
+            /// Gets the PlaceHolderText of ReplyAction which is appeared at Notification.
+            /// It will be displayed to the text input box on the active notification.
+            /// </summary>
+            public string PlaceHolderText { get; internal set; }
+
+            /// <summary>
+            /// Gets a max length of text input.
+            /// </summary>
+            public int ReplyMax { get; internal set; }
+
+            /// <summary>
+            /// Gets the button displayed in the replyaction.
+            /// </summary>
+            public ButtonActionArgs Button { get; internal set; }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsStyle.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsStyle.cs
new file mode 100755 (executable)
index 0000000..5ba07c7
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    /// <summary>
+    /// This class provides the methods and properties to get information about the posted or updated notification.
+    /// </summary>
+    public partial class NotificationEventArgs
+    {
+        public abstract class StyleArgs
+        {
+            internal abstract string Key { get; }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventListenerErrorFactory.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventListenerErrorFactory.cs
new file mode 100755 (executable)
index 0000000..8a6bbcb
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    using System;
+    using System.Runtime.CompilerServices;
+
+    internal static class NotificationEventListenerErrorFactory
+    {
+        private const string LogTag = "Tizen.Applications.NotificationEventListener";
+
+        internal static Exception GetException(
+            Interop.NotificationEventListener.ErrorCode err,
+            string msg,
+            [CallerMemberName] string memberName = "",
+            [CallerFilePath] string filePath = "",
+            [CallerLineNumber] int lineNumber = 0)
+        {
+            Log.Error(LogTag, memberName + " : " + lineNumber);
+            switch (err)
+            {
+                case Interop.NotificationEventListener.ErrorCode.InvalidParameter:
+                    Log.Error(LogTag, msg);
+                    return new ArgumentException(err + " error occurred.");
+                case Interop.NotificationEventListener.ErrorCode.PermissionDenied:
+                    Log.Error(LogTag, msg);
+                    return new UnauthorizedAccessException(err + "Permission denied.");
+                default:
+                    Log.Error(LogTag, msg);
+                    return new InvalidOperationException(err + " error occurred.");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs
new file mode 100755 (executable)
index 0000000..5f02395
--- /dev/null
@@ -0,0 +1,417 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel;
+    using System.Runtime.InteropServices;
+
+    /// <summary>
+    /// This class provides a way to register callback function for some notification events.
+    /// </summary>
+    /// <remarks>
+    /// The event listener can use this class to get a list of notification or to clear notifications.
+    /// </remarks>
+    public partial class NotificationListenerManager
+    {
+        private const string LogTag = "Tizen.Applications.NotificationEventListener";
+
+        private static event EventHandler<NotificationEventArgs> AddEventHandler;
+
+        private static event EventHandler<NotificationEventArgs> UpdateEventHandler;
+
+        private static event EventHandler<NotificationDeleteEventArgs> DeleteEventHandler;
+
+        private static Interop.NotificationEventListener.ChangedCallback callback;
+
+        [StructLayout(LayoutKind.Sequential)]
+        private struct NotificationOperation
+        {
+            NotificationOperationType type;
+            int uniqueNumber;
+            int extraInformation1;
+            int extraInformation2;
+            IntPtr notification;
+        }
+
+        private static int GetEventHandleLength()
+        {
+            int length = 0;
+
+            length += (DeleteEventHandler == null) ? 0 : DeleteEventHandler.GetInvocationList().Length;
+            length += (UpdateEventHandler == null) ? 0 : UpdateEventHandler.GetInvocationList().Length;
+            length += (AddEventHandler == null) ? 0 : AddEventHandler.GetInvocationList().Length;
+
+            return length;
+        }
+
+        /// <summary>
+        /// Registers a callback for notification insert event.
+        /// </summary>
+        /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
+        /// <exception cref="UnauthorizedAccessException"> Thrown in case of Permission deny.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static event EventHandler<NotificationEventArgs> NotificationAddEventHandler
+        {
+            add
+            {
+                if (callback == null)
+                {
+                    callback = new Interop.NotificationEventListener.ChangedCallback(ChangedEvent);
+                }
+
+                if (GetEventHandleLength() == 0)
+                {
+                    Interop.NotificationEventListener.ErrorCode err = Interop.NotificationEventListener.SetChangedCallback(callback, IntPtr.Zero);
+                    if (err != (int)Interop.NotificationEventListener.ErrorCode.None)
+                    {
+                        throw NotificationEventListenerErrorFactory.GetException(err, "unable to set changed callback");
+                    }
+                }
+
+                AddEventHandler += value;
+            }
+
+            remove
+            {
+                if (AddEventHandler != null && AddEventHandler.GetInvocationList().Length > 0)
+                {
+                    AddEventHandler -= value;
+
+                    if (GetEventHandleLength() == 0)
+                    {
+                        Interop.NotificationEventListener.ErrorCode err = Interop.NotificationEventListener.UnsetChangedCallback(callback);
+                        if (err != (int)Interop.NotificationEventListener.ErrorCode.None)
+                        {
+                            throw NotificationEventListenerErrorFactory.GetException(err, "unable to unset changed callback");
+                        }
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// Registers a callback for notification update event.
+        /// </summary>
+        /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
+        /// <exception cref="UnauthorizedAccessException"> Thrown in case of Permission deny.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static event EventHandler<NotificationEventArgs> NotificationUpdateEventHandler
+        {
+            add
+            {
+                if (callback == null)
+                {
+                    callback = new Interop.NotificationEventListener.ChangedCallback(ChangedEvent);
+                }
+
+                if (GetEventHandleLength() == 0)
+                {
+                    Interop.NotificationEventListener.ErrorCode err = Interop.NotificationEventListener.SetChangedCallback(callback, IntPtr.Zero);
+                    if (err != Interop.NotificationEventListener.ErrorCode.None)
+                    {
+                        throw NotificationEventListenerErrorFactory.GetException(err, "unable to set changed callback");
+                    }
+                }
+
+                UpdateEventHandler += value;
+            }
+
+            remove
+            {
+                if (UpdateEventHandler != null && UpdateEventHandler.GetInvocationList().Length > 0)
+                {
+                    UpdateEventHandler -= value;
+
+                    if (GetEventHandleLength() == 0)
+                    {
+                        Interop.NotificationEventListener.ErrorCode err = Interop.NotificationEventListener.UnsetChangedCallback(callback);
+                        if (err != Interop.NotificationEventListener.ErrorCode.None)
+                        {
+                            throw NotificationEventListenerErrorFactory.GetException(err, "unable to unset changed callback");
+                        }
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// Registers a callback for notification delete event.
+        /// </summary>
+        /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
+        /// <exception cref="UnauthorizedAccessException"> Thrown in case of Permission deny.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static event EventHandler<NotificationDeleteEventArgs> NotificationDeleteEventHandler
+        {
+            add
+            {
+                if (callback == null)
+                {
+                    callback = new Interop.NotificationEventListener.ChangedCallback(ChangedEvent);
+                }
+
+                if (GetEventHandleLength() == 0)
+                {
+                    Interop.NotificationEventListener.ErrorCode err = Interop.NotificationEventListener.SetChangedCallback(callback, IntPtr.Zero);
+                    if (err != Interop.NotificationEventListener.ErrorCode.None)
+                    {
+                        throw NotificationEventListenerErrorFactory.GetException(err, "unable to set changed callback");
+                    }
+                }
+
+                DeleteEventHandler += value;
+            }
+
+            remove
+            {
+                if (DeleteEventHandler != null && DeleteEventHandler.GetInvocationList().Length > 0)
+                {
+                    DeleteEventHandler -= value;
+
+                    if (GetEventHandleLength() == 0)
+                    {
+                        Interop.NotificationEventListener.ErrorCode err = Interop.NotificationEventListener.UnsetChangedCallback(callback);
+                        if (err != Interop.NotificationEventListener.ErrorCode.None)
+                        {
+                            throw NotificationEventListenerErrorFactory.GetException(err, "unable to unset changed callback");
+                        }
+                    }
+                }
+            }
+        }
+
+        private static void ChangedEvent(IntPtr userData, NotificationType type, IntPtr operationList, int num)
+        {
+            IntPtr operationType;
+            IntPtr uniqueNumber;
+            IntPtr notification;
+
+            NotificationEventArgs eventargs;
+            NotificationDeleteEventArgs deleteargs;
+
+            for (int i = 0; i < num; i++)
+            {
+                uniqueNumber = IntPtr.Zero;
+                operationType = IntPtr.Zero;
+                notification = IntPtr.Zero;
+
+                Interop.NotificationEventListener.GetOperationData(operationList + (i * Marshal.SizeOf<NotificationOperation>()), NotificationOperationDataType.Type, out operationType);
+                Interop.NotificationEventListener.GetOperationData(operationList + (i * Marshal.SizeOf<NotificationOperation>()), NotificationOperationDataType.UniqueNumber, out uniqueNumber);
+                Interop.NotificationEventListener.GetOperationData(operationList + (i * Marshal.SizeOf<NotificationOperation>()), NotificationOperationDataType.Notification, out notification);
+
+                if (operationType == IntPtr.Zero)
+                {
+                    Log.Error(LogTag, "unable to get operationType");
+                    continue;
+                }
+
+                Log.Info(LogTag, "type : " + ((int)operationType).ToString());
+                Log.Info(LogTag, "Add : " + (AddEventHandler == null ? "0" : AddEventHandler.GetInvocationList().Length.ToString()));
+                Log.Info(LogTag, "update: " + (UpdateEventHandler == null ? "0" : UpdateEventHandler.GetInvocationList().Length.ToString()));
+                Log.Info(LogTag, "delete : " + (DeleteEventHandler == null ? "0" : DeleteEventHandler.GetInvocationList().Length.ToString()));
+
+                switch ((int)operationType)
+                {
+                    case (int)NotificationOperationType.Insert:
+                        if (notification != IntPtr.Zero)
+                        {
+                            try
+                            {
+                                eventargs = NotificationEventArgsBinder.BindObject(notification, false);
+                                AddEventHandler?.Invoke(null, eventargs);
+                            }
+                            catch (Exception e)
+                            {
+                                Log.Error(LogTag, e.Message);
+                            }
+                        }
+
+                        break;
+
+                    case (int)NotificationOperationType.Update:
+                        if (notification != IntPtr.Zero)
+                        {
+                            try
+                            {
+                                eventargs = NotificationEventArgsBinder.BindObject(notification, false);
+                                UpdateEventHandler?.Invoke(null, eventargs);
+                            }
+                            catch (Exception e)
+                            {
+                                Log.Error(LogTag, e.Message);
+                            }
+                        }
+
+                        break;
+
+                    case (int)NotificationOperationType.Delete:
+                        if (uniqueNumber != IntPtr.Zero)
+                        {
+                            try
+                            {
+                                deleteargs = NotificationDeleteEventArgsBinder.BindObject((int)uniqueNumber);
+                                DeleteEventHandler?.Invoke(null, deleteargs);
+                            }
+                            catch (Exception e)
+                            {
+                                Log.Error(LogTag, e.Message);
+                            }
+                        }
+
+                        break;
+
+                    default:
+                        Log.Info(LogTag, "Event : " + (int)operationType);
+                        break;
+                }
+            }
+        }
+
+        /// <summary>
+        /// Deletes a Notification with appId and uniqueNumber.
+        /// </summary>
+        /// <param name="appId">The name of the application you want to delete.</param>
+        /// <param name="uniqueNumber">The unique number of the notification.</param>
+        /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
+        /// <exception cref="UnauthorizedAccessException"> Thrown in case of Permission deny.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static void Delete(string appId, int uniqueNumber)
+        {
+            Interop.NotificationEventListener.ErrorCode err;
+
+            if (string.IsNullOrEmpty(appId) || uniqueNumber < 0)
+            {
+                throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter");
+            }
+
+            err = Interop.NotificationEventListener.Delete(appId, 0, uniqueNumber);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                throw NotificationEventListenerErrorFactory.GetException(err, "unable to delete");
+            }
+        }
+
+        /// <summary>
+        /// Deletes all Notification.
+        /// </summary>
+        /// <exception cref="UnauthorizedAccessException"> Thrown in case of Permission deny.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static void DeleteAll()
+        {
+            Interop.NotificationEventListener.ErrorCode err;
+
+            err = Interop.NotificationEventListener.DeleteAll((int)NotificationType.Notification);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                throw NotificationEventListenerErrorFactory.GetException(err, "delete all notifications failed of Noti type");
+            }
+
+            err = Interop.NotificationEventListener.DeleteAll((int)NotificationType.Ongoing);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                throw NotificationEventListenerErrorFactory.GetException(err, "delete all notifications failed of Ongoing type");
+            }
+        }
+
+        /// <summary>
+        /// Returns the notification list handle.
+        /// </summary>
+        /// <exception cref="UnauthorizedAccessException"> Thrown in case of Permission deny.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        public static IList<NotificationEventArgs> GetList()
+        {
+            Interop.NotificationEventListener.ErrorCode err;
+            IntPtr notificationList = IntPtr.Zero;
+            IntPtr currentList = IntPtr.Zero;
+            IList<NotificationEventArgs> list = new List<NotificationEventArgs>();
+
+            err = Interop.NotificationEventListener.GetList(NotificationType.Notification, -1, out notificationList);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                throw NotificationEventListenerErrorFactory.GetException(err, "unable to get notification list");
+            }
+
+            if (notificationList != IntPtr.Zero)
+            {
+                currentList = notificationList;
+                while (currentList != IntPtr.Zero)
+                {
+                    IntPtr notification;
+                    NotificationEventArgs eventargs = new NotificationEventArgs();
+
+                    notification = Interop.NotificationEventListener.GetData(currentList);
+
+                    eventargs = NotificationEventArgsBinder.BindObject(notification, false);
+
+                    list.Add(eventargs);
+
+                    currentList = Interop.NotificationEventListener.GetNext(currentList);
+                }
+
+                Interop.NotificationEventListener.NotificationListFree(notificationList);
+                notificationList = IntPtr.Zero;
+            }
+
+            err = Interop.NotificationEventListener.GetList(NotificationType.Ongoing, -1, out notificationList);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                throw NotificationEventListenerErrorFactory.GetException(err, "unable to get notification list");
+            }
+
+            if (notificationList != IntPtr.Zero)
+            {
+                currentList = notificationList;
+                while (currentList != IntPtr.Zero)
+                {
+                    IntPtr notification;
+                    NotificationEventArgs eventargs = new NotificationEventArgs();
+
+                    notification = Interop.NotificationEventListener.GetData(currentList);
+
+                    eventargs = NotificationEventArgsBinder.BindObject(notification, false);
+
+                    list.Add(eventargs);
+
+                    currentList = Interop.NotificationEventListener.GetNext(currentList);
+                }
+
+                Interop.NotificationEventListener.NotificationListFree(notificationList);
+            }
+
+            return list;
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static void SendEvent(int uniqueNumber, UserEventType type)
+        {
+            Interop.NotificationEventListener.ErrorCode err;
+
+            err = Interop.NotificationEventListener.SendEvent(uniqueNumber, (int)type);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                throw NotificationEventListenerErrorFactory.GetException(err, "failed to send event");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationProgressArgsBinder.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationProgressArgsBinder.cs
new file mode 100755 (executable)
index 0000000..8611503
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    internal static class NotificationProgressArgBinder
+    {
+        internal static void BindObject(NotificationEventArgs eventargs)
+        {
+            NotificationLayout layout;
+            Interop.NotificationEventListener.GetLayout(eventargs.Handle, out layout);
+
+            if (layout == NotificationLayout.OngoingProgress)
+            {
+                ProgressCategory category;
+                double current, max;
+
+                Interop.NotificationEventListener.GetOngoingType(eventargs.Handle, out category);
+                Interop.NotificationEventListener.GetProgress(eventargs.Handle, out current);
+                Interop.NotificationEventListener.GetProgressSize(eventargs.Handle, out max);
+
+                if (category == ProgressCategory.Percent)
+                {
+                    current *= 100;
+
+                    if (current == 0 && max == 0)
+                        category = ProgressCategory.PendingBar;
+                }
+
+                eventargs.Progress = new NotificationEventArgs.ProgressArgs();
+                eventargs.Progress.Current = current;
+                eventargs.Progress.Max = max;
+                eventargs.Progress.Category = category;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationReplyActionArgsBinder.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationReplyActionArgsBinder.cs
new file mode 100755 (executable)
index 0000000..a851009
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    using System;
+
+    internal static class NotificationReplyActionArgBinder
+    {
+        private const string LogTag = "Tizen.Applications.NotificationEventListener";
+
+        internal static void BindObject(NotificationEventArgs eventargs)
+        {
+            string text;
+            int max;
+            bool isExisted = false;
+            SafeAppControlHandle appcontrol = null;
+            Bundle bundle;
+            NotificationEventArgs.ReplyActionArgs reply = new NotificationEventArgs.ReplyActionArgs();
+            NotificationEventArgs.ButtonActionArgs button = new NotificationEventArgs.ButtonActionArgs();
+            string replyKey = "__PARENT_INDEX__";
+
+            Interop.NotificationEventListener.GetImage(eventargs.Handle, NotificationImage.TextInputButton, out text);
+            if (string.IsNullOrEmpty(text) == false)
+            {
+                isExisted = true;
+                button.ImagePath = text;
+            }
+
+            Interop.NotificationEventListener.GetText(eventargs.Handle, NotificationText.InputButton, out text);
+            if (string.IsNullOrEmpty(text) == false)
+            {
+                isExisted = true;
+                button.Text = text;
+            }
+
+            Interop.NotificationEventListener.GetEventHandler(eventargs.Handle, (int)ClickEventType.InputButton, out appcontrol);
+
+            if (appcontrol != null && appcontrol.IsInvalid == false)
+            {
+                button.Action = new AppControl(appcontrol);
+                isExisted = true;
+            }
+
+            reply.Button = button;
+
+            Interop.NotificationEventListener.GetText(eventargs.Handle, NotificationText.PlaceHolder, out text);
+
+            if (string.IsNullOrEmpty(text) == false)
+            {
+                isExisted = true;
+                reply.PlaceHolderText = text;
+            }
+
+            Interop.NotificationEventListener.GetPlaceHolderLength(eventargs.Handle, out max);
+            reply.ReplyMax = max;
+            if (max > 0)
+            {
+                isExisted = true;
+            }
+
+            if (eventargs.Extender.TryGetValue(replyKey, out bundle))
+            {
+                if (bundle.Contains(replyKey))
+                {
+                    string parentIndex;
+                    if (bundle.TryGetItem(replyKey, out parentIndex))
+                    {
+                        try
+                        {
+                            reply.ParentIndex = (ButtonIndex)int.Parse(parentIndex);
+                            isExisted = true;
+                        }
+                        catch (Exception ex)
+                        {
+                            Log.Error(LogTag, "unable to get ParentIndex " + ex.Message);
+                        }
+                    }
+                }
+            }
+
+            if (isExisted)
+            {
+                (eventargs.Style["Active"] as NotificationEventArgs.ActiveStyleArgs).Reply = reply;
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationStyleArgsBinder.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationStyleArgsBinder.cs
new file mode 100755 (executable)
index 0000000..f45e4aa
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.NotificationEventListener
+{
+    using System;
+
+    internal static class NotificationStyleArgBinder
+    {
+        internal static void BindObject(NotificationEventArgs eventargs)
+        {
+            bool autoRemove;
+            string path;
+            int styleList;
+            int timeout;
+
+            Interop.NotificationEventListener.GetStyleList(eventargs.Handle, out styleList);
+
+            if ((styleList & (int)NotificationDisplayApplist.Active) != 0)
+            {
+                NotificationEventArgs.ActiveStyleArgs activeStyle = new NotificationEventArgs.ActiveStyleArgs();
+                eventargs.Style.Add(activeStyle.Key, activeStyle);
+
+                for (int i = (int)ClickEventType.FirstButton; i <= (int)ClickEventType.ThirdButton; i++)
+                {
+                    NotificationButtonActionArgBinder.BindObject(eventargs, i);
+                }
+
+                Interop.NotificationEventListener.GetAutoRemove(eventargs.Handle, out autoRemove);
+                activeStyle.IsAutoRemove = autoRemove;
+
+                Interop.NotificationEventListener.GetImage(eventargs.Handle, NotificationImage.Background, out path);
+                activeStyle.BackgroundImage = path;
+
+                int index;
+                Interop.NotificationEventListener.GetDefaultButton(eventargs.Handle, out index);
+                activeStyle.DefaultButton = (ButtonIndex)(index - 1);
+
+                Interop.NotificationEventListener.GetHideTimeout(eventargs.Handle, out timeout);
+                activeStyle.HideTimeout = timeout;
+
+                try
+                {
+                    Interop.NotificationEventListener.GetDeleteTimeout(eventargs.Handle, out timeout);
+                }
+                catch (TypeLoadException)
+                {
+                    //To support in API version 3.0
+                    timeout = 60;
+                }
+                activeStyle.DeleteTimeout = timeout;
+
+                NotificationReplyActionArgBinder.BindObject(eventargs);
+            }
+
+            if ((styleList & (int)NotificationDisplayApplist.Lock) != 0)
+            {
+                NotificationEventArgs.LockStyleArgs lockStyle = new NotificationEventArgs.LockStyleArgs();
+                eventargs.Style.Add(lockStyle.Key, lockStyle);
+
+                Interop.NotificationEventListener.GetImage(eventargs.Handle, NotificationImage.Lockscreen, out path);
+                lockStyle.IconPath = path;
+
+                Interop.NotificationEventListener.GetImage(eventargs.Handle, NotificationImage.ThumbnailLockscreen, out path);
+                lockStyle.Thumbnail = path;
+            }
+
+            if ((styleList & (int)NotificationDisplayApplist.Ticker) != 0 || (styleList & (int)NotificationDisplayApplist.Indicator) != 0)
+            {
+                NotificationEventArgs.IndicatorStyleArgs indicatorStyle = new NotificationEventArgs.IndicatorStyleArgs();
+                eventargs.Style.Add(indicatorStyle.Key, indicatorStyle);
+
+                Interop.NotificationEventListener.GetImage(eventargs.Handle, NotificationImage.Indicator, out path);
+                indicatorStyle.IconPath = path;
+
+                Interop.NotificationEventListener.GetText(eventargs.Handle, NotificationText.FirstMainText, out path);
+                indicatorStyle.SubText = path;
+            }
+       }
+    }
+}
diff --git a/src/Tizen.Applications.PackageManager/Interop/Interop.Libraries.cs b/src/Tizen.Applications.PackageManager/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..83cbc6e
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string PackageManager = "libcapi-appfw-package-manager.so.0";
+    }
+}
diff --git a/src/Tizen.Applications.PackageManager/Interop/Interop.Package.cs b/src/Tizen.Applications.PackageManager/Interop/Interop.Package.cs
new file mode 100644 (file)
index 0000000..67de930
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+using ErrorCode = Interop.PackageManager.ErrorCode;
+using StorageType = Interop.PackageManager.StorageType;
+using CertCompareResultType = Interop.PackageManager.CertCompareResultType;
+
+internal static partial class Interop
+{
+    internal static partial class Package
+    {
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate bool PackageInfoAppInfoCallback(AppType appType, string appId, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate bool PackageInfoCertificateInfoCallback(IntPtr handle, CertificateType certType, string certValue, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate bool PackageInfoPrivilegeInfoCallback(string privilege, IntPtr userData);
+
+        // Any change here might require changes in Tizen.Applications.AppType enum
+        internal enum AppType
+        {
+            All = 0,
+            Ui = 1,
+            Service = 2
+        }
+
+        internal enum CertificateType
+        {
+            AuthorRootCertificate = 0,
+            AuthorIntermediateCertificate = 1,
+            AuthorSignerCertificate = 2,
+            DistributorRootCertificate = 3,
+            DistributorIntermediateCertificate = 4,
+            DistributorSignerCertificate = 5,
+            Distributor2RootCertificate = 6,
+            Distributor2IntermediateCertificate = 7,
+            Distributor2SignerCertificate = 8
+        }
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_foreach_app_from_package")]
+        internal static extern ErrorCode PackageInfoForeachAppInfo(IntPtr handle, AppType appType, PackageInfoAppInfoCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_foreach_cert_info")]
+        internal static extern ErrorCode PackageInfoForeachCertificateInfo(IntPtr handle, PackageInfoCertificateInfoCallback callback, IntPtr user_data);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_foreach_privilege_info")]
+        internal static extern ErrorCode PackageInfoForeachPrivilegeInfo(IntPtr handle, PackageInfoPrivilegeInfoCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_create")]
+        internal static extern ErrorCode PackageInfoCreate(string packageId, out IntPtr handle);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_destroy")]
+        internal static extern ErrorCode PackageInfoDestroy(IntPtr handle);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_get_package")]
+        internal static extern ErrorCode PackageInfoGetPackage(IntPtr handle, out string packageId);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_get_label")]
+        internal static extern ErrorCode PackageInfoGetLabel(IntPtr handle, out string label);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_get_icon")]
+        internal static extern ErrorCode PackageInfoGetIconPath(IntPtr handle, out string path);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_get_version")]
+        internal static extern ErrorCode PackageInfoGetVersion(IntPtr handle, out string version);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_get_type")]
+        internal static extern ErrorCode PackageInfoGetType(IntPtr handle, out string type);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_get_installed_storage")]
+        internal static extern ErrorCode PackageInfoGetInstalledStorage(IntPtr handle, out StorageType storage);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_get_root_path")]
+        internal static extern ErrorCode PackageInfoGetRootPath(IntPtr handle, out string path);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_get_tep_name")]
+        internal static extern ErrorCode PackageInfoGetTepName(IntPtr handle, out string name);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_is_system_package")]
+        internal static extern ErrorCode PackageInfoIsSystemPackage(IntPtr handle, out bool system);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_is_removable_package")]
+        internal static extern ErrorCode PackageInfoIsRemovablePackage(IntPtr handle, out bool removable);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_is_preload_package")]
+        internal static extern ErrorCode PackageInfoIsPreloadPackage(IntPtr handle, out bool preload);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_is_accessible")]
+        internal static extern ErrorCode PackageInfoIsAccessible(IntPtr handle, out bool accessible);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_get_installed_time")]
+        internal static extern ErrorCode PackageInfoGetInstalledTime(IntPtr handle, out int installedTime);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_compare_package_cert_info")]
+        internal static extern ErrorCode PackageCompareCertInfo(string lhsPackageId, string rhsPackageId, out CertCompareResultType result);
+    }
+}
diff --git a/src/Tizen.Applications.PackageManager/Interop/Interop.PackageManager.cs b/src/Tizen.Applications.PackageManager/Interop/Interop.PackageManager.cs
new file mode 100755 (executable)
index 0000000..92ad54e
--- /dev/null
@@ -0,0 +1,231 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Applications;
+
+internal static partial class Interop
+{
+    internal static partial class PackageManager
+    {
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void PackageManagerEventCallback(string type, string packageId, EventType eventType, PackageEventState eventState, int progress, ErrorCode error, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate bool PackageManagerPackageInfoCallback(IntPtr handle, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void PackageManagerSizeInfoCallback(string packageId, IntPtr sizeInfoHandle, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void PackageManagerTotalSizeInfoCallback(IntPtr sizeInfoHandle, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void PackageManagerRequestEventCallback(int requestId, string type, string packageId, EventType eventType, PackageEventState eventState, int progress, ErrorCode error, IntPtr userData);
+
+        // Any change here might require changes in Tizen.Applications.PackageManagerEventError enum
+        internal enum ErrorCode
+        {
+            None = Tizen.Internals.Errors.ErrorCode.None,
+            InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+            OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+            IoError = Tizen.Internals.Errors.ErrorCode.IoError,
+            NoSuchPackage = -0x01150000 | 0x71,
+            SystemError = -0x01150000 | 0x72,
+            PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied
+        }
+
+        // Any change here might require changes in Tizen.Applications.PackageEventState enum
+        internal enum PackageEventState
+        {
+            Started = 0,
+            Processing = 1,
+            Completed = 2,
+            Failed = 3
+        }
+
+        [Flags]
+        internal enum EventStatus
+        {
+            All = 0x00,
+            Install = 0x01,
+            Uninstall = 0x02,
+            Upgrade = 0x04,
+            Move = 0x08,
+            ClearData = 0x10,
+            Progress = 0x20,
+        }
+
+        internal enum EventType
+        {
+            Install = 0,
+            Uninstall = 1,
+            Update = 2,
+            Move = 3,
+            ClearData = 4
+        }
+
+        internal enum CertCompareResultType
+        {
+            Match = 0,
+            Mismatch,
+            LhsNoCert,
+            RhsNoCert,
+            BothNoCert
+        }
+
+        internal enum PackageManagerPermissionType
+        {
+            Normal = 0,
+            Signature,
+            Privilege
+        }
+
+        // Any change here might require changes in Tizen.Applications.StorageType enum
+        internal enum StorageType
+        {
+            Internal = 0,
+            External = 1
+        }
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_create")]
+        internal static extern ErrorCode PackageManagerCreate(out SafePackageManagerHandle managerHandle);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_destroy")]
+        internal static extern ErrorCode PackageManagerDestroy(IntPtr managerHandle);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_set_event_status")]
+        internal static extern ErrorCode PackageManagerSetEvenStatus(SafePackageManagerHandle managerHandle, EventStatus eventStatus);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_set_event_cb")]
+        internal static extern ErrorCode PackageManagerSetEvent(SafePackageManagerHandle managerHandle, PackageManagerEventCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_unset_event_cb")]
+        internal static extern ErrorCode PackageManagerUnsetEvent(SafePackageManagerHandle managerHandle);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_foreach_package_info")]
+        internal static extern ErrorCode PackageManagerForeachPackageInfo(PackageManagerPackageInfoCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_get_package_size_info")]
+        internal static extern ErrorCode PackageManagerGetSizeInfo(string packageId, PackageManagerSizeInfoCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_get_total_package_size_info")]
+        internal static extern ErrorCode PackageManagerGetTotalSizeInfo(PackageManagerTotalSizeInfoCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_get_package_id_by_app_id")]
+        internal static extern ErrorCode PackageManageGetPackageIdByAppId(string app_id, out string package_id);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_get_package_info")]
+        internal static extern ErrorCode PackageManagerGetPackageInfo(string packageId, out IntPtr packageInfoHandle);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_clear_cache_dir")]
+        internal static extern ErrorCode PackageManagerClearCacheDir(string packageId);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_clear_all_cache_dir")]
+        internal static extern ErrorCode PackageManagerClearAllCacheDir();
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_clear_data_dir")]
+        internal static extern ErrorCode PackageManagerClearDataDir(string packageId);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_filter_create")]
+        internal static extern ErrorCode PackageManagerFilterCreate(out IntPtr handle);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_filter_destroy")]
+        internal static extern ErrorCode PackageManagerFilterDestroy(IntPtr handle);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_filter_add_bool")]
+        internal static extern ErrorCode PackageManagerFilterAdd(IntPtr handle, string property, bool value);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_filter_foreach_package_info")]
+        internal static extern ErrorCode PackageManagerFilterForeachPackageInfo(IntPtr handle, PackageManagerPackageInfoCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_data_size")]
+        internal static extern ErrorCode PackageSizeInfoGetDataSize(IntPtr handle, out long dataSize);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_cache_size")]
+        internal static extern ErrorCode PackageSizeInfoGetCacheSize(IntPtr handle, out long cacheSize);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_app_size")]
+        internal static extern ErrorCode PackageSizeInfoGetAppSize(IntPtr handle, out long appSize);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_external_data_size")]
+        internal static extern ErrorCode PackageSizeInfoGetExtDataSize(IntPtr handle, out long extDataSize);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_external_cache_size")]
+        internal static extern ErrorCode PackageSizeInfoGetExtCacheSize(IntPtr handle, out long extCacheSize);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_external_app_size")]
+        internal static extern ErrorCode PackageSizeInfoGetExtAppSize(IntPtr handle, out long extAppSize);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_create")]
+        internal static extern ErrorCode PackageManagerRequestCreate(out SafePackageManagerRequestHandle requestHandle);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_destroy")]
+        internal static extern ErrorCode PackageManagerRequestDestroy(IntPtr requestHandle);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_set_type")]
+        internal static extern ErrorCode PackageManagerRequestSetType(SafePackageManagerRequestHandle requestHandle, string type);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_set_tep")]
+        internal static extern ErrorCode PackageManagerRequestSetTepPath(SafePackageManagerRequestHandle requestHandle, string tepPath);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_install")]
+        internal static extern ErrorCode PackageManagerRequestInstall(SafePackageManagerRequestHandle requestHandle, string path, out int id);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_mount_install")]
+        internal static extern ErrorCode PackageManagerRequestMountInstall(SafePackageManagerRequestHandle requestHandle, string path, out int id);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_uninstall")]
+        internal static extern ErrorCode PackageManagerRequestUninstall(SafePackageManagerRequestHandle requestHandle, string name, out int id);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_move")]
+        internal static extern ErrorCode PackageManagerRequestMove(SafePackageManagerRequestHandle requestHandle, string name, StorageType moveToStorageType);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_compare_package_cert_info")]
+        internal static extern ErrorCode PackageManagerCompareCertInfo(string lhsPackageId, string rhsPackageId, out CertCompareResultType CompareResult);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_compare_app_cert_info")]
+        internal static extern ErrorCode PackageManagerCompareCertInfoByApplicationId(string lhsPackageId, string rhsPackageId, out CertCompareResultType CompareResult);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_is_preload_package_by_app_id")]
+        internal static extern ErrorCode PackageManagerIsPreloadPackageByApplicationId(string ApplicationId, out bool IsPreload);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_get_permission_type")]
+        internal static extern ErrorCode PackageManagerGetPermissionType(string ApplicationId, out PackageManagerPermissionType PermissionType);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_drm_generate_license_request")]
+        internal static extern ErrorCode PackageManagerDrmGenerateLicenseRequest(string responseData, out string requestData, out string licenseUrl);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_drm_register_license")]
+        internal static extern ErrorCode PackageManagerDrmRegisterLicense(string responseData);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_drm_decrypt_package")]
+        internal static extern ErrorCode PackageManagerDrmDecryptPackage(string drmFilePath, string decryptedFilePath);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_install_with_cb")]
+        internal static extern ErrorCode PackageManagerRequestInstallWithCB(SafePackageManagerRequestHandle requestHandle, string path, PackageManagerRequestEventCallback callback, IntPtr userData, out int id);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_mount_install_with_cb")]
+        internal static extern ErrorCode PackageManagerRequestMountInstallWithCB(SafePackageManagerRequestHandle requestHandle, string path, PackageManagerRequestEventCallback callback, IntPtr userData, out int id);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_uninstall_with_cb")]
+        internal static extern ErrorCode PackageManagerRequestUninstallWithCB(SafePackageManagerRequestHandle requestHandle, string name, PackageManagerRequestEventCallback callback, IntPtr userData, out int id);
+
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_move_with_cb")]
+        internal static extern ErrorCode PackageManagerRequestMoveWithCB(SafePackageManagerRequestHandle requestHandle, string name, StorageType moveToStorageType, PackageManagerRequestEventCallback callback, IntPtr userData, out int id);
+    }
+}
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications.PackageManager.csproj b/src/Tizen.Applications.PackageManager/Tizen.Applications.PackageManager.csproj
new file mode 100755 (executable)
index 0000000..9ae2f92
--- /dev/null
@@ -0,0 +1,19 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <Import Project="../build/build.props" />
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.3</TargetFramework>
+    <Version>1.5.9</Version>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Applications.PackageManager.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+    <GenerateReferenceAssembly>True</GenerateReferenceAssembly>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications.PackageManager.snk b/src/Tizen.Applications.PackageManager/Tizen.Applications.PackageManager.snk
new file mode 100755 (executable)
index 0000000..7ac1b00
Binary files /dev/null and b/src/Tizen.Applications.PackageManager/Tizen.Applications.PackageManager.snk differ
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/CertCompareResultType.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/CertCompareResultType.cs
new file mode 100644 (file)
index 0000000..cd1512b
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for certificate compare result type.
+    /// </summary>
+    public enum CertCompareResultType
+    {
+        /// <summary>
+        /// Certificates are matched.
+        /// </summary>
+        Match = Interop.PackageManager.CertCompareResultType.Match,
+        /// <summary>
+        /// Certificates are not matched.
+        /// </summary>
+        Mismatch = Interop.PackageManager.CertCompareResultType.Mismatch,
+        /// <summary>
+        /// First package doesn't have certificate.
+        /// </summary>
+        LhsNoCert = Interop.PackageManager.CertCompareResultType.LhsNoCert,
+        /// <summary>
+        /// Second package doesn't have certificate.
+        /// </summary>
+        RhsNoCert = Interop.PackageManager.CertCompareResultType.RhsNoCert,
+        /// <summary>
+        /// Certificates of both packages are not exist.
+        /// </summary>
+        BothNoCert = Interop.PackageManager.CertCompareResultType.BothNoCert
+    }
+}
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/CertificateType.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/CertificateType.cs
new file mode 100755 (executable)
index 0000000..b9d5858
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for certification type.
+    /// </summary>
+    public enum CertificateType
+    {
+        /// <summary>
+        /// Author Certificate.
+        /// </summary>
+        Author,
+        /// <summary>
+        /// Distributor Certificate.
+        /// </summary>
+        Distributor,
+        /// <summary>
+        /// Distributor2 Certificate.
+        /// </summary>
+        Distributor2,
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/InstallationMode.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/InstallationMode.cs
new file mode 100755 (executable)
index 0000000..da643db
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for installation mode.
+    /// </summary>
+    public enum InstallationMode
+    {
+        /// <summary>
+        /// Normal Mode.
+        /// </summary>
+        Normal,
+        /// <summary>
+        /// Mount Mode.
+        /// </summary>
+        Mount
+    }
+}
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/Package.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/Package.cs
new file mode 100755 (executable)
index 0000000..3dcd619
--- /dev/null
@@ -0,0 +1,348 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// This class provide methods and properties to get information about packages.
+    /// </summary>
+    public class Package
+    {
+        private const string LogTag = "Tizen.Applications";
+
+        private string _id = string.Empty;
+        private string _label = string.Empty;
+        private string _iconPath = string.Empty;
+        private string _version = string.Empty;
+        private PackageType _type;
+        private Interop.PackageManager.StorageType _installedStorageType;
+        private string _rootPath = string.Empty;
+        private string _expansionPackageName = string.Empty;
+        private bool _isSystemPackage;
+        private bool _isRemovable;
+        private bool _isPreloaded;
+        private bool _isAccessible;
+        private IReadOnlyDictionary<CertificateType, PackageCertificate> _certificates;
+        private List<string> _privileges;
+        private int _installedTime;
+
+        private Package(string pkgId)
+        {
+            _id = pkgId;
+        }
+
+        /// <summary>
+        /// Package ID.
+        /// </summary>
+        public string Id { get { return _id; } }
+
+        /// <summary>
+        /// Label of the package.
+        /// </summary>
+        public string Label { get { return _label; } }
+
+        /// <summary>
+        /// Absolute path to the icon image.
+        /// </summary>
+        public string IconPath { get { return _iconPath; } }
+
+        /// <summary>
+        /// Version of the package.
+        /// </summary>
+        public string Version { get { return _version; } }
+
+        /// <summary>
+        /// Type of the package.
+        /// </summary>
+        public PackageType PackageType { get { return _type; } }
+
+        /// <summary>
+        /// Installed storage type for the package.
+        /// </summary>
+        public StorageType InstalledStorageType { get { return (StorageType)_installedStorageType; } }
+
+        /// <summary>
+        /// Root path for the package.
+        /// </summary>
+        public string RootPath { get { return _rootPath; } }
+
+        /// <summary>
+        /// Expansion package name for the package.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public string TizenExpansionPackageName { get { return _expansionPackageName; } }
+
+        /// <summary>
+        /// Checks whether the package is system package.
+        /// </summary>
+        public bool IsSystemPackage { get { return _isSystemPackage; } }
+
+        /// <summary>
+        /// Checks whether the package is removable.
+        /// </summary>
+        public bool IsRemovable { get { return _isRemovable; } }
+
+        /// <summary>
+        /// Checks whether the package is preloaded.
+        /// </summary>
+        public bool IsPreloaded { get { return _isPreloaded; } }
+
+        /// <summary>
+        /// Checks whether the current package is accessible.
+        /// </summary>
+        public bool IsAccessible { get { return _isAccessible; } }
+
+        /// <summary>
+        /// Certificate information for the package
+        /// </summary>
+        public IReadOnlyDictionary<CertificateType, PackageCertificate> Certificates { get { return _certificates; } }
+
+        /// <summary>
+        /// Requested privilege for the package
+        /// </summary>
+        public IEnumerable<string> Privileges { get { return _privileges; } }
+
+        /// <summary>
+        /// Installed time of the package.
+        /// </summary>
+        public int InstalledTime { get { return _installedTime; } }
+
+        /// <summary>
+        /// Retrieves all application IDs of this package.
+        /// </summary>
+        /// <returns>Returns a dictionary containing all application info for given application type.</returns>
+        public IEnumerable<ApplicationInfo> GetApplications()
+        {
+            return GetApplications(ApplicationType.All);
+        }
+
+        /// <summary>
+        /// Retrieves all application IDs of this package.
+        /// </summary>
+        /// <param name="type">Optional: AppType enum value</param>
+        /// <returns>Returns a dictionary containing all application info for given application type.</returns>
+        public IEnumerable<ApplicationInfo> GetApplications(ApplicationType type)
+        {
+            List<ApplicationInfo> appInfoList = new List<ApplicationInfo>();
+            Interop.Package.PackageInfoAppInfoCallback cb = (Interop.Package.AppType appType, string appId, IntPtr userData) =>
+            {
+                appInfoList.Add(new ApplicationInfo(appId));
+                return true;
+            };
+
+            IntPtr packageInfoHandle;
+            Interop.PackageManager.ErrorCode err = Interop.Package.PackageInfoCreate(Id, out packageInfoHandle);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to create native handle for package info of {0}. err = {1}", Id, err));
+            }
+
+            err = Interop.Package.PackageInfoForeachAppInfo(packageInfoHandle, (Interop.Package.AppType)type, cb, IntPtr.Zero);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to application info of {0}. err = {1}", Id, err));
+            }
+
+            err = Interop.Package.PackageInfoDestroy(packageInfoHandle);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to destroy native handle for package info of {0}. err = {1}", Id, err));
+            }
+            return appInfoList;
+        }
+
+        /// <summary>
+        /// Gets size information for this package.
+        /// </summary>
+        /// <returns>package size information</returns>
+        /// <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
+        public async Task<PackageSizeInformation> GetSizeInformationAsync()
+        {
+            TaskCompletionSource<PackageSizeInformation> tcs = new TaskCompletionSource<PackageSizeInformation>();
+            Interop.PackageManager.PackageManagerSizeInfoCallback sizeInfoCb = (pkgId, sizeInfoHandle, userData) =>
+            {
+                if (sizeInfoHandle != IntPtr.Zero && Id == pkgId)
+                {
+                    var pkgSizeInfo = PackageSizeInformation.GetPackageSizeInformation(sizeInfoHandle);
+                    tcs.TrySetResult(pkgSizeInfo);
+                }
+            };
+
+            Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerGetSizeInfo(Id, sizeInfoCb, IntPtr.Zero);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                tcs.TrySetException(PackageManagerErrorFactory.GetException(err, "Failed to get total package size info of " + Id));
+            }
+            return await tcs.Task.ConfigureAwait(false);
+        }
+
+        /// <summary>
+        /// Compare certificate information with given package id.
+        /// </summary>
+        /// <param name="packageId">Id of the package</param>
+        /// <returns>Certificate comparison result</returns>
+        /// <exception cref="ArgumentException">Thrown when failed when input package ID is invalid</exception>
+        /// <exception cref="System.IO.IOException">Thrown when method failed due to internal IO error</exception>
+        public CertCompareResultType CompareCertInfo(string packageId)
+        {
+            Interop.PackageManager.CertCompareResultType compareResult;
+            Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerCompareCertInfo(Id, packageId, out compareResult);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                throw PackageManagerErrorFactory.GetException(err, "Failed to compare package cert info");
+            }
+
+            return (CertCompareResultType)compareResult;
+        }
+
+        // This method assumes that given arguments are already validated and have valid values.
+        internal static Package CreatePackage(IntPtr handle, string pkgId)
+        {
+            Package package = new Package(pkgId);
+
+            var err = Interop.PackageManager.ErrorCode.None;
+            err = Interop.Package.PackageInfoGetLabel(handle, out package._label);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, "Failed to get package label of " + pkgId);
+            }
+            err = Interop.Package.PackageInfoGetIconPath(handle, out package._iconPath);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, "Failed to get package icon path of " + pkgId);
+            }
+            err = Interop.Package.PackageInfoGetVersion(handle, out package._version);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, "Failed to get package version of " + pkgId);
+            }
+
+            string type;
+            Interop.Package.PackageInfoGetType(handle, out type);
+            if (Enum.TryParse(type, true, out package._type) == false)
+            {
+                Log.Warn(LogTag, "Failed to get package type of " + pkgId);
+            }
+            err = Interop.Package.PackageInfoGetRootPath(handle, out package._rootPath);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, "Failed to get package root directory of " + pkgId);
+            }
+            err = Interop.Package.PackageInfoGetTepName(handle, out package._expansionPackageName);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, "Failed to get expansion package name of " + pkgId);
+                package._expansionPackageName = string.Empty;
+            }
+
+            err = Interop.Package.PackageInfoGetInstalledStorage(handle, out package._installedStorageType);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, "Failed to get installed storage type of " + pkgId);
+            }
+            Interop.Package.PackageInfoIsSystemPackage(handle, out package._isSystemPackage);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, "Failed to get whether package " + pkgId + " is system package or not");
+            }
+            Interop.Package.PackageInfoIsRemovablePackage(handle, out package._isRemovable);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, "Failed to get whether package " + pkgId + " is removable or not");
+            }
+            Interop.Package.PackageInfoIsPreloadPackage(handle, out package._isPreloaded);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, "Failed to get whether package " + pkgId + " is preloaded or not");
+            }
+            Interop.Package.PackageInfoIsAccessible(handle, out package._isAccessible);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, "Failed to get whether package " + pkgId + " is accessible or not");
+            }
+            try
+            {
+                Interop.Package.PackageInfoGetInstalledTime(handle, out package._installedTime);
+                if (err != Interop.PackageManager.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, "Failed to get installed time of " + pkgId);
+                }
+            }
+            catch (TypeLoadException)
+            {
+                // To support in API vesion 3.0
+                package._installedTime = 0;
+            }
+
+            package._certificates = PackageCertificate.GetPackageCertificates(handle);
+            package._privileges = GetPackagePrivilegeInformation(handle);
+            return package;
+        }
+
+        internal static Package GetPackage(string packageId)
+        {
+            IntPtr packageInfoHandle;
+            Interop.PackageManager.ErrorCode err = Interop.Package.PackageInfoCreate(packageId, out packageInfoHandle);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                throw PackageManagerErrorFactory.GetException(err, string.Format("Failed to create native handle for package info of {0}", packageId));
+            }
+
+            Package package = CreatePackage(packageInfoHandle, packageId);
+
+            err = Interop.Package.PackageInfoDestroy(packageInfoHandle);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to destroy native handle for package info of {0}. err = {1}", packageId, err));
+            }
+            return package;
+        }
+
+        internal static Package GetPackage(IntPtr packageInfoHandle)
+        {
+            String packageId;
+            Interop.PackageManager.ErrorCode err = Interop.Package.PackageInfoGetPackage(packageInfoHandle, out packageId);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                throw PackageManagerErrorFactory.GetException(err, "Failed to get package id for given package handle.");
+            }
+            return CreatePackage(packageInfoHandle, packageId);
+        }
+
+        private static List<string> GetPackagePrivilegeInformation(IntPtr packageInfoHandle)
+        {
+            List<string> privileges = new List<string>();
+            Interop.Package.PackageInfoPrivilegeInfoCallback privilegeInfoCb = (privilege, userData) =>
+            {
+                privileges.Add(privilege);
+                return true;
+            };
+
+            Interop.PackageManager.ErrorCode err = Interop.Package.PackageInfoForeachPrivilegeInfo(packageInfoHandle, privilegeInfoCb, IntPtr.Zero);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to get privilage info. err = {0}", err));
+            }
+            return privileges;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageCertificate.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageCertificate.cs
new file mode 100755 (executable)
index 0000000..914d21a
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// This class provides information about package certification.
+    /// </summary>
+    public class PackageCertificate
+    {
+        private const string LogTag = "Tizen.Applications";
+
+        private readonly string _root;
+        private readonly string _intermediate;
+        private readonly string _signer;
+
+        internal PackageCertificate(string root, string intermediate, string signer)
+        {
+            _root = root;
+            _intermediate = intermediate;
+            _signer = signer;
+        }
+
+        /// <summary>
+        /// Root certificate
+        /// </summary>
+        public string Root { get { return _root;  } }
+
+        /// <summary>
+        /// Intermediate certificate
+        /// </summary>
+        public string Intermediate { get { return _intermediate; } }
+
+        /// <summary>
+        /// Signer certificate
+        /// </summary>
+        public string Signer { get { return _signer; } }
+
+        internal static IReadOnlyDictionary<CertificateType, PackageCertificate> GetPackageCertificates(IntPtr packageInfoHandle)
+        {
+            Dictionary<Interop.Package.CertificateType, string> nativeCertificates = new Dictionary<Interop.Package.CertificateType, string>();
+            Interop.Package.PackageInfoCertificateInfoCallback certificateInfoCb = (handle, certType, certValue, userData) =>
+            {
+                if (certValue == null) certValue = string.Empty;
+                nativeCertificates.Add(certType, certValue);
+                return true;
+            };
+
+            Interop.PackageManager.ErrorCode err = Interop.Package.PackageInfoForeachCertificateInfo(packageInfoHandle, certificateInfoCb, IntPtr.Zero);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to get certificate info. err = {0}", err));
+            }
+
+            Dictionary<CertificateType, PackageCertificate> certificates = new Dictionary<CertificateType, PackageCertificate>();
+            string authorRootCertificate = GetValue(nativeCertificates, Interop.Package.CertificateType.AuthorRootCertificate);
+            string authorIntermediateCertificate = GetValue(nativeCertificates, Interop.Package.CertificateType.AuthorIntermediateCertificate);
+            string aurthorSignerCertificate = GetValue(nativeCertificates, Interop.Package.CertificateType.AuthorSignerCertificate);
+            certificates.Add(CertificateType.Author, new PackageCertificate(authorRootCertificate, authorIntermediateCertificate, aurthorSignerCertificate));
+
+            string distRootCertificate = GetValue(nativeCertificates, Interop.Package.CertificateType.DistributorRootCertificate);
+            string distIntermediateCertificate = GetValue(nativeCertificates, Interop.Package.CertificateType.DistributorIntermediateCertificate);
+            string distSignerCertificate = GetValue(nativeCertificates, Interop.Package.CertificateType.DistributorSignerCertificate);
+            certificates.Add(CertificateType.Distributor, new PackageCertificate(distRootCertificate, distIntermediateCertificate, distSignerCertificate));
+
+            string dist2RootCertificate = GetValue(nativeCertificates, Interop.Package.CertificateType.Distributor2RootCertificate);
+            string dist2IntermediateCertificate = GetValue(nativeCertificates, Interop.Package.CertificateType.Distributor2RootCertificate);
+            string dist2SignerCertificate = GetValue(nativeCertificates, Interop.Package.CertificateType.Distributor2RootCertificate);
+            certificates.Add(CertificateType.Distributor2, new PackageCertificate(dist2RootCertificate, dist2IntermediateCertificate, dist2SignerCertificate));
+
+            return certificates;
+        }
+
+        private static string GetValue(IDictionary<Interop.Package.CertificateType, string> dict, Interop.Package.CertificateType key)
+        {
+            string value;
+            dict.TryGetValue(key, out value);
+            return value;
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageDrm.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageDrm.cs
new file mode 100644 (file)
index 0000000..cb45bbb
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// This class provide methods and properties for DRM operation
+    /// </summary>
+    public class PackageDrm
+    {
+        private string _responseData;
+        private string _requestData;
+        private string _licenseUrl;
+        private PackageDrm(string responseData, string requestData, string licenseUrl)
+        {
+            _responseData = responseData;
+            _requestData = requestData;
+            _licenseUrl = licenseUrl;
+        }
+
+        /// <summary>
+        /// Returns response data
+        /// </summary>
+        /// <returns>Returns response data which is given when GenerateLicenseRequest has invoked</returns>
+        public string ResponseData { get { return _responseData; } }
+
+        /// <summary>
+        /// Returns request data
+        /// </summary>
+        /// <returns>Returns request data which is generated when GenerateLicenseRequest has invoked</returns>
+        public string RequestData { get { return _requestData; } }
+
+        /// <summary>
+        /// Returns license URL
+        /// </summary>
+        /// <returns>Returns license URL which is generated when GenerateLicenseRequest has invoked</returns>
+        public string LicenseUrl { get { return _licenseUrl; } }
+
+        internal static PackageDrm CreateDrmRequest(string responseData, string requestData, string licenseUrl)
+        {
+            PackageDrm packageDrm = new PackageDrm(responseData, requestData, licenseUrl);
+            return packageDrm;
+        }
+
+        internal static PackageDrm GenerateLicenseRequest(string responseData)
+        {
+            string requestData;
+            string licenseUrl;
+            Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerDrmGenerateLicenseRequest(responseData, out requestData, out licenseUrl);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                throw PackageManagerErrorFactory.GetException(err, "Failed to generate license request");
+            }
+
+            PackageDrm packageDrm = CreateDrmRequest(responseData, requestData, licenseUrl);
+            return packageDrm;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageEventState.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageEventState.cs
new file mode 100755 (executable)
index 0000000..827a87f
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for package manager event state.
+    /// </summary>
+    public enum PackageEventState
+    {
+        /// <summary>
+        /// Processing started
+        /// </summary>
+        Started = Interop.PackageManager.PackageEventState.Started,
+        /// <summary>
+        /// Processing state.
+        /// </summary>
+        Processing = Interop.PackageManager.PackageEventState.Processing,
+        /// <summary>
+        /// Processing Completed.
+        /// </summary>
+        Completed = Interop.PackageManager.PackageEventState.Completed,
+        /// <summary>
+        /// Processing Failed.
+        /// </summary>
+        Failed = Interop.PackageManager.PackageEventState.Failed
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageEventType.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageEventType.cs
new file mode 100755 (executable)
index 0000000..15d1f1b
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for package manager event type.
+    /// </summary>
+    public enum PackageEventType
+    {
+        /// <summary>
+        /// Install event.
+        /// </summary>
+        Install = Interop.PackageManager.EventType.Install,
+        /// <summary>
+        /// Uninstall event.
+        /// </summary>
+        Uninstall = Interop.PackageManager.EventType.Uninstall,
+        /// <summary>
+        /// Update event.
+        /// </summary>
+        Update = Interop.PackageManager.EventType.Update,
+        /// <summary>
+        /// Move event.
+        /// </summary>
+        Move = Interop.PackageManager.EventType.Move,
+        /// <summary>
+        /// ClearData event.
+        /// </summary>
+        ClearData = Interop.PackageManager.EventType.ClearData
+    }
+}
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageFilter.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageFilter.cs
new file mode 100755 (executable)
index 0000000..8ebff43
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System.Collections.Generic;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// This class is a parameter of PackageManager::GetPackages method.
+    /// </summary>
+    public class PackageFilter
+    {
+        private IDictionary<string, bool> _filter;
+
+        /// <summary>
+        /// Default constructor with empty filter list. All installed applications will satisfy this filter unless updated with more specific filters.
+        /// </summary>
+        public PackageFilter()
+        {
+            _filter = new Dictionary<string, bool>();
+        }
+
+        /// <summary>
+        /// Constructor with specific filters. Using this will filter out installed packages which do not meet the criteria of the filters.
+        /// </summary>
+        public PackageFilter(IDictionary<string, bool> filter)
+        {
+            _filter = filter;
+        }
+
+        /// <summary>
+        /// Filters to be used in the GetPackages method.
+        /// </summary>
+        public IDictionary<string, bool> Filters
+        {
+            get
+            {
+                return _filter;
+            }
+        }
+
+        /// <summary>
+        /// This class contains possible keys for filter to be used in the GetPackages method.
+        /// </summary>
+        public static class Keys
+        {
+            /// <summary>
+            /// Key of the boolean property for filtering whether the package is removable
+            /// </summary>
+            public const string Removable = "PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE";
+            /// <summary>
+            /// Key of the boolean property for filtering whether the package is readonly.
+            /// </summary>
+            public const string ReadOnly = "PMINFO_PKGINFO_PROP_PACKAGE_READONLY";
+            /// <summary>
+            /// Key of the boolean property for filtering whether the package supports disabling.
+            /// </summary>
+            public const string SupportsDisable = "PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE";
+            /// <summary>
+            /// Key of the boolean property for filtering whether the package is disabled.
+            /// </summary>
+            public const string Disable = "PMINFO_PKGINFO_PROP_PACKAGE_DISABLE";
+            /// <summary>
+            /// Key of the boolean property for filtering whether the package is preloaded.
+            /// </summary>
+            public const string Preload = "PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD";
+        }
+    }
+}
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs
new file mode 100755 (executable)
index 0000000..b7f37ef
--- /dev/null
@@ -0,0 +1,1152 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using System.IO;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// PackageManager class. This class has the methods and events of the PackageManager.
+    /// </summary>
+    /// <remarks>
+    /// The package manager is one of the core modules of Tizen application framework, and responsible for getting their information.
+    /// You can also retrieve information related to the packages that are installed on the device.
+    /// </remarks>
+    public static class PackageManager
+    {
+        private const string LogTag = "Tizen.Applications.PackageManager";
+
+        private static SafePackageManagerHandle s_handle = new SafePackageManagerHandle();
+        private static Interop.PackageManager.EventStatus s_eventStatus = Interop.PackageManager.EventStatus.All;
+        private static event EventHandler<PackageManagerEventArgs> s_installEventHandler;
+        private static event EventHandler<PackageManagerEventArgs> s_uninstallEventHandler;
+        private static event EventHandler<PackageManagerEventArgs> s_updateEventHandler;
+        private static event EventHandler<PackageManagerEventArgs> s_moveEventHandler;
+        private static event EventHandler<PackageManagerEventArgs> s_clearDataEventHandler;
+
+        private static Interop.PackageManager.PackageManagerEventCallback s_packageManagerEventCallback;
+
+        /// <summary>
+        /// Event Callback Method for the request.
+        /// </summary>
+        /// <param name="type">Type of the package which was requested</param>
+        /// <param name="packageId">ID of the package which was requested</param>
+        /// <param name="eventType">Event type of the request</param>
+        /// <param name="eventState">Current event state of the request</param>
+        /// <param name="progress">Progress for the request being processed by the package manager (in percent)</param>
+        public delegate void RequestEventCallback(string type, string packageId, PackageEventType eventType, PackageEventState eventState, int progress);
+
+        private static Dictionary<int, RequestEventCallback> RequestCallbacks = new Dictionary<int, RequestEventCallback>();
+        private static Dictionary<int, SafePackageManagerRequestHandle> RequestHandles = new Dictionary<int, SafePackageManagerRequestHandle>();
+
+        private delegate Interop.PackageManager.ErrorCode InstallMethodWithCallback(SafePackageManagerRequestHandle requestHandle, string pkgPath, Interop.PackageManager.PackageManagerRequestEventCallback requestCallback, IntPtr userData, out int requestID);
+        private delegate Interop.PackageManager.ErrorCode InstallMethod(SafePackageManagerRequestHandle requestHandle, string pkgPath, out int requestID);
+
+        /// <summary>
+        /// InstallProgressChanged event. This event is occurred when a package is getting installed and the progress of the request to the package manager changes.
+        /// </summary>
+        public static event EventHandler<PackageManagerEventArgs> InstallProgressChanged
+        {
+            add
+            {
+                SetPackageManagerEventStatus(Interop.PackageManager.EventStatus.Install);
+                RegisterPackageManagerEventIfNeeded();
+                s_installEventHandler += value;
+            }
+            remove
+            {
+                s_installEventHandler -= value;
+                UnregisterPackageManagerEventIfNeeded();
+                UnsetPackageManagerEventStatus();
+            }
+        }
+
+        /// <summary>
+        /// UninstallProgressChanged event. This event is occurred when a package is getting uninstalled and the progress of the request to the package manager changes.
+        /// </summary>
+        public static event EventHandler<PackageManagerEventArgs> UninstallProgressChanged
+        {
+            add
+            {
+                SetPackageManagerEventStatus(Interop.PackageManager.EventStatus.Uninstall);
+                RegisterPackageManagerEventIfNeeded();
+                s_uninstallEventHandler += value;
+            }
+            remove
+            {
+                s_uninstallEventHandler -= value;
+                UnregisterPackageManagerEventIfNeeded();
+                UnsetPackageManagerEventStatus();
+            }
+        }
+
+        /// <summary>
+        /// UpdateProgressChanged event. This event is occurred when a package is getting updated and the progress of the request to the package manager changes.
+        /// </summary>
+        public static event EventHandler<PackageManagerEventArgs> UpdateProgressChanged
+        {
+            add
+            {
+                SetPackageManagerEventStatus(Interop.PackageManager.EventStatus.Upgrade);
+                RegisterPackageManagerEventIfNeeded();
+                s_updateEventHandler += value;
+            }
+            remove
+            {
+                s_updateEventHandler -= value;
+                UnregisterPackageManagerEventIfNeeded();
+                UnsetPackageManagerEventStatus();
+            }
+        }
+
+        /// <summary>
+        /// MoveProgressChanged event. This event is occurred when a package is getting moved and the progress of the request to the package manager changes.
+        /// </summary>
+        public static event EventHandler<PackageManagerEventArgs> MoveProgressChanged
+        {
+            add
+            {
+                SetPackageManagerEventStatus(Interop.PackageManager.EventStatus.Move);
+                RegisterPackageManagerEventIfNeeded();
+                s_moveEventHandler += value;
+            }
+            remove
+            {
+                s_moveEventHandler -= value;
+                UnregisterPackageManagerEventIfNeeded();
+                UnsetPackageManagerEventStatus();
+            }
+        }
+
+        /// <summary>
+        /// ClearDataProgressChanged event. This event is occurred when data directories are cleared in the given package.
+        /// </summary>
+        public static event EventHandler<PackageManagerEventArgs> ClearDataProgressChanged
+        {
+            add
+            {
+                SetPackageManagerEventStatus(Interop.PackageManager.EventStatus.ClearData);
+                RegisterPackageManagerEventIfNeeded();
+                s_clearDataEventHandler += value;
+            }
+            remove
+            {
+                s_clearDataEventHandler -= value;
+                UnregisterPackageManagerEventIfNeeded();
+                UnsetPackageManagerEventStatus();
+            }
+        }
+
+        private static SafePackageManagerHandle Handle
+        {
+            get
+            {
+                if (s_handle.IsInvalid)
+                {
+                    var err = Interop.PackageManager.PackageManagerCreate(out s_handle);
+                    if (err != Interop.PackageManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, string.Format("Failed to create package manager handle. err = {0}", err));
+                    }
+                }
+                return s_handle;
+            }
+        }
+
+        private static Interop.PackageManager.PackageManagerRequestEventCallback internalRequestEventCallback = (id, packageType, packageId, eventType, eventState, progress, error, userData) =>
+        {
+            if (RequestCallbacks.ContainsKey(id))
+            {
+                try
+                {
+                    RequestCallbacks[id](packageType, packageId, (PackageEventType)eventType, (PackageEventState)eventState, progress);
+                    if (eventState == Interop.PackageManager.PackageEventState.Completed || eventState == Interop.PackageManager.PackageEventState.Failed)
+                    {
+                        Log.Debug(LogTag, string.Format("release request handle for id : {0}", id));
+                        RequestHandles[id].Dispose();
+                        RequestHandles.Remove(id);
+                        RequestCallbacks.Remove(id);
+                    }
+                }
+                catch (Exception e)
+                {
+                    Log.Warn(LogTag, e.Message);
+                    RequestHandles[id].Dispose();
+                    RequestHandles.Remove(id);
+                    RequestCallbacks.Remove(id);
+                }
+            }
+        };
+
+        /// <summary>
+        /// Gets the package ID for the given app ID.
+        /// </summary>
+        /// <param name="applicationId">The ID of the application</param>
+        /// <returns>Returns the ID of the package. Empty string if App ID does not exist</returns>
+        /// <exception cref="OutOfMemoryException">Thrown when there is not enough memory to continue the execution of the method</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+        /// <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
+        public static string GetPackageIdByApplicationId(string applicationId)
+        {
+            string packageId;
+            var err = Interop.PackageManager.PackageManageGetPackageIdByAppId(applicationId, out packageId);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to get package Id of {0}. err = {1}", applicationId, err));
+                if (err != Interop.PackageManager.ErrorCode.InvalidParameter)
+                {
+                    throw PackageManagerErrorFactory.GetException(err, "Failed to get package Id");
+                }
+            }
+            return packageId;
+        }
+
+        /// <summary>
+        /// Gets the package information for the given package.
+        /// </summary>
+        /// <param name="packageId">The ID of the package</param>
+        /// <returns>Returns the package information for the given package ID.</returns>
+        /// <exception cref="ArgumentException">Thrown when failed when input package ID is invalid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when there is not enough memory to continue the execution of the method</exception>
+        /// <exception cref="System.IO.IOException">Thrown when method failed due to internal IO error</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+        /// <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
+        public static Package GetPackage(string packageId)
+        {
+            return Package.GetPackage(packageId);
+        }
+
+        /// <summary>
+        /// Clears the application's internal and external cache directory.
+        /// </summary>
+        /// <param name="packageId">Id of the package</param>
+        /// <exception cref="OutOfMemoryException">Thrown when there is not enough memory to continue the execution of the method</exception>
+        /// <exception cref="System.IO.IOException">Thrown when method failed due to internal IO error</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+        /// <exception cref="SystemException">Thrown when method failed due to internal system error</exception>
+        /// <privilege>http://tizen.org/privilege/packagemanager.clearcache</privilege>
+        public static void ClearCacheDirectory(string packageId)
+        {
+            Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerClearCacheDir(packageId);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to clear cache directory for {0}. err = {1}", packageId, err));
+                throw PackageManagerErrorFactory.GetException(err, "Failed to clear cache directory");
+            }
+        }
+
+        /// <summary>
+        /// Clears all application's internal and external cache directory.
+        /// </summary>
+        /// <exception cref="OutOfMemoryException">Thrown when there is not enough memory to continue the execution of the method</exception>
+        /// <exception cref="System.IO.IOException">Thrown when method failed due to internal IO error</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+        /// <exception cref="SystemException">Thrown when method failed due to internal system error</exception>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static void ClearAllCacheDirectory()
+        {
+            var err = Interop.PackageManager.PackageManagerClearAllCacheDir();
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to clear all cache directories. err = {0}", err));
+                throw PackageManagerErrorFactory.GetException(err, "Failed to clear all cache directories");
+            }
+        }
+
+        /// <summary>
+        /// Clears the application's internal and external data directories
+        /// </summary>
+        /// <remarks>
+        /// All files under data, shared/data and shared/trusted in the internal storage are removed.
+        /// And, If external storeage exists, then all files under data and shared/trusted in the external storage are removed.
+        /// </remarks>
+        /// <param name="packageId">Id of the package</param>
+        /// <exception cref="OutOfMemoryException">Thrown when there is not enough memory to continue the execution of the method</exception>
+        /// <exception cref="System.IO.IOException">Thrown when method failed due to internal IO error</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+        /// <exception cref="SystemException">Thrown when method failed due to internal system error</exception>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static void ClearDataDirectory(string packageId)
+        {
+            Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerClearDataDir(packageId);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to clear data directory for {0}. err = {1}", packageId, err));
+                throw PackageManagerErrorFactory.GetException(err, "Failed to clear data directory");
+            }
+        }
+
+        /// <summary>
+        /// Retrieves package information of all installed packages.
+        /// </summary>
+        /// <returns>Returns the list of packages.</returns>
+        /// <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
+        public static IEnumerable<Package> GetPackages()
+        {
+            return GetPackages(null);
+        }
+
+        /// <summary>
+        /// Retrieves package information of all installed packages satisfying filter conditions.
+        /// </summary>
+        /// <param name="filter">Optional - package filters</param>
+        /// <returns>Returns the list of packages.</returns>
+        /// <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
+        public static IEnumerable<Package> GetPackages(PackageFilter filter)
+        {
+            List<Package> packageList = new List<Package>();
+
+            IntPtr filterHandle;
+            var err = Interop.PackageManager.PackageManagerFilterCreate(out filterHandle);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to create package filter handle. err = {0}", err));
+                return packageList;
+            }
+
+            if (filter != null && filter.Filters != null)
+            {
+                foreach (KeyValuePair<string, bool> entry in filter?.Filters)
+                {
+                    err = Interop.PackageManager.PackageManagerFilterAdd(filterHandle, entry.Key, entry.Value);
+                    if (err != Interop.PackageManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, string.Format("Failed to configure package filter. err = {0}", err));
+                        break;
+                    }
+                }
+            }
+
+            if (err == Interop.PackageManager.ErrorCode.None)
+            {
+                Interop.PackageManager.PackageManagerPackageInfoCallback cb = (handle, userData) =>
+                {
+                    packageList.Add(Package.GetPackage(handle));
+                    return true;
+                };
+
+                err = Interop.PackageManager.PackageManagerFilterForeachPackageInfo(filterHandle, cb, IntPtr.Zero);
+                if (err != Interop.PackageManager.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, string.Format("Failed to get package Informations. err = {0}", err));
+                }
+            }
+
+            err = Interop.PackageManager.PackageManagerFilterDestroy(filterHandle);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to destroy package filter handle. err = {0}", err));
+            }
+            return packageList;
+        }
+
+        /// <summary>
+        /// Gets the total package size information.
+        /// </summary>
+        /// <returns>Returns the total package size information asynchronously.</returns>
+        /// <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
+        public static async Task<PackageSizeInformation> GetTotalSizeInformationAsync()
+        {
+            TaskCompletionSource<PackageSizeInformation> tcs = new TaskCompletionSource<PackageSizeInformation>();
+            Interop.PackageManager.PackageManagerTotalSizeInfoCallback cb = (handle, userData) =>
+            {
+                if (handle != IntPtr.Zero)
+                {
+                    tcs.TrySetResult(PackageSizeInformation.GetPackageSizeInformation(handle));
+                }
+            };
+
+            var err = Interop.PackageManager.PackageManagerGetTotalSizeInfo(cb, IntPtr.Zero);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                tcs.TrySetException(PackageManagerErrorFactory.GetException(err, "Failed to get total package size info"));
+            }
+            return await tcs.Task.ConfigureAwait(false);
+        }
+
+        /// <summary>
+        /// Installs package located at the given path
+        /// </summary>
+        /// <param name="packagePath">Absolute path for the package to be installed</param>
+        /// <returns>Returns true if installtion request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of installation is seccessful.
+        /// To check the result of installation, the caller should check the progress using InstallProgressChanged event.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Install(string packagePath, InstallationMode installMode = InstallationMode.Normal)
+        {
+            return Install(packagePath, null, PackageType.UNKNOWN, null, installMode);
+        }
+
+        /// <summary>
+        /// Installs package located at the given path
+        /// </summary>
+        /// <param name="packagePath">Absolute path for the package to be installed</param>
+        /// <param name="eventCallback">The event callback will be invoked only for the current request</param>
+        /// <param name="installMode">Optional parameter to indicate special installation mode</param>
+        /// <returns>Returns true if installtion request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of installation is seccessful.
+        /// To check the result of installation, the caller should check the progress using InstallProgressChanged event OR eventCallback.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Install(string packagePath, RequestEventCallback eventCallback, InstallationMode installMode = InstallationMode.Normal)
+        {
+            return Install(packagePath, null, PackageType.UNKNOWN, eventCallback, installMode);
+        }
+
+        /// <summary>
+        /// Installs package located at the given path
+        /// </summary>
+        /// <param name="packagePath">Absolute path for the package to be installed</param>
+        /// <param name="type">Package type for the package to be installed</param>
+        /// <param name="installMode">Optional parameter to indicate special installation mode</param>
+        /// <returns>Returns true if installtion request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of installation is seccessful.
+        /// To check the result of installation, the caller should check the progress using InstallProgressChanged event.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Install(string packagePath, PackageType type, InstallationMode installMode = InstallationMode.Normal)
+        {
+            return Install(packagePath, null, type, null, installMode);
+        }
+
+        /// <summary>
+        /// Installs package located at the given path
+        /// </summary>
+        /// <param name="packagePath">Absolute path for the package to be installed</param>
+        /// <param name="expansionPackagePath">Absolute path for the expansion package to be installed</param>
+        /// <param name="installMode">Optional parameter to indicate special installation mode</param>
+        /// <returns>Returns true if installtion request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of installation is seccessful.
+        /// To check the result of installation, the caller should check the progress using InstallProgressChanged event.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Install(string packagePath, string expansionPackagePath, InstallationMode installMode = InstallationMode.Normal)
+        {
+            return Install(packagePath, expansionPackagePath, PackageType.UNKNOWN, null, installMode);
+        }
+
+        /// <summary>
+        /// Installs package located at the given path
+        /// </summary>
+        /// <param name="packagePath">Absolute path for the package to be installed</param>
+        /// <param name="type">Package type for the package to be installed</param>
+        /// <param name="eventCallback">The event callback will be invoked only for the current request</param>
+        /// <param name="installMode">Optional parameter to indicate special installation mode</param>
+        /// <returns>Returns true if installtion request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of installation is seccessful.
+        /// To check the result of installation, the caller should check the progress using InstallProgressChanged event OR eventCallback.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Install(string packagePath, PackageType type, RequestEventCallback eventCallback, InstallationMode installMode = InstallationMode.Normal)
+        {
+            return Install(packagePath, null, type, eventCallback, installMode);
+        }
+
+        /// <summary>
+        /// Installs package located at the given path
+        /// </summary>
+        /// <param name="packagePath">Absolute path for the package to be installed</param>
+        /// <param name="expansionPackagePath">Absolute path for the expansion package to be installed</param>
+        /// <param name="eventCallback">The event callback will be invoked only for the current request</param>
+        /// <param name="installMode">Optional parameter to indicate special installation mode</param>
+        /// <returns>Returns true if installtion request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of installation is seccessful.
+        /// To check the result of installation, the caller should check the progress using InstallProgressChanged event OR eventCallback.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Install(string packagePath, string expansionPackagePath, RequestEventCallback eventCallback, InstallationMode installMode = InstallationMode.Normal)
+        {
+            return Install(packagePath, expansionPackagePath, PackageType.UNKNOWN, eventCallback, installMode);
+        }
+
+        /// <summary>
+        /// Installs package located at the given path
+        /// </summary>
+        /// <param name="packagePath">Absolute path for the package to be installed</param>
+        /// <param name="expansionPackagePath">Absolute path for the expansion package to be installed</param>
+        /// <param name="type">Package type for the package to be installed</param>
+        /// <param name="installMode">Optional parameter to indicate special installation mode</param>
+        /// <returns>Returns true if installtion request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of installation is seccessful.
+        /// To check the result of installation, the caller should check the progress using InstallProgressChanged event.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Install(string packagePath, string expansionPackagePath, PackageType type, InstallationMode installMode = InstallationMode.Normal)
+        {
+            return Install(packagePath, expansionPackagePath, type, null, installMode);
+        }
+
+        /// <summary>
+        /// Installs package located at the given path
+        /// </summary>
+        /// <param name="packagePath">Absolute path for the package to be installed</param>
+        /// <param name="expansionPackagePath">Absolute path for the expansion package to be installed</param>
+        /// <param name="type">Package type for the package to be installed</param>
+        /// <param name="eventCallback">The event callback will be invoked only for the current request</param>
+        /// <param name="installMode">Optional parameter to indicate special installation mode</param>
+        /// <returns>Returns true if installtion request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of installation is seccessful.
+        /// To check the result of installation, the caller should check the progress using InstallProgressChanged event OR eventCallback.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Install(string packagePath, string expansionPackagePath, PackageType type, RequestEventCallback eventCallback, InstallationMode installMode = InstallationMode.Normal)
+        {
+            SafePackageManagerRequestHandle RequestHandle;
+            var err = Interop.PackageManager.PackageManagerRequestCreate(out RequestHandle);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to install package {0}. Error in creating package manager request handle. err = {1}", packagePath, err));
+                return false;
+            }
+
+            try
+            {
+                if (type != PackageType.UNKNOWN)
+                {
+                    err = Interop.PackageManager.PackageManagerRequestSetType(RequestHandle, type.ToString().ToLower());
+                    if (err != Interop.PackageManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, string.Format("Failed to install package {0}. Error in setting request package type. err = {1}", packagePath, err));
+                        RequestHandle.Dispose();
+                        return false;
+                    }
+                }
+
+                if (!string.IsNullOrEmpty(expansionPackagePath))
+                {
+                    err = Interop.PackageManager.PackageManagerRequestSetTepPath(RequestHandle, expansionPackagePath);
+                    if (err != Interop.PackageManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, string.Format("Failed to install package {0}. Error in setting request package mode. err = {1}", packagePath, err));
+                        RequestHandle.Dispose();
+                        return false;
+                    }
+                }
+
+                int requestId;
+                if (eventCallback != null)
+                {
+                    InstallMethodWithCallback install;
+                    if (installMode == InstallationMode.Mount)
+                    {
+                        install = Interop.PackageManager.PackageManagerRequestMountInstallWithCB;
+                    }
+                    else
+                    {
+                        install = Interop.PackageManager.PackageManagerRequestInstallWithCB;
+                    }
+                    err = install(RequestHandle, packagePath, internalRequestEventCallback, IntPtr.Zero, out requestId);
+                    if (err == Interop.PackageManager.ErrorCode.None)
+                    {
+                        RequestCallbacks.Add(requestId, eventCallback);
+                        RequestHandles.Add(requestId, RequestHandle);
+                    }
+                    else
+                    {
+                        Log.Warn(LogTag, string.Format("Failed to install package {0}. err = {1}", packagePath, err));
+                        RequestHandle.Dispose();
+                        return false;
+                    }
+                }
+                else
+                {
+                    InstallMethod install;
+                    if (installMode == InstallationMode.Mount)
+                    {
+                        install = Interop.PackageManager.PackageManagerRequestMountInstall;
+                    }
+                    else
+                    {
+                        install = Interop.PackageManager.PackageManagerRequestInstall;
+                    }
+                    err = install(RequestHandle, packagePath, out requestId);
+                    if (err != Interop.PackageManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, string.Format("Failed to install package {0}. err = {1}", packagePath, err));
+                        RequestHandle.Dispose();
+                        return false;
+                    }
+                    // RequestHandle isn't necessary when this method is called without 'eventCallback' parameter.
+                    RequestHandle.Dispose();
+                }
+                return true;
+            }
+            catch (Exception e)
+            {
+                Log.Warn(LogTag, e.Message);
+                RequestHandle.Dispose();
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// Uninstalls package with the given name.
+        /// </summary>
+        /// <param name="packageId">Id of the package to be uninstalled</param>
+        /// <returns>Returns true if uninstallation request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of uninstallation is seccessful.
+        /// To check the result of uninstallation, the caller should check the progress using UninstallProgressChanged event.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Uninstall(string packageId)
+        {
+            return Uninstall(packageId, PackageType.UNKNOWN, null);
+        }
+
+        /// <summary>
+        /// Uninstalls package with the given name.
+        /// </summary>
+        /// <param name="packageId">Id of the package to be uninstalled</param>
+        /// <param name="type">Optional - Package type for the package to be uninstalled</param>
+        /// <returns>Returns true if uninstalltion request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of uninstallation is seccessful.
+        /// To check the result of uninstallation, the caller should check the progress using UninstallProgressChanged event.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Uninstall(string packageId, PackageType type)
+        {
+            return Uninstall(packageId, type, null);
+        }
+
+        /// <summary>
+        /// Uninstalls package with the given name.
+        /// </summary>
+        /// <param name="packageId">Id of the package to be uninstalled</param>
+        /// <param name="eventCallback">Optional - The event callback will be invoked only for the current request</param>
+        /// <returns>Returns true if uninstalltion request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of uninstallation is seccessful.
+        /// To check the result of uninstallation, the caller should check the progress using UninstallProgressChanged event OR eventCallback.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Uninstall(string packageId, RequestEventCallback eventCallback)
+        {
+            return Uninstall(packageId, PackageType.UNKNOWN, eventCallback);
+        }
+
+        /// <summary>
+        /// Uninstalls package with the given name.
+        /// </summary>
+        /// <param name="packageId">Id of the package to be uninstalled</param>
+        /// <param name="type">Optional - Package type for the package to be uninstalled</param>
+        /// <param name="eventCallback">Optional - The event callback will be invoked only for the current request</param>
+        /// <returns>Returns true if uninstalltion request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of uninstallation is seccessful.
+        /// To check the result of uninstallation, the caller should check the progress using UninstallProgressChanged event OR eventCallback.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Uninstall(string packageId, PackageType type, RequestEventCallback eventCallback)
+        {
+            SafePackageManagerRequestHandle RequestHandle;
+            var err = Interop.PackageManager.PackageManagerRequestCreate(out RequestHandle);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to uninstall package {0}. Error in creating package manager request handle. err = {1}", packageId, err));
+                return false;
+            }
+
+            try
+            {
+                err = Interop.PackageManager.PackageManagerRequestSetType(RequestHandle, type.ToString().ToLower());
+                if (err != Interop.PackageManager.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, string.Format("Failed to uninstall package {0}. Error in setting request package type. err = {1}", packageId, err));
+                    RequestHandle.Dispose();
+                    return false;
+                }
+
+                int requestId;
+                if (eventCallback != null)
+                {
+                    err = Interop.PackageManager.PackageManagerRequestUninstallWithCB(RequestHandle, packageId, internalRequestEventCallback, IntPtr.Zero, out requestId);
+                    if (err == Interop.PackageManager.ErrorCode.None)
+                    {
+                        RequestCallbacks.Add(requestId, eventCallback);
+                        RequestHandles.Add(requestId, RequestHandle);
+                    }
+                    else
+                    {
+                        Log.Warn(LogTag, string.Format("Failed to uninstall package {0}. err = {1}", packageId, err));
+                        RequestHandle.Dispose();
+                        return false;
+                    }
+                }
+                else
+                {
+                    err = Interop.PackageManager.PackageManagerRequestUninstall(RequestHandle, packageId, out requestId);
+                    if (err != Interop.PackageManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, string.Format("Failed to uninstall package. err = {0}", err));
+                        RequestHandle.Dispose();
+                        return false;
+                    }
+                    // RequestHandle isn't necessary when this method is called without 'eventCallback' parameter.
+                    RequestHandle.Dispose();
+                }
+                return true;
+            }
+            catch (Exception e)
+            {
+                Log.Warn(LogTag, e.Message);
+                RequestHandle.Dispose();
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// Move package to given storage.
+        /// </summary>
+        /// <param name="packageId">Id of the package to be moved</param>
+        /// <param name="newStorage">Storage, package should be moved to</param>
+        /// <returns>Returns true if move request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of move is seccessful.
+        /// To check the result of move, the caller should check the progress using MoveProgressChanged event.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Move(string packageId, StorageType newStorage)
+        {
+            return Move(packageId, PackageType.UNKNOWN, newStorage, null);
+        }
+
+        /// <summary>
+        /// Move package to given storage.
+        /// </summary>
+        /// <param name="packageId">Id of the package to be moved</param>
+        /// <param name="type">Optional - Package type for the package to be moved</param>
+        /// <param name="newStorage">Storage, package should be moved to</param>
+        /// <returns>Returns true if move request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of move is seccessful.
+        /// To check the result of move, the caller should check the progress using MoveProgressChanged event.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Move(string packageId, PackageType type, StorageType newStorage)
+        {
+            return Move(packageId, type, newStorage, null);
+        }
+
+        /// <summary>
+        /// Move package to given storage.
+        /// </summary>
+        /// <param name="packageId">Id of the package to be moved</param>
+        /// <param name="newStorage">Storage, package should be moved to</param>
+        /// <param name="eventCallback">Optional - The event callback will be invoked only for the current request</param>
+        /// <returns>Returns true if move request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of move is seccessful.
+        /// To check the result of move, the caller should check the progress using MoveProgressChanged event.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Move(string packageId, StorageType newStorage, RequestEventCallback eventCallback)
+        {
+            return Move(packageId, PackageType.UNKNOWN, newStorage, eventCallback);
+        }
+
+        /// <summary>
+        /// Move package to given storage.
+        /// </summary>
+        /// <param name="packageId">Id of the package to be moved</param>
+        /// <param name="type">Optional - Package type for the package to be moved</param>
+        /// <param name="newStorage">Storage, package should be moved to</param>
+        /// <param name="eventCallback">Optional - The event callback will be invoked only for the current request</param>
+        /// <returns>Returns true if move request is successful, false otherwise.</returns>
+        /// <remarks>
+        /// The 'true' means that just the request of move is seccessful.
+        /// To check the result of move, the caller should check the progress using MoveProgressChanged event.
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        public static bool Move(string packageId, PackageType type, StorageType newStorage, RequestEventCallback eventCallback)
+        {
+            SafePackageManagerRequestHandle RequestHandle;
+            var err = Interop.PackageManager.PackageManagerRequestCreate(out RequestHandle);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to create package manager request handle. err = {0}", err));
+                return false;
+            }
+
+            try
+            {
+                bool result = true;
+                err = Interop.PackageManager.PackageManagerRequestSetType(RequestHandle, type.ToString().ToLower());
+                if (err != Interop.PackageManager.ErrorCode.None)
+                {
+                    Log.Warn(LogTag, string.Format("Failed to move package. Error in setting request package type. err = {0}", err));
+                    RequestHandle.Dispose();
+                    return false;
+                }
+
+                if (eventCallback != null)
+                {
+                    int requestId;
+                    err = Interop.PackageManager.PackageManagerRequestMoveWithCB(RequestHandle, packageId, (Interop.PackageManager.StorageType)newStorage, internalRequestEventCallback, IntPtr.Zero, out requestId);
+                    if (err == Interop.PackageManager.ErrorCode.None)
+                    {
+                        RequestCallbacks.Add(requestId, eventCallback);
+                        RequestHandles.Add(requestId, RequestHandle);
+                    }
+                    else
+                    {
+                        Log.Warn(LogTag, string.Format("Failed to move package to requested location. err = {0}", err));
+                        RequestHandle.Dispose();
+                        result = false;
+                    }
+                }
+                else
+                {
+                    err = Interop.PackageManager.PackageManagerRequestMove(RequestHandle, packageId, (Interop.PackageManager.StorageType)newStorage);
+                    if (err != Interop.PackageManager.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, string.Format("Failed to move package to requested location. err = {0}", err));
+                        RequestHandle.Dispose();
+                        result = false;
+                    }
+                    // RequestHandle isn't necessary when this method is called without 'eventCallback' parameter.
+                    RequestHandle.Dispose();
+                }
+                return result;
+            }
+            catch (Exception e)
+            {
+                Log.Warn(LogTag, e.Message);
+                RequestHandle.Dispose();
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// Gets permission type of package which has given application id
+        /// </summary>
+        /// <param name="applicationId">Id of the application</param>
+        /// <returns>Returns permission type.</returns>
+        /// <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
+        /// <exception cref="ArgumentException">Thrown when failed when input package ID is invalid</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+        public static PermissionType GetPermissionTypeByApplicationId(string applicationId)
+        {
+            Interop.PackageManager.PackageManagerPermissionType permissionType;
+            Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerGetPermissionType(applicationId, out permissionType);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                throw PackageManagerErrorFactory.GetException(err, "Failed to get permission type.");
+            }
+
+            return (PermissionType)permissionType;
+        }
+
+        /// <summary>
+        /// Gets package's preload attribute which contain given applicion id
+        /// </summary>
+        /// <param name="applicationId">Id of the application</param>
+        /// <returns>Returns true if package is preloaded. Otherwise return false.</returns>
+        /// <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
+        /// <exception cref="ArgumentException">Thrown when failed when input package ID is invalid</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+        public static bool IsPreloadPackageByApplicationId(string applicationId)
+        {
+            bool isPreloadPackage;
+            Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerIsPreloadPackageByApplicationId(applicationId, out isPreloadPackage);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                throw PackageManagerErrorFactory.GetException(err, "Failed to get preload info");
+            }
+
+            return isPreloadPackage;
+        }
+
+        /// <summary>
+        /// Compare certificate of two packages
+        /// </summary>
+        /// <param name="lhsPackageId">package id to compare</param>
+        /// <param name="rhsPackageId">package id to be compared</param>
+        /// <returns>Returns certificate comparison result.</returns>
+        /// <exception cref="ArgumentException">Thrown when failed when input package ID is invalid</exception>
+        /// <exception cref="System.IO.IOException">Thrown when method failed due to internal IO error</exception>
+        public static CertCompareResultType CompareCertInfo(string lhsPackageId, string rhsPackageId)
+        {
+            Interop.PackageManager.CertCompareResultType compareResult;
+            Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerCompareCertInfo(lhsPackageId, rhsPackageId, out compareResult);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                throw PackageManagerErrorFactory.GetException(err, "Failed to compare cert info");
+            }
+
+            return (CertCompareResultType)compareResult;
+        }
+
+        /// <summary>
+        /// Compare certificate of two packages which contain each given application id
+        /// </summary>
+        /// <param name="lhsApplicationId">application id to compare</param>
+        /// <param name="rhsApplicationId">application id to be compared</param>
+        /// <returns>Returns certificate comparison result.</returns>
+        /// <exception cref="ArgumentException">Thrown when failed when input package ID is invalid</exception>
+        /// <exception cref="System.IO.IOException">Thrown when method failed due to internal IO error</exception>
+        public static CertCompareResultType CompareCertInfoByApplicationId(string lhsApplicationId, string rhsApplicationId)
+        {
+            Interop.PackageManager.CertCompareResultType compareResult;
+            Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerCompareCertInfoByApplicationId(lhsApplicationId, rhsApplicationId, out compareResult);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                throw PackageManagerErrorFactory.GetException(err, "Failed to compare cert info by application id");
+            }
+
+            return (CertCompareResultType)compareResult;
+        }
+
+        /// <summary>
+        /// Drm nested class. This class has the PackageManager's drm related methods.
+        /// </summary>
+        public static class Drm
+        {
+            /// <summary>
+            /// Generates request for getting license
+            /// </summary>
+            /// <param name="responseData">Response data string of the purchase request</param>
+            /// <returns>Returns package drm information of given response data which contains require data and license url</returns>
+            /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+            /// <privlevel>platform</privlevel>
+            /// <exception cref="ArgumentException">Thrown when failed when input package ID is invalid</exception>
+            /// <exception cref="OutOfMemoryException">Thrown when there is not enough memory to continue the execution of the method</exception>
+            /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+            /// <exception cref="SystemException">Thrown when method failed due to internal system error</exception>
+            public static PackageDrm GenerateLicenseRequest(string responseData)
+            {
+                return PackageDrm.GenerateLicenseRequest(responseData);
+
+            }
+
+            /// <summary>
+            /// Registers encrypted license
+            /// </summary>
+            /// <param name="responseData">The response data string of the rights request</param>
+            /// <returns>Returns true if succeed. Otherwise return false</returns>
+            /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+            /// <privlevel>platform</privlevel>
+            /// <exception cref="ArgumentException">Thrown when failed when input package ID is invalid</exception>
+            /// <exception cref="OutOfMemoryException">Thrown when there is not enough memory to continue the execution of the method</exception>
+            /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+            /// <exception cref="SystemException">Thrown when method failed due to internal system error</exception>
+            public static bool RegisterLicense(string responseData)
+            {
+                Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerDrmRegisterLicense(responseData);
+                if (err != Interop.PackageManager.ErrorCode.None)
+                {
+                    throw PackageManagerErrorFactory.GetException(err, "Failed to register drm license");
+                }
+
+                return true;
+            }
+
+            /// <summary>
+            /// Decrypts contents which is encrypted
+            /// </summary>
+            /// <param name="drmFilePath">Drm file path</param>
+            /// <param name="decryptedFilePath">Decrypted file path</param>
+            /// <returns>Returns true if succeed. Otherwise return false</returns>
+            /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+            /// <privlevel>platform</privlevel>
+            /// <exception cref="ArgumentException">Thrown when failed when input package ID is invalid</exception>
+            /// <exception cref="OutOfMemoryException">Thrown when there is not enough memory to continue the execution of the method</exception>
+            /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+            /// <exception cref="SystemException">Thrown when method failed due to internal system error</exception>
+            public static bool DecryptPackage(string drmFilePath, string decryptedFilePath)
+            {
+                Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerDrmDecryptPackage(drmFilePath, decryptedFilePath);
+                if (err != Interop.PackageManager.ErrorCode.None)
+                {
+                    throw PackageManagerErrorFactory.GetException(err, "Failed to decrypt drm package");
+                }
+
+                return true;
+            }
+        }
+
+        private static void SetPackageManagerEventStatus(Interop.PackageManager.EventStatus status)
+        {
+            if (Handle.IsInvalid) return;
+
+            Interop.PackageManager.EventStatus eventStatus = s_eventStatus;
+            eventStatus |= status;
+            if (eventStatus != Interop.PackageManager.EventStatus.All)
+                eventStatus |= Interop.PackageManager.EventStatus.Progress;
+
+            var err = Interop.PackageManager.ErrorCode.None;
+            if (s_eventStatus != eventStatus)
+            {
+                err = Interop.PackageManager.PackageManagerSetEvenStatus(Handle, eventStatus);
+                if (err == Interop.PackageManager.ErrorCode.None)
+                {
+                    s_eventStatus = eventStatus;
+                    Log.Debug(LogTag, string.Format("New Event Status flag: {0}", s_eventStatus));
+                    return;
+                }
+                Log.Debug(LogTag, string.Format("Failed to set flag for {0} event. err = {1}", eventStatus, err));
+            }
+        }
+
+        private static void UnsetPackageManagerEventStatus()
+        {
+            if (Handle.IsInvalid) return;
+
+            Interop.PackageManager.EventStatus eventStatus = Interop.PackageManager.EventStatus.All;
+            if (s_installEventHandler != null) eventStatus |= Interop.PackageManager.EventStatus.Install;
+            if (s_uninstallEventHandler != null) eventStatus |= Interop.PackageManager.EventStatus.Uninstall;
+            if (s_updateEventHandler != null) eventStatus |= Interop.PackageManager.EventStatus.Upgrade;
+            if (s_moveEventHandler != null) eventStatus |= Interop.PackageManager.EventStatus.Move;
+            if (s_clearDataEventHandler != null) eventStatus |= Interop.PackageManager.EventStatus.ClearData;
+            if (eventStatus != Interop.PackageManager.EventStatus.All)
+                eventStatus |= Interop.PackageManager.EventStatus.Progress;
+
+            var err = Interop.PackageManager.ErrorCode.None;
+            if (s_eventStatus != eventStatus)
+            {
+                err = Interop.PackageManager.PackageManagerSetEvenStatus(Handle, eventStatus);
+                if (err == Interop.PackageManager.ErrorCode.None)
+                {
+                    s_eventStatus = eventStatus;
+                    Log.Debug(LogTag, string.Format("New Event Status flag: {0}", s_eventStatus));
+                    return;
+                }
+                Log.Debug(LogTag, string.Format("Failed to set flag for {0} event. err = {1}", eventStatus, err));
+            }
+        }
+
+        private static void RegisterPackageManagerEventIfNeeded()
+        {
+            if (s_installEventHandler != null && s_uninstallEventHandler != null && s_updateEventHandler != null && s_moveEventHandler != null && s_clearDataEventHandler != null)
+            {
+                return;
+            }
+
+            var err = Interop.PackageManager.ErrorCode.None;
+            s_packageManagerEventCallback = (packageType, packageId, eventType, eventState, progress, error, user_data) =>
+            {
+                try
+                {
+                    if (eventType == Interop.PackageManager.EventType.Install)
+                    {
+                        s_installEventHandler?.Invoke(null, new PackageManagerEventArgs(packageType, packageId, (PackageEventState)eventState, progress));
+                    }
+                    else if (eventType == Interop.PackageManager.EventType.Uninstall)
+                    {
+                        s_uninstallEventHandler?.Invoke(null, new PackageManagerEventArgs(packageType, packageId, (PackageEventState)eventState, progress));
+                    }
+                    else if (eventType == Interop.PackageManager.EventType.Update)
+                    {
+                        s_updateEventHandler?.Invoke(null, new PackageManagerEventArgs(packageType, packageId, (PackageEventState)eventState, progress));
+                    }
+                    else if (eventType == Interop.PackageManager.EventType.Move)
+                    {
+                        s_moveEventHandler?.Invoke(null, new PackageManagerEventArgs(packageType, packageId, (PackageEventState)eventState, progress));
+                    }
+                    else if (eventType == Interop.PackageManager.EventType.ClearData)
+                    {
+                        s_clearDataEventHandler?.Invoke(null, new PackageManagerEventArgs(packageType, packageId, (PackageEventState)eventState, progress));
+                    }
+                }
+                catch (Exception e)
+                {
+                    Log.Warn(LogTag, e.Message);
+                }
+            };
+
+            if (!Handle.IsInvalid)
+            {
+                Log.Debug(LogTag, "Reset Package Event");
+                err = Interop.PackageManager.PackageManagerUnsetEvent(Handle);
+                if (err != Interop.PackageManager.ErrorCode.None)
+                {
+                    throw PackageManagerErrorFactory.GetException(err, "Failed to unregister package manager event event.");
+                }
+
+                err = Interop.PackageManager.PackageManagerSetEvent(Handle, s_packageManagerEventCallback, IntPtr.Zero);
+            }
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, string.Format("Failed to register callback for package manager event. err = {0}", err));
+            }
+        }
+
+        private static void UnregisterPackageManagerEventIfNeeded()
+        {
+            if (Handle.IsInvalid || s_installEventHandler != null || s_uninstallEventHandler != null || s_updateEventHandler != null || s_moveEventHandler != null || s_clearDataEventHandler != null)
+            {
+                return;
+            }
+
+            var err = Interop.PackageManager.PackageManagerUnsetEvent(Handle);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                throw PackageManagerErrorFactory.GetException(err, "Failed to unregister package manager event event.");
+            }
+        }
+    }
+
+    internal static class PackageManagerErrorFactory
+    {
+        internal static Exception GetException(Interop.PackageManager.ErrorCode err, string message)
+        {
+            string errMessage = string.Format("{0} err = {1}", message, err);
+            switch (err)
+            {
+                case Interop.PackageManager.ErrorCode.InvalidParameter:
+                case Interop.PackageManager.ErrorCode.NoSuchPackage:
+                    return new ArgumentException(errMessage);
+                case Interop.PackageManager.ErrorCode.PermissionDenied:
+                    return new UnauthorizedAccessException(errMessage);
+                case Interop.PackageManager.ErrorCode.IoError:
+                    return new global::System.IO.IOException(errMessage);
+                default:
+                    return new InvalidOperationException(errMessage);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManagerEventArgs.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManagerEventArgs.cs
new file mode 100755 (executable)
index 0000000..ba0466f
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// PackageManagerEventArgs class. This class is an event arguments of the InstallProgressChanged, UninstallProgressChanged and UpdateProgressChanged events.
+    /// </summary>
+    public class PackageManagerEventArgs : EventArgs
+    {
+        private readonly PackageType _packageType;
+        private readonly string _packageId;
+        private readonly PackageEventState _state;
+        private readonly int _progress;
+
+        internal PackageManagerEventArgs(string packageType, string packageId, PackageEventState state, int progress)
+        {
+            _packageType = PackageTypeMethods.ToPackageType(packageType);
+            _packageId = packageId;
+            _state = state;
+            _progress = progress;
+        }
+
+        /// <summary>
+        /// Type of the package to be installed, uninstalled or updated
+        /// </summary>
+        public PackageType PackageType { get { return _packageType; } }
+
+        /// <summary>
+        /// package ID to be installed, uninstalled or updated
+        /// </summary>
+        public string PackageId { get { return _packageId; } }
+
+        /// <summary>
+        /// Current state of the request to the package manager
+        /// </summary>
+        public PackageEventState State { get { return _state; } }
+
+        /// <summary>
+        /// Progress for the request being processed by the package manager (in percent).
+        /// </summary>
+        public int Progress { get { return _progress; } }
+    }
+}
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageSizeInformation.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageSizeInformation.cs
new file mode 100755 (executable)
index 0000000..7269f74
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// This class has the read only properties to get package size information.
+    /// </summary>
+    public class PackageSizeInformation
+    {
+        private long _dataSize;
+        private long _cacheSize;
+        private long _appSize;
+        private long _externalDataSize;
+        private long _externalCacheSize;
+        private long _externalAppSize;
+
+        private PackageSizeInformation() { }
+
+        /// <summary>
+        /// Data size for package.
+        /// </summary>
+        public long DataSize { get { return _dataSize; } }
+
+        /// <summary>
+        /// Cache size for package.
+        /// </summary>
+        public long CacheSize { get { return _cacheSize; } }
+
+        /// <summary>
+        /// Application size for package.
+        /// </summary>
+        public long AppSize { get { return _appSize; } }
+
+        /// <summary>
+        /// External data size for package.
+        /// </summary>
+        public long ExternalDataSize { get { return _externalDataSize; } }
+
+        /// <summary>
+        /// External cache size for package.
+        /// </summary>
+        public long ExternalCacheSize { get { return _externalCacheSize; } }
+
+        /// <summary>
+        /// External application size for package.
+        /// </summary>
+        public long ExternalAppSize { get { return _externalAppSize; } }
+
+        // This method assumes that pass handle is already validated
+        internal static PackageSizeInformation GetPackageSizeInformation(IntPtr handle)
+        {
+            var pkgSizeInfo = new PackageSizeInformation();
+            Interop.PackageManager.PackageSizeInfoGetDataSize(handle, out pkgSizeInfo._dataSize);
+            Interop.PackageManager.PackageSizeInfoGetCacheSize(handle, out pkgSizeInfo._cacheSize);
+            Interop.PackageManager.PackageSizeInfoGetAppSize(handle, out pkgSizeInfo._appSize);
+            Interop.PackageManager.PackageSizeInfoGetExtDataSize(handle, out pkgSizeInfo._externalDataSize);
+            Interop.PackageManager.PackageSizeInfoGetExtCacheSize(handle, out pkgSizeInfo._externalCacheSize);
+            Interop.PackageManager.PackageSizeInfoGetExtAppSize(handle, out pkgSizeInfo._externalAppSize);
+            return pkgSizeInfo;
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageType.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageType.cs
new file mode 100755 (executable)
index 0000000..e8a0042
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for package type.
+    /// </summary>
+    public enum PackageType
+    {
+        UNKNOWN,
+        /// <summary>
+        /// Tizen native application package
+        /// </summary>
+        TPK,
+        /// <summary>
+        /// Tizen web/ hybrid application Package
+        /// </summary>
+        WGT,
+        /// <summary>
+        /// It's a special meaning type to represent the tizen application package which is installed using rpm spec.
+        /// Only some preloaded packages can have this type.
+        /// </summary>
+        RPM
+    }
+
+    internal static class PackageTypeMethods
+    {
+        internal static PackageType ToPackageType(string type)
+        {
+            if (string.IsNullOrEmpty(type))
+            {
+                throw PackageManagerErrorFactory.GetException(Interop.PackageManager.ErrorCode.InvalidParameter, "type can't be null or empty");
+            }
+
+            string lowerType = type.ToLower();
+            if (lowerType == "tpk")
+            {
+                return PackageType.TPK;
+            }
+            else if (lowerType == "wgt")
+            {
+                return PackageType.WGT;
+            }
+            else if (lowerType == "rpm")
+            {
+                return PackageType.RPM;
+            }
+            else
+            {
+                throw PackageManagerErrorFactory.GetException(Interop.PackageManager.ErrorCode.InvalidParameter, "type should be tpk or wgt");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/PermissionType.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/PermissionType.cs
new file mode 100644 (file)
index 0000000..c4a4e2f
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for permission type.
+    /// </summary>
+    public enum PermissionType
+    {
+        /// <summary>
+        /// Permission is normal
+        /// </summary>
+        Normal,
+        /// <summary>
+        /// Permission is signature
+        /// </summary>
+        Signature,
+        /// <summary>
+        /// Permission is privilege
+        /// </summary>
+        Privilege
+    }
+}
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/SafePackageManagerHandle.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/SafePackageManagerHandle.cs
new file mode 100755 (executable)
index 0000000..15e0c82
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Applications
+{
+    internal class SafePackageManagerHandle : SafeHandle
+    {
+        /// <summary>
+        /// Initializes a new instance of the SafePackageManagerHandle class.
+        /// </summary>
+        public SafePackageManagerHandle() : base(IntPtr.Zero, true)
+        {
+        }
+
+        /// <summary>
+        /// Gets a value that indicates whether the handle is invalid.
+        /// </summary>
+        public override bool IsInvalid
+        {
+            get { return handle == IntPtr.Zero; }
+        }
+
+        /// <summary>
+        /// Executes the code required to free the SafePackageManagerHandle.
+        /// </summary>
+        /// <returns>true if the handle is released successfully</returns>
+        protected override bool ReleaseHandle()
+        {
+            Interop.PackageManager.PackageManagerDestroy(handle);
+            this.SetHandle(IntPtr.Zero);
+            return true;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/SafePackageManagerRequestHandle.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/SafePackageManagerRequestHandle.cs
new file mode 100755 (executable)
index 0000000..add74f5
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Applications
+{
+    internal class SafePackageManagerRequestHandle : SafeHandle
+    {
+        /// <summary>
+        /// Initializes a new instance of the SafePackageManagerRequestHandle class.
+        /// </summary>
+        public SafePackageManagerRequestHandle() : base(IntPtr.Zero, true)
+        {
+        }
+
+        /// <summary>
+        /// Gets a value that indicates whether the handle is invalid.
+        /// </summary>
+        public override bool IsInvalid
+        {
+            get { return handle == IntPtr.Zero; }
+        }
+
+        /// <summary>
+        /// Executes the code required to free the SafePackageManagerRequestHandle.
+        /// </summary>
+        /// <returns>true if the handle is released successfully</returns>
+        protected override bool ReleaseHandle()
+        {
+            Interop.PackageManager.PackageManagerRequestDestroy(handle);
+            this.SetHandle(IntPtr.Zero);
+            return true;
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/StorageType.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/StorageType.cs
new file mode 100755 (executable)
index 0000000..8246188
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for storage type.
+    /// </summary>
+    public enum StorageType
+    {
+        /// <summary>
+        /// Internal storage.
+        /// </summary>
+        Internal = Interop.PackageManager.StorageType.Internal,
+        /// <summary>
+        /// External storage.
+        /// </summary>
+        External = Interop.PackageManager.StorageType.External
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Preference/Interop/Interop.Libraries.cs b/src/Tizen.Applications.Preference/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..d65c742
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string Preference = "libcapi-appfw-preference.so.0";
+    }
+}
diff --git a/src/Tizen.Applications.Preference/Interop/Interop.Preference.cs b/src/Tizen.Applications.Preference/Interop/Interop.Preference.cs
new file mode 100755 (executable)
index 0000000..dd98962
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Applications;
+
+/// <summary>
+/// Contains Interop declarations of Preference classes.
+/// </summary>
+internal static partial class Interop
+{
+    /// <summary>
+    /// Contains Interop declarations of Preference device API.
+    /// </summary>
+    internal static partial class Preference
+    {
+        internal delegate void ChangedCallback(string key, IntPtr userData);
+
+        internal delegate bool ItemCallback(string key, IntPtr userData);
+
+        [DllImport(Libraries.Preference, EntryPoint = "preference_set_int")]
+        internal static extern int SetInt(string key, int value);
+
+        [DllImport(Libraries.Preference, EntryPoint = "preference_get_int")]
+        internal static extern int GetInt(string key, out int value);
+
+        [DllImport(Libraries.Preference, EntryPoint = "preference_set_double")]
+        internal static extern int SetDouble(string key, double value);
+
+        [DllImport(Libraries.Preference, EntryPoint = "preference_get_double")]
+        internal static extern int GetDouble(string key, out double value);
+
+        [DllImport(Libraries.Preference, EntryPoint = "preference_set_string")]
+        internal static extern int SetString(string key, string value);
+
+        [DllImport(Libraries.Preference, EntryPoint = "preference_get_string")]
+        internal static extern int GetString(string key, out string value);
+
+        [DllImport(Libraries.Preference, EntryPoint = "preference_set_boolean")]
+        internal static extern int SetBoolean(string key, bool value);
+
+        [DllImport(Libraries.Preference, EntryPoint = "preference_get_boolean")]
+        internal static extern int GetBoolean(string key, out bool value);
+
+        [DllImport(Libraries.Preference, EntryPoint = "preference_remove")]
+        internal static extern int Remove(string key);
+
+        [DllImport(Libraries.Preference, EntryPoint = "preference_is_existing")]
+        internal static extern int IsExisting(string key, out bool existing);
+
+        [DllImport(Libraries.Preference, EntryPoint = "preference_remove_all")]
+        internal static extern int RemoveAll();
+
+        [DllImport(Libraries.Preference, EntryPoint = "preference_set_changed_cb")]
+        internal static extern int SetChangedCb(string key, ChangedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Preference, EntryPoint = "preference_unset_changed_cb")]
+        internal static extern int UnsetChangedCb(string key);
+
+        [DllImport(Libraries.Preference, EntryPoint = "preference_foreach_item")]
+        internal static extern int ForeachItem(ItemCallback callback, IntPtr userData);
+    }
+}
diff --git a/src/Tizen.Applications.Preference/Tizen.Applications.Preference.csproj b/src/Tizen.Applications.Preference/Tizen.Applications.Preference.csproj
new file mode 100755 (executable)
index 0000000..2747892
--- /dev/null
@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <Import Project="../build/build.props" />
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.3</TargetFramework>
+    <Version>1.5.8</Version>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Applications.Preference.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Tizen" Version="$(TizenVersion)" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Applications.Preference/Tizen.Applications.Preference.snk b/src/Tizen.Applications.Preference/Tizen.Applications.Preference.snk
new file mode 100755 (executable)
index 0000000..7ac1b00
Binary files /dev/null and b/src/Tizen.Applications.Preference/Tizen.Applications.Preference.snk differ
diff --git a/src/Tizen.Applications.Preference/Tizen.Applications/Preference.cs b/src/Tizen.Applications.Preference/Tizen.Applications/Preference.cs
new file mode 100755 (executable)
index 0000000..4fd6e79
--- /dev/null
@@ -0,0 +1,463 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// The Preference class provides APIs to store and retrieve application specific data/preference. A preference is saved in the form of a key-value pair.
+    /// Keys are always text strings and value can be any one of four types: integer, double, string and boolean.
+    /// </summary>
+    public static class Preference
+    {
+        private const string LogTag = "Tizen.Applications";
+        private static Interop.Preference.ChangedCallback s_preferenceChangedCallback;
+        private static IDictionary<string, EventContext> s_eventMap = new Dictionary<string, EventContext>();
+
+        static Preference()
+        {
+            s_preferenceChangedCallback = (string key, IntPtr userData) =>
+            {
+                try
+                {
+                    s_eventMap[key]?.FireEvent();
+                }
+                catch (Exception e)
+                {
+                    Log.Warn(LogTag, e.Message);
+                }
+            };
+        }
+
+        /// <summary>
+        /// Retrieves all keys of the application preferences
+        /// </summary>
+        /// <value>
+        /// The list of keys
+        /// </value>
+        /// <example>
+        /// <code>
+        ///     Preference.Set("Option_enabled", true);
+        ///     Preference.Set("active_user", "Joe");
+        ///     Preference.Set("default_volume", 10);
+        ///     Preference.Set("brightness", "0.6");
+        ///     foreach(string key in Preference.Keys)
+        ///     {
+        ///         Console.WriteLine("key {0}", key);
+        ///     }
+        /// </code>
+        /// </example>
+        public static IEnumerable<string> Keys
+        {
+            get
+            {
+                var collection = new List<string>();
+                Interop.Preference.ItemCallback itemsCallback = (string key, IntPtr userData) =>
+                {
+                    collection.Add(key);
+                    return true;
+                };
+                Interop.Preference.ForeachItem(itemsCallback, IntPtr.Zero);
+                return collection;
+            }
+        }
+
+        /// <summary>
+        /// Gets the event context for the given key.
+        /// </summary>
+        /// <seealso cref="EventContext"/>
+        /// <param name="key">The preference key</param>
+        /// <returns>The event context of respective key</returns>
+        /// <exception cref="KeyNotFoundException">Thrown if the key is not found</exception>
+        /// <exception cref="ArgumentException">Thrown if the key is an invalid parameter.</exception>
+        /// <example>
+        /// <code>
+        ///     private static void Preference_PreferenceChanged(object sender, PreferenceChangedEventArgs e)
+        ///     {
+        ///         Console.WriteLine("key {0}", e.Key);
+        ///     }
+        ///
+        ///     Preference.EventContext context = null;
+        ///     Preference.GetEventContext("active_user").TryGetTarget(out context);
+        ///     if(context != null)
+        ///     {
+        ///         context.Changed += Preference_PreferenceChanged;
+        ///     }
+        ///
+        ///     Preference.Set("active_user", "Poe");
+        ///
+        ///     Preference.GetEventContext("active_user").TryGetTarget(out context);
+        ///     if (context != null)
+        ///     {
+        ///         context.Changed -= Preference_PreferenceChanged;
+        ///     }
+        /// </code>
+        /// </example>
+        public static WeakReference<EventContext> GetEventContext(string key)
+        {
+            if (!s_eventMap.ContainsKey(key))
+            {
+                if (Contains(key))
+                {
+                    s_eventMap[key] = new EventContext(key);
+                }
+                else
+                {
+                    throw PreferenceErrorFactory.GetException((int)PreferenceErrorFactory.PreferenceError.KeyNotAvailable);
+                }
+            }
+
+            return new WeakReference<EventContext>(s_eventMap[key]);
+        }
+
+        /// <summary>
+        /// Checks whether the given key exists in the preference.
+        /// </summary>
+        /// <param name="key">The name of the key to check</param>
+        /// <returns>true if the key exists in the preference, otherwise false</returns>
+        /// <exception cref="ArgumentException">Thrown if the key is an invalid parameter.</exception>
+        /// <exception cref="IOException">Thrown when method failed due to internal IO error.</exception>
+        /// <example>
+        /// <code>
+        ///     Preference.Set("active_user", "Joe");
+        ///     bool exists = Preference.Contains("active_user");
+        ///     if (exists)
+        ///     {
+        ///         string value = Preference.Get<string>("active_user");
+        ///         Console.WriteLine("user {0}", value);
+        ///     }
+        /// </code>
+        /// </example>
+        public static bool Contains(string key)
+        {
+            bool contains;
+            int ret = Interop.Preference.IsExisting(key, out contains);
+            if (ret != (int)PreferenceErrorFactory.PreferenceError.None)
+            {
+                Log.Error(LogTag, "Failed to find key");
+                throw PreferenceErrorFactory.GetException(ret);
+            }
+
+            return contains;
+        }
+
+        /// <summary>
+        /// Sets a key-value pair representing the preference.
+        /// </summary>
+        /// <remarks>
+        /// If the key already exists in the Preference, old value will be overwritten with new value.
+        /// Data types supported for value are: integer, double, string and bool.
+        /// </remarks>
+        /// <param name="key">The name of the key to create/modigy</param>
+        /// <param name="value">The value corresponding to the key.</param>
+        /// <exception cref="ArgumentException">Thrown if the key is an invalid parameter.</exception>
+        /// <exception cref="System.IO.IOException">Thrown when method failed due to internal IO error.</exception>
+        /// <example>
+        /// <code>
+        ///     Preference.Set("Option_enabled", true);
+        ///     Preference.Set("active_user", "Joe");
+        ///     Preference.Set("default_volume", 10);
+        ///     Preference.Set("brightness", "0.6");
+        /// </code>
+        /// </example>
+        public static void Set(string key, object value)
+        {
+            int ret = 0;
+            if (value is int)
+            {
+                ret = Interop.Preference.SetInt(key, (int)value);
+                if (ret != (int)PreferenceErrorFactory.PreferenceError.None)
+                {
+                    Log.Error(LogTag, "Failed to find key");
+                    throw PreferenceErrorFactory.GetException(ret);
+                }
+            }
+            else if (value is double)
+            {
+                ret = Interop.Preference.SetDouble(key, (double)value);
+                if (ret != (int)PreferenceErrorFactory.PreferenceError.None)
+                {
+                    Log.Error(LogTag, "Failed to find key");
+                    throw PreferenceErrorFactory.GetException(ret);
+                }
+            }
+            else if (value is string)
+            {
+                ret = Interop.Preference.SetString(key, (string)value);
+                if (ret != (int)PreferenceErrorFactory.PreferenceError.None)
+                {
+                    Log.Error(LogTag, "Failed to find key");
+                    throw PreferenceErrorFactory.GetException(ret);
+                }
+            }
+            else if (value is bool)
+            {
+                ret = Interop.Preference.SetBoolean(key, (bool)value);
+                if (ret != (int)PreferenceErrorFactory.PreferenceError.None)
+                {
+                    Log.Error(LogTag, "Failed to find key");
+                    throw PreferenceErrorFactory.GetException(ret);
+                }
+            }
+            else
+            {
+                Log.Error(LogTag, "Failed to Set");
+                throw new ArgumentException("Invalid parameter");
+            }
+        }
+
+        /// <summary>
+        /// Gets the value of a preference item with the specified key.
+        /// Note that this is a generic method.
+        /// </summary>
+        /// <typeparam name="T">The generic type to return.</typeparam>
+        /// <param name="key">The key of the preference</param>
+        /// <returns>The value of the preference item if it is of the specified generic type.</returns>
+        /// <exception cref="KeyNotFoundException">Thrown if the key is not found</exception>
+        /// <exception cref="ArgumentException">Thrown if the key is an invalid parameter.</exception>
+        /// <exception cref="System.IO.IOException">Thrown when method failed due to internal IO error.</exception>
+        /// <example>
+        /// <code>
+        ///     bool exists = Preference.Contains("active_user");
+        ///     if (exists)
+        ///     {
+        ///         string value = Preference.Get<string>("active_user");
+        ///         Console.WriteLine("user {0}", value);
+        ///     }
+        /// </code>
+        /// </example>
+        public static T Get<T>(string key)
+        {
+            object result = null;
+            int ret = (int)PreferenceErrorFactory.PreferenceError.None;
+            if (typeof(T) == typeof(bool))
+            {
+                bool val;
+                ret = Interop.Preference.GetBoolean(key, out val);
+                result = val;
+            }
+            else if (typeof(T) == typeof(int))
+            {
+                int val;
+                ret = Interop.Preference.GetInt(key, out val);
+                result = val;
+            }
+            else if (typeof(T) == typeof(string))
+            {
+                string val;
+                ret = Interop.Preference.GetString(key, out val);
+                result = val;
+            }
+            else if (typeof(T) == typeof(double))
+            {
+                double val;
+                ret = Interop.Preference.GetDouble(key, out val);
+                result = val;
+            }
+            else
+            {
+                Log.Error(LogTag, "Failed to remove key");
+                throw new ArgumentException("Invalid parameter");
+            }
+
+            if (ret != (int)PreferenceErrorFactory.PreferenceError.None)
+            {
+                Log.Error(LogTag, "Failed to remove key");
+                throw PreferenceErrorFactory.GetException(ret);
+            }
+
+            return (result != null) ? (T)result : default(T);
+        }
+
+        /// <summary>
+        /// Removes any preference value with the given key.
+        /// </summary>
+        /// <param name="key">The key to remove</param>
+        /// <exception cref="KeyNotFoundException">Thrown if the key is not found</exception>
+        /// <exception cref="System.IO.IOException">Thrown when method failed due to internal IO error.</exception>
+        /// <example>
+        /// <code>
+        ///     bool exists = Preference.Contains("active_user");
+        ///     if (exists)
+        ///     {
+        ///         string value = Preference.Remove("active_user");
+        ///     }
+        /// </code>
+        /// </example>
+        public static void Remove(string key)
+        {
+            int ret = Interop.Preference.Remove(key);
+            if (ret != (int)PreferenceErrorFactory.PreferenceError.None)
+            {
+                Log.Error(LogTag, "Failed to remove key");
+                throw PreferenceErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Removes all key-value pairs from the preference.
+        /// </summary>
+        /// <exception cref="System.IO.IOException">Thrown when method failed due to internal IO error.</exception>
+        /// <example>
+        /// <code>
+        ///     Preference.Set("Option_enabled", true);
+        ///     Preference.Set("active_user", "Joe");
+        ///     Preference.Set("default_volume", 10);
+        ///     Preference.Set("brightness", "0.6");
+        ///     Preference.RemoveAll();
+        /// </code>
+        /// </example>
+        public static void RemoveAll()
+        {
+            int ret = Interop.Preference.RemoveAll();
+            if (ret != (int)PreferenceErrorFactory.PreferenceError.None)
+            {
+                Log.Error(LogTag, "Failed to remove all keys");
+                throw PreferenceErrorFactory.GetException(ret);
+            }
+        }
+
+        private static void AllowChangeNotifications(string key)
+        {
+            int ret = Interop.Preference.SetChangedCb(key, s_preferenceChangedCallback, IntPtr.Zero);
+            if (ret != (int)PreferenceErrorFactory.PreferenceError.None)
+            {
+                Log.Error(LogTag, "Failed to set key notification");
+                throw PreferenceErrorFactory.GetException(ret);
+            }
+        }
+
+        private static void DisallowChangeNotifications(string key)
+        {
+            int ret = Interop.Preference.UnsetChangedCb(key);
+            if (ret != (int)PreferenceErrorFactory.PreferenceError.None)
+            {
+                Log.Error(LogTag, "Failed to remove key notification");
+                throw PreferenceErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// The class manages event handlers of preference keys. The class enables having event handlers for individual preference keys.
+        /// </summary>
+        public class EventContext
+        {
+            private string _key;
+
+            internal EventContext(string key)
+            {
+                _key = key;
+            }
+
+            /// <summary>
+            /// Occurs whenever there is change in the value of preference key.
+            /// </summary>
+            /// <exception cref="System.ArgumentException">Thrown when the key does not exist or when there is an invalid parameter.</exception>
+            /// <exception cref="System.InvalidOperationException">Thrown when the Bundle instance has been disposed.</exception>
+            /// <example>
+            /// <code>
+            ///     private static void Preference_PreferenceChanged(object sender, PreferenceChangedEventArgs e)
+            ///     {
+            ///         Console.WriteLine("key {0}", e.Key);
+            ///     }
+            ///     Preference.EventContext context = null;
+            ///     Preference.GetEventContext("active_user").TryGetTarget(out context);
+            ///     if(context != null)
+            ///     {
+            ///         context.Changed += Preference_PreferenceChanged;
+            ///     }
+            ///
+            ///     Preference.Set("active_user", "Poe");
+            ///
+            ///     Preference.GetEventContext("active_user").TryGetTarget(out context);
+            ///     if (context != null)
+            ///     {
+            ///         context.Changed -= Preference_PreferenceChanged;
+            ///     }
+            /// </code>
+            /// </example>
+            public event EventHandler<PreferenceChangedEventArgs> Changed
+            {
+                add
+                {
+                    if (_changed == null)
+                    {
+                        AllowChangeNotifications(_key);
+                    }
+
+                    _changed += value;
+                }
+
+                remove
+                {
+                    _changed -= value;
+                    if (_changed == null)
+                    {
+                        DisallowChangeNotifications(_key);
+                        s_eventMap.Remove(_key);
+                    }
+                }
+            }
+
+            private event EventHandler<PreferenceChangedEventArgs> _changed;
+
+            internal void FireEvent()
+            {
+                _changed?.Invoke(null, new PreferenceChangedEventArgs() { Key = _key });
+            }
+        }
+
+    }
+
+    internal static class PreferenceErrorFactory
+    {
+        internal enum PreferenceError
+        {
+            None = ErrorCode.None,
+            OutOfMemory = ErrorCode.OutOfMemory,
+            InvalidParameter = ErrorCode.InvalidParameter,
+            KeyNotAvailable = -0x01100000 | 0x30,
+            IoError = ErrorCode.IoError
+        }
+
+        static internal Exception GetException(int error)
+        {
+            if ((PreferenceError)error == PreferenceError.OutOfMemory)
+            {
+                return new OutOfMemoryException("Out of memory");
+            }
+            else if ((PreferenceError)error == PreferenceError.InvalidParameter)
+            {
+                return new ArgumentException("Invalid parameter");
+            }
+            else if ((PreferenceError)error == PreferenceError.KeyNotAvailable)
+            {
+                return new KeyNotFoundException("Key does not exist in the bundle");
+            }
+            else if ((PreferenceError)error == PreferenceError.IoError)
+            {
+                return new System.IO.IOException("I/O Error");
+            }
+            else
+            {
+                return new ArgumentException("Unknown error");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Preference/Tizen.Applications/PreferenceChangedEventArgs.cs b/src/Tizen.Applications.Preference/Tizen.Applications/PreferenceChangedEventArgs.cs
new file mode 100755 (executable)
index 0000000..5386c77
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// This class is an event arguments of the PreferenceChanged events.
+    /// </summary>
+    public class PreferenceChangedEventArgs : EventArgs
+    {
+        /// <summary>
+        /// The key of the preference whose value is changed.
+        /// </summary>
+        public string Key { get; internal set; }
+    }
+}
diff --git a/src/Tizen.Applications.Service/Interop/Interop.Libraries.cs b/src/Tizen.Applications.Service/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..145ff34
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string AppcoreAgent = "libappcore-agent.so.1";
+    }
+}
diff --git a/src/Tizen.Applications.Service/Interop/Interop.Service.cs b/src/Tizen.Applications.Service/Interop/Interop.Service.cs
new file mode 100755 (executable)
index 0000000..d4cd60d
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Applications.CoreBackend;
+using Tizen.Internals.Errors;
+
+internal static partial class Interop
+{
+    internal static partial class Service
+    {
+        internal delegate void AppEventCallback(IntPtr handle, IntPtr data);
+
+        internal delegate bool ServiceAppCreateCallback(IntPtr userData);
+
+        internal delegate void ServiceAppTerminateCallback(IntPtr userData);
+
+        internal delegate void ServiceAppControlCallback(IntPtr appControl, IntPtr userData);
+
+        [DllImport(Libraries.AppcoreAgent, EntryPoint = "service_app_main")]
+        internal static extern ErrorCode Main(int argc, string[] argv, ref ServiceAppLifecycleCallbacks callback, IntPtr userData);
+
+        [DllImport(Libraries.AppcoreAgent, EntryPoint = "service_app_exit")]
+        internal static extern void Exit();
+
+        [DllImport(Libraries.AppcoreAgent, EntryPoint = "service_app_add_event_handler")]
+        internal static extern ErrorCode AddEventHandler(out IntPtr handle, DefaultCoreBackend.AppEventType eventType, AppEventCallback callback, IntPtr data);
+
+        [DllImport(Libraries.AppcoreAgent, EntryPoint = "service_app_remove_event_handler")]
+        internal static extern ErrorCode RemoveEventHandler(IntPtr handle);
+
+        [StructLayoutAttribute(LayoutKind.Sequential)]
+        internal struct ServiceAppLifecycleCallbacks
+        {
+            public ServiceAppCreateCallback OnCreate;
+            public ServiceAppTerminateCallback OnTerminate;
+            public ServiceAppControlCallback OnAppControl;
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Service/Tizen.Applications.CoreBackend/ServiceCoreBackend.cs b/src/Tizen.Applications.Service/Tizen.Applications.CoreBackend/ServiceCoreBackend.cs
new file mode 100755 (executable)
index 0000000..bc1a096
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+using Tizen.Internals.Errors;
+
+namespace Tizen.Applications.CoreBackend
+{
+    internal class ServiceCoreBackend : DefaultCoreBackend
+    {
+        private Interop.Service.ServiceAppLifecycleCallbacks _callbacks;
+        private IntPtr _lowMemoryEventHandle = IntPtr.Zero;
+        private IntPtr _lowBatteryEventHandle = IntPtr.Zero;
+        private IntPtr _localeChangedEventHandle = IntPtr.Zero;
+        private IntPtr _regionChangedEventHandle = IntPtr.Zero;
+        private IntPtr _deviceOrientationChangedEventHandle = IntPtr.Zero;
+        private bool _disposedValue = false;
+        private Interop.Service.AppEventCallback _onLowMemoryNative;
+        private Interop.Service.AppEventCallback _onLowBatteryNative;
+        private Interop.Service.AppEventCallback _onLocaleChangedNative;
+        private Interop.Service.AppEventCallback _onRegionChangedNative;
+        private Interop.Service.AppEventCallback _onDeviceOrientationChangedNative;
+
+        public ServiceCoreBackend()
+        {
+            _callbacks.OnCreate = new Interop.Service.ServiceAppCreateCallback(OnCreateNative);
+            _callbacks.OnTerminate = new Interop.Service.ServiceAppTerminateCallback(OnTerminateNative);
+            _callbacks.OnAppControl = new Interop.Service.ServiceAppControlCallback(OnAppControlNative);
+
+            _onLowMemoryNative = new Interop.Service.AppEventCallback(OnLowMemoryNative);
+            _onLowBatteryNative = new Interop.Service.AppEventCallback(OnLowBatteryNative);
+            _onLocaleChangedNative = new Interop.Service.AppEventCallback(OnLocaleChangedNative);
+            _onRegionChangedNative = new Interop.Service.AppEventCallback(OnRegionChangedNative);
+            _onDeviceOrientationChangedNative = new Interop.Service.AppEventCallback(OnDeviceOrientationChangedNative);
+        }
+
+        public override void Exit()
+        {
+            Interop.Service.Exit();
+        }
+
+        public override void Run(string[] args)
+        {
+            base.Run(args);
+
+            ErrorCode err = ErrorCode.None;
+            err = Interop.Service.AddEventHandler(out _lowMemoryEventHandle, AppEventType.LowMemory, _onLowMemoryNative, IntPtr.Zero);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to add event handler for LowMemory event. Err = " + err);
+            }
+            err = Interop.Service.AddEventHandler(out _lowBatteryEventHandle, AppEventType.LowBattery, _onLowBatteryNative, IntPtr.Zero);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to add event handler for LowBattery event. Err = " + err);
+            }
+
+            err = Interop.Service.AddEventHandler(out _localeChangedEventHandle, AppEventType.LanguageChanged, _onLocaleChangedNative, IntPtr.Zero);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to add event handler for LocaleChanged event. Err = " + err);
+            }
+
+            err = Interop.Service.AddEventHandler(out _regionChangedEventHandle, AppEventType.RegionFormatChanged, _onRegionChangedNative, IntPtr.Zero);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to add event handler for RegionFormatChanged event. Err = " + err);
+            }
+
+            err = Interop.Service.AddEventHandler(out _deviceOrientationChangedEventHandle, AppEventType.DeviceOrientationChanged, _onDeviceOrientationChangedNative, IntPtr.Zero);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to add event handler for DeviceOrientationChanged event. Err = " + err);
+            }
+
+            err = Interop.Service.Main(args.Length, args, ref _callbacks, IntPtr.Zero);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to run the application. Err = " + err);
+            }
+        }
+
+        protected override void Dispose(bool disposing)
+        {
+            if (!_disposedValue)
+            {
+                if (disposing)
+                {
+                    // Release disposable objects
+                }
+
+                if (_lowMemoryEventHandle != IntPtr.Zero)
+                {
+                    Interop.Service.RemoveEventHandler(_lowMemoryEventHandle);
+                }
+                if (_lowBatteryEventHandle != IntPtr.Zero)
+                {
+                    Interop.Service.RemoveEventHandler(_lowBatteryEventHandle);
+                }
+                if (_localeChangedEventHandle != IntPtr.Zero)
+                {
+                    Interop.Service.RemoveEventHandler(_localeChangedEventHandle);
+                }
+                if (_regionChangedEventHandle != IntPtr.Zero)
+                {
+                    Interop.Service.RemoveEventHandler(_regionChangedEventHandle);
+                }
+
+                if (_deviceOrientationChangedEventHandle != IntPtr.Zero)
+                {
+                    Interop.Service.RemoveEventHandler(_deviceOrientationChangedEventHandle);
+                }
+
+                _disposedValue = true;
+            }
+        }
+
+        private bool OnCreateNative(IntPtr data)
+        {
+            if (Handlers.ContainsKey(EventType.Created))
+            {
+                var handler = Handlers[EventType.Created] as Action;
+                handler?.Invoke();
+            }
+            return true;
+        }
+
+        private void OnTerminateNative(IntPtr data)
+        {
+            if (Handlers.ContainsKey(EventType.Terminated))
+            {
+                var handler = Handlers[EventType.Terminated] as Action;
+                handler?.Invoke();
+            }
+        }
+
+        private void OnAppControlNative(IntPtr appControlHandle, IntPtr data)
+        {
+            if (Handlers.ContainsKey(EventType.AppControlReceived))
+            {
+                // Create a SafeAppControlHandle but the ownsHandle is false,
+                // because the appControlHandle will be closed by native appfw after this method automatically.
+                SafeAppControlHandle safeHandle = new SafeAppControlHandle(appControlHandle, false);
+
+                var handler = Handlers[EventType.AppControlReceived] as Action<AppControlReceivedEventArgs>;
+                handler?.Invoke(new AppControlReceivedEventArgs(new ReceivedAppControl(safeHandle)));
+            }
+        }
+
+        protected override void OnLowMemoryNative(IntPtr infoHandle, IntPtr data)
+        {
+            base.OnLowMemoryNative(infoHandle, data);
+        }
+
+        protected override void OnLowBatteryNative(IntPtr infoHandle, IntPtr data)
+        {
+            base.OnLowBatteryNative(infoHandle, data);
+        }
+
+        protected override void OnLocaleChangedNative(IntPtr infoHandle, IntPtr data)
+        {
+            base.OnLocaleChangedNative(infoHandle, data);
+        }
+
+        protected override void OnRegionChangedNative(IntPtr infoHandle, IntPtr data)
+        {
+            base.OnRegionChangedNative(infoHandle, data);
+        }
+
+        protected override void OnDeviceOrientationChangedNative(IntPtr infoHandle, IntPtr data)
+        {
+            base.OnDeviceOrientationChangedNative(infoHandle, data);
+        }
+
+    }
+}
diff --git a/src/Tizen.Applications.Service/Tizen.Applications.Service.csproj b/src/Tizen.Applications.Service/Tizen.Applications.Service.csproj
new file mode 100755 (executable)
index 0000000..8172d00
--- /dev/null
@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <Import Project="../build/build.props" />
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.3</TargetFramework>
+    <Version>1.5.8</Version>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Applications.Service.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Applications.Service/Tizen.Applications.Service.snk b/src/Tizen.Applications.Service/Tizen.Applications.Service.snk
new file mode 100755 (executable)
index 0000000..7ac1b00
Binary files /dev/null and b/src/Tizen.Applications.Service/Tizen.Applications.Service.snk differ
diff --git a/src/Tizen.Applications.Service/Tizen.Applications/ServiceApplication.cs b/src/Tizen.Applications.Service/Tizen.Applications/ServiceApplication.cs
new file mode 100755 (executable)
index 0000000..d8742c1
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using Tizen.Applications.CoreBackend;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Represents a service application.
+    /// </summary>
+    public class ServiceApplication : CoreApplication
+    {
+        /// <summary>
+        /// Initializes ServiceApplication class.
+        /// </summary>
+        public ServiceApplication() : base(new ServiceCoreBackend())
+        {
+        }
+
+        /// <summary>
+        /// Runs the service application's main loop.
+        /// </summary>
+        /// <param name="args">Arguments from commandline.</param>
+        public override void Run(string[] args)
+        {
+            base.Run(args);
+        }
+    }
+}
diff --git a/src/Tizen.Applications.ToastMessage/Interop/Interop.Libraries.cs b/src/Tizen.Applications.ToastMessage/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..c284ac5
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string ToastMessage = "libnotification.so.0";
+    }
+}
diff --git a/src/Tizen.Applications.ToastMessage/Interop/Interop.ToastMessage.cs b/src/Tizen.Applications.ToastMessage/Interop/Interop.ToastMessage.cs
new file mode 100755 (executable)
index 0000000..69e49db
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Applications;
+
+internal static partial class Interop
+{
+    internal static class ToastMessage
+    {
+        [DllImport(Libraries.ToastMessage, EntryPoint = "notification_status_message_post")]
+        internal static extern int ToastMessagePost(string message);
+    }
+}
diff --git a/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.csproj b/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.csproj
new file mode 100755 (executable)
index 0000000..542acf5
--- /dev/null
@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <Import Project="../build/build.props" />
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.3</TargetFramework>
+    <Version>1.5.8</Version>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Applications.ToastMessage.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.snk b/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.snk
new file mode 100755 (executable)
index 0000000..7ac1b00
Binary files /dev/null and b/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.snk differ
diff --git a/src/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessage.cs b/src/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessage.cs
new file mode 100755 (executable)
index 0000000..fd136b1
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// The class helps you create and show ToastMessage which is a view quick message for the user
+    /// </summary>
+    public sealed class ToastMessage
+    {
+
+        /// <summary>
+        /// Gets and sets message to post ToastMessage
+        /// </summary>
+        public string Message { get; set; }
+
+        /// <summary>
+        /// Posts a message on a toast popup
+        /// </summary>
+        /// <exception cref="ArgumentNullException">Thrown when Message is null</exception>
+        /// <example>
+        /// <code>
+        /// ToastMessage toast = new ToastMessage
+        /// {
+        ///     Message = "Hello TIzen"
+        /// };
+        /// toast.Post();
+        /// </code>
+        /// </example>
+        public void Post()
+        {
+            int ret = Interop.ToastMessage.ToastMessagePost(Message);
+            if (ret != (int)ToastMessageError.None)
+            {
+                throw ToastMessageErrorFactory.GetException((ToastMessageError)ret, "post toast message failed");
+            }
+        }
+    }
+
+}
diff --git a/src/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessageErrorFactory.cs b/src/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessageErrorFactory.cs
new file mode 100755 (executable)
index 0000000..cd2eebc
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+    internal enum ToastMessageError
+    {
+        None = Tizen.Internals.Errors.ErrorCode.None,
+        InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+        DBusError = -0x01140000 | 0x03,
+    }
+
+    internal class ToastMessageErrorFactory
+    {
+        private const string _logTag = "Tizen.Applications.ToastMessage";
+
+        internal static Exception GetException(ToastMessageError ret, string msg)
+        {
+            switch (ret)
+            {
+                case ToastMessageError.InvalidParameter:
+                    Log.Error(_logTag, msg);
+                    return new ArgumentException(ret + " error occurred.");
+                default:
+                    Log.Error(_logTag, msg);
+                    return new InvalidOperationException(ret + " error occurred.");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Applications.UI/Interop/Interop.Application.cs b/src/Tizen.Applications.UI/Interop/Interop.Application.cs
new file mode 100755 (executable)
index 0000000..177bfea
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Applications.CoreBackend;
+using Tizen.Internals.Errors;
+
+internal static partial class Interop
+{
+    internal static partial class Application
+    {
+        internal delegate void AppEventCallback(IntPtr handle, IntPtr data);
+
+        internal delegate bool AppCreateCallback(IntPtr userData);
+
+        internal delegate void AppPauseCallback(IntPtr userData);
+
+        internal delegate void AppResumeCallback(IntPtr userData);
+
+        internal delegate void AppTerminateCallback(IntPtr userData);
+
+        internal delegate void AppControlCallback(IntPtr appControl, IntPtr userData);
+
+        [DllImport(Libraries.Application, EntryPoint = "ui_app_main")]
+        internal static extern ErrorCode Main(int argc, string[] argv, ref UIAppLifecycleCallbacks callback, IntPtr userData);
+
+        [DllImport(Libraries.Application, EntryPoint = "ui_app_exit")]
+        internal static extern void Exit();
+
+        [DllImport(Libraries.Application, EntryPoint = "ui_app_add_event_handler")]
+        internal static extern ErrorCode AddEventHandler(out IntPtr handle, DefaultCoreBackend.AppEventType eventType, AppEventCallback callback, IntPtr data);
+
+        [DllImport(Libraries.Application, EntryPoint = "ui_app_remove_event_handler")]
+        internal static extern ErrorCode RemoveEventHandler(IntPtr handle);
+
+        [StructLayout(LayoutKind.Sequential)]
+        internal struct UIAppLifecycleCallbacks
+        {
+            public AppCreateCallback OnCreate;
+            public AppTerminateCallback OnTerminate;
+            public AppPauseCallback OnPause;
+            public AppResumeCallback OnResume;
+            public AppControlCallback OnAppControl;
+        }
+    }
+}
+
diff --git a/src/Tizen.Applications.UI/Interop/Interop.Libraries.cs b/src/Tizen.Applications.UI/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..03047b1
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string Application = "libcapi-appfw-application.so.0";
+    }
+}
diff --git a/src/Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs b/src/Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs
new file mode 100755 (executable)
index 0000000..933a4e0
--- /dev/null
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+using Tizen.Internals.Errors;
+
+namespace Tizen.Applications.CoreBackend
+{
+    internal class UICoreBackend : DefaultCoreBackend
+    {
+        private Interop.Application.UIAppLifecycleCallbacks _callbacks;
+        private IntPtr _lowMemoryEventHandle = IntPtr.Zero;
+        private IntPtr _lowBatteryEventHandle = IntPtr.Zero;
+        private IntPtr _localeChangedEventHandle = IntPtr.Zero;
+        private IntPtr _regionChangedEventHandle = IntPtr.Zero;
+        private IntPtr _deviceOrientationChangedEventHandle = IntPtr.Zero;
+        private bool _disposedValue = false;
+        private Interop.Application.AppEventCallback _onLowMemoryNative;
+        private Interop.Application.AppEventCallback _onLowBatteryNative;
+        private Interop.Application.AppEventCallback _onLocaleChangedNative;
+        private Interop.Application.AppEventCallback _onRegionChangedNative;
+        private Interop.Application.AppEventCallback _onDeviceOrientationChangedNative;
+
+        public UICoreBackend()
+        {
+            _callbacks.OnCreate = new Interop.Application.AppCreateCallback(OnCreateNative);
+            _callbacks.OnTerminate = new Interop.Application.AppTerminateCallback(OnTerminateNative);
+            _callbacks.OnAppControl = new Interop.Application.AppControlCallback(OnAppControlNative);
+            _callbacks.OnResume = new Interop.Application.AppResumeCallback(OnResumeNative);
+            _callbacks.OnPause = new Interop.Application.AppPauseCallback(OnPauseNative);
+
+            _onLowMemoryNative = new Interop.Application.AppEventCallback(OnLowMemoryNative);
+            _onLowBatteryNative = new Interop.Application.AppEventCallback(OnLowBatteryNative);
+            _onLocaleChangedNative = new Interop.Application.AppEventCallback(OnLocaleChangedNative);
+            _onRegionChangedNative = new Interop.Application.AppEventCallback(OnRegionChangedNative);
+            _onDeviceOrientationChangedNative = new Interop.Application.AppEventCallback(OnDeviceOrientationChangedNative);
+        }
+
+        public override void Exit()
+        {
+            Interop.Application.Exit();
+        }
+
+        public override void Run(string[] args)
+        {
+            base.Run(args);
+
+            ErrorCode err = ErrorCode.None;
+            err = Interop.Application.AddEventHandler(out _lowMemoryEventHandle, AppEventType.LowMemory, _onLowMemoryNative, IntPtr.Zero);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to add event handler for LowMemory event. Err = " + err);
+            }
+            err = Interop.Application.AddEventHandler(out _lowBatteryEventHandle, AppEventType.LowBattery, _onLowBatteryNative, IntPtr.Zero);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to add event handler for LowBattery event. Err = " + err);
+            }
+
+            err = Interop.Application.AddEventHandler(out _localeChangedEventHandle, AppEventType.LanguageChanged, _onLocaleChangedNative, IntPtr.Zero);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to add event handler for LocaleChanged event. Err = " + err);
+            }
+
+            err = Interop.Application.AddEventHandler(out _regionChangedEventHandle, AppEventType.RegionFormatChanged, _onRegionChangedNative, IntPtr.Zero);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to add event handler for RegionFormatChanged event. Err = " + err);
+            }
+
+            err = Interop.Application.AddEventHandler(out _deviceOrientationChangedEventHandle, AppEventType.DeviceOrientationChanged, _onDeviceOrientationChangedNative, IntPtr.Zero);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to add event handler for DeviceOrientationChanged event. Err = " + err);
+            }
+
+            err = Interop.Application.Main(args.Length, args, ref _callbacks, IntPtr.Zero);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to run the application. Err = " + err);
+            }
+        }
+
+        protected override void Dispose(bool disposing)
+        {
+            if (!_disposedValue)
+            {
+                if (disposing)
+                {
+                    // Release disposable objects
+                }
+
+                if (_lowMemoryEventHandle != IntPtr.Zero)
+                {
+                    Interop.Application.RemoveEventHandler(_lowMemoryEventHandle);
+                }
+                if (_lowBatteryEventHandle != IntPtr.Zero)
+                {
+                    Interop.Application.RemoveEventHandler(_lowBatteryEventHandle);
+                }
+                if (_localeChangedEventHandle != IntPtr.Zero)
+                {
+                    Interop.Application.RemoveEventHandler(_localeChangedEventHandle);
+                }
+                if (_regionChangedEventHandle != IntPtr.Zero)
+                {
+                    Interop.Application.RemoveEventHandler(_regionChangedEventHandle);
+                }
+                if (_deviceOrientationChangedEventHandle != IntPtr.Zero)
+                {
+                    Interop.Application.RemoveEventHandler(_deviceOrientationChangedEventHandle);
+                }
+
+                _disposedValue = true;
+            }
+        }
+
+        private bool OnCreateNative(IntPtr data)
+        {
+            if (Handlers.ContainsKey(EventType.PreCreated))
+            {
+                var handler = Handlers[EventType.PreCreated] as Action;
+                handler?.Invoke();
+            }
+
+            if (Handlers.ContainsKey(EventType.Created))
+            {
+                var handler = Handlers[EventType.Created] as Action;
+                handler?.Invoke();
+            }
+            return true;
+        }
+
+        private void OnTerminateNative(IntPtr data)
+        {
+            if (Handlers.ContainsKey(EventType.Terminated))
+            {
+                var handler = Handlers[EventType.Terminated] as Action;
+                handler?.Invoke();
+            }
+        }
+
+        private void OnAppControlNative(IntPtr appControlHandle, IntPtr data)
+        {
+            if (Handlers.ContainsKey(EventType.AppControlReceived))
+            {
+                // Create a SafeAppControlHandle but the ownsHandle is false,
+                // because the appControlHandle will be closed by native appfw after this method automatically.
+                SafeAppControlHandle safeHandle = new SafeAppControlHandle(appControlHandle, false);
+
+                var handler = Handlers[EventType.AppControlReceived] as Action<AppControlReceivedEventArgs>;
+                handler?.Invoke(new AppControlReceivedEventArgs(new ReceivedAppControl(safeHandle)));
+            }
+        }
+
+        private void OnResumeNative(IntPtr data)
+        {
+            if (Handlers.ContainsKey(EventType.Resumed))
+            {
+                var handler = Handlers[EventType.Resumed] as Action;
+                handler?.Invoke();
+            }
+        }
+
+        private void OnPauseNative(IntPtr data)
+        {
+            if (Handlers.ContainsKey(EventType.Paused))
+            {
+                var handler = Handlers[EventType.Paused] as Action;
+                handler?.Invoke();
+            }
+        }
+
+        protected override void OnLowMemoryNative(IntPtr infoHandle, IntPtr data)
+        {
+            base.OnLowMemoryNative(infoHandle, data);
+        }
+
+        protected override void OnLowBatteryNative(IntPtr infoHandle, IntPtr data)
+        {
+            base.OnLowBatteryNative(infoHandle, data);
+        }
+
+        protected override void OnLocaleChangedNative(IntPtr infoHandle, IntPtr data)
+        {
+            base.OnLocaleChangedNative(infoHandle, data);
+        }
+
+        protected override void OnRegionChangedNative(IntPtr infoHandle, IntPtr data)
+        {
+            base.OnRegionChangedNative(infoHandle, data);
+        }
+
+        protected override void OnDeviceOrientationChangedNative(IntPtr infoHandle, IntPtr data)
+        {
+            base.OnDeviceOrientationChangedNative(infoHandle, data);
+        }
+    }
+}
diff --git a/src/Tizen.Applications.UI/Tizen.Applications.UI.csproj b/src/Tizen.Applications.UI/Tizen.Applications.UI.csproj
new file mode 100755 (executable)
index 0000000..c293841
--- /dev/null
@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <Import Project="../build/build.props" />
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.3</TargetFramework>
+    <Version>1.5.8</Version>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Applications.UI.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Applications.UI/Tizen.Applications.UI.snk b/src/Tizen.Applications.UI/Tizen.Applications.UI.snk
new file mode 100755 (executable)
index 0000000..7ac1b00
Binary files /dev/null and b/src/Tizen.Applications.UI/Tizen.Applications.UI.snk differ
diff --git a/src/Tizen.Applications.UI/Tizen.Applications/CoreUIApplication.cs b/src/Tizen.Applications.UI/Tizen.Applications/CoreUIApplication.cs
new file mode 100755 (executable)
index 0000000..03256e7
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+using Tizen.Applications.CoreBackend;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Represents an application that have UI screen. The events for resuming and pausing are provided.
+    /// </summary>
+    public class CoreUIApplication : CoreApplication
+    {
+        /// <summary>
+        /// Initializes the CoreUIApplication class.
+        /// </summary>
+        /// <remarks>
+        /// Default backend for UI application will be used.
+        /// </remarks>
+        public CoreUIApplication() : base(new UICoreBackend())
+        {
+        }
+
+        /// <summary>
+        /// Initializes the CoreUIApplication class.
+        /// </summary>
+        /// <remarks>
+        /// If want to change the backend, use this constructor.
+        /// </remarks>
+        /// <param name="backend">The backend instance implementing ICoreBacked interface.</param>
+        public CoreUIApplication(ICoreBackend backend) : base(backend)
+        {
+        }
+
+        /// <summary>
+        /// Occurs whenever the application is resumed.
+        /// </summary>
+        public event EventHandler Resumed;
+
+        /// <summary>
+        /// Occurs whenever the application is paused.
+        /// </summary>
+        public event EventHandler Paused;
+
+        /// <summary>
+        /// Runs the UI application's main loop.
+        /// </summary>
+        /// <param name="args">Arguments from commandline.</param>
+        public override void Run(string[] args)
+        {
+            Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
+            Backend.AddEventHandler(EventType.Resumed, OnResume);
+            Backend.AddEventHandler(EventType.Paused, OnPause);
+            base.Run(args);
+        }
+
+        /// <summary>
+        /// Overrides this method if want to handle behavior before calling OnCreate().
+        /// </summary>
+        protected virtual void OnPreCreate()
+        {
+        }
+
+        /// <summary>
+        /// Overrides this method if want to handle behavior when the application is resumed.
+        /// If base.OnResume() is not called, the event 'Resumed' will not be emitted.
+        /// </summary>
+        protected virtual void OnResume()
+        {
+            Resumed?.Invoke(this, EventArgs.Empty);
+        }
+
+        /// <summary>
+        /// Overrides this method if want to handle behavior when the application is paused.
+        /// If base.OnPause() is not called, the event 'Paused' will not be emitted.
+        /// </summary>
+        protected virtual void OnPause()
+        {
+            Paused?.Invoke(this, EventArgs.Empty);
+        }
+    }
+}
diff --git a/src/Tizen.Context/Interop/Interop.AppHistory.cs b/src/Tizen.Context/Interop/Interop.AppHistory.cs
new file mode 100644 (file)
index 0000000..b6cdec2
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class CtxHistory
+    {
+        [DllImport(Library.AppHistory, EntryPoint = "ctx_history_query")]
+        internal static extern int Query(string uri, Int64 startTime, Int64 endTime, uint resultSize, out IntPtr cursor);
+
+        [DllImport(Library.AppHistory, EntryPoint = "ctx_history_is_supported")]
+        internal static extern int IsSupported(string subject, out bool supported);
+
+        [DllImport(Library.AppHistory, EntryPoint = "ctx_history_get_last_fully_charged_time")]
+        internal static extern int GetLastFullyChargedTime(out Int64 timestamp);
+
+    }
+    internal static partial class CtxHistoryCursor
+    {
+        [DllImport(Library.AppHistory, EntryPoint = "ctx_history_cursor_destroy")]
+        internal static extern void Destroy(IntPtr cursor);
+
+        [DllImport(Library.AppHistory, EntryPoint = "ctx_history_cursor_get_count")]
+        internal static extern int GetCount(IntPtr cursor, out int count);
+
+        [DllImport(Library.AppHistory, EntryPoint = "ctx_history_cursor_get_position")]
+        internal static extern int GetPosition(IntPtr cursor, out int position);
+
+        [DllImport(Library.AppHistory, EntryPoint = "ctx_history_cursor_set_position")]
+        internal static extern int SetPosition(IntPtr cursor, int position);
+
+        [DllImport(Library.AppHistory, EntryPoint = "ctx_history_cursor_first")]
+        internal static extern int First(IntPtr cursor);
+
+        [DllImport(Library.AppHistory, EntryPoint = "ctx_history_cursor_last")]
+        internal static extern int Last(IntPtr cursor);
+
+        [DllImport(Library.AppHistory, EntryPoint = "ctx_history_cursor_next")]
+        internal static extern int Next(IntPtr cursor);
+
+        [DllImport(Library.AppHistory, EntryPoint = "ctx_history_cursor_prev")]
+        internal static extern int Prev(IntPtr cursor);
+
+        [DllImport(Library.AppHistory, EntryPoint = "ctx_history_cursor_get_int64")]
+        internal static extern int GetInt64(IntPtr cursor, string key, out Int64 value);
+
+        [DllImport(Library.AppHistory, EntryPoint = "ctx_history_cursor_get_double")]
+        internal static extern int GetDouble(IntPtr cursor, string key, out double value);
+
+        [DllImport(Library.AppHistory, EntryPoint = "ctx_history_cursor_get_string")]
+        internal static extern int GetString(IntPtr cursor, string key, out string value);
+    }
+}
diff --git a/src/Tizen.Context/Interop/Interop.Libraries.cs b/src/Tizen.Context/Interop/Interop.Libraries.cs
new file mode 100644 (file)
index 0000000..8970f55
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Library
+    {
+        public const string AppHistory = "libcontext-app-history-client.so.4";
+    }
+}
diff --git a/src/Tizen.Context/Tizen.Context.AppHistory/AppHistoryErrorFactory.cs b/src/Tizen.Context/Tizen.Context.AppHistory/AppHistoryErrorFactory.cs
new file mode 100644 (file)
index 0000000..d990828
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Context.AppHistory
+{
+    internal enum AppHistoryError
+    {
+        None = ErrorCode.None,
+        InvalidParameter = ErrorCode.InvalidParameter,
+        OutOfMemory = ErrorCode.OutOfMemory,
+        PermissionDenied = ErrorCode.PermissionDenied,
+        NotSupported = ErrorCode.NotSupported,
+        NoData = ErrorCode.NoData,
+        OperationFailed = -0x02480000 | 0x04,
+    }
+
+    internal static class AppHistoryErrorFactory
+    {
+        internal const string LogTag = "Tizen.Context.AppHistory";
+
+        internal static Exception CheckAndThrowException(AppHistoryError error, string msg)
+        {
+            switch (error)
+            {
+                case AppHistoryError.None:
+                    return null;
+                case AppHistoryError.InvalidParameter:
+                    return new ArgumentException("Invalid Parameter: " + msg);
+                case AppHistoryError.OutOfMemory:
+                    return new OutOfMemoryException("Out of Memory: " + msg);
+                case AppHistoryError.PermissionDenied:
+                    return new UnauthorizedAccessException("Permission Denied: " + msg);
+                case AppHistoryError.NotSupported:
+                    return new NotSupportedException("Not Supported: " + msg);
+                case AppHistoryError.OperationFailed:
+                    return new InvalidOperationException("Operation Failed: " + msg);
+                default:
+                    return new InvalidOperationException("Unknown Error Code: " + msg);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Context/Tizen.Context.AppHistory/AppStatistics.cs b/src/Tizen.Context/Tizen.Context.AppHistory/AppStatistics.cs
new file mode 100644 (file)
index 0000000..c25b493
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Context.AppHistory
+{
+    /// <summary>
+    /// Base class for application statistics.
+    /// </summary>
+    public abstract class AppStatistics
+    {
+        internal const string AppStatsQueryResult = "QueryResult";
+        internal const string AppStatsStartTime = "StartTime";
+        internal const string AppStatsEndTime = "EndTime";
+        internal const string AppStatsResultSize = "ResultSize";
+        internal const string AppStatsAppId = "AppId";
+        internal const int DefaultResultSize = 5;
+
+        internal string Uri;
+
+        internal AppStatistics()
+        {
+        }
+
+        internal static long ConvertDateTimeToUnixTimestamp(DateTime dateTime)
+        {
+            DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
+            long unixTimestampInTicks = (dateTime.ToUniversalTime() - unixStart).Ticks;
+            return unixTimestampInTicks / TimeSpan.TicksPerSecond;
+        }
+
+        internal static DateTime ConvertUnixTimestampToDateTime(long unixTime)
+        {
+            DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
+            long unixTimeStampInTicks = unixTime * TimeSpan.TicksPerSecond;
+            return new DateTime(unixStart.Ticks + unixTimeStampInTicks, System.DateTimeKind.Utc).ToLocalTime();
+        }
+
+        internal static void CheckTimeSpan(DateTime startTime, DateTime endTime)
+        {
+            if (startTime > endTime)
+            {
+                Log.Error(AppHistoryErrorFactory.LogTag, "endTime should be greater than startTime");
+                throw AppHistoryErrorFactory.CheckAndThrowException(AppHistoryError.InvalidParameter, "endTime should be greater than startTime");
+            }
+        }
+
+        internal static void CheckResultSize(uint resultSize)
+        {
+            if (resultSize <= 0)
+            {
+                Log.Error(AppHistoryErrorFactory.LogTag, "resultSize should be greater than 0");
+                throw AppHistoryErrorFactory.CheckAndThrowException(AppHistoryError.InvalidParameter, "resultSize should be greater than 0");
+            }
+        }
+
+        internal abstract string ConvertSortOrderToString(int order);
+    }
+}
diff --git a/src/Tizen.Context/Tizen.Context.AppHistory/AppStatisticsData.cs b/src/Tizen.Context/Tizen.Context.AppHistory/AppStatisticsData.cs
new file mode 100644 (file)
index 0000000..ed46f8c
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Context.AppHistory
+{
+    /// <summary>
+    /// Base class which contains application statistics query result.
+    /// </summary>
+    public abstract class AppStatisticsData
+    {
+        internal AppStatisticsData()
+        {
+        }
+
+        /// <summary>
+        /// Gets the application id.
+        /// </summary>
+        /// <value>The application id.</value>
+        public string AppId { get; protected set; }
+    }
+}
diff --git a/src/Tizen.Context/Tizen.Context.AppHistory/BatteryStatistics.cs b/src/Tizen.Context/Tizen.Context.AppHistory/BatteryStatistics.cs
new file mode 100644 (file)
index 0000000..f820525
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Context.AppHistory
+{
+    /// <summary>
+    /// This class provides APIs to query battery consumption per application.
+    /// </summary>
+    public class BatteryStatistics : AppStatistics
+    {
+        private const string AppStatsConsumption = "TotalAmount";
+
+        /// <summary>
+        ///  The default constructor of BatteryStatistics class.
+        /// </summary>
+        /// <feature>http://tizen.org/feature/battery</feature>
+        /// <exception cref="InvalidOperationException">Thrown when method fail due to internal error.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the statistics is not supported.</exception>
+        public BatteryStatistics()
+        {
+            SortOrder = SortOrderType.ConsumptionMost;
+            Uri = ConvertSortOrderToString((int)SortOrder);
+
+            bool isSupported = false;
+            int error = Interop.CtxHistory.IsSupported(Uri, out isSupported);
+            if ((AppHistoryError)error != AppHistoryError.None)
+            {
+                throw AppHistoryErrorFactory.CheckAndThrowException((AppHistoryError)error, Uri);
+            }
+
+            if (!isSupported)
+            {
+                throw AppHistoryErrorFactory.CheckAndThrowException(AppHistoryError.NotSupported, Uri);
+            }
+        }
+
+        /// <summary>
+        /// The constructor of BatteryStatistics class.
+        /// </summary>
+        /// <param name="order">The criteria of the battery statistics sorted by.</param>
+        /// <feature>http://tizen.org/feature/battery</feature>
+        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when method fail due to internal error.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the statistics is not supported.</exception>
+        public BatteryStatistics(SortOrderType order)
+        {
+            SortOrder = order;
+            Uri = ConvertSortOrderToString((int)SortOrder);
+
+            if (Uri == null)
+            {
+                throw AppHistoryErrorFactory.CheckAndThrowException(AppHistoryError.InvalidParameter, "Invalid SortOrderType");
+            }
+
+            bool isSupported = false;
+            int error = Interop.CtxHistory.IsSupported(Uri, out isSupported);
+            if ((AppHistoryError)error != AppHistoryError.None)
+            {
+                throw AppHistoryErrorFactory.CheckAndThrowException((AppHistoryError)error, Uri);
+            }
+
+            if (!isSupported)
+            {
+                throw AppHistoryErrorFactory.CheckAndThrowException(AppHistoryError.NotSupported, Uri);
+            }
+        }
+
+        /// <summary>
+        /// Retrieves a given type of battery statistics.
+        /// </summary>
+        /// <param name="startTime">The start time of the data to be aggregated.</param>
+        /// <param name="endTime">The end time of the data to be aggregated.</param>
+        /// <returns>Battery statistics data retrieved.</returns>
+        /// <privilege>http://tizen.org/privilege/apphistory.read</privilege>
+        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when invalid operation occurs.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when the app has no privilege to retrieve app history.</exception>
+        public IReadOnlyList<BatteryStatisticsData> Query(DateTime startTime, DateTime endTime)
+        {
+            CheckTimeSpan(startTime, endTime);
+
+            return Query(startTime, endTime, DefaultResultSize);
+        }
+
+        /// <summary>
+        /// Retrieves a given type of battery statistics.
+        /// </summary>
+        /// <param name="startTime">The start time of the data to be aggregated.</param>
+        /// <param name="endTime">The end time of the data to be aggregated.</param>
+        /// <param name="resultSize">The number of data records to be retrieved.</param>
+        /// <returns>Battery statistics data retrieved.</returns>
+        /// <privilege>http://tizen.org/privilege/apphistory.read</privilege>
+        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when invalid operation occurs.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when the app has no privilege to retrieve app history.</exception>
+        public IReadOnlyList<BatteryStatisticsData> Query(DateTime startTime, DateTime endTime, uint resultSize)
+        {
+            CheckTimeSpan(startTime, endTime);
+            CheckResultSize(resultSize);
+
+            List<BatteryStatisticsData> result = new List<BatteryStatisticsData>();
+
+            IntPtr cursor = IntPtr.Zero;
+            int error = Interop.CtxHistory.Query(Uri, (int)ConvertDateTimeToUnixTimestamp(startTime), (int)ConvertDateTimeToUnixTimestamp(endTime), resultSize, out cursor);
+            if ((AppHistoryError)error == AppHistoryError.NoData)
+            {
+                return result.AsReadOnly();
+            }
+            else if ((AppHistoryError)error != AppHistoryError.None)
+            {
+                Log.Error(AppHistoryErrorFactory.LogTag, "Failed to request query battery statistics");
+                throw AppHistoryErrorFactory.CheckAndThrowException((AppHistoryError)error, "Failed to request query battery statistics");
+            }
+
+            int size;
+            error = Interop.CtxHistoryCursor.GetCount(cursor, out size);
+            Interop.CtxHistoryCursor.First(cursor);
+
+            for (int i = 0; i < size; i++)
+            {
+                result.Add(ConvertOutputToStatsData(cursor));
+                Interop.CtxHistoryCursor.Next(cursor);
+            }
+            Interop.CtxHistoryCursor.Destroy(cursor);
+
+            return result.AsReadOnly();
+        }
+
+        /// <summary>
+        /// Gets the last time when the device was fully charged.
+        /// </summary>
+        /// <returns>The last time when the device was fully charged.</returns>
+        /// <feature>http://tizen.org/feature/battery</feature>
+        /// <exception cref="NotSupportedException">Thrown when the statistics is not supported.</exception>
+        public static DateTime GetLastFullyChargedTime()
+        {
+            Int64 timestamp;
+            int error = Interop.CtxHistory.GetLastFullyChargedTime(out timestamp);
+            if ((AppHistoryError)error != AppHistoryError.None)
+            {
+                Log.Error(AppHistoryErrorFactory.LogTag, "Failed to request get last fully charged time");
+                throw AppHistoryErrorFactory.CheckAndThrowException((AppHistoryError)error, "Failed to request get last fully charged time");
+            }
+
+            return ConvertUnixTimestampToDateTime(timestamp);
+        }
+
+        internal override string ConvertSortOrderToString(int order)
+        {
+            switch ((SortOrderType)order)
+            {
+                case SortOrderType.ConsumptionMost:
+                    return "stats/battery/history";
+                default:
+                    return null;
+            }
+        }
+
+        private static BatteryStatisticsData ConvertOutputToStatsData(IntPtr cursor)
+        {
+            string appId;
+            double consumption;
+
+            Interop.CtxHistoryCursor.GetString(cursor, AppStatsAppId, out appId);
+            Interop.CtxHistoryCursor.GetDouble(cursor, AppStatsConsumption, out consumption);
+
+            return new BatteryStatisticsData(appId, consumption);
+        }
+
+        /// <summary>
+        /// Gets the criteria of battery statistics sorted by.
+        /// </summary>
+        /// <value>The criteria of battery statistics sorted by.</value>
+        public SortOrderType SortOrder { get; private set; }
+
+        /// <summary>
+        /// Sort order type of battery statistics.
+        /// </summary>
+        public enum SortOrderType
+        {
+            /// <summary>
+            /// Sorts apps by consumption, the most battery consuming apps appear first. (Default)
+            /// </summary>
+            ConsumptionMost = 0
+        }
+    }
+}
diff --git a/src/Tizen.Context/Tizen.Context.AppHistory/BatteryStatisticsData.cs b/src/Tizen.Context/Tizen.Context.AppHistory/BatteryStatisticsData.cs
new file mode 100644 (file)
index 0000000..9dd6e4c
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Context.AppHistory
+{
+    /// <summary>
+    /// The class contains battery statistics information retrieved by BatteryStatistics.
+    /// </summary>
+    public class BatteryStatisticsData : AppStatisticsData
+    {
+        internal BatteryStatisticsData(string appId, double consumption)
+        {
+            AppId = appId;
+            Consumption = consumption;
+        }
+
+        /// <summary>
+        /// Gets how many percentage of battery capacity was used by the application.
+        /// </summary>
+        /// <value>Battery consumption used by the application.</value>
+        public double Consumption { get; private set; }
+    }
+}
diff --git a/src/Tizen.Context/Tizen.Context.AppHistory/UsageStatistics.cs b/src/Tizen.Context/Tizen.Context.AppHistory/UsageStatistics.cs
new file mode 100644 (file)
index 0000000..a23d820
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Context.AppHistory
+{
+    /// <summary>
+    /// This class provides APIs to query application launch history.
+    /// </summary>
+    public class UsageStatistics : AppStatistics
+    {
+        private const string AppStatsDuration = "TotalDuration";
+        private const string AppStatsLaunchCount = "TotalCount";
+        private const string AppStatsLastLaunchTime = "LastTime";
+
+        /// <summary>
+        /// The default constructor of UsageStatistics class.
+        /// </summary>
+        /// <exception cref="InvalidOperationException">Thrown when method fail due to internal error.</exception>
+        public UsageStatistics()
+        {
+            SortOrder = SortOrderType.LastLaunchTimeNewest;
+            Uri = ConvertSortOrderToString((int)SortOrder);
+
+            bool isSupported = false;
+            int error = Interop.CtxHistory.IsSupported(Uri, out isSupported);
+            if ((AppHistoryError)error != AppHistoryError.None)
+            {
+                throw AppHistoryErrorFactory.CheckAndThrowException((AppHistoryError)error, Uri);
+            }
+
+            if (!isSupported)
+            {
+                throw AppHistoryErrorFactory.CheckAndThrowException(AppHistoryError.OperationFailed, Uri);
+            }
+        }
+
+        /// <summary>
+        /// The constructor of UsageStatistics class.
+        /// </summary>
+        /// <param name="order">The criteria of the usage statistics sorted by.</param>
+        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when method fail due to internal error.</exception>
+        public UsageStatistics(SortOrderType order)
+        {
+            SortOrder = order;
+            Uri = ConvertSortOrderToString((int)SortOrder);
+
+            if (Uri== null)
+            {
+                throw AppHistoryErrorFactory.CheckAndThrowException(AppHistoryError.InvalidParameter, "Invalid SortOrderType");
+            }
+
+            bool isSupported = false;
+            int error = Interop.CtxHistory.IsSupported(Uri, out isSupported);
+            if ((AppHistoryError)error != AppHistoryError.None)
+            {
+                throw AppHistoryErrorFactory.CheckAndThrowException((AppHistoryError)error, Uri);
+            }
+
+            if (!isSupported)
+            {
+                throw AppHistoryErrorFactory.CheckAndThrowException(AppHistoryError.OperationFailed, Uri);
+            }
+        }
+
+        /// <summary>
+        /// Retrieves a given type of usage statistics.
+        /// </summary>
+        /// <param name="startTime">The start time of the data to be aggregated.</param>
+        /// <param name="endTime">The end time of the data to be aggregated.</param>
+        /// <returns>Usage statistics data retrieved.</returns>
+        /// <privilege>http://tizen.org/privilege/apphistory.read</privilege>
+        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when invalid operation occurs.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when the app has no privilege to retrieve app history.</exception>
+        public IReadOnlyList<UsageStatisticsData> Query(DateTime startTime, DateTime endTime)
+        {
+            CheckTimeSpan(startTime, endTime);
+
+            return Query(startTime, endTime, DefaultResultSize);
+        }
+
+        /// <summary>
+        /// Retrieves a given type of usage statistics.
+        /// </summary>
+        /// <param name="startTime">The start time of the data to be aggregated.</param>
+        /// <param name="endTime">The end time of the data to be aggregated.</param>
+        /// <param name="resultSize">The number of data records to be retrieved.</param>
+        /// <returns>Usage statistics data retrieved.</returns>
+        /// <privilege>http://tizen.org/privilege/apphistory.read</privilege>
+        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when invalid operation occurs.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when the app has no privilege to retrieve app history.</exception>
+        public IReadOnlyList<UsageStatisticsData> Query(DateTime startTime, DateTime endTime, uint resultSize)
+        {
+            CheckTimeSpan(startTime, endTime);
+            CheckResultSize(resultSize);
+
+            List<UsageStatisticsData> result = new List<UsageStatisticsData>();
+
+            IntPtr cursor = IntPtr.Zero;
+            int error = Interop.CtxHistory.Query(Uri, ConvertDateTimeToUnixTimestamp(startTime), ConvertDateTimeToUnixTimestamp(endTime), resultSize, out cursor);
+            if ((AppHistoryError)error == AppHistoryError.NoData)
+            {
+                return result.AsReadOnly();
+            } else if ((AppHistoryError)error != AppHistoryError.None)
+            {
+                Log.Error(AppHistoryErrorFactory.LogTag, "Failed to request query usage statistics");
+                throw AppHistoryErrorFactory.CheckAndThrowException((AppHistoryError)error, "Failed to request query usage statistics");
+            }
+
+            int size;
+            error = Interop.CtxHistoryCursor.GetCount(cursor, out size);
+            Interop.CtxHistoryCursor.First(cursor);
+
+            for (int i = 0; i < size; i++)
+            {
+                result.Add(ConvertOutputToStatsData(cursor));
+                Interop.CtxHistoryCursor.Next(cursor);
+            }
+            Interop.CtxHistoryCursor.Destroy(cursor);
+
+            return result.AsReadOnly();
+        }
+
+        internal override string ConvertSortOrderToString(int order)
+        {
+            switch ((SortOrderType)order)
+            {
+                case SortOrderType.LastLaunchTimeNewest:
+                    return "stats/app/recently";
+                case SortOrderType.LaunchCountMost:
+                    return "stats/app/often";
+                default:
+                    return null;
+            }
+        }
+
+        private static UsageStatisticsData ConvertOutputToStatsData(IntPtr cursor)
+        {
+            string appId;
+            Int64 duration = 1;
+            Int64 launchCount = 1;
+            Int64 lastLaunchTime;
+
+            Interop.CtxHistoryCursor.GetString(cursor, AppStatsAppId, out appId);
+            Interop.CtxHistoryCursor.GetInt64(cursor, AppStatsDuration, out duration);
+            Interop.CtxHistoryCursor.GetInt64(cursor, AppStatsLaunchCount, out launchCount);
+            Interop.CtxHistoryCursor.GetInt64(cursor, AppStatsLastLaunchTime, out lastLaunchTime);
+
+            return new UsageStatisticsData(appId, (int)duration, (int)launchCount, ConvertUnixTimestampToDateTime(lastLaunchTime));
+        }
+
+        /// <summary>
+        /// Gets the criteria of usage statistics sorted by.
+        /// </summary>
+        /// <value>The criteria of usage statistics sorted by.</value>
+        public SortOrderType SortOrder { get; private set; }
+
+        /// <summary>
+        /// Sort order type of usage statistics
+        /// </summary>
+        public enum SortOrderType
+        {
+            /// <summary>
+            /// Sorts apps by the last launch time, the most recently launched apps appear first. (Default)
+            /// </summary>
+            LastLaunchTimeNewest = 0,
+            /// <summary>
+            /// Sorts apps by the launch count of being launched, the most frequently launched apps appear first.
+            /// </summary>
+            LaunchCountMost
+        }
+    }
+}
diff --git a/src/Tizen.Context/Tizen.Context.AppHistory/UsageStatisticsData.cs b/src/Tizen.Context/Tizen.Context.AppHistory/UsageStatisticsData.cs
new file mode 100644 (file)
index 0000000..c090e90
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Context.AppHistory
+{
+    /// <summary>
+    /// The class contains application usage statistics information retrieved by UsageStatistics.
+    /// </summary>
+    public class UsageStatisticsData : AppStatisticsData
+    {
+        internal UsageStatisticsData(string appId, int duration, int launchCount, DateTime lastLaunchTime)
+        {
+            AppId = appId;
+            Duration = duration;
+            LaunchCount = launchCount;
+            LastLaunchTime = lastLaunchTime;
+        }
+
+        /// <summary>
+        ///  Gets the time which the application is being displayed in the foreground in seconds.
+        /// </summary>
+        /// <value>Duration which the application is used in the foreground in seconds.</value>
+        public int Duration { get; private set; }
+
+        /// <summary>
+        ///  Gets how many times the application is used in the foreground.
+        /// </summary>
+        /// <value>How many times the application is used in the foreground.</value>
+        public int LaunchCount { get; private set; }
+
+        /// <summary>
+        /// Gets the last time when the application has been used.
+        /// </summary>
+        /// <value>The last time when the application has been used.</value>
+        public DateTime LastLaunchTime { get; private set; }
+    }
+}
diff --git a/src/Tizen.Context/Tizen.Context.csproj b/src/Tizen.Context/Tizen.Context.csproj
new file mode 100644 (file)
index 0000000..5fae570
--- /dev/null
@@ -0,0 +1,25 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+  <Version>1.0.0</Version>
+    <Authors>Samsung Electronics</Authors>
+    <Copyright>© Samsung Electronics Co., Ltd All Rights Reserved</Copyright>
+    <Description>Provides the Context APIs for Tizen .NET</Description>
+    <PackageProjectUrl>https://www.tizen.org/</PackageProjectUrl>
+    <PackageLicenseUrl>https://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
+    <PackageIconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</PackageIconUrl>
+  </PropertyGroup>
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.3</TargetFramework>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Context.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Tizen" Version="1.0.5" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Context/Tizen.Context.snk b/src/Tizen.Context/Tizen.Context.snk
new file mode 100644 (file)
index 0000000..51400f9
Binary files /dev/null and b/src/Tizen.Context/Tizen.Context.snk differ
diff --git a/src/Tizen.Convergence/Interop/Interop.Common.cs b/src/Tizen.Convergence/Interop/Interop.Common.cs
new file mode 100755 (executable)
index 0000000..bad120b
--- /dev/null
@@ -0,0 +1,41 @@
+// Copyright 2016 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal abstract class TizenSafeHandle : SafeHandle
+    {
+        public abstract void Destroy();
+
+        public TizenSafeHandle() : base(IntPtr.Zero, true)
+        {
+        }
+
+        public TizenSafeHandle(IntPtr handle) : base(handle, true)
+        {
+        }
+
+        public override bool IsInvalid
+        {
+            get
+            {
+                return handle == IntPtr.Zero;
+            }
+        }
+
+        protected override bool ReleaseHandle()
+        {
+            Destroy();
+            SetHandle(IntPtr.Zero);
+            return true;
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Interop/Interop.Internal.Conv.Channel.cs b/src/Tizen.Convergence/Interop/Interop.Internal.Conv.Channel.cs
new file mode 100755 (executable)
index 0000000..4a8a282
--- /dev/null
@@ -0,0 +1,67 @@
+// Copyright 2016 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen;
+using Tizen.Convergence;
+
+internal static partial class Interop
+{
+    internal static partial class Internal
+    {
+        internal static partial class ConvChannel
+        {
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_channel_create")]
+            internal static extern int Create(out ConvChannelHandle /* conv_channel_h */ handle);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_channel_destroy")]
+            internal static extern int Destroy(IntPtr /* conv_channel_h */ handle);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_channel_get_string")]
+            internal static extern int GetString(ConvChannelHandle /* conv_channel_h */ handle, string key, out IntPtr value);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_channel_set_string")]
+            internal static extern int SetString(ConvChannelHandle /* conv_channel_h */ handle, string key, string value);
+        }
+
+        internal class ConvChannelHandle : TizenSafeHandle
+        {
+            private bool _ownsHandle = true;
+
+            public ConvChannelHandle(): base()
+            {
+
+            }
+
+            public ConvChannelHandle(IntPtr handle)
+                : base(handle)
+            {
+            }
+
+            public ConvChannelHandle(IntPtr handle, bool ownsHandle)
+                : base(handle)
+            {
+                _ownsHandle = ownsHandle;
+            }
+
+            public override void Destroy()
+            {
+                if (_ownsHandle && handle != IntPtr.Zero)
+                {
+                    var err = ConvChannel.Destroy(this.handle);
+                    if (err != (int)ConvErrorCode.None)
+                    {
+                        Log.Error(ErrorFactory.LogTag, "Failed to destroy conv channel handle");
+                        throw ErrorFactory.GetException(err);
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Interop/Interop.Internal.Conv.Device.cs b/src/Tizen.Convergence/Interop/Interop.Internal.Conv.Device.cs
new file mode 100755 (executable)
index 0000000..cbee849
--- /dev/null
@@ -0,0 +1,62 @@
+// Copyright 2016 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen;
+using Tizen.Convergence;
+
+internal static partial class Interop
+{
+    internal static partial class Internal
+    {
+        internal static partial class ConvDevice
+        {
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_device_clone")]
+            internal static extern int Clone(IntPtr /* conv_device_h */ originalHandle, out ConvDeviceHandle /* conv_device_h */ targetHandle);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_device_destroy")]
+            internal static extern int Destroy(IntPtr /* conv_device_h */ handle);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_device_get_property_string")]
+            internal static extern int GetPropertyString(ConvDeviceHandle /* conv_device_h */ handle, string key, out IntPtr value);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_device_foreach_service")]
+            internal static extern int ForeachService(ConvDeviceHandle /* conv_device_h */ handle, ConvServiceForeachCallback cb, IntPtr /* void */ userData);
+
+            [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+            internal delegate void ConvServiceForeachCallback(IntPtr serviceHandle, IntPtr /* void */ userData);
+        }
+
+        internal class ConvDeviceHandle : TizenSafeHandle
+        {
+            public ConvDeviceHandle() : base()
+            {
+
+            }
+
+            public ConvDeviceHandle(IntPtr handle)
+                : base(handle)
+            {
+            }
+
+            public override void Destroy()
+            {
+                if (handle != IntPtr.Zero)
+                {
+                    var err = ConvDevice.Destroy(this.handle);
+                    if (err != (int)ConvErrorCode.None)
+                    {
+                        Log.Error(ErrorFactory.LogTag, "Failed to destroy conv device handle");
+                        throw ErrorFactory.GetException(err);
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Interop/Interop.Internal.Conv.Manager.cs b/src/Tizen.Convergence/Interop/Interop.Internal.Conv.Manager.cs
new file mode 100755 (executable)
index 0000000..cfdc9e5
--- /dev/null
@@ -0,0 +1,79 @@
+// Copyright 2016 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen;
+using Tizen.Convergence;
+
+internal static partial class Interop
+{
+    internal static partial class Internal
+    {
+        public enum ConvDiscoveryResult
+        {
+            /// <summary>
+            /// Discovery Error
+            /// </summary>
+            Error = -1,
+            /// <summary>
+            /// Discovery Success
+            /// </summary>
+            Success = 0,
+            /// <summary>
+            /// Discovery finished
+            /// </summary>
+            Finished,
+            /// <summary>
+            /// Discovery lost
+            /// </summary>
+            Lost,
+        }
+
+        internal static partial class ConvManager
+        {
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_create")]
+            internal static extern int ConvCreate(out ConvManagerHandle /* conv_h */ handle);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_destroy")]
+            internal static extern int ConvDestroy(IntPtr /* conv_h */ handle);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_discovery_start")]
+            internal static extern int ConvDiscoveryStart(ConvManagerHandle /* conv_h */ handle, int timeoutSeconds, ConvDiscoveryCallback callback, IntPtr /* void */ userData);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_discovery_stop")]
+            internal static extern int ConvDiscoveryStop(ConvManagerHandle /* conv_h */ handle);
+
+            [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+            internal delegate void ConvDiscoveryCallback(IntPtr /* conv_device_h */ deviceHandle, ConvDiscoveryResult /* conv_discovery_result_e */ result, IntPtr /* void */ userData);
+        }
+
+        internal class ConvManagerHandle : TizenSafeHandle
+        {
+            public ConvManagerHandle() : base()
+            {
+
+            }
+
+            public ConvManagerHandle(IntPtr handle)
+                : base(handle)
+            {
+            }
+
+            public override void Destroy()
+            {
+                var err = ConvManager.ConvDestroy(this.handle);
+                if (err != (int)ConvErrorCode.None)
+                {
+                    Log.Error(ErrorFactory.LogTag, "Failed to destroy conv manager handle");
+                    throw ErrorFactory.GetException(err);
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Convergence/Interop/Interop.Internal.Conv.Payload.cs b/src/Tizen.Convergence/Interop/Interop.Internal.Conv.Payload.cs
new file mode 100755 (executable)
index 0000000..902e5e0
--- /dev/null
@@ -0,0 +1,79 @@
+// Copyright 2016 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen;
+using Tizen.Convergence;
+
+internal static partial class Interop
+{
+    internal static partial class Internal
+    {
+        internal static partial class ConvPayload
+        {
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_create")]
+            internal static extern int Create(out ConvPayloadHandle /* conv_payload_h */ handle);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_destroy")]
+            internal static extern int Destroy(IntPtr /* conv_payload_h */ handle);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_set_string")]
+            internal static extern int SetString(ConvPayloadHandle /* conv_payload_h */ handle, string key, string value);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_get_string")]
+            internal static extern int GetString(ConvPayloadHandle /* conv_payload_h */ handle, string key, out IntPtr value);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_set_byte")]
+            internal static extern int SetByte(ConvPayloadHandle /* conv_payload_h */ handle, string key, int length, byte[] value);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_get_byte")]
+            internal static extern int GetByte(ConvPayloadHandle /* conv_payload_h */ handle, string key, out int length, out IntPtr value);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_set_binary")]
+            internal static extern int SetBinary(ConvPayloadHandle /* conv_payload_h */ handle, int length, byte[] value);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_get_binary")]
+            internal static extern int GetBinary(ConvPayloadHandle /* conv_payload_h */ handle, out int length, out IntPtr value);
+        }
+
+        internal class ConvPayloadHandle : TizenSafeHandle
+        {
+            private bool _ownsHandle = true;
+
+            public ConvPayloadHandle(): base()
+            {
+
+            }
+
+            public ConvPayloadHandle(IntPtr handle)
+                : base(handle)
+            {
+            }
+
+            public ConvPayloadHandle(IntPtr handle, bool ownsHandle)
+                : base(handle)
+            {
+                _ownsHandle = ownsHandle;
+            }
+
+            public override void Destroy()
+            {
+                if (_ownsHandle && handle != IntPtr.Zero)
+                {
+                    var err = ConvPayload.Destroy(this.handle);
+                    if (err != (int)ConvErrorCode.None)
+                    {
+                        Log.Error(ErrorFactory.LogTag, "Failed to destroy conv payload handle");
+                        throw ErrorFactory.GetException(err);
+                    }
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Convergence/Interop/Interop.Internal.Conv.Service.cs b/src/Tizen.Convergence/Interop/Interop.Internal.Conv.Service.cs
new file mode 100755 (executable)
index 0000000..e99233a
--- /dev/null
@@ -0,0 +1,107 @@
+// Copyright 2016 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen;
+using Tizen.Convergence;
+
+internal static partial class Interop
+{
+    internal static partial class Internal
+    {
+        internal enum ServiceType
+        {
+            /// <summary>
+            /// Undefined service
+            /// </summary>
+            None = -1,
+
+            /// <summary>
+            /// App-to-app communication service
+            /// </summary>
+            AppCommunication = 0,
+
+            /// <summary>
+            /// Remote app-control service
+            /// </summary>
+            RemoteAppControl,
+        }
+
+        internal static partial class ConvService
+        {
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_service_create")]
+            internal static extern int Create(out ConvServiceHandle /* conv_service_h */ handle);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_service_clone")]
+            internal static extern int Clone(IntPtr /* conv_service_h */ originalHandle, out ConvServiceHandle /* conv_service_h */ targetHandle);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_service_destroy")]
+            internal static extern int Destroy(IntPtr /* conv_service_h */ handle);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_service_get_property_string")]
+            internal static extern int GetPropertyString(ConvServiceHandle /* conv_service_h */ handle, string key, out IntPtr value);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_service_set_property_string")]
+            internal static extern int SetPropertyString(ConvServiceHandle /* conv_service_h */ handle, string key, string value);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_service_get_type")]
+            internal static extern int GetType(IntPtr /* conv_service_h */ handle, out int /* conv_service_e */ value);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_service_set_type")]
+            internal static extern int SetType(ConvServiceHandle /* conv_service_h */ handle, int /* conv_service_e */ value);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_service_start")]
+            internal static extern int Start(ConvServiceHandle /* conv_service_h */ handle, ConvChannelHandle channel, ConvPayloadHandle payload);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_service_read")]
+            internal static extern int Read(ConvServiceHandle /* conv_service_h */ handle, ConvChannelHandle channel, ConvPayloadHandle payload);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_service_publish")]
+            internal static extern int Publish(ConvServiceHandle /* conv_service_h */ handle, ConvChannelHandle channel, ConvPayloadHandle payload);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_service_stop")]
+            internal static extern int Stop(ConvServiceHandle /* conv_service_h */ handle, ConvChannelHandle channel, ConvPayloadHandle payload);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_service_set_listener_cb")]
+            internal static extern int SetListenerCb(ConvServiceHandle /* conv_service_h */ handle, ConvServiceListenerCallback callback, IntPtr /* void */ userData);
+
+            [DllImport(Libraries.Convergence, EntryPoint = "conv_service_unset_listener_cb")]
+            internal static extern int UnsetListenerCb(ConvServiceHandle /* conv_service_h */ handle);
+
+            [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+            internal delegate void ConvServiceListenerCallback(IntPtr /* conv_service_h */ serviceHandle, IntPtr channelHandle, int error, IntPtr result, IntPtr /* void */ userData);
+        }
+
+        internal class ConvServiceHandle : TizenSafeHandle
+        {
+            public ConvServiceHandle(): base()
+            {
+
+            }
+
+            public ConvServiceHandle(IntPtr handle)
+                : base(handle)
+            {
+            }
+
+            public override void Destroy()
+            {
+                if (handle != IntPtr.Zero)
+                {
+                    var err = ConvService.Destroy(this.handle);
+                    if (err != (int)ConvErrorCode.None)
+                    {
+                        Log.Error(ErrorFactory.LogTag, "Failed to destroy conv service handle");
+                        throw ErrorFactory.GetException(err);
+                    }
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Convergence/Interop/Interop.Libc.cs b/src/Tizen.Convergence/Interop/Interop.Libc.cs
new file mode 100755 (executable)
index 0000000..13c7170
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Libc
+    {
+        [DllImport(Libraries.Libc, EntryPoint = "free", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Free(IntPtr ptr);
+    }
+}
diff --git a/src/Tizen.Convergence/Interop/Interop.Libraries.cs b/src/Tizen.Convergence/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..072ed2f
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    /// <summary>
+    /// Wrapper class for maintaining names of dependent native libraries.
+    /// </summary>
+    internal static partial class Libraries
+    {
+        public const string Convergence = "libd2d-conv-manager.so.0";
+        public const string Glib = "libglib-2.0.so.0";
+        public const string Libc = "libc.so.6";
+    }
+}
diff --git a/src/Tizen.Convergence/Tizen.Convergence.csproj b/src/Tizen.Convergence/Tizen.Convergence.csproj
new file mode 100644 (file)
index 0000000..3f295ec
--- /dev/null
@@ -0,0 +1,25 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  
+  <PropertyGroup>
+    <Version>1.0.0</Version>
+    <Authors>Samsung Electronics</Authors>
+    <Copyright>© Samsung Electronics Co., Ltd All Rights Reserved</Copyright>
+    <Description>Device to device convergence C# API for Tizen .NET</Description>
+    <PackageProjectUrl>https://www.tizen.org/</PackageProjectUrl>
+    <PackageLicenseUrl>https://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
+    <PackageIconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</PackageIconUrl>
+  </PropertyGroup>
+  
+  <PropertyGroup>
+    <TargetFramework>netstandard1.6</TargetFramework>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Convergence.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+  
+  <ItemGroup>
+    <PackageReference Include="Tizen" Version="1.0.5" />
+  </ItemGroup>
+  
+</Project>
diff --git a/src/Tizen.Convergence/Tizen.Convergence.snk b/src/Tizen.Convergence/Tizen.Convergence.snk
new file mode 100755 (executable)
index 0000000..d4c3b08
Binary files /dev/null and b/src/Tizen.Convergence/Tizen.Convergence.snk differ
diff --git a/src/Tizen.Convergence/Tizen.Convergence/InternalAppCommunicationService.cs b/src/Tizen.Convergence/Tizen.Convergence/InternalAppCommunicationService.cs
new file mode 100755 (executable)
index 0000000..64b5658
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.ComponentModel;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Convergence
+{
+    /// <summary>
+    /// The class provides APIs to support App to App communication service which relies on a remote server.
+    /// The initialization and execution of a server app (the app on the side with the Remote Server, e.g. TV) and a client app (e.g. the app on the mobile or wearable device) are slightly different.
+    /// On the server side an instance of the App Communication Service should be created and started by the app. Note, on the client side the service handle shouldn’t be created, but obtained during discovery.
+    /// For more information, refer Tizen D2D convergence specification
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class InternalAppCommunicationService : InternalService
+    {
+        /// <summary>
+        /// The constructor
+        /// </summary>
+        /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+        /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+        public InternalAppCommunicationService() :
+                base(Interop.Internal.ServiceType.AppCommunication)
+        {
+
+        }
+
+        internal InternalAppCommunicationService(IntPtr serviceHandle) :
+                    base(serviceHandle)
+        {
+
+        }
+
+        /// <summary>
+        /// Starts and initiates the service
+        /// </summary>
+        /// <param name="channel">Channel to specify a logical session for the service</param>
+        /// <param name="payload">Contains additional data for start request. Refer D2D Convergence specification for more information</param>
+        /// <privilege>http://tizen.org/privilege/internet</privilege>
+        /// <privilege>http://tizen.org/privilege/bluetooth</privilege>
+        /// <privilege>http://tizen.org/privilege/d2d.datasharing</privilege>
+        /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+        /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the request is not supported as per Tizen D2D convergence specification </exception>
+        /// <exception cref="ArgumentNullException">Thrown when any of the arugments are null</exception>
+        /// <seealso cref="Service.ServiceEventOccurred"> The result of the request is delivered through this event</seealso>
+        public void Start(InternalChannel channel, InternalPayload payload)
+        {
+            if (channel == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            Interop.Internal.ConvPayloadHandle handle = (payload == null) ? new Interop.Internal.ConvPayloadHandle() : payload._payloadHandle;
+            int ret = Interop.Internal.ConvService.Start(_serviceHandle, channel._channelHandle, handle);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Interop: Failed to start app communication service:" + ErrorFacts.GetErrorMessage(ret));
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Reads data from the channel opened on the service
+        /// </summary>
+        /// <param name="channel">Channel representing a logical session on the service</param>
+        /// <param name="payload">Contains additional data for start request. Refer D2D Convergence specification for more information</param>
+        /// <privilege>http://tizen.org/privilege/internet</privilege>
+        /// <privilege>http://tizen.org/privilege/bluetooth</privilege>
+        /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+        /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the request is not supported as per Tizen D2D convergence specification </exception>
+        /// <exception cref="ArgumentNullException">Thrown when any of the arugments are null</exception>
+        /// <seealso cref="Service.ServiceEventOccurred"> The result of the request is delivered through this event</seealso>
+        public void Read(InternalChannel channel, InternalPayload payload)
+        {
+            if (channel == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            Interop.Internal.ConvPayloadHandle handle = (payload == null) ? new Interop.Internal.ConvPayloadHandle() : payload._payloadHandle;
+            int ret = Interop.Internal.ConvService.Read(_serviceHandle, channel._channelHandle, handle);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Interop: Failed to read app communication service:" + ErrorFacts.GetErrorMessage(ret));
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Publishes a message to the remote server application
+        /// </summary>
+        /// <param name="channel">Channel representing a logical session on the service</param>
+        /// <param name="payload">Contains additional data for start request. Refer D2D Convergence specification for more information</param>
+        /// <privilege>http://tizen.org/privilege/internet</privilege>
+        /// <privilege>http://tizen.org/privilege/bluetooth</privilege>
+        /// <privilege>http://tizen.org/privilege/d2d.datasharing</privilege>
+        /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+        /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the request is not supported as per Tizen D2D convergence specification </exception>
+        /// <exception cref="ArgumentNullException">Thrown when any of the arugments are null</exception>
+        /// <seealso cref="Service.ServiceEventOccurred"> The result of the request is delivered through this event</seealso>
+        public void Publish(InternalChannel channel, InternalPayload payload)
+        {
+            if (channel == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            Interop.Internal.ConvPayloadHandle handle = (payload == null) ? new Interop.Internal.ConvPayloadHandle() : payload._payloadHandle;
+            int ret = Interop.Internal.ConvService.Publish(_serviceHandle, channel._channelHandle, handle);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Interop: Failed to publish app communication service:" + ErrorFacts.GetErrorMessage(ret));
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Stops the channel opened on the remote server application
+        /// </summary>
+        /// <param name="channel">Channel representing a logical session on the service</param>
+        /// <param name="payload">Contains additional data for start request. Refer D2D Convergence specification for more information</param>
+        /// <privilege>http://tizen.org/privilege/internet</privilege>
+        /// <privilege>http://tizen.org/privilege/bluetooth</privilege>
+        /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+        /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the request is not supported as per Tizen D2D convergence specification </exception>
+        /// <exception cref="ArgumentNullException">Thrown when any of the arugments are null</exception>
+        /// <seealso cref="Service.ServiceEventOccurred"> The result of the request is delivered through this event</seealso>
+        public void Stop(InternalChannel channel, InternalPayload payload)
+        {
+            if (channel == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            Interop.Internal.ConvPayloadHandle handle = (payload == null) ? new Interop.Internal.ConvPayloadHandle() : payload._payloadHandle;
+            int ret = Interop.Internal.ConvService.Stop(_serviceHandle, channel._channelHandle, handle);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Interop: Failed to start stop communication service:" + ErrorFacts.GetErrorMessage(ret));
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Tizen.Convergence/InternalChannel.cs b/src/Tizen.Convergence/Tizen.Convergence/InternalChannel.cs
new file mode 100755 (executable)
index 0000000..72b00ec
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace Tizen.Convergence
+{
+    /// <summary>
+    /// The Channel class provies a logical session for communicating with AppCommunicationService.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class InternalChannel : IDisposable
+    {
+        internal Interop.Internal.ConvChannelHandle _channelHandle;
+        internal const string ChannelUriKey = "uri";
+        internal const string ChannelIdKey = "channel_id";
+
+        /// <summary>
+        /// The constructor
+        /// </summary>
+        /// <param name="uri">Uri of the server side app</param>
+        /// <param name="id">Unique identifier</param>
+        /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+        /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+        /// <exception cref="ArgumentNullException">Throws when the arguments passed are null</exception>
+        public InternalChannel(string uri, string id)
+        {
+            if (uri == null || id == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            int ret = Interop.Internal.ConvChannel.Create(out _channelHandle);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to create channel");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            ret = Interop.Internal.ConvChannel.SetString(_channelHandle, ChannelUriKey, uri);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to create channel");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            ret = Interop.Internal.ConvChannel.SetString(_channelHandle, ChannelIdKey, id);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to create channel");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            Uri = uri;
+            Id = id;
+        }
+
+        internal InternalChannel(IntPtr channelHandle)
+        {
+            _channelHandle = new Interop.Internal.ConvChannelHandle(channelHandle, false);
+
+            IntPtr stringPtr = IntPtr.Zero;
+            int ret = Interop.Internal.ConvChannel.GetString(_channelHandle, ChannelUriKey, out stringPtr);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to create channel");
+                throw ErrorFactory.GetException(ret);
+            }
+            Uri = Marshal.PtrToStringAnsi(stringPtr);
+            Interop.Libc.Free(stringPtr);
+
+            ret = Interop.Internal.ConvChannel.GetString(_channelHandle, ChannelIdKey, out stringPtr);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to create channel");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            Id = Marshal.PtrToStringAnsi(stringPtr);
+            Interop.Libc.Free(stringPtr);
+        }
+
+        /// <summary>
+        /// Uri of the server side app
+        /// </summary>
+        public string Uri { get; }
+
+        /// <summary>
+        /// Unique identifier
+        /// </summary>
+        public string Id { get; }
+
+        /// <summary>
+        /// The dispose method
+        /// </summary>
+        public void Dispose()
+        {
+            _channelHandle.Dispose();
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Tizen.Convergence/InternalDevice.cs b/src/Tizen.Convergence/Tizen.Convergence/InternalDevice.cs
new file mode 100755 (executable)
index 0000000..0676fca
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace Tizen.Convergence
+{
+    /// <summary>
+    /// The class encapsulates a D2D convergence compliant device information
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class InternalDevice : IDisposable
+    {
+        internal const string DeviceIdKey = "device_id";
+        internal const string DeviceNameKey = "device_name";
+        internal const string DeviceTypeKey = "device_type";
+        internal Interop.Internal.ConvDeviceHandle _deviceHandle;
+        internal List<InternalService> _services = new List<InternalService>();
+
+        /// <summary>
+        /// The Unique ID of the device
+        /// </summary>
+        public string Id { get;}
+
+        /// <summary>
+        /// Name of the device
+        /// </summary>
+        public string Name { get;}
+
+        /// <summary>
+        /// The profile of the device
+        /// </summary>
+        public string Type { get; }
+
+        /// <summary>
+        /// List of services supported by the device
+        /// </summary>
+        public IEnumerable<InternalService> Services
+        {
+            get
+            {
+                return _services;
+            }
+        }
+
+        internal InternalDevice(IntPtr deviceHandle)
+        {
+            int ret = Interop.Internal.ConvDevice.Clone(deviceHandle, out _deviceHandle);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to clone device");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            IntPtr stringPtr = IntPtr.Zero;
+            ret = Interop.Internal.ConvDevice.GetPropertyString(_deviceHandle, DeviceIdKey, out stringPtr);
+            if (ret == (int)ConvErrorCode.None)
+            {
+                Id = Marshal.PtrToStringAnsi(stringPtr);
+                Interop.Libc.Free(stringPtr);
+            }
+
+            ret = Interop.Internal.ConvDevice.GetPropertyString(_deviceHandle, DeviceNameKey, out stringPtr);
+            if (ret == (int)ConvErrorCode.None)
+            {
+                Name = Marshal.PtrToStringAnsi(stringPtr);
+                Interop.Libc.Free(stringPtr);
+            }
+
+            ret = Interop.Internal.ConvDevice.GetPropertyString(_deviceHandle, DeviceTypeKey, out stringPtr);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Type = Marshal.PtrToStringAnsi(stringPtr);
+                Interop.Libc.Free(stringPtr);
+            }
+
+            Log.Debug(ErrorFactory.LogTag, "Device ID ,Name, and Type:[" + Id +"," + Name +"," + Type +"]");
+
+            Interop.Internal.ConvDevice.ConvServiceForeachCallback cb = (IntPtr serviceHandle, IntPtr userData) =>
+            {
+                    _services.Add(InternalService.GetService(serviceHandle));
+            };
+
+            ret = Interop.Internal.ConvDevice.ForeachService(_deviceHandle, cb, IntPtr.Zero);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to get device services");
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// The dispose method
+        /// </summary>
+        public void Dispose()
+        {
+            _deviceHandle.Dispose();
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Tizen.Convergence/InternalDeviceFinder.cs b/src/Tizen.Convergence/Tizen.Convergence/InternalDeviceFinder.cs
new file mode 100755 (executable)
index 0000000..aea5f89
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using Tizen;
+using System.Threading;
+using System.Threading.Tasks;
+using System.ComponentModel;
+
+namespace Tizen.Convergence
+{
+    /// <summary>
+    /// DeviceFinder provides API to find all nearby Tizen D2D convergence compliant devices
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class InternalDeviceFinder : IDisposable
+    {
+        internal Interop.Internal.ConvManagerHandle _convManagerHandle;
+
+        /// <summary>
+        /// The constructor
+        /// </summary>
+        /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+        /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+        public InternalDeviceFinder()
+        {
+            int ret = Interop.Internal.ConvManager.ConvCreate(out _convManagerHandle);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to create conv manager handle");
+                throw ErrorFactory.GetException(ret);
+            }
+
+        }
+
+        /// <summary>
+        /// DeviceFound event is triggered when a device is found during discovery procedure
+        /// </summary>
+        public event EventHandler<InternalDeviceFoundEventArgs> DeviceFound;
+
+        /// <summary>
+        /// Starts the discovery of nearby devices
+        /// </summary>
+        /// <param name="timeOut">Seconds for discovery timeout. 0 will use default timeout value</param>
+        /// <param name="cancellationToken">Cancellation token required to cancel the current discovery</param>
+        /// <privilege>http://tizen.org/privilege/internet</privilege>
+        /// <privilege>http://tizen.org/privilege/bluetooth</privilege>
+        /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+        /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the request is not supported as per Tizen D2D convergence specification </exception>
+        /// <seealso cref="DeviceFound"> Devices found are delivered through this event</seealso>
+        /// <returns>Task with discovery result</returns>
+        public async Task StartFindingAsync(int timeOut, CancellationToken cancellationToken = default(CancellationToken))
+        {
+            var task = new TaskCompletionSource<bool>();
+            Interop.Internal.ConvManager.ConvDiscoveryCallback discoveredCb = (IntPtr deviceHandle, Interop.Internal.ConvDiscoveryResult result, IntPtr userData) =>
+            {
+                Log.Debug(ErrorFactory.LogTag, "discovery callback called with result:[" + result + "]");
+                switch (result)
+                {
+                    case Interop.Internal.ConvDiscoveryResult.Success:
+                        {
+                            InternalDevice device = new InternalDevice(deviceHandle);
+                            InternalDeviceFoundEventArgs deviceFoundEventArgs = new InternalDeviceFoundEventArgs()
+                            {
+                                Device = device
+                            };
+                            DeviceFound?.Invoke(this, deviceFoundEventArgs);
+                            break;
+                        }
+                    case Interop.Internal.ConvDiscoveryResult.Error:
+                        {
+                            task.TrySetException(new InvalidOperationException("Discovery error occured"));
+                            break;
+                        }
+                    case Interop.Internal.ConvDiscoveryResult.Lost:
+                        {
+                            task.TrySetException(new InvalidOperationException("Discovery Lost"));
+                            break;
+                        }
+                    case Interop.Internal.ConvDiscoveryResult.Finished:
+                        {
+                            Log.Debug(ErrorFactory.LogTag, "discovery process finished");
+                            task.TrySetResult(true);
+                            break;
+                        }
+                }
+            };
+            int ret = Interop.Internal.ConvManager.ConvDiscoveryStart(_convManagerHandle, timeOut, discoveredCb, IntPtr.Zero);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to start finding devices");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            if (cancellationToken != CancellationToken.None)
+            {
+                cancellationToken.Register(() =>
+                {
+                    int error = Interop.Internal.ConvManager.ConvDiscoveryStop(_convManagerHandle);
+                    if (error != (int)ConvErrorCode.None)
+                    {
+                        Log.Error(ErrorFactory.LogTag, "Failed to stop finding devices" + Internals.Errors.ErrorFacts.GetErrorMessage(error));
+                        throw ErrorFactory.GetException(error);
+                    }
+                    task.TrySetCanceled();
+                });
+            }
+            await task.Task;
+        }
+
+        /// <summary>
+        /// The dispose method
+        /// </summary>
+        public void Dispose()
+        {
+            _convManagerHandle.Dispose();
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Tizen.Convergence/InternalDeviceFoundEventArgs.cs b/src/Tizen.Convergence/Tizen.Convergence/InternalDeviceFoundEventArgs.cs
new file mode 100755 (executable)
index 0000000..60c3df0
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.ComponentModel;
+
+namespace Tizen.Convergence
+{
+    /// <summary>
+    /// Contains arguments for the event DeviceFound.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class InternalDeviceFoundEventArgs : EventArgs
+    {
+        internal InternalDeviceFoundEventArgs() { }
+
+        /// <summary>
+        /// The device found
+        /// </summary>
+        public InternalDevice Device { get; internal set; }
+    }
+}
diff --git a/src/Tizen.Convergence/Tizen.Convergence/InternalErrorFactory.cs b/src/Tizen.Convergence/Tizen.Convergence/InternalErrorFactory.cs
new file mode 100755 (executable)
index 0000000..8954997
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen.Internals.Errors;
+using System.Threading.Tasks;
+using System.Threading;
+
+namespace Tizen.Convergence
+{
+    internal enum ConvErrorCode
+    {
+        None = ErrorCode.None,
+        OutOfMemory = ErrorCode.OutOfMemory,
+        InvalidParameter = ErrorCode.InvalidParameter,
+        InvalidOperation = ErrorCode.InvalidOperation,
+        NoData = ErrorCode.NoData,
+        NotSupported = ErrorCode.NotSupported,
+        PermissionDenied = ErrorCode.PermissionDenied,
+    }
+
+    internal class ErrorFactory
+    {
+        internal static string LogTag = "Tizen.Convergence";
+
+        internal static Exception GetException(int error)
+        {
+            if ((ConvErrorCode)error == ConvErrorCode.OutOfMemory)
+            {
+                return new OutOfMemoryException("Out of memory");
+            }
+            else if ((ConvErrorCode)error == ConvErrorCode.InvalidParameter)
+            {
+                return new ArgumentException("Invalid parameter");
+            }
+            else if ((ConvErrorCode)error == ConvErrorCode.InvalidOperation)
+            {
+                return new InvalidOperationException("Invalid operation");
+            }
+            else if ((ConvErrorCode)error == ConvErrorCode.NotSupported)
+            {
+                return new NotSupportedException("Unsupported feature http://tizen.org/feature/convergence.d2d");
+            }
+            else if ((ConvErrorCode)error == ConvErrorCode.PermissionDenied)
+            {
+                return new UnauthorizedAccessException("Permission denied. (http://tizen.org/privilege/internet, http://tizen.org/privilege/bluetooth, http://tizen.org/privilege/d2d.datasharing)");
+            }
+            else if ((ConvErrorCode)error == ConvErrorCode.NoData)
+            {
+                return new InvalidOperationException("The payload is empty");
+            }
+            else
+            {
+                return new Exception("Unknown error");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Tizen.Convergence/InternalPayload.cs b/src/Tizen.Convergence/Tizen.Convergence/InternalPayload.cs
new file mode 100755 (executable)
index 0000000..d5df0a8
--- /dev/null
@@ -0,0 +1,219 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace Tizen.Convergence
+{
+    /// <summary>
+    /// Represents a payload used in Tizen D2D convergence
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class InternalPayload : IDisposable
+    {
+        internal Interop.Internal.ConvPayloadHandle _payloadHandle;
+
+        /// <summary>
+        /// The constructor
+        /// </summary>
+        /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+        /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+        public InternalPayload()
+        {
+            int ret = Interop.Internal.ConvPayload.Create(out _payloadHandle);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to create payload");
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+
+        internal InternalPayload(IntPtr payloadHandle)
+        {
+            _payloadHandle = new Interop.Internal.ConvPayloadHandle(payloadHandle, false);
+        }
+
+        /// <summary>
+        /// Adds a key-value pair to payload
+        /// </summary>
+        /// <param name="key">The key of the attribute</param>
+        /// <param name="value">The value of the attribute</param>
+        /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+        /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+        /// <exception cref="ArgumentNullException">Thrown if the arguments passed are null </exception>
+        public void Set(string key, string value)
+        {
+            if(key == null || value == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            int ret = 0;
+            if (value is string)
+            {
+                ret = Interop.Internal.ConvPayload.SetString(_payloadHandle, key, value);
+                if (ret != (int)ConvErrorCode.None)
+                {
+                    Log.Error(ErrorFactory.LogTag, "Failed to add string to payload");
+                    throw ErrorFactory.GetException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Adds a key-value pair to payload
+        /// </summary>
+        /// <param name="key">The key of the attribute</param>
+        /// <param name="value">The value of the attribute</param>
+        /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+        /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+        /// <exception cref="ArgumentNullException">Thrown if the arguments passed are null </exception>
+        public void Set(string key, byte[] value)
+        {
+            if (key == null || value == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            int ret = 0;
+            ret = Interop.Internal.ConvPayload.SetByte(_payloadHandle, key, value.Length, value);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to add string to payload");
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+
+
+        /// <summary>
+        /// Sets binary to payload.
+        /// </summary>
+        /// <param name="value">The binary to set</param>
+        /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+        /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+        /// <exception cref="ArgumentNullException">Thrown if the arguments passed are null </exception>
+        public void Set(byte[] value)
+        {
+            if (value == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            int ret = 0;
+            ret = Interop.Internal.ConvPayload.SetBinary(_payloadHandle, value.Length, value);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to add binary to payload");
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Gets the value of the key from payload
+        /// </summary>
+        /// <param name="key">The key of the attribute</param>
+        /// <param name="value">The value of the attribute</param>
+        /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+        /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+        /// <exception cref="ArgumentNullException">Thrown if the arguments passed are null </exception>
+        /// <exception cref="ArgumentException">Thrown if the key is not found </exception>
+        public void Get(string key, out string value)
+        {
+            if (key == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            IntPtr stringPtr = IntPtr.Zero;
+            int ret = 0;
+            ret = Interop.Internal.ConvPayload.GetString(_payloadHandle, key, out stringPtr);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to add string to payload");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            value = Marshal.PtrToStringAnsi(stringPtr);
+            Interop.Libc.Free(stringPtr);
+        }
+
+        /// <summary>
+        /// Gets the value of the key from payload
+        /// </summary>
+        /// <param name="key">The key of the attribute</param>
+        /// <param name="value">The value of the attribute</param>
+        /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+        /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+        /// <exception cref="ArgumentNullException">Thrown if the arguments passed are null </exception>
+        /// <exception cref="ArgumentException">Thrown if the key is not found </exception>
+        public void Get(string key, out byte[] value)
+        {
+            if (key == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            int ret = 0;
+            IntPtr byteArrayPtr;
+            int byteArraySize;
+            ret = Interop.Internal.ConvPayload.GetByte(_payloadHandle, key, out byteArraySize, out byteArrayPtr);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to add string to payload");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            byte[] byteArray = new byte[byteArraySize];
+            Marshal.Copy(byteArrayPtr, byteArray, 0, byteArraySize);
+            value = byteArray;
+            Interop.Libc.Free(byteArrayPtr);
+        }
+
+        /// <summary>
+        /// Gets binary from payload
+        /// </summary>
+        /// <param name="value">The result value</param>
+        /// <feature>http://tizen.org/feature/convergence.d2d</feature>
+        /// <exception cref="NotSupportedException">Thrown if the required feature is not supported.</exception>
+        public void Get(out byte[] value)
+        {
+            int ret = 0;
+            IntPtr byteArrayPtr;
+            int byteArraySize;
+            ret = Interop.Internal.ConvPayload.GetBinary(_payloadHandle, out byteArraySize, out byteArrayPtr);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to get binary from payload");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            byte[] byteArray = new byte[byteArraySize];
+            Marshal.Copy(byteArrayPtr, byteArray, 0, byteArraySize);
+            value = byteArray;
+            Interop.Libc.Free(byteArrayPtr);
+        }
+
+        /// <summary>
+        /// The dispose method
+        /// </summary>
+        public void Dispose()
+        {
+            _payloadHandle.Dispose();
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Tizen.Convergence/InternalService.cs b/src/Tizen.Convergence/Tizen.Convergence/InternalService.cs
new file mode 100755 (executable)
index 0000000..6740231
--- /dev/null
@@ -0,0 +1,192 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace Tizen.Convergence
+{
+    /// <summary>
+    /// The class abstracts the features provided by Tizen D2D Convergence.
+    /// </summary>
+    /// <seealso cref="AppCommunicationService"/>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public abstract class InternalService : IDisposable
+    {
+        internal Interop.Internal.ConvServiceHandle _serviceHandle;
+        internal const string ServiceIdKey = "service_id";
+        internal const string ServiceVersionKey = "service_version";
+
+        private event EventHandler<InternalServiceEventOccuredEventArgs> _serviceEventOccured;
+
+        internal InternalService(Interop.Internal.ServiceType type)
+        {
+            int ret = Interop.Internal.ConvService.Create(out _serviceHandle);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to create service handle");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            ret = Interop.Internal.ConvService.SetType(_serviceHandle, (int)type);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to create service handle");
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+
+        internal InternalService(IntPtr existingServiceHandle)
+        {
+            int ret = Interop.Internal.ConvService.Clone(existingServiceHandle, out _serviceHandle);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to clone device");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            IntPtr stringPtr = IntPtr.Zero;
+            ret = Interop.Internal.ConvService.GetPropertyString(_serviceHandle, ServiceIdKey, out stringPtr);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to get service Id");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            Id = Marshal.PtrToStringAnsi(stringPtr);
+            Interop.Libc.Free(stringPtr);
+
+            ret = Interop.Internal.ConvService.GetPropertyString(_serviceHandle, ServiceVersionKey, out stringPtr);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to get service version");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            Version = Marshal.PtrToStringAnsi(stringPtr);
+            Interop.Libc.Free(stringPtr);
+        }
+
+        /// <summary>
+        /// The ID of the service
+        /// </summary>
+        public string Id { get; }
+
+        /// <summary>
+        /// The Version of the service
+        /// </summary>
+        public string Version { get; }
+
+        /// <summary>
+        /// The event handler for Service Events(Start/Publish/Read/Stop)
+        /// </summary>
+        public event EventHandler<InternalServiceEventOccuredEventArgs> ServiceEventOccurred
+        {
+            add
+            {
+                if (_serviceEventOccured == null)
+                {
+                    RegisterServiceEventListener();
+                }
+                _serviceEventOccured += value;
+            }
+            remove
+            {
+                _serviceEventOccured -= value;
+                if (_serviceEventOccured == null)
+                {
+                    UnregisterServiceEventListener();
+                }
+            }
+        }
+
+        /// <summary>
+        /// The event handler for service error events
+        /// </summary>
+        public event EventHandler<InternalServiceErrorOccuredEventArgs> ServiceErrorOccured;
+
+        /// <summary>
+        /// The dispose method
+        /// </summary>
+        public void Dispose()
+        {
+            _serviceHandle.Dispose();
+        }
+
+        internal static InternalService GetService(IntPtr serviceHandle)
+        {
+            InternalService service = null;
+            int serviceType;
+            int ret = Interop.Internal.ConvService.GetType(serviceHandle, out serviceType);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to get service version");
+                throw ErrorFactory.GetException(ret);
+            }
+            if (serviceType == (int)Interop.Internal.ServiceType.AppCommunication)
+            {
+                service = new InternalAppCommunicationService(serviceHandle);
+            }
+
+            return service;
+        }
+
+        private void RegisterServiceEventListener()
+        {
+            int ret = Interop.Internal.ConvService.SetListenerCb(_serviceHandle, serviceEventsCb, IntPtr.Zero);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to set listener for service events");
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+
+        private void UnregisterServiceEventListener()
+        {
+            int ret = Interop.Internal.ConvService.UnsetListenerCb(_serviceHandle);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to unset listener for service events");
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+
+        private void serviceEventsCb(IntPtr serviceHandle, IntPtr channelHandle, int error, IntPtr resultPayloadHandle, IntPtr userData)
+        {
+            Log.Debug(ErrorFactory.LogTag, "service event occured. error code :[" + error + "]");
+
+            if (error == (int)ConvErrorCode.None)
+            {
+                var channel = (channelHandle == IntPtr.Zero) ? null : new InternalChannel(channelHandle);
+                var payload = (resultPayloadHandle == IntPtr.Zero) ? null : new InternalPayload(resultPayloadHandle);
+                _serviceEventOccured?.Invoke(this, new InternalServiceEventOccuredEventArgs()
+                {
+                    Payload = payload,
+                    Channel = channel
+                });
+            }
+            else
+            {
+                var eventArgs = new InternalServiceErrorOccuredEventArgs()
+                {
+                    Exception = ErrorFactory.GetException(error)
+                };
+                ServiceErrorOccured?.Invoke(this, eventArgs);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Tizen.Convergence/InternalServiceErrorOccuredEventArgs.cs b/src/Tizen.Convergence/Tizen.Convergence/InternalServiceErrorOccuredEventArgs.cs
new file mode 100755 (executable)
index 0000000..104a05b
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.ComponentModel;
+
+namespace Tizen.Convergence
+{
+    /// <summary>
+    /// Contains arguments for the event ServiceErrorOccured.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class InternalServiceErrorOccuredEventArgs : EventArgs
+    {
+        internal InternalServiceErrorOccuredEventArgs() { }
+
+        /// <summary>
+        /// The exception
+        /// </summary>
+        public Exception Exception { get; internal set; }
+    }
+}
diff --git a/src/Tizen.Convergence/Tizen.Convergence/InternalServiceEventOccuredEventArgs.cs b/src/Tizen.Convergence/Tizen.Convergence/InternalServiceEventOccuredEventArgs.cs
new file mode 100755 (executable)
index 0000000..e07c9e3
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.ComponentModel;
+
+namespace Tizen.Convergence
+{
+    /// <summary>
+    /// Contains arguments for ServiceEventOccured
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class InternalServiceEventOccuredEventArgs : EventArgs
+    {
+        internal InternalServiceEventOccuredEventArgs() { }
+
+        /// <summary>
+        /// The channel on which the event occured
+        /// </summary>
+        public InternalChannel Channel { get; internal set; }
+
+        /// <summary>
+        /// The payload containing the result
+        /// </summary>
+        public InternalPayload Payload { get; internal set; }
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Interop/Interop.Bluetooth.cs b/src/Tizen.Network.Bluetooth/Interop/Interop.Bluetooth.cs
new file mode 100755 (executable)
index 0000000..86ac67e
--- /dev/null
@@ -0,0 +1,597 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen.Network.Bluetooth;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Bluetooth
+    {
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void StateChangedCallback(int result, int state, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void NameChangedCallback(string deviceName, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void VisibilityModeChangedCallback(int result, int visibility, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void VisibilityDurationChangedCallback(int duration, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void DiscoveryStateChangedCallback(int result, BluetoothDeviceDiscoveryState state, IntPtr deviceInfo, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool BondedDeviceCallback([MarshalAs(UnmanagedType.Struct)]ref BluetoothDeviceStruct device, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void BondCreatedCallback(int result, [MarshalAs(UnmanagedType.Struct)]ref BluetoothDeviceStruct device, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void BondDestroyedCallback(int result, string deviceAddress, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void AuthorizationChangedCallback(int authorization, string deviceAddress, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void ServiceSearchedCallback(int result, [MarshalAs(UnmanagedType.Struct)]ref BluetoothDeviceSdpStruct sdp, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void DeviceConnectionStateChangedCallback(bool connected, [MarshalAs(UnmanagedType.Struct)]ref BluetoothDeviceConnectionStruct device, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool ConnectedProfileCallback(int profile, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void DataReceivedCallback([MarshalAs(UnmanagedType.Struct)]ref SocketDataStruct socketData, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void SocketConnectionStateChangedCallback(int result, BluetoothSocketState connectionState, [MarshalAs(UnmanagedType.Struct)]ref SocketConnectionStruct socketConnection, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void AudioConnectionStateChangedCallback(int result, bool connected, string deviceAddress, int profileType, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void HidConnectionStateChangedCallback(int result, bool connected, string deviceAddress, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void TargetConnectionStateChangedCallback(bool connected, string deviceAddress, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void EqualizerStateChangedCallback(int equalizer, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void RepeatModeChangedCallback(int repeat, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void ShuffleModeChangedCallback(int shuffle, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void ScanModeChangedCallback(int scan, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void ConnectionChangedCallback(int result, bool connected, string deviceAddress, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void ClientCharacteristicValueChangedCallback(IntPtr characteristicHandle, string value, int len, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void GattClientRequestedCallback(int result, IntPtr handle, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool GattForEachCallback(int total, int index, IntPtr handle, IntPtr userData);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_initialize")]
+        internal static extern int Initialize();
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_deinitialize")]
+        internal static extern int Deinitialize();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_get_name")]
+        internal static extern int GetName(out string name);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_set_name")]
+        internal static extern int SetName(string name);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_get_state")]
+        internal static extern int GetState(out BluetoothState isActivated);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_get_address")]
+        internal static extern int GetAddress(out string address);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_get_visibility")]
+        internal static extern int GetVisibility(out int visibility, out int duration);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_is_discovering")]
+        internal static extern int IsDiscovering(out bool isDiscovering);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_start_device_discovery")]
+        internal static extern int StartDiscovery();
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_stop_device_discovery")]
+        internal static extern int StopDiscovery();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_foreach_bonded_device")]
+        internal static extern int GetBondedDevices(BondedDeviceCallback bondedDeviceCb, IntPtr userData);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_get_bonded_device_info")]
+        internal static extern int GetBondedDeviceByAddress(string deviceAddress, out IntPtr deviceInfo);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_free_device_info")]
+        internal static extern int FreeDeviceInfo(BluetoothDeviceStruct deviceInfo);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_is_service_used")]
+        internal static extern int IsServiceUsed(string serviceUuid, out bool used);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_get_local_oob_data")]
+        internal static extern int GetOobData(out IntPtr hash, out IntPtr randomizer, out int hashLen, out int randomizerLen);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_set_remote_oob_data")]
+        internal static extern int SetOobData(string deviceAddress, IntPtr hash, IntPtr randomizer, int hashLen, int randomizerLen);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_remove_remote_oob_data")]
+        internal static extern int RemoveOobData(string deviceAddress);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_set_state_changed_cb")]
+        internal static extern int SetStateChangedCallback(StateChangedCallback stateChangedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_unset_state_changed_cb")]
+        internal static extern int UnsetStateChangedCallback();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_set_name_changed_cb")]
+        internal static extern int SetNameChangedCallback(NameChangedCallback nameChangedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_unset_name_changed_cb")]
+        internal static extern int UnsetNameChangedCallback();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_set_visibility_mode_changed_cb")]
+        internal static extern int SetVisibilityModeChangedCallback(VisibilityModeChangedCallback visibilityChangedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_unset_visibility_mode_changed_cb")]
+        internal static extern int UnsetVisibilityModeChangedCallback();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_set_visibility_duration_changed_cb")]
+        internal static extern int SetVisibilityDurationChangedCallback(VisibilityDurationChangedCallback durationChangedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_unset_visibility_duration_changed_cb")]
+        internal static extern int UnsetVisibilityDurationChangedCallback();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_set_device_discovery_state_changed_cb")]
+        internal static extern int SetDiscoveryStateChangedCallback(DiscoveryStateChangedCallback discoveryChangedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_unset_device_discovery_state_changed_cb")]
+        internal static extern int UnsetDiscoveryStateChangedCallback();
+
+        //Bluetooth Device
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_create_bond")]
+        internal static extern int CreateBond(string deviceAddress);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_destroy_bond")]
+        internal static extern int DestroyBond(string deviceAddress);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_cancel_bonding")]
+        internal static extern int CancelBonding();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_set_alias")]
+        internal static extern int SetAlias(string deviceAddress, string alias);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_set_authorization")]
+        internal static extern int SetAuthorization(string deviceAddress, int state);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_get_service_mask_from_uuid_list")]
+        internal static extern int GetMaskFromUuid([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr, SizeParamIndex = 1)] string[] uuids, int count, out BluetoothServiceClassType serviceMask);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_start_service_search")]
+        internal static extern int StartServiceSearch(string deviceAddress);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_foreach_connected_profiles")]
+        internal static extern int GetConnectedProfiles(string deviceAddress, ConnectedProfileCallback connectedProfileCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_is_profile_connected")]
+        internal static extern int IsProfileConnected(string deviceAddress, int profile, out bool connectionStatus);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_set_bond_created_cb")]
+        internal static extern int SetBondCreatedCallback(BondCreatedCallback bondCreatedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_unset_bond_created_cb")]
+        internal static extern int UnsetBondCreatedCallback();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_set_bond_destroyed_cb")]
+        internal static extern int SetBondDestroyedCallback(BondDestroyedCallback bondDestroyedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_unset_bond_destroyed_cb")]
+        internal static extern int UnsetBondDestroyedCallback();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_set_authorization_changed_cb")]
+        internal static extern int SetAuthorizationChangedCallback(AuthorizationChangedCallback authorizationChangedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_unset_authorization_changed_cb")]
+        internal static extern int UnsetAuthorizationChangedCallback();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_set_service_searched_cb")]
+        internal static extern int SetServiceSearchedCallback(ServiceSearchedCallback serviceSearchedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_unset_service_searched_cb")]
+        internal static extern int UnsetServiceSearchedCallback();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_set_connection_state_changed_cb")]
+        internal static extern int SetConnectionStateChangedCallback(DeviceConnectionStateChangedCallback connectionChangedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_unset_connection_state_changed_cb")]
+        internal static extern int UnsetConnectionStateChangedCallback();
+
+        // Bluetooth LE Adapter
+
+        //Callback for event
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void AdapterLeScanResultChangedCallBack(int result,
+            [MarshalAs(UnmanagedType.Struct)]ref BluetoothLeScanDataStruct scanData, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate void AdvertisingStateChangedCallBack(int result, IntPtr advertiserHandle,
+                            BluetoothLeAdvertisingState advertisingState, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate void GattConnectionStateChangedCallBack(int result, bool connected,
+                                        string remoteAddress, IntPtr userData);
+
+        //Bluetooth Le Adapter Apis
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_start_scan")]
+        public static extern int StartScan(AdapterLeScanResultChangedCallBack callback, IntPtr userData);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_stop_scan")]
+        public static extern int StopScan();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_get_scan_result_service_uuids")]
+        public static extern int GetScanResultServiceUuid(ref BluetoothLeScanDataStruct scanData,
+            BluetoothLePacketType packetType, ref IntPtr uuids, ref int count);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_get_scan_result_device_name")]
+        public static extern int GetLeScanResultDeviceName(ref BluetoothLeScanDataStruct scanData,
+                            BluetoothLePacketType packetType, out string deviceName);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_get_scan_result_tx_power_level")]
+        public static extern int GetScanResultTxPowerLevel(ref BluetoothLeScanDataStruct scanData,
+                            BluetoothLePacketType packetType, out int txPowerLevel);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_get_scan_result_service_solicitation_uuids")]
+        public static extern int GetScaResultSvcSolicitationUuids(ref BluetoothLeScanDataStruct scanData,
+                            BluetoothLePacketType packetType, out IntPtr uuids, out int count);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_get_scan_result_service_data_list")]
+        public static extern int GetScanResultServiceDataList(ref BluetoothLeScanDataStruct scanData,
+                            BluetoothLePacketType PacketType, out IntPtr serviceDataArray, out int count);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_free_service_data_list")]
+        public static extern int FreeServiceDataList(IntPtr serviceData, int count);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_get_scan_result_appearance")]\r
+        public static extern int GetScanResultAppearance(ref BluetoothLeScanDataStruct scanData,
+                            BluetoothLePacketType packetType, out int appearance);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_get_scan_result_manufacturer_data")]
+        public static extern int GetScanResultManufacturerData(ref BluetoothLeScanDataStruct scanData,
+                            BluetoothLePacketType packetType, out int manufId, out IntPtr manufData,
+                            out int manufDataLength);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_connect")]
+        internal static extern int GattConnect(string deviceAddress, bool autoConnect);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_disconnect")]
+        internal static extern int GattDisconnect(string deviceAddress);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_set_connection_state_changed_cb")]
+        internal static extern int SetGattConnectionStateChangedCallback(
+            GattConnectionStateChangedCallBack gattConnectionChangedCb, IntPtr userData);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_unset_connection_state_changed_cb")]
+        internal static extern int UnsetGattConnectionStateChangedCallback();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_create_advertiser")]
+        public static extern int CreateAdvertiser(out IntPtr advertiserHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_destroy_advertiser")]
+        public static extern int DestroyAdvertiser(IntPtr advertiserHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_add_advertising_service_uuid")]
+        public static extern int AddAdvertisingServiceUuid(IntPtr advertiserHandle,
+                                    BluetoothLePacketType PacketType, string uuid);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_add_advertising_service_solicitation_uuid")]
+        public static extern int AddAdvertisingServiceSolicitationUuid(IntPtr advertiserHandle,
+            BluetoothLePacketType PacketType, string uuid);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_add_advertising_service_data")]
+        public static extern int AddAdvertisingServiceData(IntPtr advertiserHandle,
+            BluetoothLePacketType PacketType, string uuid, IntPtr serviceData, int serviceDatalength);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_set_advertising_appearance")]
+        public static extern int SetAdvertisingAppearance(IntPtr advertiserHandle,
+                                    BluetoothLePacketType packetType, int appearance);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_add_advertising_manufacturer_data")]
+        public static extern int AddAdvertisingManufData(IntPtr advertiserHandle, BluetoothLePacketType packetType,
+            int manufId, IntPtr manufData, int manufacturerDataLength);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_set_advertising_device_name")]
+        public static extern int SetAdvertisingDeviceName(IntPtr advertiserHandle, BluetoothLePacketType packetType,
+                                                bool includeName);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_set_advertising_tx_power_level")]
+        public static extern int SetAdvertisingTxPowerLevel(IntPtr advertiserHandle, BluetoothLePacketType packetType,
+                                                bool includePowerLevel);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_clear_advertising_data")]
+        public static extern int ClearAdvertisingData(IntPtr advertiserHandle, BluetoothLePacketType packetType);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_start_advertising_new")]
+        public static extern int BluetoothLeStartAdvertising(IntPtr advertiserHandle,
+                                         AdvertisingStateChangedCallBack callback, IntPtr userData);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_stop_advertising")]
+        public static extern int BluetoothLeStopAdvertising(IntPtr advertiserHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_set_advertising_mode")]
+        public static extern int SetAdvertisingMode(IntPtr advertiserHandle,
+                                        BluetoothLeAdvertisingMode advertisingMode);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_set_advertising_connectable")]
+        public static extern int SetAdvertisingConnectable(IntPtr advertiserHandle,
+                                        bool connectable);
+
+        //Bluetooth Socket
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_create_rfcomm")]
+        internal static extern int CreateServerSocket(string serviceUuid, out int socketFd);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_destroy_rfcomm")]
+        internal static extern int DestroyServerSocket(int socketFd);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_listen_and_accept_rfcomm")]
+        internal static extern int Listen(int socketFd, int pendingConnections);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_connect_rfcomm")]
+        internal static extern int ConnectSocket(string address, string serviceUuid);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_disconnect_rfcomm")]
+        internal static extern int DisconnectSocket(int socketFd);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_send_data")]
+        internal static extern int SendData(int socketFd, string data, int dataLength);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_set_data_received_cb")]
+        internal static extern int SetDataReceivedCallback(DataReceivedCallback callback, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_unset_data_received_cb")]
+        internal static extern int UnsetDataReceivedCallback();
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_set_connection_state_changed_cb")]
+        internal static extern int SetConnectionStateChangedCallback(SocketConnectionStateChangedCallback callback, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_unset_connection_state_changed_cb")]
+        internal static extern int UnsetSocketConnectionStateChangedCallback();
+
+        // Bluetooth Audio
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_audio_initialize")]
+        internal static extern int InitializeAudio();
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_audio_deinitialize")]
+        internal static extern int DeinitializeAudio();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_audio_connect")]
+        internal static extern int Connect(string deviceAddress, int profileType);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_audio_disconnect")]
+        internal static extern int Disconnect(string deviceAddress, int profileType);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_audio_set_connection_state_changed_cb")]
+        internal static extern int SetAudioConnectionStateChangedCallback(AudioConnectionStateChangedCallback audioStateChangedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_audio_unset_connection_state_changed_cb")]
+        internal static extern int UnsetAudioConnectionStateChangedCallback();
+
+        //Bluetooth Hid
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_host_initialize")]
+        internal static extern int InitializeHid(HidConnectionStateChangedCallback hidConnectionChangedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_host_deinitialize")]
+        internal static extern int DeinitializeHid();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_host_connect")]
+        internal static extern int Connect(string deviceAddress);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_host_disconnect")]
+        internal static extern int Disconnect(string deviceAddress);
+
+        //Bluetooth Avrcp
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_initialize")]
+        internal static extern int InitializeAvrcp(TargetConnectionStateChangedCallback targetStateChangedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_deinitialize")]
+        internal static extern int DeinitializeAvrcp();
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_notify_equalizer_state")]
+        internal static extern int NotifyEqualizerState(int state);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_notify_repeat_mode")]
+        internal static extern int NotifyRepeatMode(int repeat);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_notify_shuffle_mode")]
+        internal static extern int NotifyShuffleMode(int shuffle);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_notify_scan_mode")]
+        internal static extern int NotifyScanMode(int scan);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_notify_player_state")]
+        internal static extern int NotifyPlayerState(int state);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_notify_position")]
+        internal static extern int NotifyCurrentPosition(uint position);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_notify_track")]
+        internal static extern int NotifyTrack(string title, string artist, string album, string genre, uint trackNum, uint totaltracks, uint duration);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_set_equalizer_state_changed_cb")]
+        internal static extern int SetEqualizerStateChangedCallback(EqualizerStateChangedCallback equalizerStateChangedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_unset_equalizer_state_changed_cb")]
+        internal static extern int UnsetEqualizerStateChangedCallback();
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_set_repeat_mode_changed_cb")]
+        internal static extern int SetRepeatModeChangedCallback(RepeatModeChangedCallback repeatModeChangedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_unset_repeat_mode_changed_cb")]
+        internal static extern int UnsetRepeatModeChangedCallback();
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_set_shuffle_mode_changed_cb")]
+        internal static extern int SetShuffleModeChangedCallback(ShuffleModeChangedCallback shuffleModeChangedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_unset_shuffle_mode_changed_cb")]
+        internal static extern int UnsetShuffleModeChangedCallback();
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_set_scan_mode_changed_cb")]
+        internal static extern int SetScanModeChangedCallback(ScanModeChangedCallback scanModeChangedCb, IntPtr userData);
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_unset_scan_mode_changed_cb")]
+        internal static extern int UnsetScanModeChangedCallback();
+
+        // Bluetooth GATT
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate bool BtGattForeachCallback(int total, int index, IntPtr gattHandle, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void BtGattServerReadValueRequestedCallback(string clientAddress, int requestId, IntPtr serverHandle, IntPtr gattHandle, int offset, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void BtGattServerWriteValueRequestedCallback(string clientAddress, int requestId, IntPtr serverHandle, IntPtr gattHandle, int offset, bool response_needed, byte[] value, int len, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void BtClientCharacteristicValueChangedCallback(IntPtr characteristicHandle, byte[] value, int len, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void BtGattServerNotificationStateChangeCallback(bool notify, IntPtr serverHandle, IntPtr characteristicHandle, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void BtGattServerNotificationSentCallback(int result, string clientAddress, IntPtr serverHandle, IntPtr characteristicHandle, bool completed, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void BtGattClientRequestCompletedCallback(int result, IntPtr requestHandle, IntPtr userData);
+
+        // Gatt Attribute
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_destroy")]
+        internal static extern int BtGattDestroy(IntPtr gattHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_get_uuid")]
+        internal static extern int BtGattGetUuid(BluetoothGattAttributeHandle gattHandle, out string uuid);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_get_value")]
+        internal static extern int BtGattGetValue(BluetoothGattAttributeHandle gattHandle, out IntPtr nativeValue, out int valueLength);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_set_value")]
+        internal static extern int BtGattSetValue(BluetoothGattAttributeHandle gattHandle, byte[] value, int valueLength);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_get_int_value")]
+        internal static extern int BtGattGetIntValue(BluetoothGattAttributeHandle gattHandle, int type, int offset, out int value);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_set_int_value")]
+        internal static extern int BtGattSetIntValue(BluetoothGattAttributeHandle gattHandle, int type, int value, int offset);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_get_float_value")]
+        internal static extern int BtGattGetFloatValue(BluetoothGattAttributeHandle gattHandle, int type, int offset, out float value);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_set_float_value")]
+        internal static extern int BtGattSetFloatValue(BluetoothGattAttributeHandle gattHandle, int type, int mantissa, int exponent, int offset);
+
+        // GATT Descriptor
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_descriptor_create")]
+        internal static extern int BtGattDescriptorCreate(string uuid, int permissions, byte[] value, int valueLength, out BluetoothGattAttributeHandle descriptorHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_descriptor_get_permissions")]
+        internal static extern int BtGattDescriptorGetPermissions(BluetoothGattAttributeHandle descriptorHandle, out int permissions);
+
+        // GATT Characteristic
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_create")]
+        internal static extern int BtGattCharacteristicCreate(string uuid, int permissions, int properties, byte[] value, int valueLength, out BluetoothGattAttributeHandle characteristicHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_get_permissions")]
+        internal static extern int BtGattCharacteristicGetPermissions(BluetoothGattAttributeHandle characteristicHandle, out int permissions);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_get_properties")]
+        internal static extern int BtGattCharacteristicGetProperties(BluetoothGattAttributeHandle characteristicHandle, out int properties);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_set_properties")]
+        internal static extern int BtGattCharacteristicSetProperties(BluetoothGattAttributeHandle characteristicHandle, int properties);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_get_write_type")]
+        internal static extern int BtGattCharacteristicGetWriteType(BluetoothGattAttributeHandle characteristicHandle, out int writeType);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_set_write_type")]
+        internal static extern int BtGattCharacteristicSetWriteType(BluetoothGattAttributeHandle characteristicHandle, int writeType);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_add_descriptor")]
+        internal static extern int BtGattCharacteristicAddDescriptor(BluetoothGattAttributeHandle characteristicHandle, BluetoothGattAttributeHandle descriptorHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_get_descriptor")]
+        internal static extern int BtGattCharacteristicGetDescriptor(BluetoothGattAttributeHandle characteristicHandle, string uuid, out BluetoothGattAttributeHandle descriptorHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_foreach_descriptors")]
+        internal static extern int BtGattCharacteristicForeachDescriptors(BluetoothGattAttributeHandle characteristicHandle, BtGattForeachCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_set_characteristic_value_changed_cb")]
+        internal static extern int BtGattClientSetCharacteristicValueChangedCallback(BluetoothGattAttributeHandle characteristicHandle, BtClientCharacteristicValueChangedCallback cb, IntPtr userData);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_unset_characteristic_value_changed_cb")]
+        internal static extern int BtGattClientUnsetCharacteristicValueChangedCallback(BluetoothGattAttributeHandle characteristicHandle);
+
+        // GATT Service
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_service_create")]
+        internal static extern int BtGattServiceCreate(string uuid, int type, out BluetoothGattAttributeHandle serviceHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_service_add_characteristic")]
+        internal static extern int BtGattServiceAddCharacteristic(BluetoothGattAttributeHandle serviceHandle, BluetoothGattAttributeHandle characteristicHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_service_get_characteristic")]
+        internal static extern int BtGattServiceGetCharacteristic(BluetoothGattAttributeHandle serviceHandle, string uuid, out BluetoothGattAttributeHandle characteristicHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_service_foreach_characteristics")]
+        internal static extern int BtGattServiceForeachCharacteristics(BluetoothGattAttributeHandle serviceHandle, BtGattForeachCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_service_add_included_service")]
+        internal static extern int BtGattServiceAddIncludedService(BluetoothGattAttributeHandle serviceHandle, BluetoothGattAttributeHandle includedServiceHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_service_get_included_service")]
+        internal static extern int BtGattServiceGetIncludedService(BluetoothGattAttributeHandle serviceHandle, string uuid, out BluetoothGattAttributeHandle includedServiceHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_service_foreach_included_services")]
+        internal static extern int BtGattServiceForeachIncludedServices(BluetoothGattAttributeHandle serviceHandle, BtGattForeachCallback callback, IntPtr userData);
+
+        // GATT Client
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_destroy")]
+        internal static extern int BtGattClientDestroy(IntPtr clientHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_create")]
+        internal static extern int BtGattClientCreate(string remoteAddress, out BluetoothGattClientHandle clientHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_get_remote_address")]
+        internal static extern int BtGattClientGetRemoteAddress(BluetoothGattClientHandle clientHandle, out string remoteAddress);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_get_service")]
+        internal static extern int BtGattClientGetService(BluetoothGattClientHandle clientHandle, string uuid, out BluetoothGattAttributeHandle serviceHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_foreach_services")]
+        internal static extern int BtGattClientForeachServices(BluetoothGattClientHandle clientHandle, BtGattForeachCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_read_value")]
+        internal static extern int BtGattClientReadValue(BluetoothGattAttributeHandle gattHandle, BtGattClientRequestCompletedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_write_value")]
+        internal static extern int BtGattClientWriteValue(BluetoothGattAttributeHandle gattHandle, BtGattClientRequestCompletedCallback callback, IntPtr userData);
+
+        // GATT Server
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_destroy")]
+        internal static extern int BtGattServerDestroy(IntPtr serverHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_create")]
+        internal static extern int BtGattServerCreate(out BluetoothGattServerHandle serverHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_initialize")]
+        internal static extern int BtGattServerInitialize();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_deinitialize")]
+        internal static extern int BtGattServerDeinitialize();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_set_read_value_requested_cb")]
+        internal static extern int BtGattServerSetReadValueRequestedCallback(BluetoothGattAttributeHandle gattHandle, BtGattServerReadValueRequestedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_set_write_value_requested_cb")]
+        internal static extern int BtGattServerSetWriteValueRequestedCallback(BluetoothGattAttributeHandle gattHandle, BtGattServerWriteValueRequestedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_set_characteristic_notification_state_change_cb")]
+        internal static extern int BtGattServeSetNotificationStateChangeCallback(BluetoothGattAttributeHandle characteristicHandle, BtGattServerNotificationStateChangeCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_start")]
+        internal static extern int BtGattServerStart();
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_register_service")]
+        internal static extern int BtGattServerRegisterService(BluetoothGattServerHandle serverHandle, BluetoothGattAttributeHandle serviceHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_unregister_service")]
+        internal static extern int BtGattServerUnregisterService(BluetoothGattServerHandle serverHandle, BluetoothGattAttributeHandle serviceHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_unregister_all_services")]
+        internal static extern int BtGattServerUnregisterAllServices(BluetoothGattServerHandle serverHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_get_service")]
+        internal static extern int BtGattServerGetService(BluetoothGattServerHandle serverHandle, string uuid, out BluetoothGattAttributeHandle serviceHandle);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_foreach_services")]
+        internal static extern int BtGattServerForeachServices(BluetoothGattServerHandle serverHandle, BtGattForeachCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_send_response")]
+        internal static extern int BtGattServerSendResponse(int requestId, int requestType, int offset, int status, byte[] value, int valueLen);
+
+        [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_notify_characteristic_changed_value")]
+        internal static extern int BtGattServerNotify(BluetoothGattAttributeHandle characteristicHandle, BtGattServerNotificationSentCallback callback, string clientAddress, IntPtr userData);
+    }
+}
+
+
diff --git a/src/Tizen.Network.Bluetooth/Interop/Interop.Glib.cs b/src/Tizen.Network.Bluetooth/Interop/Interop.Glib.cs
new file mode 100644 (file)
index 0000000..576a6e2
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Glib
+    {
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool GSourceFunc(IntPtr userData);
+
+        [DllImport(Libraries.Glib, EntryPoint = "g_idle_add", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern uint IdleAdd(GSourceFunc d, IntPtr data);
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Interop/Interop.Libc.cs b/src/Tizen.Network.Bluetooth/Interop/Interop.Libc.cs
new file mode 100644 (file)
index 0000000..825599e
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Libc
+    {
+        [DllImport(Libraries.Libc, EntryPoint = "free", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Free(IntPtr ptr);
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Interop/Interop.Libraries.cs b/src/Tizen.Network.Bluetooth/Interop/Interop.Libraries.cs
new file mode 100644 (file)
index 0000000..4aa83d4
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string Bluetooth = "libcapi-network-bluetooth.so.0";
+        public const string Glib = "libglib-2.0.so.0";
+        public const string Libc = "libc.so.6";
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth.csproj b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth.csproj
new file mode 100644 (file)
index 0000000..a88028a
--- /dev/null
@@ -0,0 +1,25 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <Version>1.0.9</Version>
+    <Authors>Samsung Electronics</Authors>
+    <Copyright>© Samsung Electronics Co., Ltd All Rights Reserved</Copyright>
+    <Description>Provides the Bluetooth API for Tizen .NET</Description>
+    <PackageProjectUrl>https://www.tizen.org/</PackageProjectUrl>
+    <PackageLicenseUrl>https://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
+    <PackageIconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</PackageIconUrl>
+  </PropertyGroup>
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.6</TargetFramework>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Network.Bluetooth.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Tizen" Version="1.0.5" />
+    <PackageReference Include="Tizen.System.Information" Version="1.0.4" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth.snk b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth.snk
new file mode 100644 (file)
index 0000000..f3d151d
Binary files /dev/null and b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth.snk differ
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAdapter.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAdapter.cs
new file mode 100644 (file)
index 0000000..ee9aca5
--- /dev/null
@@ -0,0 +1,506 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Network.Bluetooth
+{
+    /// <summary>
+    /// This class is used to control the Bluetooth adapter and get the list of bonded devices.<br>
+    /// The BluetoothAdapter class is used to discover neighbouring bluetooth devices.
+    /// </summary>
+    /// <privilege> http://tizen.org/privilege/bluetooth </privilege>
+    static public class BluetoothAdapter
+    {
+        /// <summary>
+        /// A property to check whether the Bluetooth is enabled.
+        /// </summary>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
+        static public bool IsBluetoothEnabled
+        {
+            get
+            {
+                return BluetoothAdapterImpl.Instance.IsBluetoothEnabled;
+            }
+        }
+
+        /// <summary>
+        /// The local adapter address.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
+        static public string Address
+        {
+            get
+            {
+                if (IsBluetoothEnabled)
+                {
+                    return BluetoothAdapterImpl.Instance.Address;
+                }
+                else
+                {
+                    return null;
+                }
+            }
+        }
+
+        /// <summary>
+        /// The name of the local adapter.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
+        static public string Name
+        {
+            get
+            {
+                if (IsBluetoothEnabled)
+                {
+                    return BluetoothAdapterImpl.Instance.Name;
+                }
+                else
+                {
+                    return null;
+                }
+            }
+            set
+            {
+                BluetoothAdapterImpl.Instance.Name = value;
+            }
+        }
+
+        /// <summary>
+        /// The visibility mode of the Bluetooth adapter.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
+        static public VisibilityMode Visibility
+        {
+            get
+            {
+                if (IsBluetoothEnabled)
+                {
+                    return BluetoothAdapterImpl.Instance.Visibility;
+                }
+                else
+                {
+                    return VisibilityMode.NonDiscoverable;
+                }
+            }
+        }
+
+        /// <summary>
+        /// A property to check whether the device discovery process is in progress.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
+        static public bool IsDiscoveryInProgress
+        {
+            get
+            {
+                if (IsBluetoothEnabled)
+                {
+                    return BluetoothAdapterImpl.Instance.IsDiscoveryInProgress;
+                }
+                else
+                {
+                    return false;
+                }
+            }
+        }
+
+        /// <summary>
+        /// The remaining time, in seconds, until the visibility mode is changed from TimeLimitedDiscoverable to NonDiscoverable.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
+        static public int RemainingTimeAsVisible
+        {
+            get
+            {
+                if (IsBluetoothEnabled)
+                {
+                    return BluetoothAdapterImpl.Instance.RemainingTimeAsVisible;
+                }
+                else
+                {
+                    return 0;
+                }
+            }
+        }
+
+        /// <summary>
+        /// The StateChanged event is raised when the Bluetooth adapter state is changed.
+        /// </summary>
+        static public event EventHandler<StateChangedEventArgs> StateChanged
+        {
+            add
+            {
+                BluetoothAdapterImpl.Instance.StateChanged += value;
+            }
+            remove
+            {
+                BluetoothAdapterImpl.Instance.StateChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// The NameChanged event is raised when the Bluetooth adapter name is changed.
+        /// </summary>
+        static public event EventHandler<NameChangedEventArgs> NameChanged
+        {
+            add
+            {
+                BluetoothAdapterImpl.Instance.NameChanged += value;
+            }
+            remove
+            {
+                BluetoothAdapterImpl.Instance.NameChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// The VisibilityModeChanged event is raised when the Bluetooth adapter visibility mode is changed.
+        /// </summary>
+        static public event EventHandler<VisibilityModeChangedEventArgs> VisibilityModeChanged
+        {
+            add
+            {
+                BluetoothAdapterImpl.Instance.VisibilityModeChanged += value;
+            }
+            remove
+            {
+                BluetoothAdapterImpl.Instance.VisibilityModeChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// The VisibilityDurationChanged event is raised very second until the visibility mode is changed to NonDiscoverable.
+        /// </summary>
+        static public event EventHandler<VisibilityDurationChangedEventArgs> VisibilityDurationChanged
+        {
+            add
+            {
+                BluetoothAdapterImpl.Instance.VisibilityDurationChanged += value;
+            }
+            remove
+            {
+                BluetoothAdapterImpl.Instance.VisibilityDurationChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// The DiscoveryStateChanged event is raised when the device discovery state is changed.
+        /// </summary>
+        static public event EventHandler<DiscoveryStateChangedEventArgs> DiscoveryStateChanged
+        {
+            add
+            {
+                BluetoothAdapterImpl.Instance.DiscoveryStateChanged += value;
+            }
+            remove
+            {
+                BluetoothAdapterImpl.Instance.DiscoveryStateChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// This event is called when the LE scan result is obtained.
+        /// </summary>
+        static public event EventHandler<AdapterLeScanResultChangedEventArgs> ScanResultChanged
+        {
+            add
+            {
+                BluetoothLeImplAdapter.Instance.AdapterLeScanResultChanged += value;
+            }
+            remove {
+                BluetoothLeImplAdapter.Instance.AdapterLeScanResultChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// Starts the device discovery process.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled and the device discovery process can be stopped by StopDiscovery().
+        /// If this succeeds, the DiscoveryStateChanged event will be invoked.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or the start discovery fails.</exception>
+        static public void StartDiscovery()
+        {
+            if (IsBluetoothEnabled)
+            {
+                BluetoothAdapterImpl.Instance.StartDiscovery();
+            }
+        }
+
+        /// <summary>
+        /// Stops the device discovery process.
+        /// </summary>
+        /// <remarks>
+        /// The device discovery process must be in progress with StartDiscovery().
+        /// If this succeeds, the DiscoveryStateChanged event will be invoked.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled or 
+        /// the discovery process is not is progress. </exception>
+        static public void StopDiscovery()
+        {
+            if (IsDiscoveryInProgress)
+            {
+                BluetoothAdapterImpl.Instance.StopDiscovery();
+            }
+        }
+
+        /// <summary>
+        /// Retrieves the device information of all bonded devices.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <returns> The list of the bonded BluetoothDeviceInfo objects.</returns>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or reading the Bonded devices list is failed.</exception>
+        static public IEnumerable<BluetoothDevice> GetBondedDevices()
+        {
+            if (IsBluetoothEnabled)
+            {
+                return BluetoothAdapterImpl.Instance.GetBondedDevices();
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        /// <summary>
+        /// Gets the device information of a bonded device.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <returns> Information of the bonded BluetoothDeviceInfo object.</returns>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or reading the bonded device information fails.</exception>
+        static public BluetoothDevice GetBondedDevice(string address)
+        {
+            if (IsBluetoothEnabled)
+            {
+                return BluetoothAdapterImpl.Instance.GetBondedDevice(address);
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        /// <summary>
+        /// Checks whether the UUID of service is used or not.
+        /// </summary>
+        /// <returns><c>true</c> if the specified serviceUuid is used, otherwise <c>false</c>.</returns>
+        /// <param name="serviceUuid">The UUID of Service.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
+        static public bool IsServiceUsed(string serviceUuid)
+        {
+            return BluetoothAdapterImpl.Instance.IsServiceUsed(serviceUuid);
+        }
+
+        /// <summary>
+        /// Gets the hash and the randomizer value of the local OOB data object.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <returns>The BluetoothOobData object.</returns>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or the read OObData procedure is failed.</exception>
+        static public BluetoothOobData GetLocalOobData()
+        {
+            if (IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                return BluetoothAdapterImpl.Instance.GetLocalOobData();
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        /// <summary>
+        /// Sets the hash and the randmoizer value of the OOB data into the remote device.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <param name="address">The remote device address.</param>
+        /// <param name="oobData">The BluetoothOobData object.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or the set OobData procedure is failed.</exception>
+        static public void SetRemoteOobData(string address, BluetoothOobData oobData)
+        {
+            if (IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                BluetoothAdapterImpl.Instance.SetRemoteOobData(address, oobData);
+            }
+        }
+
+        /// <summary>
+        /// Removes the hash and the randomizer value of the OOB data from the remote device.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <param name="address">The remote device address.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.
+        /// or if the Remove Oobdata procedure is failed.</exception>
+        static public void RemoveRemoteOobData(string address)
+        {
+            if (IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                BluetoothAdapterImpl.Instance.RemoveRemoteOobData(address);
+            }
+        }
+
+        /// <summary>
+        /// Starts the Bluetooth LE scan operation to discover BLE devices
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>The result of the operation StartLeScan.
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// or the Start LE scan is failed.</exception>
+        static public void StartLeScan()
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                int ret = BluetoothLeImplAdapter.Instance.StartScan ();
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to in start the le scan operation, Error - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        /// <summary>
+        /// Stops the Bluetooth LE scan operation.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>The result of the operation stopLescan.
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// or the Stop LE scan is failed.</exception>
+        static public void StopLeScan()
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                int ret = BluetoothLeImplAdapter.Instance.StopScan ();
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to stop the le scan operation, Error - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        /// <summary>
+        /// Returns the BluetoothLeAdvertiser instance.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled before calling this API.
+        /// </remarks>
+        /// <returns>The BluetoothLeAdvertiser instance.</returns>
+        static public BluetoothLeAdvertiser GetBluetoothLeAdvertiser()
+        {
+            return BluetoothLeAdvertiser.Instance;
+        }
+
+        /// <summary>
+        /// Registers a rfcomm server socket with a specific UUID.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled before calling this API.
+        /// </remarks>
+        /// <returns>The BluetoothServerSocket instance.</returns>
+        /// <param name="serviceUuid">The UUID of service to provide.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or the socket create error occurs.</exception>
+        static public BluetoothServerSocket CreateServerSocket(string serviceUuid)
+        {
+            if (IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                return BluetoothAdapterImpl.Instance.CreateServerSocket (serviceUuid);
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        /// <summary>
+        /// Removes the rfcomm server socket which was created using CreateServerSocket().
+        /// </summary>
+        /// <remarks>
+        /// The socket must be created with CreateServerSocket(). The ConnectionStateChanged event is raised after this API is called.
+        /// </remarks>
+        /// <param name="socket">The server socket instance is created using CreateServerSocket().</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or the socket destroy error occurs.</exception>
+        static public void DestroyServerSocket(BluetoothServerSocket socket)
+        {
+            if (IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                BluetoothAdapterImpl.Instance.DestroyServerSocket(socket);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAdapterImpl.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAdapterImpl.cs
new file mode 100644 (file)
index 0000000..7adcffe
--- /dev/null
@@ -0,0 +1,636 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Bluetooth
+{
+    static internal class Globals
+    {
+        internal const string LogTag = "Tizen.Network.Bluetooth";
+        internal static bool IsInitialize = false;
+        internal static bool IsAudioInitialize = false;
+        internal static bool IsHidInitialize = false;
+    }
+
+    internal partial class BluetoothAdapterImpl : IDisposable
+    {
+        private event EventHandler<StateChangedEventArgs> _stateChanged;
+        private event EventHandler<NameChangedEventArgs> _nameChanged;
+        private event EventHandler<VisibilityModeChangedEventArgs> _visibilityModeChanged;
+        private event EventHandler<VisibilityDurationChangedEventArgs> _visibilityDurationChanged;
+        private event EventHandler<DiscoveryStateChangedEventArgs> _discoveryStateChanged;
+
+        private Interop.Bluetooth.StateChangedCallback _stateChangedCallback;
+        private Interop.Bluetooth.NameChangedCallback _nameChangedCallback;
+        private Interop.Bluetooth.VisibilityModeChangedCallback _visibilityChangedCallback;
+        private Interop.Bluetooth.VisibilityDurationChangedCallback _visibilitydurationChangedCallback;
+        private Interop.Bluetooth.DiscoveryStateChangedCallback _discoveryStateChangedCallback;
+
+        private static readonly BluetoothAdapterImpl _instance = new BluetoothAdapterImpl();
+        private bool disposed = false;
+
+        internal event EventHandler<StateChangedEventArgs> StateChanged
+        {
+            add
+            {
+                if (_stateChanged == null)
+                {
+                    RegisterStateChangedEvent();
+                }
+                _stateChanged += value;
+            }
+            remove
+            {
+                _stateChanged -= value;
+                if (_stateChanged == null)
+                {
+                    UnregisterStateChangedEvent();
+                }
+            }
+        }
+
+        internal event EventHandler<NameChangedEventArgs> NameChanged
+        {
+            add
+            {
+                if (_nameChanged == null)
+                {
+                    RegisterNameChangedEvent();
+                }
+                _nameChanged += value;
+            }
+            remove
+            {
+                _nameChanged -= value;
+                if (_nameChanged == null)
+                {
+                    UnregisterNameChangedEvent();
+                }
+            }
+        }
+
+        internal event EventHandler<VisibilityModeChangedEventArgs> VisibilityModeChanged
+        {
+            add
+            {
+                if (_visibilityModeChanged == null)
+                {
+                    RegisterVisibilityChangedEvent();
+                }
+                _visibilityModeChanged += value;
+            }
+            remove
+            {
+                _visibilityModeChanged -= value;
+                if (_visibilityModeChanged == null)
+                {
+                    UnregisterVisibilityChangedEvent();
+                }
+            }
+        }
+
+        internal event EventHandler<VisibilityDurationChangedEventArgs> VisibilityDurationChanged
+        {
+            add
+            {
+                if (_visibilityDurationChanged == null)
+                {
+                    RegisterVisibilityDurationChangedEvent();
+                }
+                _visibilityDurationChanged += value;
+            }
+            remove
+            {
+                _visibilityDurationChanged -= value;
+                if (_visibilityDurationChanged == null)
+                {
+                    UnregisterVisibilityDurationChangedEvent();
+                }
+            }
+        }
+
+        internal event EventHandler<DiscoveryStateChangedEventArgs> DiscoveryStateChanged
+        {
+            add
+            {
+                if (_discoveryStateChanged == null)
+                {
+                    RegisterDiscoveryStateChangedEvent();
+                }
+                _discoveryStateChanged+= value;
+            }
+            remove
+            {
+                _discoveryStateChanged -= value;
+                if (_discoveryStateChanged == null)
+                {
+                    UnregisterDiscoveryStateChangedEvent();
+                }
+            }
+        }
+
+        private void RegisterStateChangedEvent()
+        {
+            _stateChangedCallback = (int result, int state, IntPtr userData) =>
+            {
+                if (_stateChanged != null)
+                {
+                    BluetoothState st = (BluetoothState)state;
+                    BluetoothError res = (BluetoothError)result;
+                    _stateChanged(null, new StateChangedEventArgs(res,st));
+                }
+            };
+            int ret = Interop.Bluetooth.SetStateChangedCallback(_stateChangedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set state changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void UnregisterStateChangedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetStateChangedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset state changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void RegisterNameChangedEvent()
+        {
+            _nameChangedCallback = (string deviceName, IntPtr userData) =>
+            {
+                if (_nameChanged != null)
+                {
+                    _nameChanged(null, new NameChangedEventArgs(deviceName));
+                }
+            };
+            int ret = Interop.Bluetooth.SetNameChangedCallback(_nameChangedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set name changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void UnregisterNameChangedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetNameChangedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset name changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void RegisterVisibilityChangedEvent()
+        {
+            _visibilityChangedCallback = (int result, int mode, IntPtr userData) =>
+            {
+                if (_visibilityModeChanged != null)
+                {
+                    VisibilityMode visibility = (VisibilityMode)mode;
+                    BluetoothError res = (BluetoothError)result;
+                    _visibilityModeChanged(null, new VisibilityModeChangedEventArgs(res,visibility));
+                }
+            };
+            int ret = Interop.Bluetooth.SetVisibilityModeChangedCallback(_visibilityChangedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set visibility mode changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void UnregisterVisibilityChangedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetVisibilityModeChangedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset visibility mode changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void RegisterVisibilityDurationChangedEvent()
+        {
+            _visibilitydurationChangedCallback = (int duration, IntPtr userData) =>
+            {
+                if (_visibilityDurationChanged != null)
+                {
+                    _visibilityDurationChanged(null, new VisibilityDurationChangedEventArgs(duration));
+                }
+            };
+            int ret = Interop.Bluetooth.SetVisibilityDurationChangedCallback(_visibilitydurationChangedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set visibility duration changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void UnregisterVisibilityDurationChangedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetVisibilityDurationChangedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset visiiblity duration changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void RegisterDiscoveryStateChangedEvent()
+        {
+            _discoveryStateChangedCallback = (int result, BluetoothDeviceDiscoveryState state, IntPtr deviceInfo, IntPtr userData) =>
+            {
+                Log.Info(Globals.LogTag, "Discovery state changed callback is called");
+                if (_discoveryStateChanged != null)
+                {
+                    BluetoothError res = (BluetoothError)result;
+                    switch(state)
+                    {
+                    case BluetoothDeviceDiscoveryState.Started:
+                        _discoveryStateChanged(null, new DiscoveryStateChangedEventArgs(res,state));
+                        break;
+                    case BluetoothDeviceDiscoveryState.Finished:
+                        {
+                            _discoveryStateChanged(null, new DiscoveryStateChangedEventArgs(res,state));
+                            break;
+                        }
+                    case BluetoothDeviceDiscoveryState.Found:
+                        {
+                            BluetoothDiscoveredDeviceStruct info = (BluetoothDiscoveredDeviceStruct)Marshal.PtrToStructure(deviceInfo, typeof(BluetoothDiscoveredDeviceStruct));
+                            _discoveryStateChanged(null, new DiscoveryStateChangedEventArgs(res,state,BluetoothUtils.ConvertStructToDiscoveredDevice(info)));
+                            break;
+                        }
+                    default:
+                        break;
+                    }
+                }
+            };
+            int ret = Interop.Bluetooth.SetDiscoveryStateChangedCallback(_discoveryStateChangedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set discovery state changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void UnregisterDiscoveryStateChangedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetDiscoveryStateChangedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset discovery state changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        internal bool IsBluetoothEnabled
+        {
+            get
+            {
+                BluetoothState active;
+                int ret = Interop.Bluetooth.GetState(out active);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get state, Error - " + (BluetoothError)ret);
+                }
+                if (active == BluetoothState.Enabled)
+                    return true;
+                else
+                    return false;
+            }
+        }
+        internal string Address
+        {
+            get
+            {
+                string address;
+                int ret = Interop.Bluetooth.GetAddress(out address);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get address, Error - " + (BluetoothError)ret);
+                    return "";
+                }
+                return address;
+            }
+        }
+
+        internal VisibilityMode Visibility
+        {
+            get
+            {
+                int visibilityMode;
+                int time;
+                int ret = Interop.Bluetooth.GetVisibility(out visibilityMode, out time);
+                if(ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get visibility mode, Error - " + (BluetoothError)ret);
+                    return VisibilityMode.NonDiscoverable;
+                }
+                return (VisibilityMode)visibilityMode;
+            }
+        }
+
+        internal bool IsDiscoveryInProgress
+        {
+            get
+            {
+                bool isDiscovering;
+                int ret = Interop.Bluetooth.IsDiscovering(out isDiscovering);
+                if(ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get discovery progress state, Error - " + (BluetoothError)ret);
+                }
+                return isDiscovering;
+            }
+        }
+
+        internal int RemainingTimeAsVisible
+        {
+            get
+            {
+                int duration = 0;
+                int visibilityMode;
+                int ret = Interop.Bluetooth.GetVisibility(out visibilityMode, out duration);
+                if ((ret != (int)BluetoothError.None) || ((VisibilityMode)visibilityMode != VisibilityMode.TimeLimitedDiscoverable))
+                {
+                    Log.Error(Globals.LogTag, "Failed to get remaining visible time, Error - " + (BluetoothError)ret);
+                }
+                return duration;
+            }
+        }
+
+        internal string Name
+        {
+            get
+            {
+                string name;
+                int ret = Interop.Bluetooth.GetName(out name);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get adapter name, Error - " + (BluetoothError)ret);
+                    return "";
+                }
+                return name;
+            }
+            set
+            {
+                int ret = Interop.Bluetooth.SetName(value.ToString());
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to set adapter name, Error - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+        }
+
+        internal void StartDiscovery()
+        {
+            int ret = Interop.Bluetooth.StartDiscovery();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to start discovery, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        internal void StopDiscovery()
+        {
+            int ret = Interop.Bluetooth.StopDiscovery();
+            if(ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to stop discovery, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        internal IEnumerable<BluetoothDevice> GetBondedDevices()
+        {
+            List<BluetoothDevice> deviceList = new List<BluetoothDevice>();
+            Interop.Bluetooth.BondedDeviceCallback callback = (ref BluetoothDeviceStruct deviceInfo, IntPtr userData) =>
+            {
+                Log.Info(Globals.LogTag, "Bonded devices cb is called");
+                if(!deviceInfo.Equals(null))
+                {
+                    deviceList.Add(BluetoothUtils.ConvertStructToDeviceClass(deviceInfo));
+                }
+                return true;
+            };
+            int ret = Interop.Bluetooth.GetBondedDevices(callback, IntPtr.Zero);
+            if(ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to get bonded devices, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+            return deviceList;
+        }
+
+        internal BluetoothDevice GetBondedDevice(string address)
+        {
+            IntPtr deviceInfo;
+            int ret = Interop.Bluetooth.GetBondedDeviceByAddress(address, out deviceInfo);
+            if(ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to get bonded device by address, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+            BluetoothDeviceStruct device = (BluetoothDeviceStruct)Marshal.PtrToStructure(deviceInfo, typeof(BluetoothDeviceStruct));
+
+            return BluetoothUtils.ConvertStructToDeviceClass(device);
+        }
+
+        internal bool IsServiceUsed(string serviceUuid)
+        {
+            bool isUsed;
+            int ret = Interop.Bluetooth.IsServiceUsed(serviceUuid, out isUsed);
+            if(ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to check the usage of service, Error - " + (BluetoothError)ret);
+            }
+            return isUsed;
+        }
+
+        internal BluetoothOobData GetLocalOobData()
+        {
+            BluetoothOobData oobData = new BluetoothOobData();
+            IntPtr hash;
+            IntPtr randomizer;
+            int hashLength;
+            int randomizerLength;
+            int ret = Interop.Bluetooth.GetOobData(out hash, out randomizer, out hashLength, out randomizerLength);
+            if(ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to get the local oob data, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+
+            byte[] hashArr = new byte[hashLength];
+            Marshal.Copy(hash, hashArr, 0, hashLength);
+            byte[] randomizerArr = new byte[randomizerLength];
+            Marshal.Copy(randomizer, randomizerArr, 0, randomizerLength);
+
+            oobData.HashValue = hashArr;
+            oobData.RandomizerValue = randomizerArr;
+            return oobData;
+        }
+
+        internal void SetRemoteOobData(string deviceAddress, BluetoothOobData oobData)
+        {
+            byte[] hash = oobData.HashValue;
+            byte[] randomizer = oobData.RandomizerValue;
+            int hashLength = hash.Length;
+            int randomizerLength = randomizer.Length;
+
+            IntPtr hashPtr = Marshal.AllocHGlobal(hashLength);
+            Marshal.Copy(hash, 0, hashPtr, hashLength);
+            IntPtr randomizerPtr = Marshal.AllocHGlobal(randomizerLength);
+            Marshal.Copy(randomizer, 0, randomizerPtr, randomizerLength);
+
+            int ret = Interop.Bluetooth.SetOobData(deviceAddress, hashPtr, randomizerPtr, hashLength, randomizerLength);
+            if(ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set the remote oob data, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        internal void RemoveRemoteOobData(string deviceAddress)
+        {
+            int ret = Interop.Bluetooth.RemoveOobData(deviceAddress);
+            if(ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to remove the remote oob data, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        internal BluetoothServerSocket CreateServerSocket(string serviceUuid)
+        {
+            int socketFd;
+            int ret = Interop.Bluetooth.CreateServerSocket(serviceUuid, out socketFd);
+            if(ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to create server socket, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+            Log.Info (Globals.LogTag, "Created socketfd: "+ socketFd);
+            return new BluetoothServerSocket(socketFd);
+        }
+
+        internal void DestroyServerSocket(BluetoothServerSocket socket)
+        {
+            int ret = Interop.Bluetooth.DestroyServerSocket(socket.socketFd);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to destroy socket, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        internal static BluetoothAdapterImpl Instance
+        {
+            get
+            {
+                return _instance;
+            }
+        }
+
+        private BluetoothAdapterImpl()
+        {
+            initialize();
+        }
+
+        ~BluetoothAdapterImpl()
+        {
+            Dispose(false);
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            if (disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects.
+            }
+            //Free unmanaged objects
+            RemoveAllRegisteredEvent();
+            deinitialize();
+            disposed = true;
+        }
+
+        private void initialize()
+        {
+            int ret = Interop.Bluetooth.Initialize();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error (Globals.LogTag, "Failed to initialize bluetooth, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException (ret);
+            }
+            else
+            {
+                Globals.IsInitialize = true;
+            }
+        }
+
+        private void deinitialize()
+        {
+            int ret = Interop.Bluetooth.Deinitialize();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error (Globals.LogTag, "Failed to deinitialize bluetooth, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException (ret);
+            }
+            else
+            {
+                Globals.IsInitialize = false;
+            }
+        }
+
+        private void RemoveAllRegisteredEvent()
+        {
+            //unregister all remaining events when this object is released.
+            if (_stateChanged != null)
+            {
+                UnregisterStateChangedEvent();
+            }
+
+            if (_nameChanged != null)
+            {
+                UnregisterNameChangedEvent();
+            }
+
+            if (_visibilityDurationChanged != null)
+            {
+                UnregisterVisibilityDurationChangedEvent();
+            }
+
+            if (_visibilityModeChanged != null)
+            {
+                UnregisterVisibilityChangedEvent();
+            }
+
+            if (_discoveryStateChanged != null)
+            {
+                UnregisterDiscoveryStateChangedEvent();
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAudio.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAudio.cs
new file mode 100644 (file)
index 0000000..614607f
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Network.Bluetooth
+{
+    /// <summary>
+    /// This class is used to handle the connection with other Bluetooth audio devices
+    /// like headset, hands-free, and headphone.
+    /// </summary>
+    /// <privilege> http://tizen.org/privilege/bluetooth </privilege>
+    public class BluetoothAudio : BluetoothProfile
+    {
+        internal BluetoothAudio()
+        {
+        }
+
+        /// <summary>
+        /// The AudioConnectionStateChanged event is called when the audio connection state is changed.
+        /// </summary>
+        public event EventHandler<AudioConnectionStateChangedEventArgs> AudioConnectionStateChanged
+        {
+            add
+            {
+                BluetoothAudioImpl.Instance.AudioConnectionStateChanged += value;
+            }
+            remove
+            {
+                BluetoothAudioImpl.Instance.AudioConnectionStateChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// Connects the remote device with the given audio profile.
+        /// </summary>
+        /// <remarks>
+        /// The device must be bonded with the remote device by CreateBond(). If connection request succeeds, the AudioConnectionStateChanged event will be invoked.
+        /// If audio profile type is All and this request succeeds, then the AudioConnectionStateChanged event will be called twice when HspHfp <br>
+        /// and AdvancedAudioDistribution is connected.
+        /// </remarks>
+        /// <param name="profileType">The type of the audio profile.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when the connection attempt fails.</exception>
+        public void Connect(BluetoothAudioProfileType profileType)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                int ret = BluetoothAudioImpl.Instance.Connect(RemoteAddress, profileType);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to Connect - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        /// <summary>
+        /// Disconnects the remote device with the given audio profile.
+        /// </summary>
+        /// <remarks>
+        /// The device must be connected by Connect(). If the disconnection request succeeds, the AudioConnectionStateChanged event will be invoked.
+        /// If audio profile type is All and this request succeeds, then the AudioConnectionStateChanged event will be called twice when HspHfp <br>
+        /// and AdvancedAudioDistribution is disconnected.
+        /// </remarks>
+        /// <param name="type">The type of the audio profile.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when Disconnection attempt fails.</exception>
+        public void Disconnect(BluetoothAudioProfileType type)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                int ret = BluetoothAudioImpl.Instance.Disconnect(RemoteAddress, type);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to Disconnect - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAudioImpl.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAudioImpl.cs
new file mode 100644 (file)
index 0000000..6570dc9
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Network.Bluetooth
+{
+    internal class BluetoothAudioImpl : IDisposable
+    {
+        private event EventHandler<AudioConnectionStateChangedEventArgs> _audioConnectionChanged;
+        private Interop.Bluetooth.AudioConnectionStateChangedCallback _audioConnectionChangedCallback;
+
+        private static readonly BluetoothAudioImpl _instance = new BluetoothAudioImpl();
+        private bool disposed = false;
+
+        internal event EventHandler<AudioConnectionStateChangedEventArgs> AudioConnectionStateChanged
+        {
+            add
+            {
+                if (_audioConnectionChanged == null)
+                {
+                    RegisterAudioConnectionChangedEvent();
+                }
+                _audioConnectionChanged += value;
+            }
+            remove
+            {
+                _audioConnectionChanged -= value;
+                if (_audioConnectionChanged == null)
+                {
+                    UnregisterAudioConnectionChangedEvent();
+                }
+            }
+        }
+
+        private void RegisterAudioConnectionChangedEvent()
+        {
+            _audioConnectionChangedCallback = (int result, bool connected, string deviceAddress, int profileType, IntPtr userData) =>
+            {
+                if (_audioConnectionChanged != null)
+                {
+                    _audioConnectionChanged(null, new AudioConnectionStateChangedEventArgs(result, connected, deviceAddress, (BluetoothAudioProfileType)profileType));
+                }
+            };
+            int ret = Interop.Bluetooth.SetAudioConnectionStateChangedCallback(_audioConnectionChangedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set audio connection changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void UnregisterAudioConnectionChangedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetAudioConnectionStateChangedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset audio connection changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        internal int Connect(string deviceAddress, BluetoothAudioProfileType type)
+        {
+            int ret = Interop.Bluetooth.Connect(deviceAddress, (int)type);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to connect device with the given profile type, Error - " + (BluetoothError)ret);
+            }
+            return ret;
+        }
+
+        internal int Disconnect(string deviceAddress, BluetoothAudioProfileType type)
+        {
+            int ret = Interop.Bluetooth.Disconnect(deviceAddress, (int)type);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to disconnect device with the given profile type, Error - " + (BluetoothError)ret);
+            }
+            return ret;
+        }
+
+        internal static BluetoothAudioImpl Instance
+        {
+            get
+            {
+                return _instance;
+            }
+        }
+
+        private BluetoothAudioImpl ()
+        {
+            Log.Info(Globals.LogTag, "Initializing audio");
+            initialize();
+        }
+
+        ~BluetoothAudioImpl()
+        {
+            Dispose(false);
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            if (disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects.
+            }
+            //Free unmanaged objects
+            deinitialize();
+            RemoveAllRegisteredEvent();
+            disposed = true;
+        }
+
+        private void initialize()
+        {
+            if (Globals.IsInitialize)
+            {
+                int ret = Interop.Bluetooth.InitializeAudio ();
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to initialize bluetoothaudio, Error - " + (BluetoothError)ret);
+                    Globals.IsAudioInitialize = false;
+                    BluetoothErrorFactory.ThrowBluetoothException (ret);
+                }
+                else
+                {
+                    Globals.IsAudioInitialize = true;
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotInitialized);
+            }
+        }
+
+        private void deinitialize()
+        {
+            if (Globals.IsAudioInitialize) {
+                int ret = Interop.Bluetooth.DeinitializeAudio ();
+                if (ret != (int)BluetoothError.None) {
+                    Log.Error (Globals.LogTag, "Failed to deinitialize bluetoothaudio, Error - " + (BluetoothError)ret);
+                }
+            }
+        }
+
+        private void RemoveAllRegisteredEvent()
+        {
+            if (_audioConnectionChanged != null)
+            {
+                UnregisterAudioConnectionChangedEvent();
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAvrcp.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAvrcp.cs
new file mode 100644 (file)
index 0000000..ac814ee
--- /dev/null
@@ -0,0 +1,262 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Network.Bluetooth
+{
+    /// <summary>
+    /// This class is used to notify changes of the target device (For example, media player) to the control device (For example, headset).
+    /// </summary>
+    /// <privilege> http://tizen.org/privilege/bluetooth </privilege>
+    public class BluetoothAvrcp : BluetoothProfile
+    {
+        internal BluetoothAvrcp()
+        {
+        }
+
+        /// <summary>
+        /// The TargetConnectionStateChanged event is invoked when the connection state is changed.
+        /// </summary>
+        public event EventHandler<TargetConnectionStateChangedEventArgs> TargetConnectionStateChanged
+        {
+            add
+            {
+                BluetoothAvrcpImpl.Instance.TargetConnectionStateChanged += value;
+            }
+            remove
+            {
+                BluetoothAvrcpImpl.Instance.TargetConnectionStateChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// The EqualizerStateChanged event is invoked when the equalizer state is changed by the remote control device.
+        /// </summary>
+        public event EventHandler<EqualizerStateChangedEventArgs> EqualizerStateChanged
+        {
+            add
+            {
+                BluetoothAvrcpImpl.Instance.EqualizerStateChanged += value;
+            }
+            remove
+            {
+                BluetoothAvrcpImpl.Instance.EqualizerStateChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// The RepeatModeChanged event is invoked when the repeat mode is changed by the remote control device.
+        /// </summary>
+        public event EventHandler<RepeatModeChangedEventArgs> RepeatModeChanged
+        {
+            add
+            {
+                BluetoothAvrcpImpl.Instance.RepeatModeChanged += value;
+            }
+            remove
+            {
+                BluetoothAvrcpImpl.Instance.RepeatModeChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// The ShuffleModeChanged event is invoked when the shuffle mode is changed by the remote control device.
+        /// </summary>
+        public event EventHandler<ShuffleModeChangedeventArgs> ShuffleModeChanged
+        {
+            add
+            {
+                BluetoothAvrcpImpl.Instance.ShuffleModeChanged += value;
+            }
+            remove
+            {
+                BluetoothAvrcpImpl.Instance.ShuffleModeChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// The ScanModeChanged event is invoked when the scan mode is changed by the remote control device.
+        /// </summary>
+        public event EventHandler<ScanModeChangedEventArgs> ScanModeChanged
+        {
+            add
+            {
+                BluetoothAvrcpImpl.Instance.ScanModeChanged += value;
+            }
+            remove
+            {
+                BluetoothAvrcpImpl.Instance.ScanModeChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// Notifies the equalize state to the remote device.
+        /// </summary>
+        /// <remarks>
+        /// The remote device must be connected.
+        /// </remarks>
+        /// <param name="state">The equalizer state.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when notifying the equalizer state to the remote device fails.</exception>
+        public void NotifyEqualizerState(EqualizerState state)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                BluetoothAvrcpImpl.Instance.NotifyEqualizeState(state);
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        /// <summary>
+        /// Notifies the repeat mode to the remote device.
+        /// </summary>
+        /// <remarks>
+        /// The remote device must be connected.
+        /// </remarks>
+        /// <param name="mode">The repeat mode.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when notifying the repeat mode state to the remote device fails.</exception>
+        /// </exception>
+        public void NotifyRepeatMode(RepeatMode mode)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                BluetoothAvrcpImpl.Instance.NotifyRepeatMode(mode);
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        /// <summary>
+        /// Notifies the shuffle mode to the remote device.
+        /// </summary>
+        /// <remarks>
+        /// The remote device must be connected.
+        /// </remarks>
+        /// <param name="mode">The shuffle mode.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when notifying the shuffle mode state to the remote device fails.</exception>
+        public void NotifyShuffleMode(ShuffleMode mode)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                BluetoothAvrcpImpl.Instance.NotifyShuffleMode(mode);
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        /// <summary>
+        /// Notifies the scan mode to the remote device.
+        /// </summary>
+        /// <remarks>
+        /// The remote device must be connected.
+        /// </remarks>
+        /// <param name="mode">The scan mode.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when notifying the scan mode state to the remote device fails.</exception>
+        public void NotifyScanMode(ScanMode mode)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                BluetoothAvrcpImpl.Instance.NotifyScanMode(mode);
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        /// <summary>
+        /// Notifies the player state to the remote device.
+        /// </summary>
+        /// <remarks>
+        /// The remote device must be connected.
+        /// </remarks>
+        /// <param name="state">The player state.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when notifying the player state to the remote device fails.</exception>
+        public void NotifyPlayerState(PlayerState state)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                BluetoothAvrcpImpl.Instance.NotifyPlayerState(state);
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        /// <summary>
+        /// Notifies the current position of the song to the remote device.
+        /// </summary>
+        /// <remarks>
+        /// The remote device must be connected.
+        /// </remarks>
+        /// <param name="position">The current position in milliseconds.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when notifying the current position state to the remote device fails.</exception>
+        public void NotifyCurrentPosition(uint position)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                BluetoothAvrcpImpl.Instance.NotifyCurrentPosition(position);
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        /// <summary>
+        /// Notifies the track to the remote device.
+        /// </summary>
+        /// <remarks>
+        /// The remote device must be connected.
+        /// </remarks>
+        /// <param name="trackData">The data of the track.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when notifying the shuffle track state to the remote device fails.</exception>
+        public void NotifyTrack(Track trackData)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                BluetoothAvrcpImpl.Instance.NotifyTrack(trackData);
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+    }
+}
+
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAvrcpImpl.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAvrcpImpl.cs
new file mode 100644 (file)
index 0000000..28abda8
--- /dev/null
@@ -0,0 +1,419 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Network.Bluetooth
+{
+    internal class BluetoothAvrcpImpl : IDisposable
+    {
+        private event EventHandler<TargetConnectionStateChangedEventArgs> _targetConnectionChanged;
+        private event EventHandler<EqualizerStateChangedEventArgs> _equalizerStateChanged;
+        private event EventHandler<RepeatModeChangedEventArgs> _repeatModeChanged;
+        private event EventHandler<ScanModeChangedEventArgs> _scanModeChanged;
+        private event EventHandler<ShuffleModeChangedeventArgs> _shuffleModeChanged;
+
+        private Interop.Bluetooth.TargetConnectionStateChangedCallback _targetConnectionChangedCallback;
+        private Interop.Bluetooth.EqualizerStateChangedCallback _equalizerStateChangedCallback;
+        private Interop.Bluetooth.RepeatModeChangedCallback _repeatModeChangedCallback;
+        private Interop.Bluetooth.ShuffleModeChangedCallback _shuffleModeChangedCallback;
+        private Interop.Bluetooth.ScanModeChangedCallback _scanModeChangedCallback;
+
+        private static BluetoothAvrcpImpl _instance = new BluetoothAvrcpImpl();
+        private bool disposed = false;
+
+        internal event EventHandler<TargetConnectionStateChangedEventArgs> TargetConnectionStateChanged
+        {
+            add
+            {
+                _targetConnectionChanged += value;
+            }
+            remove
+            {
+                _targetConnectionChanged -= value;
+            }
+        }
+
+        internal event EventHandler<EqualizerStateChangedEventArgs> EqualizerStateChanged
+        {
+            add
+            {
+                if (_equalizerStateChanged == null)
+                {
+                    RegisterEqualizerStateChangedEvent();
+                }
+                _equalizerStateChanged += value;
+            }
+            remove
+            {
+                _equalizerStateChanged -= value;
+                if (_equalizerStateChanged == null)
+                {
+                    UnregisterEqualizerStateChangedEvent();
+                }
+            }
+        }
+
+        internal event EventHandler<RepeatModeChangedEventArgs> RepeatModeChanged
+        {
+            add
+            {
+                if (_repeatModeChanged == null)
+                {
+                    RegisterRepeatModeChangedEvent();
+                }
+                _repeatModeChanged += value;
+            }
+            remove
+            {
+                _repeatModeChanged -= value;
+                if (_repeatModeChanged == null)
+                {
+                    UnregisterRepeatModeChangedEvent();
+                }
+            }
+        }
+
+        internal event EventHandler<ShuffleModeChangedeventArgs> ShuffleModeChanged
+        {
+            add
+            {
+                if (_shuffleModeChanged == null)
+                {
+                    RegisterShuffleModeChangedEvent();
+                }
+                _shuffleModeChanged += value;
+            }
+            remove
+            {
+                _shuffleModeChanged -= value;
+                if (_shuffleModeChanged == null)
+                {
+                    UnregisterShuffleModeChangedEvent();
+                }
+            }
+        }
+
+        internal event EventHandler<ScanModeChangedEventArgs> ScanModeChanged
+        {
+            add
+            {
+                if (_scanModeChanged == null)
+                {
+                    RegisterScanModeChangedEvent();
+                }
+                _scanModeChanged += value;
+            }
+            remove
+            {
+                _scanModeChanged -= value;
+                if (_scanModeChanged == null)
+                {
+                    UnregisterScanModeChangedEvent();
+                }
+            }
+        }
+
+        private void RegisterEqualizerStateChangedEvent()
+        {
+            _equalizerStateChangedCallback = (int equalizer, IntPtr userData) =>
+            {
+                if (_equalizerStateChanged != null)
+                {
+                    EqualizerState state = (EqualizerState) equalizer;
+                    _equalizerStateChanged(null, new EqualizerStateChangedEventArgs(state));
+                }
+            };
+            int ret = Interop.Bluetooth.SetEqualizerStateChangedCallback(_equalizerStateChangedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set equalizer state changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+        private void UnregisterEqualizerStateChangedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetEqualizerStateChangedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset equalizer state changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void RegisterRepeatModeChangedEvent()
+        {
+            _repeatModeChangedCallback = (int repeat, IntPtr userData) =>
+            {
+                if (_repeatModeChanged != null)
+                {
+                    RepeatMode mode = (RepeatMode)repeat;
+                    _repeatModeChanged(null, new RepeatModeChangedEventArgs(mode));
+                }
+            };
+            int ret = Interop.Bluetooth.SetRepeatModeChangedCallback(_repeatModeChangedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set repeat mode changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+        private void UnregisterRepeatModeChangedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetRepeatModeChangedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset repeat mode changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void RegisterShuffleModeChangedEvent()
+        {
+            Log.Debug (Globals.LogTag, "inside RegisterShuffleModeChangedEvent");
+            _shuffleModeChangedCallback = (int shuffle, IntPtr userData) =>
+            {
+                Log.Debug (Globals.LogTag, "inside RegisterShuffleModeChangedEvent callback");
+                if (_shuffleModeChanged != null)
+                {
+                    ShuffleMode mode = (ShuffleMode) shuffle;
+                    _shuffleModeChanged(null, new ShuffleModeChangedeventArgs(mode));
+                }
+            };
+            int ret = Interop.Bluetooth.SetShuffleModeChangedCallback(_shuffleModeChangedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Debug (Globals.LogTag, "failed inside RegisterShuffleModeChangedEvent");
+                Log.Error(Globals.LogTag, "Failed to set shuffle mode changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+        private void UnregisterShuffleModeChangedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetShuffleModeChangedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset shuffle mode changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void RegisterScanModeChangedEvent()
+        {
+            _scanModeChangedCallback = (int scan, IntPtr userData) =>
+            {
+                if (_scanModeChanged != null)
+                {
+                    ScanMode mode = (ScanMode) scan;
+                    _scanModeChanged(null, new ScanModeChangedEventArgs(mode));
+                }
+            };
+            int ret = Interop.Bluetooth.SetScanModeChangedCallback(_scanModeChangedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set scan mode changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+        private void UnregisterScanModeChangedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetScanModeChangedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset scan mode changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void targetInitialize()
+        {
+            if (Globals.IsInitialize)
+            {
+                _targetConnectionChangedCallback = (bool connected, string deviceAddress, IntPtr userData) =>
+                {
+                    if (_targetConnectionChanged != null)
+                    {
+                        _targetConnectionChanged(null, new TargetConnectionStateChangedEventArgs(connected, deviceAddress));
+                    }
+                };
+
+                int ret = Interop.Bluetooth.InitializeAvrcp(_targetConnectionChangedCallback, IntPtr.Zero);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error (Globals.LogTag, "Failed to initialize bluetooth avrcp, Error - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+                else
+                {
+                    Globals.IsAudioInitialize = true;
+                }
+            }
+            else
+            {
+                Log.Error(Globals.LogTag, "Failed to initialize Avrcp, BT not initialized");
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotInitialized);
+            }
+        }
+
+        private void targetDeinitialize()
+        {
+            if (Globals.IsAudioInitialize)
+            {
+                int ret = Interop.Bluetooth.DeinitializeAvrcp();
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error (Globals.LogTag, "Failed to deinitialize bluetooth avrcp, Error - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+                else
+                {
+                    Globals.IsAudioInitialize = false;
+                }
+            }
+        }
+
+        internal void NotifyEqualizeState(EqualizerState state)
+        {
+            int ret = Interop.Bluetooth.NotifyEqualizerState((int)state);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to notify equalizer state to remote device, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        internal void NotifyRepeatMode(RepeatMode repeat)
+        {
+            int ret = Interop.Bluetooth.NotifyRepeatMode((int)repeat);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to notify repeat mode to remote device, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        internal void NotifyShuffleMode(ShuffleMode shuffle)
+        {
+            int ret = Interop.Bluetooth.NotifyShuffleMode((int)shuffle);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to notify shuffle mode to remote device, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        internal void NotifyScanMode(ScanMode scan)
+        {
+            int ret = Interop.Bluetooth.NotifyScanMode((int)scan);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to notify scan mode to remote device, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        internal void NotifyPlayerState(PlayerState state)
+        {
+            int ret = Interop.Bluetooth.NotifyPlayerState((int)state);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to notify player state to remote device, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        internal void NotifyCurrentPosition(uint position)
+        {
+            int ret = Interop.Bluetooth.NotifyCurrentPosition(position);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to notify position to remote device, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        internal void NotifyTrack(Track trackData)
+        {
+            string title = trackData.Title;
+            string artist = trackData.Artist;
+            string album = trackData.Album;
+            string genre = trackData.Genre;
+            uint trackNum = trackData.TrackNum;
+            uint totalTracks = trackData.TotalTracks;
+            uint duration = trackData.Duration;
+
+            int ret = Interop.Bluetooth.NotifyTrack(title, artist, album, genre, trackNum, totalTracks, duration);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to notify track data to the remote device, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        internal static BluetoothAvrcpImpl Instance
+        {
+            get
+            {
+                return _instance;
+            }
+        }
+
+        private BluetoothAvrcpImpl()
+        {
+            targetInitialize();
+        }
+
+        ~BluetoothAvrcpImpl()
+        {
+            Dispose(false);
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            if (disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects.
+            }
+            //Free unmanaged objects
+            targetDeinitialize();
+            RemoveAllRegisteredEvent();
+            disposed = true;
+        }
+
+        private void RemoveAllRegisteredEvent()
+        {
+            //unregister all remaining events when this object is released.
+            if (_equalizerStateChanged != null)
+            {
+                UnregisterEqualizerStateChangedEvent();
+            }
+            if (_repeatModeChanged != null)
+            {
+                UnregisterRepeatModeChangedEvent();
+            }
+            if (_scanModeChanged != null)
+            {
+                UnregisterScanModeChangedEvent();
+            }
+            if (_shuffleModeChanged != null)
+            {
+                UnregisterShuffleModeChangedEvent();
+            }
+        }
+    }
+}
+
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothData.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothData.cs
new file mode 100644 (file)
index 0000000..cf386c5
--- /dev/null
@@ -0,0 +1,499 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+using System.Collections.Concurrent;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+
+namespace Tizen.Network.Bluetooth
+{
+    /// <summary>
+    /// This class is used to handle the device class types and the service.
+    /// </summary>
+    public class BluetoothClass
+    {
+        internal BluetoothMajorDeviceClassType MajorType;
+        internal BluetoothMinorDeviceClassType MinorType;
+        internal int Mask;
+
+        internal BluetoothClass()
+        {
+        }
+
+        /// <summary>
+        /// The type of the major device class.
+        /// </summary>
+        public BluetoothMajorDeviceClassType MajorDeviceClassType
+        {
+            get
+            {
+                return MajorType;
+            }
+        }
+        /// <summary>
+        /// The type of the minor device class.
+        /// </summary>
+        public BluetoothMinorDeviceClassType MinorDeviceClassType
+        {
+            get
+            {
+                return MinorType;
+            }
+        }
+        /// <summary>
+        /// The major service class mask.
+        /// </summary>
+        public int MajorServiceClassMask
+        {
+            get
+            {
+                return Mask;
+            }
+        }
+    }
+
+    /// <summary>
+    /// This class contains the information of the Bluetooth OOB data.
+    /// </summary>
+    public class BluetoothOobData
+    {
+        /// <summary>
+        /// The default constructor. Initializes an object of the BluetoothOobData.
+        /// </summary>
+        public BluetoothOobData()
+        {
+        }
+
+        /// <summary>
+        /// The hash value.
+        /// </summary>
+        public byte[] HashValue
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// The randomizer value.
+        /// </summary>
+        public byte[] RandomizerValue
+        {
+            get;
+            set;
+        }
+    }
+
+    /// <summary>
+    /// This class contains the information of the Bluetooth device SDP data.
+    /// </summary>
+    public class BluetoothDeviceSdpData
+    {
+        internal string Address;
+        internal Collection<string> Uuid;
+
+        internal BluetoothDeviceSdpData()
+        {
+        }
+
+        /// <summary>
+        /// The device address.
+        /// </summary>
+        public string DeviceAddress
+        {
+            get
+            {
+                return Address;
+            }
+        }
+        /// <summary>
+        /// The service UUID.
+        /// </summary>
+        public IEnumerable<string> ServiceUuid
+        {
+            get
+            {
+                return Uuid;
+            }
+        }
+    }
+
+    /// <summary>
+    /// This class contains the information of the Bluetooth device connection data.
+    /// </summary>
+    public class BluetoothDeviceConnectionData
+    {
+        internal string RemoteAddress;
+        internal BluetoothConnectionLinkType Link;
+        internal BluetoothDisconnectReason Reason;
+
+        internal BluetoothDeviceConnectionData()
+        {
+        }
+
+        /// <summary>
+        /// The device address.
+        /// </summary>
+        public string Address
+        {
+            get
+            {
+                return RemoteAddress;
+            }
+        }
+        /// <summary>
+        /// The type of the connection link.
+        /// </summary>
+        public BluetoothConnectionLinkType LinkType
+        {
+            get
+            {
+                return Link;
+            }
+        }
+        /// <summary>
+        /// The disconnect reason.
+        /// </summary>
+        public BluetoothDisconnectReason DisconnectReason
+        {
+            get
+            {
+                return Reason;
+            }
+        }
+    }
+
+    /// <summary>
+    /// This class contains the information of the track data.
+    /// </summary>
+    public class Track
+    {
+        /// <summary>
+        /// The default constructor. Initializes an object of the track.
+        /// </summary>
+        public Track()
+        {
+        }
+
+        /// <summary>
+        /// The title of the track.
+        /// </summary>
+        public string Title
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// The artist of the track.
+        /// </summary>
+        public string Artist
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// The album of the track.
+        /// </summary>
+        public string Album
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// The genre of the track.
+        /// </summary>
+        public string Genre
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// The track number.
+        /// </summary>
+        public uint TrackNum
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// The number of all tracks.
+        /// </summary>
+        public uint TotalTracks
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// The duration of the track in milliseconds.
+        /// </summary>
+        public uint Duration
+        {
+            get;
+            set;
+        }
+    }
+
+    /// <summary>
+    /// This class contains the information of the manufacturer data.
+    /// </summary>
+    public class ManufacturerData
+    {
+        /// <summary>
+        /// The default Constructor. Initializes an object of the ManufacturerData.
+        /// </summary>
+        public ManufacturerData()
+        {
+        }
+
+        /// <summary>
+        /// The manufacturer ID.
+        /// </summary>
+        public int Id
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// The length of the manufacturer data.
+        /// </summary>
+        public int DataLength
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// The manufacturer data.
+        /// </summary>
+        public byte[] Data
+        {
+            get;
+            set;
+        }
+    }
+
+    internal class BluetoothLeScanData
+    {
+        internal string RemoteAddress
+        {
+            get;
+            set;
+        }
+        internal BluetoothLeDeviceAddressType AddressType
+        {
+            get;
+            set;
+        }
+        internal int Rssi
+        {
+            get;
+            set;
+        }
+        internal int AdvDataLength
+        {
+            get;
+            set;
+        }
+        internal byte[] AdvData
+        {
+            get;
+            set;
+        }
+        internal int ScanDataLength
+        {
+            get;
+            set;
+        }
+        internal byte[] ScanData
+        {
+            get;
+            set;
+        }
+    }
+
+    /// <summary>
+    /// This class contains the information of the Bluetooth service data.
+    /// </summary>
+    public class BluetoothServiceData
+    {
+        /// <summary>
+        /// The default constructor. Initializes an object of the BluetoothServiceData.
+        /// </summary>
+        public BluetoothServiceData()
+        {
+        }
+
+        /// <summary>
+        /// The UUID of the service.
+        /// </summary>
+        public string Uuid
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// The data length of the service data.
+        /// </summary>
+        public int DataLength
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// The service data.
+        /// </summary>
+        public byte[] Data
+        {
+            get;
+            set;
+        }
+    }
+
+    /// <summary>
+    /// This class contains the service data information.
+    /// </summary>
+    public class BluetoothLeServiceData
+    {
+        internal string Uuid;
+        internal byte[] Data;
+        internal int Length;
+
+        internal BluetoothLeServiceData()
+        {
+        }
+
+        /// <summary>
+        /// The Bluetooth LE service UUID.
+        /// </summary>
+        public string ServiceUuid
+        {
+            get
+            {
+                return Uuid;
+            }
+        }
+        /// <summary>
+        /// The Bluetooth LE service data.
+        /// </summary>
+        public byte[] ServiceData
+        {
+            get
+            {
+                return Data;
+            }
+        }
+        /// <summary>
+        /// The length of the service data.
+        /// </summary>
+        public int ServiceDataLength
+        {
+            get
+            {
+                return Length;
+            }
+        }
+    }
+
+    /// <summary>
+    /// This class contains the information of the socket data.
+    /// </summary>
+    public class SocketData
+    {
+        internal string RecvData;
+        internal int Size;
+        internal int Fd;
+
+        internal SocketData()
+        {
+        }
+
+        /// <summary>
+        /// The socket FD.
+        /// </summary>
+        public int SocketFd
+        {
+            get
+            {
+                return Fd;
+            }
+        }
+        /// <summary>
+        /// The length of the received data.
+        /// </summary>
+        public int DataSize
+        {
+            get
+            {
+                return Size;
+            }
+        }
+        /// <summary>
+        /// The received data.
+        /// </summary>
+        public string Data
+        {
+            get
+            {
+                return RecvData;
+            }
+        }
+    }
+
+    /// <summary>
+    /// This class contains the information of the socket connection.
+    /// </summary>
+    public class SocketConnection
+    {
+        internal string Uuid;
+        internal string RemoteAddress;
+        internal int Fd;
+
+        internal SocketConnection()
+        {
+        }
+
+        /// <summary>
+        /// The connected socket FD.
+        /// </summary>
+        public int SocketFd
+        {
+            get
+            {
+                return Fd;
+            }
+        }
+        /// <summary>
+        /// The remote device address.
+        /// </summary>
+        public string Address
+        {
+            get
+            {
+                return RemoteAddress;
+            }
+        }
+        /// <summary>
+        /// The service UUID.
+        /// </summary>
+        public string ServiceUuid
+        {
+            get
+            {
+                return Uuid;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothDevice.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothDevice.cs
new file mode 100644 (file)
index 0000000..b0debee
--- /dev/null
@@ -0,0 +1,695 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Collections.Concurrent;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+
+namespace Tizen.Network.Bluetooth
+{
+    /// <summary>
+    /// This class is used to handle the connection with other devices and set authorization of other devices.<br>
+    /// The BluetoothDevice class is used to search for services available on remote devices.
+    /// </summary>
+    /// <privilege> http://tizen.org/privilege/bluetooth </privilege>
+    public class BluetoothDevice
+    {
+        private event EventHandler<BondCreatedEventArgs> _bondCreated;
+        private event EventHandler<BondDestroyedEventArgs> _bondDestroyed;
+        private event EventHandler<AuthorizationChangedEventArgs> _authorizationChanged;
+        private event EventHandler<ServiceSearchedEventArgs> _serviceSearched;
+        private event EventHandler<DeviceConnectionStateChangedEventArgs> _connectionChanged;
+
+        private Interop.Bluetooth.BondCreatedCallback _bondCreatedCallback;
+        private Interop.Bluetooth.BondDestroyedCallback _bondDestroyedCallback;
+        private Interop.Bluetooth.AuthorizationChangedCallback _authorizationChangedCallback;
+        private Interop.Bluetooth.ServiceSearchedCallback _serviceSearchedCallback;
+        private Interop.Bluetooth.DeviceConnectionStateChangedCallback _connectionChangedCallback;
+
+        internal string RemoteDeviceAddress;
+        internal string RemoteDeviceName;
+        internal int RemoteDeviceRssi;
+        internal BluetoothClass RemoteDeviceClass;
+        internal Collection<string> RemoteDeviceService;
+        internal int RemoteDeviceCount;
+        internal bool RemotePaired;
+        internal bool RemoteAuthorized;
+        internal bool RemoteConnected;
+        internal BluetoothAppearanceType RemoteAppearance;
+        internal int RemoteManufLength;
+        internal string RemoteManufData;
+
+        internal BluetoothDevice()
+        {
+        }
+
+        /// <summary>
+        /// The address of the device.
+        /// </summary>
+        public string Address
+        {
+            get
+            {
+                return RemoteDeviceAddress;
+            }
+        }
+        /// <summary>
+        /// The name of the device.
+        /// </summary>
+        public string Name
+        {
+            get
+            {
+                return RemoteDeviceName;
+            }
+        }
+        /// <summary>
+        /// The strength indicator of received signal of the device.
+        /// </summary>
+        public int Rssi
+        {
+            get
+            {
+                return RemoteDeviceRssi;
+            }
+        }
+        /// <summary>
+        /// The class of the device.
+        /// </summary>
+        public BluetoothClass Class
+        {
+            get
+            {
+                return RemoteDeviceClass;
+            }
+        }
+        /// <summary>
+        /// The service UUID list of the device.
+        /// </summary>
+        public IEnumerable<string> ServiceUuidList
+        {
+            get
+            {
+                return RemoteDeviceService;
+            }
+        }
+        /// <summary>
+        /// The number of services.
+        /// </summary>
+        public int ServiceCount
+        {
+            get
+            {
+                return RemoteDeviceCount;
+            }
+        }
+        /// <summary>
+        /// The paired state of the device.
+        /// </summary>
+        public bool IsPaired
+        {
+            get
+            {
+                return RemotePaired;
+            }
+        }
+        /// <summary>
+        /// The connection state of the device.
+        /// </summary>
+        public bool IsConnected
+        {
+            get
+            {
+                return RemoteConnected;
+            }
+        }
+        /// <summary>
+        /// The authorization state of the device.
+        /// </summary>
+        public bool IsAuthorized
+        {
+            get
+            {
+                return RemoteAuthorized;
+            }
+        }
+        /// <summary>
+        /// The Bluetooth appearance.
+        /// </summary>
+        public BluetoothAppearanceType AppearanceType
+        {
+            get
+            {
+                return RemoteAppearance;
+            }
+        }
+
+        /// <summary>
+        /// The length of the manufacturer data.
+        /// </summary>
+        public int ManufacturerDataLength
+        {
+            get
+            {
+                return RemoteManufLength;
+            }
+        }
+        /// <summary>
+        /// The manufacturer data.
+        /// </summary>
+        public string ManufacturerData
+        {
+            get
+            {
+                return RemoteManufData;
+            }
+        }
+
+        /// <summary>
+        /// The BondCreated event is raised when the process of creating the bond is finished.
+        /// </summary>
+        public event EventHandler<BondCreatedEventArgs> BondCreated
+        {
+            add
+            {
+                if (_bondCreated == null)
+                {
+                    RegisterBondCreatedEvent();
+                }
+                _bondCreated += value;
+            }
+            remove
+            {
+                _bondCreated -= value;
+                if (_bondCreated == null)
+                {
+                    UnregisterBondCreatedEvent();
+                }
+            }
+        }
+
+        /// <summary>
+        /// The BondDestroyed event is raised when the bond is destroyed.
+        /// </summary>
+        public event EventHandler<BondDestroyedEventArgs> BondDestroyed
+        {
+            add
+            {
+                if (_bondDestroyed == null)
+                {
+                    RegisterBondDestroyedEvent();
+                }
+                _bondDestroyed += value;
+            }
+            remove
+            {
+                _bondDestroyed -= value;
+                if (_bondDestroyed == null)
+                {
+                    UnregisterBondDestroyedEvent();
+                }
+            }
+        }
+
+        /// <summary>
+        /// The AuthorizationChanged event is raised when the authorization of the device is changed.
+        /// </summary>
+        public event EventHandler<AuthorizationChangedEventArgs> AuthorizationChanged
+        {
+            add
+            {
+                if (_authorizationChanged == null)
+                {
+                    RegisterAuthorizationChangedEvent();
+                }
+                _authorizationChanged += value;
+            }
+            remove
+            {
+                _authorizationChanged -= value;
+                if (_authorizationChanged == null)
+                {
+                    UnregisterAuthorizationChangedEvent();
+                }
+            }
+        }
+
+        /// <summary>
+        /// The ServiceSearched event is raised when the process of service searched is finished.
+        /// </summary>
+        public event EventHandler<ServiceSearchedEventArgs> ServiceSearched
+        {
+            add
+            {
+                if (_serviceSearched == null)
+                {
+                    RegisterServiceSearchedEvent();
+                }
+                _serviceSearched += value;
+            }
+            remove
+            {
+                _serviceSearched -= value;
+                if (_serviceSearched == null)
+                {
+                    UnregisterServiceSearchedEvent();
+                }
+            }
+        }
+
+        /// <summary>
+        /// The ConnectionStateChanged event is raised when the connection state is changed.
+        /// </summary>
+        public event EventHandler<DeviceConnectionStateChangedEventArgs> ConnectionStateChanged
+        {
+            add
+            {
+                if (_connectionChanged == null)
+                {
+                    RegisterConnectionChangedEvent();
+                }
+                _connectionChanged += value;
+            }
+            remove
+            {
+                _connectionChanged -= value;
+                if (_connectionChanged == null)
+                {
+                    UnregisterConnectionChangedEvent();
+                }
+            }
+        }
+
+        private void RegisterBondCreatedEvent()
+        {
+            _bondCreatedCallback = (int result, ref BluetoothDeviceStruct device, IntPtr userData) =>
+            {
+                if (_bondCreated != null)
+                {
+                    BluetoothError res = (BluetoothError)result;
+                    _bondCreated(null, new BondCreatedEventArgs(res, BluetoothUtils.ConvertStructToDeviceClass(device)));
+                }
+            };
+            int ret = Interop.Bluetooth.SetBondCreatedCallback(_bondCreatedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set bond created callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void UnregisterBondCreatedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetBondCreatedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset bond created callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void RegisterBondDestroyedEvent()
+        {
+            _bondDestroyedCallback = (int result, string deviceAddress, IntPtr userData) =>
+            {
+                if (_bondDestroyed != null)
+                {
+                    BluetoothError res = (BluetoothError)result;
+                    _bondDestroyed(null, new BondDestroyedEventArgs(res, deviceAddress));
+                }
+            };
+            int ret = Interop.Bluetooth.SetBondDestroyedCallback(_bondDestroyedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set bond destroyed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void UnregisterBondDestroyedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetBondDestroyedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset bond destroyed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void RegisterServiceSearchedEvent()
+        {
+            _serviceSearchedCallback = (int result, ref BluetoothDeviceSdpStruct sdp, IntPtr userData) =>
+            {
+                Log.Info(Globals.LogTag, "Servicesearched cb is called");
+                if (_serviceSearched != null)
+                {
+                    BluetoothError res = (BluetoothError)result;
+                    _serviceSearched(null, new ServiceSearchedEventArgs(res, BluetoothUtils.ConvertStructToSdpData(sdp)));
+                }
+            };
+            int ret = Interop.Bluetooth.SetServiceSearchedCallback(_serviceSearchedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set service searched callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void UnregisterServiceSearchedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetServiceSearchedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset service searched callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void RegisterAuthorizationChangedEvent()
+        {
+            _authorizationChangedCallback = (int authorization, string deviceAddress, IntPtr userData) =>
+            {
+                Log.Info(Globals.LogTag, "Authorization changed cb is called");
+                if (_authorizationChanged != null)
+                {
+                    BluetoothAuthorizationType auth = (BluetoothAuthorizationType)authorization;
+                    _authorizationChanged(null, new AuthorizationChangedEventArgs(auth, deviceAddress));
+                }
+            };
+            int ret = Interop.Bluetooth.SetAuthorizationChangedCallback(_authorizationChangedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set authroization changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void UnregisterAuthorizationChangedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetAuthorizationChangedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset authroization changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void RegisterConnectionChangedEvent()
+        {
+            _connectionChangedCallback = (bool connected, ref BluetoothDeviceConnectionStruct device, IntPtr userData) =>
+            {
+                Log.Info(Globals.LogTag, "Connection state changed cb is called");
+                if (_connectionChanged != null)
+                {
+                    _connectionChanged(null, new DeviceConnectionStateChangedEventArgs(connected, BluetoothUtils.ConvertStructToConnectionData(device)));
+                }
+            };
+
+            int ret = Interop.Bluetooth.SetConnectionStateChangedCallback(_connectionChangedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set connection state changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        private void UnregisterConnectionChangedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetConnectionStateChangedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset connection state changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        /// <summary>
+        /// Creates a bond with the remote Bluetooth device.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled and the remote device must be discoverable by StartDiscovery(). The bond can be destroyed by DestroyBond().
+        /// The bonding request can be cancelled by CancelBonding(). If this succeeds, the BondCreated event will be invoked.
+        /// </remarks>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the create bonding process to the remote device fails.</exception>
+        public void CreateBond()
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled)
+            {
+                int ret = Interop.Bluetooth.CreateBond(RemoteDeviceAddress);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to create bond, Error - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Cancels the bonding process.
+        /// </summary>
+        /// <remarks>
+        /// Bonding must be in progress by CreateBond().
+        /// </remarks>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the cancel bonding procedure to remote device fails.</exception>
+        public void CancelBonding()
+        {
+            int ret = Interop.Bluetooth.CancelBonding();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to cancel bonding process, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Destroys the bond.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled and the bond must be created by CreateBond().
+        /// If this succeeds, the BondDestroyed event will be invoked.
+        /// </remarks>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the destroy bonding procedure fails.</exception>
+        public void DestroyBond()
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled)
+            {
+                int ret = Interop.Bluetooth.DestroyBond(RemoteDeviceAddress);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to destroy bond, Error - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Sets an alias for the bonded device.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled and the bond must be created by CreateBond().
+        /// </remarks>
+        /// <param name="aliasName">The alias name of the remote device.</param>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the set alias name to remote device fails.</exception>
+        public void SetAlias(string aliasName)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled)
+            {
+                int ret = Interop.Bluetooth.SetAlias(RemoteDeviceAddress, aliasName);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to set alias name, Error - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Sets the authorization of a bonded device.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled and the bond must be created by CreateBond().
+        /// If this succeeds, the AuthorizationChanged event will be invoked.
+        /// </remarks>
+        /// <param name="authorizationState">The authorization state.</param>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the set authorization to remote device fails.</exception>
+        public void SetAuthorization(BluetoothAuthorizationType authorizationState)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled)
+            {
+                int ret = Interop.Bluetooth.SetAuthorization(RemoteDeviceAddress, (int)authorizationState);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to set authroization state, Error - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Gets the mask from the UUID.
+        /// </summary>
+        /// <returns>The service mask list converted from the given UUID list.</returns>
+        /// <param name="uuids">The UUID list of the device.</param>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the get Mask from UUID fails.</exception>
+        public BluetoothServiceClassType GetMaskFromUuid(string[] uuids)
+        {
+            BluetoothServiceClassType serviceMask;
+
+            int ret = Interop.Bluetooth.GetMaskFromUuid(uuids, uuids.Length, out serviceMask);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to get service mask, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+            return serviceMask;
+        }
+
+        /// <summary>
+        /// Starts the search for services supported by the specified device.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled and remote device must be discoverable by StartDiscovery(). The bond must be created by CreateBond().
+        /// If this succeeds, the ServiceSearched event will be invoked.
+        /// </remarks>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the remote device service search fails.</exception>
+        public void StartServiceSearch()
+        {
+            Log.Info(Globals.LogTag, "startservicesearch entry");
+            if (BluetoothAdapter.IsBluetoothEnabled)
+            {
+                int ret = Interop.Bluetooth.StartServiceSearch(RemoteDeviceAddress);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to start service search, Error - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Gets the connected profiles.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <returns>The connected Bluetooth profiles.</returns>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when there is no BT connection.</exception>
+        public IEnumerable<BluetoothProfileType> GetConnectedProfiles()
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled)
+            {
+                List<BluetoothProfileType> profileList = new List<BluetoothProfileType>();
+                Interop.Bluetooth.ConnectedProfileCallback callback = (int profile, IntPtr userData) =>
+                {
+                    if (!profile.Equals(null))
+                    {
+                        profileList.Add((BluetoothProfileType)profile);
+                    }
+                    return true;
+                };
+                int ret = Interop.Bluetooth.GetConnectedProfiles(RemoteDeviceAddress, callback, IntPtr.Zero);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get connected profiles, Error - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+                return profileList;
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        /// <summary>
+        /// Determines if profile is connected to the specified remote device.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <returns><c>true</c> if profile is connected, otherwise <c>false</c>.</returns>
+        /// <param name="profileType">The Bluetooth profile type.</param>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when there is no BT connection.</exception>
+        public bool IsProfileConnected(BluetoothProfileType profileType)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled)
+            {
+                bool isConnected;
+                int ret = Interop.Bluetooth.IsProfileConnected(RemoteDeviceAddress, (int)profileType, out isConnected);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get profile connected state, Error - " + (BluetoothError)ret);
+                }
+                return isConnected;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// Returns the instance of the Bluetooth profile type.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        public T GetProfile<T>() where T : BluetoothProfile
+        {
+            /*
+             * FIXME: Find a proper way for dynamic allocation.
+             */
+            T profile = null;
+            String type = typeof(T).ToString();
+            if (type.Equals("Tizen.Network.Bluetooth.BluetoothAudio"))
+            {
+                BluetoothAudio audio = new BluetoothAudio();
+                profile = (audio as T);
+            }
+            else if (type.Equals("Tizen.Network.Bluetooth.BluetoothAvrcp"))
+            {
+                BluetoothAvrcp avrcp = new BluetoothAvrcp();
+                profile = (avrcp as T);
+            }
+            else if (type.Equals("Tizen.Network.Bluetooth.BluetoothHid"))
+            {
+                BluetoothHid hid = new BluetoothHid();
+                profile = (hid as T);
+            }
+
+            if (profile != null)
+            {
+                profile.RemoteAddress = RemoteDeviceAddress;
+            }
+            return profile;
+        }
+
+        /// <summary>
+        /// Creates the client socket.
+        /// </summary>
+        /// <returns>The IBluetoothClientSocket instance.</returns>
+        /// <param name="serviceUuid">The UUID of the service.</param>
+        public IBluetoothClientSocket CreateSocket(string serviceUuid)
+        {
+            BluetoothSocket clientSocket = new BluetoothSocket();
+            clientSocket.remoteAddress = this.Address;
+            clientSocket.serviceUuid = serviceUuid;
+            return (IBluetoothClientSocket)clientSocket;
+        }
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothEnumerations.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothEnumerations.cs
new file mode 100644 (file)
index 0000000..1842de9
--- /dev/null
@@ -0,0 +1,1202 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Network.Bluetooth
+{
+    /// <summary>
+    /// Enumeration for the Bluetooth states.
+    /// </summary>
+    public enum BluetoothState
+    {
+        /// <summary>
+        /// The disabled state.
+        /// </summary>
+        Disabled = 0,
+        /// <summary>
+        /// The enabled state.
+        /// </summary>
+        Enabled
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth errors.
+    /// </summary>
+    public enum BluetoothError
+    {
+        /// <summary>
+        /// Successful.
+        /// </summary>
+        None = ErrorCode.None,
+        /// <summary>
+        /// Operation canceled.
+        /// </summary>
+        Cancelled = ErrorCode.Canceled,
+        /// <summary>
+        /// Invalid parameter.
+        /// </summary>
+        InvalidParameter = ErrorCode.InvalidParameter,
+        /// <summary>
+        /// Out of memory.
+        /// </summary>
+        OutOfMemory = ErrorCode.OutOfMemory,
+        /// <summary>
+        /// Device or resource busy.
+        /// </summary>
+        ResourceBusy = ErrorCode.ResourceBusy,
+        /// <summary>
+        /// Timeout error.
+        /// </summary>
+        TimedOut = ErrorCode.TimedOut,
+        /// <summary>
+        /// Operation now in progress.
+        /// </summary>
+        NowInProgress = ErrorCode.NowInProgress,
+        /// <summary>
+        /// Bluetooth is not supported.
+        /// </summary>
+        NotSupported = ErrorCode.NotSupported,
+        /// <summary>
+        /// Permission denied.
+        /// </summary>
+        PermissionDenied = ErrorCode.PermissionDenied,
+        /// <summary>
+        /// Quota exceeded.
+        /// </summary>
+        QuotaExceeded = ErrorCode.QuotaExceeded,
+        /// <summary>
+        /// No data available.
+        /// </summary>
+        NoData = ErrorCode.NoData,
+        /// <summary>
+        /// Local adapter not initialized.
+        /// </summary>
+        NotInitialized = -0x01C00000 | 0x0101,
+        /// <summary>
+        /// Local adapter not enabled.
+        /// </summary>
+        NotEnabled = -0x01C00000 | 0x0102,
+        /// <summary>
+        /// Operation already done.
+        /// </summary>
+        AlreadyDone = -0x01C00000 | 0x0103,
+        /// <summary>
+        /// Operation failed.
+        /// </summary>
+        OperationFailed = -0x01C00000 | 0x0104,
+        /// <summary>
+        /// Operation not in progress.
+        /// </summary>
+        NotInProgress = -0x01C00000 | 0x0105,
+        /// <summary>
+        /// Remote device not bonded.
+        /// </summary>
+        RemoteDeviceNotBonded = -0x01C00000 | 0x0106,
+        /// <summary>
+        /// Authentication rejected.
+        /// </summary>
+        AuthRejected = -0x01C00000 | 0x0107,
+        /// <summary>
+        /// Authentication failed.
+        /// </summary>
+        AuthFailed = -0x01C00000 | 0x0108,
+        /// <summary>
+        /// Remote device not found.
+        /// </summary>
+        RemoteDeviceNotFound = -0x01C00000 | 0x0109,
+        /// <summary>
+        /// Service search failed.
+        /// </summary>
+        ServiceSearchFailed = -0x01C00000 | 0x010A,
+        /// <summary>
+        /// Remote device is not connected.
+        /// </summary>
+        RemoteDeviceNotConnected = -0x01C00000 | 0x010B,
+        /// <summary>
+        /// Resource temporarily unavailable.
+        /// </summary>
+        ResourceUnavailable = -0x01C00000 | 0x010C,
+        /// <summary>
+        /// Service Not Found.
+        /// </summary>
+        ServiceNotFound = -0x01C00000 | 0x010D
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth visibility modes.
+    /// </summary>
+    public enum VisibilityMode
+    {
+        /// <summary>
+        /// The non-discoverable mode.
+        /// </summary>
+        NonDiscoverable = 0,
+        /// <summary>
+        /// The discoverable mode.
+        /// </summary>
+        Discoverable = 1,
+        /// <summary>
+        /// The discoverable mode with limited time.
+        /// </summary>
+        TimeLimitedDiscoverable = 2
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth major device class types.
+    /// </summary>
+    public enum BluetoothMajorDeviceClassType
+    {
+        /// <summary>
+        /// The miscellaneous major class type.
+        /// </summary>
+        Misc = 0x00,
+        /// <summary>
+        /// The computer major class type.
+        /// </summary>
+        Computer = 0x01,
+        /// <summary>
+        /// The phone major class type.
+        /// </summary>
+        Phone = 0x02,
+        /// <summary>
+        /// The LAN/Network access point major class type.
+        /// </summary>
+        LanNetworkAccessPoint = 0x03,
+        /// <summary>
+        /// The audio/video major class type.
+        /// </summary>
+        AudioVideo = 0x04,
+        /// <summary>
+        /// The peripheral major class type.
+        /// </summary>
+        Peripheral = 0x05,
+        /// <summary>
+        /// The imaging major class type.
+        /// </summary>
+        Imaging = 0x06,
+        /// <summary>
+        /// The wearable major class type.
+        /// </summary>
+        Wearable = 0x07,
+        /// <summary>
+        /// The toy major class type.
+        /// </summary>
+        Toy = 0x08,
+        /// <summary>
+        /// The health major class type.
+        /// </summary>
+        Health = 0x09,
+        /// <summary>
+        /// The uncategorized major class type.
+        /// </summary>
+        Uncategorized = 0x1F
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth minor device class types.
+    /// </summary>
+    public enum BluetoothMinorDeviceClassType
+    {
+        /// <summary>
+        /// The uncategorized computer minor class type.
+        /// </summary>
+        ComputerUncategorized = 0x00,
+        /// <summary>
+        /// The desktop workstation computer minor class type.
+        /// </summary>
+        ComputerDesktopWorkstation = 0x04,
+        /// <summary>
+        /// The server computer minor class type.
+        /// </summary>
+        ComputerServer = 0x08,
+        /// <summary>
+        /// The laptop computer minor class type.
+        /// </summary>
+        ComputerLaptop = 0x0C,
+        /// <summary>
+        /// The handheld PC/PDA computer minor class type.
+        /// </summary>
+        ComputerHandheldPcOrPda = 0x10,
+        /// <summary>
+        /// The palm sized PC/PDA computer minor class type.
+        /// </summary>
+        ComputerPalmSizedPcOrPda = 0x14,
+        /// <summary>
+        /// The wearable computer minor class type.
+        /// </summary>
+        ComputerWearableComputer = 0x18,
+
+        /// <summary>
+        /// The unclassified phone minor class type.
+        /// </summary>
+        PhoneUncategorized = 0x00,
+        /// <summary>
+        /// The cellular phone minor class type.
+        /// </summary>
+        PhoneCellular = 0x04,
+        /// <summary>
+        /// The cordless phone minor class type.
+        /// </summary>
+        PhoneCordless = 0x08,
+        /// <summary>
+        /// The smartphone phone minor class type.
+        /// </summary>
+        PhoneSmartPhone = 0x0C,
+        /// <summary>
+        /// The wired modem or voice gateway phone minor class type.
+        /// </summary>
+        PhoneWiredModemOrVoiceGateway = 0x10,
+        /// <summary>
+        /// The ISDN phone minor class type.
+        /// </summary>
+        PhoneCommonIsdnAccess = 0x14,
+
+        /// <summary>
+        /// Fully available LAN/Network access point minor class type.
+        /// </summary>
+        LanNetworkAccessPointFullyAvailable = 0x04,
+        /// <summary>
+        /// 1-17% utilized LAN/Network access point minor class type.
+        /// </summary>
+        LanNetworkAccessPoint1To17PercentUtilized = 0x20,
+        /// <summary>
+        /// 17-33% utilized LAN/Network access point minor class type.
+        /// </summary>
+        LanNetworkAccessPoint17To33PercentUtilized = 0x40,
+        /// <summary>
+        /// 33-50% utilized LAN/Network access point minor class type.
+        /// </summary>
+        LanNetworkAccessPoint33To50PercentUtilized = 0x60,
+        /// <summary>
+        /// 50-67% utilized LAN/Network access point minor class type.
+        /// </summary>
+        LanNetworkAccessPoint50To67PercentUtilized = 0x80,
+        /// <summary>
+        /// 67-83% utilized LAN/Network access point minor class type.
+        /// </summary>
+        LanNetworkAccessPoint67To83PercentUtilized = 0xA0,
+        /// <summary>
+        /// 83-99% utilized LAN/Network access point minor class type.
+        /// </summary>
+        LanNetworkAccessPoint83To99PercentUtilized = 0xC0,
+        /// <summary>
+        /// No service available LAN/Network access point minor class type.
+        /// </summary>
+        LanNetworkAccessPointNoServiceAvailable = 0xE0,
+
+        /// <summary>
+        /// The uncategorized audio/video minor class type.
+        /// </summary>
+        AudioVideoUncategorized = 0x00,
+        /// <summary>
+        /// The wearable headset audio/video minor class type.
+        /// </summary>
+        AudioVideoWearableHeadset = 0x04,
+        /// <summary>
+        /// The hands free audio/video minor class type.
+        /// </summary>
+        AudioVideoHandsFree = 0x08,
+        /// <summary>
+        /// The microphone audio/video minor class type.
+        /// </summary>
+        AudioVideoMicrophone = 0x10,
+        /// <summary>
+        /// The loudspeaker audio/video minor class type.
+        /// </summary>
+        AudioVideoLoudspeaker = 0x14,
+        /// <summary>
+        /// The headphones audio/video minor class type.
+        /// </summary>
+        AudioVideoHeadphones = 0x18,
+        /// <summary>
+        /// The portable audio audio/video minor class type.
+        /// </summary>
+        AudioVideoPortableAudio = 0x1C,
+        /// <summary>
+        /// The car audio audio/video minor class type.
+        /// </summary>
+        AudioVideoCarAudio = 0x20,
+        /// <summary>
+        /// The SetTopbox audio/video minor class type.
+        /// </summary>
+        AudioVideoSetTopBox = 0x24,
+        /// <summary>
+        /// The Hi-Fi audio/video minor class type.
+        /// </summary>
+        AudioVideoHifiAudioDevice = 0x28,
+        /// <summary>
+        /// The VCR audio/video minor class type.
+        /// </summary>
+        AudioVideoVcr = 0x2C,
+        /// <summary>
+        /// The video camera audio/video minor class type.
+        /// </summary>
+        AudioVideoVideoCamera = 0x30,
+        /// <summary>
+        /// Camcorder audio/video minor class type.
+        /// </summary>
+        AudioVideoCamcorder = 0x34,
+        /// <summary>
+        /// The video monitor audio/video minor class type.
+        /// </summary>
+        AudioVideoVideoMonitor = 0x38,
+        /// <summary>
+        /// The video display and loudspeaker audio/video minor class type.
+        /// </summary>
+        AudioVideoVideoDisplayLoudspeaker = 0x3C,
+        /// <summary>
+        /// The video conferencing audio/video minor class type.
+        /// </summary>
+        AudioVideoVideoConferencing = 0x40,
+        /// <summary>
+        /// The gaming/toy audio/video minor class type.
+        /// </summary>
+        AudioVideoGamingToy = 0x48,
+
+        /// <summary>
+        /// The uncategorized peripheral minor class type.
+        /// </summary>
+        PeripheralUncategorized = 0x00,
+        /// <summary>
+        /// The keyboard peripheral minor class type.
+        /// </summary>
+        PeripheralKeyBoard = 0x40,
+        /// <summary>
+        /// The pointing device peripheral minor class type.
+        /// </summary>
+        PeripheralPointingDevice = 0x80,
+        /// <summary>
+        /// The combo keyboard peripheral minor class type.
+        /// </summary>
+        PeripheralComboKeyboardPointingDevice = 0xC0,
+        /// <summary>
+        /// The joystick peripheral minor class type.
+        /// </summary>
+        PeripheralJoystick = 0x04,
+        /// <summary>
+        /// The game pad peripheral minor class type.
+        /// </summary>
+        PeripheralGamePad = 0x08,
+        /// <summary>
+        /// The remote control peripheral minor class type.
+        /// </summary>
+        PeripheralRemoteControl = 0x0C,
+        /// <summary>
+        /// The sensing device peripheral minor class type.
+        /// </summary>
+        PeripheralSensingDevice = 0x10,
+        /// <summary>
+        /// The digitizer peripheral minor class type.
+        /// </summary>
+        PeripheralDigitizerTablet = 0x14,
+        /// <summary>
+        /// The card reader peripheral minor class type.
+        /// </summary>
+        PeripheralCardReader = 0x18,
+        /// <summary>
+        /// The digital pen peripheral minor class type.
+        /// </summary>
+        PeripheralDigitalPen = 0x1C,
+        /// <summary>
+        /// The handheld scanner peripheral minor class type.
+        /// </summary>
+        PeripheralHandheldScanner = 0x20,
+        /// <summary>
+        /// The handheld gestural input computer minor class type.
+        /// </summary>
+        PeripheralHandheldGesturalInputDevice = 0x24,
+
+        /// <summary>
+        /// The display imaging minor class type.
+        /// </summary>
+        ImagingDisplay = 0x10,
+        /// <summary>
+        /// The camera imaging minor class type.
+        /// </summary>
+        ImagingCamera = 0x20,
+        /// <summary>
+        /// The scanner imaging minor class type.
+        /// </summary>
+        ImagingScanner = 0x40,
+        /// <summary>
+        /// The printer imaging minor class type.
+        /// </summary>
+        ImagingPrinter = 0x80,
+
+        /// <summary>
+        /// The wrist watch wearable minor class type.
+        /// </summary>
+        WearableWristWatch = 0x04,
+        /// <summary>
+        /// The pager wearable minor class type.
+        /// </summary>
+        WearablePager = 0x08,
+        /// <summary>
+        /// The jacket wearable minor class type.
+        /// </summary>
+        WearableJacket = 0x0C,
+        /// <summary>
+        /// The helmet wearable minor class type.
+        /// </summary>
+        WearableHelmet = 0x10,
+        /// <summary>
+        /// The glasses wearable minor class type.
+        /// </summary>
+        WearableGlasses = 0x14,
+
+        /// <summary>
+        /// The robot toy minor class type.
+        /// </summary>
+        ToyRobot = 0x04,
+        /// <summary>
+        /// The vehicle toy minor class type.
+        /// </summary>
+        ToyVehicle = 0x08,
+        /// <summary>
+        /// The doll toy minor class type.
+        /// </summary>
+        ToyDollAction = 0x0C,
+        /// <summary>
+        /// The controller toy minor class type.
+        /// </summary>
+        ToyController = 0x10,
+        /// <summary>
+        /// The game toy minor class type.
+        /// </summary>
+        ToyGame = 0x14,
+
+        /// <summary>
+        /// The uncategorized health minor class type.
+        /// </summary>
+        HealthUncategorized = 0x00,
+        /// <summary>
+        /// The BP monitor health minor class type.
+        /// </summary>
+        HealthBloodPressureMonitor = 0x04,
+        /// <summary>
+        /// The thermometer health minor class type.
+        /// </summary>
+        HealthThermometer = 0x08,
+        /// <summary>
+        /// The scale health minor class type.
+        /// </summary>
+        HealthWeighingScale = 0x0C,
+        /// <summary>
+        /// The glucose meter health minor class type.
+        /// </summary>
+        HealthGlucoseMeter= 0x10,
+        /// <summary>
+        /// The pulse oximeter health minor class type.
+        /// </summary>
+        HealthPulseOximeter = 0x14,
+        /// <summary>
+        /// The heart/pulse rate monitor health minor class type.
+        /// </summary>
+        HealthHeartPulseRateMonitor = 0x18,
+        /// <summary>
+        /// The display health minor class type.
+        /// </summary>
+        HealthDataDisplay = 0x1C,
+        /// <summary>
+        /// The step counter health minor class type.
+        /// </summary>
+        HealthStepCounter = 0x20,
+        /// <summary>
+        /// The body composition analyzer health minor class type.
+        /// </summary>
+        HealthBodyCompositionAnalyzer = 0x24,
+        /// <summary>
+        /// The peak flow monitor health minor class type.
+        /// </summary>
+        HealthPeakFlowMonitor = 0x28,
+        /// <summary>
+        /// The medication monitor health minor class type.
+        /// </summary>
+        HealthMedicationMonitor = 0x2C,
+        /// <summary>
+        /// The knee prosthesis health minor class type.
+        /// </summary>
+        HealthKneeProsthesis = 0x30,
+        /// <summary>
+        /// The ankle prosthesis health minor class type.
+        /// </summary>
+        HealthAnkleProsthesis = 0x34
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth device discovery states.
+    /// </summary>
+    public enum BluetoothDeviceDiscoveryState
+    {
+        /// <summary>
+        /// The device discovery is started.
+        /// </summary>
+        Started = 0,
+        /// <summary>
+        /// The device discovery is finished.
+        /// </summary>
+        Finished,
+        /// <summary>
+        /// The remote device is found.
+        /// </summary>
+        Found
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth appearance types.
+    /// </summary>
+    public enum BluetoothAppearanceType
+    {
+        /// <summary>
+        /// Unknown.
+        /// </summary>
+        Unknown = 0,
+        /// <summary>
+        /// Generic phone.
+        /// </summary>
+        GenericPhone = 1,
+        /// <summary>
+        /// Generic computer.
+        /// </summary>
+        GenericComputer = 2,
+        /// <summary>
+        /// Generic watch.
+        /// </summary>
+        GenericWatch = 3
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth audio profile types.
+    /// </summary>
+    public enum BluetoothAudioProfileType
+    {
+        /// <summary>
+        /// All supported profiles of audio.
+        /// </summary>
+        All = 0,
+        /// <summary>
+        /// The Headset and Hands-Free profile.
+        /// </summary>
+        HspHfp,
+        /// <summary>
+        /// The Advanced Audio Distribution profile.
+        /// </summary>
+        AdvancedAudioDistribution,
+        /// <summary>
+        /// The Audio Gateway profile.
+        /// </summary>
+        AudioGateway,
+        /// <summary>
+        /// The Advanced Audio Distribution profile sink role.
+        /// </summary>
+        AdvancedAudioDistributionSink
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth service class types.
+    /// </summary>
+    public enum BluetoothServiceClassType
+    {
+        /// <summary>
+        /// No service class.
+        /// </summary>
+        None = 0,
+        /// <summary>
+        /// The RES service class.
+        /// </summary>
+        Res = 0x00000001,
+        /// <summary>
+        /// The SPP service class.
+        /// </summary>
+        Spp = 0x00000002,
+        /// <summary>
+        /// The DUN service class.
+        /// </summary>
+        Dun = 0x00000004,
+        /// <summary>
+        /// The FAX service class.
+        /// </summary>
+        Fax = 0x00000008,
+        /// <summary>
+        /// The LAP service class.
+        /// </summary>
+        Lap = 0x00000010,
+        /// <summary>
+        /// The HSP service class.
+        /// </summary>
+        Hsp = 0x00000020,
+        /// <summary>
+        /// The HFPservice class.
+        /// </summary>
+        Hfp = 0x00000040,
+        /// <summary>
+        /// The OPP service class.
+        /// </summary>
+        Opp = 0x00000080,
+        /// <summary>
+        /// The FTP service class.
+        /// </summary>
+        Ftp = 0x00000100,
+        /// <summary>
+        /// The CTP service class.
+        /// </summary>
+        Ctp = 0x00000200,
+        /// <summary>
+        /// The ICP service class.
+        /// </summary>
+        Icp = 0x00000400,
+        /// <summary>
+        /// The Sync service class.
+        /// </summary>
+        Sync = 0x00000800,
+        /// <summary>
+        /// The BPP service class.
+        /// </summary>
+        Bpp = 0x00001000,
+        /// <summary>
+        /// The BIP service class.
+        /// </summary>
+        Bip = 0x00002000,
+        /// <summary>
+        /// The PANU service class.
+        /// </summary>
+        Panu = 0x00004000,
+        /// <summary>
+        /// The NAP service class.
+        /// </summary>
+        Nap = 0x00008000,
+        /// <summary>
+        /// The GN service class.
+        /// </summary>
+        Gn = 0x00010000,
+        /// <summary>
+        /// The SAP service class.
+        /// </summary>
+        Sap = 0x00020000,
+        /// <summary>
+        /// The A2DP service class.
+        /// </summary>
+        A2dp = 0x00040000,
+        /// <summary>
+        /// The AVRCP service class.
+        /// </summary>
+        Avrcp = 0x00080000,
+        /// <summary>
+        /// The PBAP service class.
+        /// </summary>
+        Pbap = 0x00100000,
+        /// <summary>
+        /// The HID service class.
+        /// </summary>
+        Hid = 0x00200000,
+        /// <summary>
+        /// The A2DP Source service class.
+        /// </summary>
+        A2dpSource = 0x00400000,
+        /// <summary>
+        /// All service class.
+        /// </summary>
+        All = 0x00FFFFFF,
+        /// <summary>
+        /// The Max service class.
+        /// </summary>
+        Max
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth profile types.
+    /// </summary>
+    public enum BluetoothProfileType
+    {
+        /// <summary>
+        /// The RFCOMM profile.
+        /// </summary>
+        Rfcomm = 0,
+        /// <summary>
+        /// The Advanced Audio Distribution Profile Source role.
+        /// </summary>
+        AdvancedAudioDistribution,
+        /// <summary>
+        /// The Headset profile.
+        /// </summary>
+        Headset,
+        /// <summary>
+        /// The Human Interface Device profile.
+        /// </summary>
+        HumanInterfaceDevice,
+        /// <summary>
+        /// The Network Access Point profile.
+        /// </summary>
+        NetworkAccessPoint,
+        /// <summary>
+        /// The Audio Gateway profile.
+        /// </summary>
+        AudioGateway,
+        /// <summary>
+        /// The Generic Attribute profile.
+        /// </summary>
+        GenericAttribute,
+        /// <summary>
+        /// The NAP Server profile.
+        /// </summary>
+        NapServer,
+        /// <summary>
+        /// The advanced Audio Distribution profile sink role.
+        /// </summary>
+        AdvancedAudioDistributionSink
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth authorization types.
+    /// </summary>
+    public enum BluetoothAuthorizationType
+    {
+        /// <summary>
+        /// The authorized type.
+        /// </summary>
+        Authorized = 0,
+        /// <summary>
+        /// The unauthorized type.
+        /// </summary>
+        Unauthorized
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth connection link types.
+    /// </summary>
+    public enum BluetoothConnectionLinkType
+    {
+        /// <summary>
+        /// The BR/EDR link.
+        /// </summary>
+        BrEdr = 0,
+        /// <summary>
+        /// The LE link.
+        /// </summary>
+        Le,
+        /// <summary>
+        /// The default connection type.
+        /// </summary>
+        Default
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth disconnect reason.
+    /// </summary>
+    public enum BluetoothDisconnectReason
+    {
+        /// <summary>
+        /// The disconnected by unknown reason.
+        /// </summary>
+        Unknown = 0,
+        /// <summary>
+        /// The disconnected by timeout.
+        /// </summary>
+        Timeout,
+        /// <summary>
+        /// The disconnected by local host.
+        /// </summary>
+        LocalHost,
+        /// <summary>
+        /// The disconnected by remote.
+        /// </summary>
+        Remote
+    }
+
+    /// <summary>
+    /// Enumeration for the connected Bluetooth device event roles.
+    /// </summary>
+    public enum BluetoothSocketRole
+    {
+        /// <summary>
+        /// Unknown role.
+        /// </summary>
+        Unknown,
+        /// <summary>
+        /// The server role.
+        /// </summary>
+        Server,
+        /// <summary>
+        /// The client role.
+        /// </summary>
+        Client
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth socket connection states.
+    /// </summary>
+    public enum BluetoothSocketState
+    {
+        /// <summary>
+        /// The RFCOMM is connected.
+        /// </summary>
+        Connected,
+        /// <summary>
+        /// The RFCOMM is disconnected.
+        /// </summary>
+        Disconnected
+    }
+
+    /// <summary>
+    /// Enumeration for the equalizer states.
+    /// </summary>
+    public enum EqualizerState
+    {
+        /// <summary>
+        /// Equalizer Off.
+        /// </summary>
+        Off = 0,
+        /// <summary>
+        /// Equalizer On.
+        /// </summary>
+        On
+    }
+
+    /// <summary>
+    /// Enumeration for the repeat modes.
+    /// </summary>
+    public enum RepeatMode
+    {
+        /// <summary>
+        /// Repeat off.
+        /// </summary>
+        Off = 0,
+        /// <summary>
+        /// Single track repeat.
+        /// </summary>
+        SingleTrack,
+        /// <summary>
+        /// All track repeat.
+        /// </summary>
+        AllTrack,
+        /// <summary>
+        /// Group repeat.
+        /// </summary>
+        Group
+    }
+
+    /// <summary>
+    /// Enumeration for the shuffle modes.
+    /// </summary>
+    public enum ShuffleMode
+    {
+        /// <summary>
+        /// Shuffle off.
+        /// </summary>
+        Off = 0,
+        /// <summary>
+        /// All tracks shuffle.
+        /// </summary>
+        AllTrack,
+        /// <summary>
+        /// Group shuffle.
+        /// </summary>
+        Group
+    }
+
+    /// <summary>
+    /// Enumeration for the scan modes.
+    /// </summary>
+    public enum ScanMode
+    {
+        /// <summary>
+        /// Scan off.
+        /// </summary>
+        Off = 0,
+        /// <summary>
+        /// All tracks scan.
+        /// </summary>
+        AllTrack,
+        /// <summary>
+        /// Group scan.
+        /// </summary>
+        Group
+    }
+
+    /// <summary>
+    /// Enumeration for the player states.
+    /// </summary>
+    public enum PlayerState
+    {
+        /// <summary>
+        /// The stopped state.
+        /// </summary>
+        Stopped = 0,
+        /// <summary>
+        /// The playing state.
+        /// </summary>
+        Playing,
+        /// <summary>
+        /// The paused state.
+        /// </summary>
+        Paused,
+        /// <summary>
+        /// The seek forward state.
+        /// </summary>
+        SeekForward,
+        /// <summary>
+        /// The seek rewind state.
+        /// </summary>
+        SeekRewind
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth LE device address types.
+    /// </summary>
+    public enum BluetoothLeDeviceAddressType
+    {
+        /// <summary>
+        /// The Buetooth LE public address.
+        /// </summary>
+        BluetoothLePublicAddress,
+        /// <summary>
+        /// The Bluetooth LE private address.
+        /// </summary>
+        BluetoothLePrivateAddress
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth LePacket types.
+    /// </summary>
+    public enum BluetoothLePacketType
+    {
+        /// <summary>
+        /// The Bluetooth LE advertising packet.
+        /// </summary>
+        BluetoothLeAdvertisingPacket,
+        /// <summary>
+        /// The Bluetooth LE scan response packet.
+        /// </summary>
+        BluetoothLeScanResponsePacket
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth LE data types.
+    /// </summary>
+    public enum BluetoothLeDataType
+    {
+        /// <summary>
+        /// The Bluetooth LE packet data list 16 bit service uuid.
+        /// </summary>
+        BluetoothLePacketDataList16BitServiceUuid,
+        /// <summary>
+        /// The Bluetooth LE packet manufacturer data.
+        /// </summary>
+        BluetoothLePacketManufacturerData
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth LE advertising mode types.
+    /// </summary>
+    public enum BluetoothLeAdvertisingMode
+    {
+        /// <summary>
+        /// The Bluetooth LE advertising balanced mode.
+        /// </summary>
+        BluetoothLeAdvertisingBalancedMode,
+        /// <summary>
+        /// The Bluetooth LE advertising low latency mode.
+        /// </summary>
+        BluetoothLeAdvertisingLowLatencyMode,
+        /// <summary>
+        /// The Bluetooth LE advertising low energy mode.
+        /// </summary>
+        BluetoothLeAdvertisingLowEnergyMode
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth LE advertising mode type.
+    /// </summary>
+    public enum BluetoothLeAdvertisingState
+    {
+        /// <summary>
+        /// The Bluetooth LE advertising stopped.
+        /// </summary>
+        BluetoothLeAdvertisingStopped,
+        /// <summary>
+        /// The Bluetooth LE advertising started.
+        /// </summary>
+        BluetoothLeAdvertisingStarted
+    }
+
+    /// <summary>
+    /// Enumeration for the integer type for GATT handle's values.
+    /// </summary>
+    public enum IntDataType
+    {
+        /// <summary>
+        /// The 8-bit signed integer type.
+        /// </summary>
+        SignedInt8,
+        /// <summary>
+        /// The 16-bit signed integer type.
+        /// </summary>
+        SignedInt16,
+        /// <summary>
+        /// The 32-bit signed integer type.
+        /// </summary>
+        SignedInt32,
+        /// <summary>
+        /// The 8-bit unsigned integer type.
+        /// </summary>
+        UnsignedInt8,
+        /// <summary>
+        /// The 16-bit unsigned integer type.
+        /// </summary>
+        UnsignedInt16,
+        /// <summary>
+        /// The 32-bit unsigned integer type.
+        /// </summary>
+        UnsignedInt32
+    }
+
+    /// <summary>
+    /// Enumerations of the float type for GATT handle's values.
+    /// </summary>
+    public enum FloatDataType
+    {
+        /// <summary>
+        /// The 32-bit float type.
+        /// </summary>
+        Float,
+        /// <summary>
+        /// The 16-bit float type.
+        /// </summary>
+        SFloat,
+    }
+
+    /// <summary>
+    /// Enumeration for the GATT handle's types.
+    /// </summary>
+    public enum GattHandleType
+    {
+        /// <summary>
+        /// The GATT service type.
+        /// </summary>
+        Service,
+        /// <summary>
+        /// The GATT characteristic type.
+        /// </summary>
+        Characteristic,
+        /// <summary>
+        /// The GATT descriptor type.
+        /// </summary>
+        Descriptor
+    }
+
+    /// <summary>
+    /// Enumeration for the service types.
+    /// </summary>
+    public enum BluetoothGattServiceType
+    {
+        /// <summary>
+        /// The GATT primary service type.
+        /// </summary>
+        Primary,
+        /// <summary>
+        /// The GATT secondary service type.
+        /// </summary>
+        Secondary
+    }
+
+    /// <summary>
+    /// Enumeration for the characteristic's property.
+    /// </summary>
+    [Flags]
+    public enum BluetoothGattProperty
+    {
+        /// <summary>
+        /// The broadcast property.
+        /// </summary>
+        Broadcast = 1,
+        /// <summary>
+        /// The read property.
+        /// </summary>
+        Read = 2,
+        /// <summary>
+        /// The write without response property.
+        /// </summary>
+        WriteWithoutResponse = 4,
+        /// <summary>
+        /// The write property.
+        /// </summary>
+        Write = 8,
+        /// <summary>
+        /// The notify property.
+        /// </summary>
+        Notify = 16,
+        /// <summary>
+        /// The indicate property.
+        /// </summary>
+        Indicate = 32,
+        /// <summary>
+        /// The authenticated signed writes property.
+        /// </summary>
+        AuthenticatedSignedWrites = 64,
+        /// <summary>
+        /// The extended properties.
+        /// </summary>
+        ExtendedProperties = 128,
+    }
+
+    /// <summary>
+    /// Enumeration for the Bluetooth GATT permission types.
+    /// </summary>
+    [Flags]
+    public enum BluetoothGattPermission
+    {
+        /// <summary>
+        /// Read permission.
+        /// </summary>
+        Read = 1,
+        /// <summary>
+        /// Write permission.
+        /// </summary>
+        Write = 2,
+    }
+
+    /// <summary>
+    /// Enumeration for the write types.
+    /// </summary>
+    public enum BluetoothGattWriteType
+    {
+        /// <summary>
+        /// The write without response.
+        /// </summary>
+        NoResponse,
+        /// <summary>
+        /// The write with response.
+        /// </summary>
+        WriteWithResponse
+    }
+
+    /// <summary>
+    /// Enumeration for the remote device request types for attributes.
+    /// </summary>
+    public enum BluetoothGattRequestType
+    {
+        /// <summary>
+        /// Read requested.
+        /// </summary>
+        Read = 0,
+        /// <summary>
+        /// Write requested.
+        /// </summary>
+        Write = 1,
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothError.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothError.cs
new file mode 100644 (file)
index 0000000..9f418e3
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Network.Bluetooth
+{
+    static internal class BluetoothErrorFactory
+    {
+        static internal void ThrowBluetoothException(int exception)
+        {
+            BluetoothError error = (BluetoothError)exception;
+            switch (error)
+            {
+            case BluetoothError.InvalidParameter:
+                throw new InvalidOperationException("Invalid parameter");
+
+            case BluetoothError.Cancelled:
+                throw new InvalidOperationException("Operation cancelled");
+
+            case BluetoothError.AlreadyDone:
+                throw new InvalidOperationException("Operation already done");
+
+            case BluetoothError.TimedOut:
+                throw new InvalidOperationException("Timeout error");
+
+            case BluetoothError.AuthFailed:
+                throw new InvalidOperationException("Authentication failed");
+
+            case BluetoothError.AuthRejected:
+                throw new InvalidOperationException("Authentication rejected");
+
+            case BluetoothError.NoData:
+                throw new InvalidOperationException("No data available");
+
+            case BluetoothError.NotEnabled:
+                throw new InvalidOperationException("Local adapter not enabled");
+
+            case BluetoothError.NotInitialized:
+                throw new InvalidOperationException("Local adapter not initialized");
+
+            case BluetoothError.NowInProgress:
+                throw new InvalidOperationException("Operation now in progress");
+
+            case BluetoothError.NotInProgress:
+                throw new InvalidOperationException("Operation not in progress");
+
+            case BluetoothError.NotSupported:
+                throw new NotSupportedException("Bluetooth is not supported");
+
+            case BluetoothError.OperationFailed:
+                throw new InvalidOperationException("Operation failed");
+
+            case BluetoothError.OutOfMemory:
+                throw new InvalidOperationException("Out of memory");
+
+            case BluetoothError.PermissionDenied:
+                throw new InvalidOperationException("Permission denied");
+
+            case BluetoothError.QuotaExceeded:
+                throw new InvalidOperationException("Quota exceeded");
+
+            case BluetoothError.RemoteDeviceNotBonded:
+                throw new InvalidOperationException("Remote device not bonded");
+
+            case BluetoothError.RemoteDeviceNotConnected:
+                throw new InvalidOperationException("Remote device not connected");
+
+            case BluetoothError.RemoteDeviceNotFound:
+                throw new InvalidOperationException("Remote device not found");
+
+            case BluetoothError.ResourceBusy:
+                throw new InvalidOperationException("Device or resource busy");
+
+            case BluetoothError.ResourceUnavailable:
+                throw new InvalidOperationException("Resource temporarily unavailable");
+
+            case BluetoothError.ServiceNotFound:
+                throw new InvalidOperationException("Service Not Found");
+
+            case BluetoothError.ServiceSearchFailed:
+                throw new InvalidOperationException("Service search failed");
+
+            default:
+                throw new InvalidOperationException("Unknown exception");
+            }
+        }
+    }
+}
+
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothEventArgs.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothEventArgs.cs
new file mode 100644 (file)
index 0000000..c7e6740
--- /dev/null
@@ -0,0 +1,1044 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Network.Bluetooth
+{
+    /// <summary>
+    /// An extended EventArgs class contains the changed Bluetooth state.
+    /// </summary>
+    public class StateChangedEventArgs : EventArgs
+    {
+        private BluetoothState _type;
+        private BluetoothError _result;
+
+        internal StateChangedEventArgs(BluetoothError result, BluetoothState type)
+        {
+            _type = type;
+            _result = result;
+        }
+
+        /// <summary>
+        /// The state of Bluetooth.
+        /// </summary>
+        public BluetoothState BTState
+        {
+            get
+            {
+                return _type;
+            }
+        }
+
+        /// <summary>
+        /// The BluetoothError result.
+        /// </summary>
+        public BluetoothError Result
+        {
+            get
+            {
+                return _result;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the changed Bluetooth name.
+    /// </summary>
+    public class NameChangedEventArgs : EventArgs
+    {
+        private string _name;
+
+        internal NameChangedEventArgs(string name)
+        {
+            _name = name;
+        }
+
+        /// <summary>
+        /// The name of the device.
+        /// </summary>
+        public string DeviceName
+        {
+            get
+            {
+                return _name;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the changed Bluetooth visibility mode.
+    /// </summary>
+    public class VisibilityModeChangedEventArgs : EventArgs
+    {
+        private VisibilityMode _mode;
+        private BluetoothError _result;
+
+        internal VisibilityModeChangedEventArgs(BluetoothError result, VisibilityMode mode)
+        {
+            _result = result;
+            _mode = mode;
+        }
+
+        /// <summary>
+        /// The visibility mode.
+        /// </summary>
+        public VisibilityMode Visibility
+        {
+            get
+            {
+                return _mode;
+            }
+        }
+
+        /// <summary>
+        /// The BluetoothError result.
+        /// </summary>
+        public BluetoothError Result
+        {
+            get
+            {
+                return _result;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the duration until the visibility mode is changed from TimeLimitedDiscoverable to NonDiscoverable.
+    /// </summary>
+    public class VisibilityDurationChangedEventArgs : EventArgs
+    {
+        private int _duration;
+
+        internal VisibilityDurationChangedEventArgs(int duration)
+        {
+            _duration = duration;
+        }
+
+        /// <summary>
+        /// The duration.
+        /// </summary>
+        public int Duration
+        {
+            get
+            {
+                return _duration;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the changed Bluetooth device discovery state and the discovered device information.
+    /// </summary>
+    public class DiscoveryStateChangedEventArgs : EventArgs
+    {
+        private BluetoothError _result;
+        private BluetoothDeviceDiscoveryState _state;
+        private BluetoothDevice _device;
+
+        internal DiscoveryStateChangedEventArgs(BluetoothError result, BluetoothDeviceDiscoveryState state)
+        {
+            _result = result;
+            _state = state;
+        }
+
+        internal DiscoveryStateChangedEventArgs(BluetoothError result, BluetoothDeviceDiscoveryState state, BluetoothDevice device)
+        {
+            _result = result;
+            _state = state;
+            _device = device;
+        }
+
+        /// <summary>
+        /// The BluetoothError result.
+        /// </summary>
+        public BluetoothError Result
+        {
+            get
+            {
+                return _result;
+            }
+        }
+
+        /// <summary>
+        /// The state of the discovery.
+        /// </summary>
+        public BluetoothDeviceDiscoveryState DiscoveryState
+        {
+            get
+            {
+                return _state;
+            }
+        }
+
+        /// <summary>
+        /// The remote device found.
+        /// </summary>
+        public BluetoothDevice DeviceFound
+        {
+            get
+            {
+                return _device;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the bonded device information.
+    /// </summary>
+    public class BondCreatedEventArgs : EventArgs
+    {
+        private BluetoothError _result;
+        private BluetoothDevice _device;
+
+        internal BondCreatedEventArgs(BluetoothError result, BluetoothDevice device)
+        {
+            _result = result;
+            _device = device;
+        }
+
+        /// <summary>
+        /// The BluetoothError result.
+        /// </summary>
+        public BluetoothError Result
+        {
+            get
+            {
+                return _result;
+            }
+        }
+
+        /// <summary>
+        /// The remote device.
+        /// </summary>
+        public BluetoothDevice Device
+        {
+            get
+            {
+                return _device;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the address of the remote Bluetooth device to destroy bond with.
+    /// </summary>
+    public class BondDestroyedEventArgs : EventArgs
+    {
+        private BluetoothError _result;
+        private string _address;
+
+        internal BondDestroyedEventArgs(BluetoothError result, string address)
+        {
+            _result = result;
+            _address = address;
+        }
+
+        /// <summary>
+        /// The BluetoothError result.
+        /// </summary>
+        public BluetoothError Result
+        {
+            get
+            {
+                return _result;
+            }
+        }
+
+        /// <summary>
+        /// The remote device address.
+        /// </summary>
+        /// <value>The device address.</value>
+        public string DeviceAddress
+        {
+            get
+            {
+                return _address;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the authorization state and the address of the remote Bluetooth device.
+    /// </summary>
+    public class AuthorizationChangedEventArgs : EventArgs
+    {
+        private BluetoothAuthorizationType _authType;
+        private string _address;
+
+        internal AuthorizationChangedEventArgs(BluetoothAuthorizationType authType, string address)
+        {
+            _authType = authType;
+            _address = address;
+        }
+
+        /// <summary>
+        /// The authorization.
+        /// </summary>
+        public BluetoothAuthorizationType Authorization
+        {
+            get
+            {
+                return _authType;
+            }
+        }
+
+        /// <summary>
+        /// The device address.
+        /// </summary>
+        public string DeviceAddress
+        {
+            get
+            {
+                return _address;
+            }
+        }
+
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the service lists found on the remote Bluetooth device.
+    /// </summary>
+    public class ServiceSearchedEventArgs : EventArgs
+    {
+        private BluetoothDeviceSdpData _sdpData;
+        private BluetoothError _result;
+
+        internal ServiceSearchedEventArgs(BluetoothError result, BluetoothDeviceSdpData sdpData)
+        {
+            _result = result;
+            _sdpData = sdpData;
+        }
+
+        /// <summary>
+        /// The BluetoothError result.
+        /// </summary>
+        public BluetoothError Result
+        {
+            get
+            {
+                return _result;
+            }
+        }
+        /// <summary>
+        /// The sdp data.
+        /// </summary>
+        public BluetoothDeviceSdpData SdpData
+        {
+            get
+            {
+                return _sdpData;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the connection state and the connection information of the remote device.
+    /// </summary>
+    public class DeviceConnectionStateChangedEventArgs : EventArgs
+    {
+        private bool _isConnected;
+        private BluetoothDeviceConnectionData _connectionData;
+
+        internal DeviceConnectionStateChangedEventArgs(bool isConnected, BluetoothDeviceConnectionData connectionData)
+        {
+            _isConnected = isConnected;
+            _connectionData = connectionData;
+        }
+
+        /// <summary>
+        /// A value indicating whether the device is connected.
+        /// </summary>
+        public bool IsConnected
+        {
+            get
+            {
+                return _isConnected;
+            }
+        }
+
+        /// <summary>
+        /// The device connection data.
+        /// </summary>
+        public BluetoothDeviceConnectionData ConnectionData
+        {
+            get
+            {
+                return _connectionData;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the data received information.
+    /// </summary>
+    public class SocketDataReceivedEventArgs : EventArgs
+    {
+        private SocketData _data;
+
+        internal SocketDataReceivedEventArgs(SocketData data)
+        {
+            _data = data;
+        }
+
+        /// <summary>
+        /// The socket data.
+        /// </summary>
+        public SocketData Data
+        {
+            get
+            {
+                return _data;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the changed connection state.
+    /// </summary>
+    public class SocketConnectionStateChangedEventArgs : EventArgs
+    {
+        private BluetoothError _result;
+        private BluetoothSocketState _state;
+        private SocketConnection _connection;
+
+        internal SocketConnectionStateChangedEventArgs(BluetoothError result, BluetoothSocketState state, SocketConnection connection)
+        {
+            _result = result;
+            _state = state;
+            _connection = connection;
+        }
+
+        /// <summary>
+        /// The BluetoothError result.
+        /// </summary>
+        public BluetoothError Result
+        {
+            get
+            {
+                return _result;
+            }
+        }
+
+        /// <summary>
+        /// The socket state.
+        /// </summary>
+        public BluetoothSocketState State
+        {
+            get
+            {
+                return _state;
+            }
+        }
+
+        /// <summary>
+        /// The socket connection.
+        /// </summary>
+        public SocketConnection Connection
+        {
+            get
+            {
+                return _connection;
+            }
+        }
+    }
+
+    public class AcceptStateChangedEventArgs : EventArgs
+    {
+        private BluetoothError _result;
+        private BluetoothSocketState _state;
+        private SocketConnection _connection;
+        private IBluetoothServerSocket _server;
+
+        internal AcceptStateChangedEventArgs(BluetoothError result, BluetoothSocketState state, SocketConnection connection, BluetoothSocket server)
+        {
+            _result = result;
+            _state = state;
+            _connection = connection;
+            _server = (IBluetoothServerSocket)server;
+        }
+
+        /// <summary>
+        /// The BluetoothError result.
+        /// </summary>
+        public BluetoothError Result
+        {
+            get
+            {
+                return _result;
+            }
+        }
+
+        /// <summary>
+        /// The socket state.
+        /// </summary>
+        public BluetoothSocketState State
+        {
+            get
+            {
+                return _state;
+            }
+        }
+
+        /// <summary>
+        /// The socket connection.
+        /// </summary>
+        public SocketConnection Connection
+        {
+            get
+            {
+                return _connection;
+            }
+        }
+
+        /// <summary>
+        /// The server socket instance.
+        /// </summary>
+        public IBluetoothServerSocket Server
+        {
+            get
+            {
+                return _server;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the connection state, remote address, and the type of audio profile.
+    /// </summary>
+    public class AudioConnectionStateChangedEventArgs : EventArgs
+    {
+        private int _result;
+        private bool _isConnected;
+        private string _address;
+        private BluetoothAudioProfileType _type;
+
+        internal AudioConnectionStateChangedEventArgs(int result, bool isConnected, string address, BluetoothAudioProfileType type)
+        {
+            _result = result;
+            _type = type;
+            _isConnected = isConnected;
+            _address = address;
+        }
+
+        /// <summary>
+        /// The result.
+        /// </summary>
+        public int Result
+        {
+            get
+            {
+                return _result;
+            }
+        }
+
+        /// <summary>
+        /// A value indicating whether this instance is connected.
+        /// </summary>
+        public bool IsConnected
+        {
+            get
+            {
+                return _isConnected;
+            }
+        }
+
+        /// <summary>
+        /// The address.
+        /// </summary>
+        public string Address
+        {
+            get
+            {
+                return _address;
+            }
+        }
+
+        /// <summary>
+        /// The type of the audio profile.
+        /// </summary>
+        public BluetoothAudioProfileType ProfileType
+        {
+            get
+            {
+                return _type;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the connection state and the address of the remote Bluetooth device.
+    /// </summary>
+    public class HidConnectionStateChangedEventArgs : EventArgs
+    {
+        private int _result;
+        private bool _isConnected;
+        private string _address;
+
+        internal HidConnectionStateChangedEventArgs(int result, bool isConnected, string address)
+        {
+            _result = result;
+            _isConnected = isConnected;
+            _address = address;
+        }
+
+        /// <summary>
+        /// The result.
+        /// </summary>
+        public int Result
+        {
+            get
+            {
+                return _result;
+            }
+        }
+
+        /// <summary>
+        /// A value indicating whether this instance is connected.
+        /// </summary>
+        public bool IsConnected
+        {
+            get
+            {
+                return _isConnected;
+            }
+        }
+
+        /// <summary>
+        /// The address.
+        /// </summary>
+        public string Address
+        {
+            get
+            {
+                return _address;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the changed equalizer state.
+    /// </summary>
+    public class EqualizerStateChangedEventArgs : EventArgs
+    {
+        private EqualizerState _state;
+
+        internal EqualizerStateChangedEventArgs(EqualizerState state)
+        {
+            _state = state;
+        }
+
+        /// <summary>
+        /// The state of the equalizer.
+        /// </summary>
+        public EqualizerState State
+        {
+            get
+            {
+                return _state;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the changed repeat mode.
+    /// </summary>
+    public class RepeatModeChangedEventArgs : EventArgs
+    {
+        private RepeatMode _mode;
+
+        internal RepeatModeChangedEventArgs(RepeatMode mode)
+        {
+            _mode = mode;
+        }
+
+        /// <summary>
+        /// The repeat mode.
+        /// </summary>
+        public RepeatMode Mode
+        {
+            get
+            {
+                return _mode;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the changed shuffle mode.
+    /// </summary>
+    public class ShuffleModeChangedeventArgs : EventArgs
+    {
+        private ShuffleMode _mode;
+
+        internal ShuffleModeChangedeventArgs(ShuffleMode mode)
+        {
+            _mode = mode;
+        }
+
+        /// <summary>
+        /// The shuffle mode.
+        /// </summary>
+        public ShuffleMode Mode
+        {
+            get
+            {
+                return _mode;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the changed scan mode.
+    /// </summary>
+    public class ScanModeChangedEventArgs : EventArgs
+    {
+        private ScanMode _mode;
+
+        internal ScanModeChangedEventArgs(ScanMode mode)
+        {
+            _mode = mode;
+        }
+
+        /// <summary>
+        /// The scan mode.
+        /// </summary>
+        public ScanMode Mode
+        {
+            get
+            {
+                return _mode;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the connection state and the remote device address.
+    /// </summary>
+    public class TargetConnectionStateChangedEventArgs : EventArgs
+    {
+        private bool _isConnected;
+        private string _address;
+
+        internal TargetConnectionStateChangedEventArgs(bool isConnected, string address)
+        {
+            _isConnected = isConnected;
+            _address = address;
+        }
+
+        /// <summary>
+        /// A value indicating whether this instance is connected.
+        /// </summary>
+        public bool IsConnected
+        {
+            get
+            {
+                return _isConnected;
+            }
+        }
+
+        /// <summary>
+        /// The address.
+        /// </summary>
+        public string Address
+        {
+            get
+            {
+                return _address;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the changed Bluetooth LE advertising state changed information.
+    /// </summary>
+    public class AdvertisingStateChangedEventArgs : EventArgs
+    {
+        private BluetoothLeAdvertisingState _state;
+        private int _result;
+        private IntPtr _advertiserHandle;
+
+               //TODO : Add conversion code from IntPtr to BluetoothLeAdvertiser class later
+        internal AdvertisingStateChangedEventArgs(int result, IntPtr advertiserHandle,
+            BluetoothLeAdvertisingState state)
+        {
+            _result = result;
+            _advertiserHandle = advertiserHandle;
+            _state = state;
+        }
+
+        /// <summary>
+        /// The result.
+        /// </summary>
+        public int Result
+        {
+            get
+            {
+                return _result;
+            }
+        }
+
+        /// <summary>
+        /// The advertiser handle.
+        /// </summary>
+        public IntPtr AdvertiserHandle
+        {
+            get
+            {
+                return _advertiserHandle;
+            }
+        }
+
+        /// <summary>
+        /// The LE advertising state.
+        /// </summary>
+        public BluetoothLeAdvertisingState State
+        {
+            get
+            {
+                return _state;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the changed Bluetooth LE scan result information.
+    /// </summary>
+    public class AdapterLeScanResultChangedEventArgs : EventArgs
+    {
+        private BluetoothLeDevice _deviceData;
+        private BluetoothError _result;
+
+        internal AdapterLeScanResultChangedEventArgs(BluetoothError result, BluetoothLeDevice deviceData)
+        {
+            _deviceData = deviceData;
+            _result = result;
+        }
+
+        /// <summary>
+        /// The result.
+        /// </summary>
+        public BluetoothError Result
+        {
+            get
+            {
+                return _result;
+            }
+        }
+
+        /// <summary>
+        /// The LE device data.
+        /// </summary>
+        public BluetoothLeDevice DeviceData
+        {
+            get
+            {
+                return _deviceData;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the changed Bluetooth LE GATT connection state.
+    /// </summary>
+    public class GattConnectionStateChangedEventArgs : EventArgs
+    {
+        private bool _isConnected;
+        private int _result;
+        private string _remoteAddress;
+
+        internal GattConnectionStateChangedEventArgs(int result, bool connected, string remoteAddress)
+        {
+            _isConnected = connected;
+            _result = result;
+            _remoteAddress = remoteAddress;
+        }
+
+        /// <summary>
+        /// The result.
+        /// </summary>
+        public int Result
+        {
+            get
+            {
+                return _result;
+            }
+        }
+
+        /// <summary>
+        /// A value indicating whether this instance is connected.
+        /// </summary>
+        public bool IsConnected
+        {
+            get
+            {
+                return _isConnected;
+            }
+        }
+
+        /// <summary>
+        /// The remote address.
+        /// </summary>
+        public string RemoteAddress
+        {
+            get
+            {
+                return _remoteAddress;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the changed attribute value.
+    /// </summary>
+    public class ValueChangedEventArgs : EventArgs
+    {
+        internal ValueChangedEventArgs(byte[] value)
+        {
+            Value = value;
+        }
+
+        /// <summary>
+        /// The attribute value.
+        /// </summary>
+        public byte[] Value { get; }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the read value request data.
+    /// </summary>
+    public class ReadRequestedEventArgs : EventArgs
+    {
+        internal ReadRequestedEventArgs(BluetoothGattServer server, string clientAddress, int requestId, int offset)
+        {
+            Server = server;
+            ClientAddress = clientAddress;
+            RequestId = requestId;
+            Offset = offset;
+        }
+
+        /// <summary>
+        /// The GATT server instance.
+        /// </summary>
+        public BluetoothGattServer Server { get; }
+        /// <summary>
+        /// The client address.
+        /// </summary>
+        public string ClientAddress { get; }
+        /// <summary>
+        /// The request identifier.
+        /// </summary>
+        public int RequestId { get; }
+        /// <summary>
+        /// The offset.
+        /// </summary>
+        public int Offset { get; }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the read value request data.
+    /// </summary>
+    public class WriteRequestedEventArgs : EventArgs
+    {
+        internal WriteRequestedEventArgs(BluetoothGattServer server, string clientAddress, int requestId, byte[] value, int offset, bool response_needed)
+        {
+            Server = server;
+            ClientAddress = clientAddress;
+            RequestId = requestId;
+            Value = value;
+            Offset = offset;
+            Response_needed = response_needed;
+        }
+
+        /// <summary>
+        /// The GATT server instance.
+        /// </summary>
+        public BluetoothGattServer Server { get; }
+        /// <summary>
+        /// The client address.
+        /// </summary>
+        public string ClientAddress { get; }
+        /// <summary>
+        /// The request identifier.
+        /// </summary>
+        public int RequestId { get; }
+        /// <summary>
+        /// The read value.
+        /// </summary>
+        public byte[] Value { get; }
+        /// <summary>
+        /// The offset.
+        /// </summary>
+        public int Offset { get; }
+        /// <summary>
+        /// Indicates whether a response is required by the remote device.
+        /// </summary>
+        public bool Response_needed { get; }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the client preference to enable or disable the Notification/Indication.
+    /// </summary>
+    public class NotificationStateChangedEventArg : EventArgs
+    {
+        internal NotificationStateChangedEventArg(BluetoothGattServer server, bool value)
+        {
+            Server = server;
+            Value = value;
+        }
+
+        /// <summary>
+        /// The GATT server instance.
+        /// </summary>
+        public BluetoothGattServer Server { get; }
+        /// <summary>
+        /// A value indicating whether the notification is enabled.
+        /// </summary>
+        public bool Value { get; }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class contains the read value request data.
+    /// </summary>
+    public class NotificationSentEventArg : EventArgs
+    {
+        internal NotificationSentEventArg(BluetoothGattServer server, string clientAddress, int result, bool completed)
+        {
+            Result = result;
+            ClientAddress = clientAddress;
+            Server = server;
+            Completed = completed;
+        }
+
+        /// <summary>
+        /// The GATT server instance.
+        /// </summary>
+        public BluetoothGattServer Server { get; }
+        /// <summary>
+        /// The client address.
+        /// </summary>
+        public string ClientAddress { get; }
+        /// <summary>
+        /// The result.
+        /// </summary>
+        public int Result { get; }
+        /// <summary>
+        /// Gets a value indicating whether the notification sent is completed.
+        /// </summary>
+        public bool Completed { get; }
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs
new file mode 100644 (file)
index 0000000..923f99c
--- /dev/null
@@ -0,0 +1,966 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tizen.Network.Bluetooth
+{
+    /// <summary>
+    /// The Bluetooth GATT server.
+    /// </summary>
+    public class BluetoothGattServer
+    {
+        private static BluetoothGattServer _instance;
+        private BluetoothGattServerImpl _impl;
+        private BluetoothGattServer()
+        {
+            _impl = new BluetoothGattServerImpl();
+        }
+
+        /// <summary>
+        /// (event) This event is called when the indication acknowledgement is received for each notified client.
+        /// </summary>
+        public event EventHandler<NotificationSentEventArg> NotificationSent
+        {
+            add
+            {
+                _impl._notificationSent += value;
+            }
+            remove
+            {
+                _impl._notificationSent -= value;
+            }
+        }
+
+        /// <summary>
+        /// Creates the Bluetooth GATT server.
+        /// </summary>
+        /// <returns></returns>
+        /// <exception cref="System.NotSupportedException">Thrown when the BT/BTLE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the create GATT server fails.</exception>
+        public static BluetoothGattServer CreateServer()
+        {
+            if (_instance == null)
+            {
+                BluetoothGattServer server = new BluetoothGattServer();
+                if (server.IsValid())
+                {
+                    _instance = server;
+                }
+            }
+            return _instance;
+        }
+
+        /// <summary>
+        /// Registers the server along with the GATT services of the application it is hosting.
+        /// </summary>
+        /// <exception cref="System.NotSupportedException">Thrown when the BT/BTLE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the register server application fails.</exception>
+        public void Start()
+        {
+            _impl.Start();
+        }
+
+        /// <summary>
+        /// Registers a specified service to this server.
+        /// </summary>
+        /// <param name="service">The service, which needs to be registered with this server.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the BT/BTLE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the register service fails.</exception>
+        public void RegisterGattService(BluetoothGattService service)
+        {
+            if (service.IsRegistered())
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.InvalidParameter);
+            }
+            _impl.RegisterGattService(this, service);
+        }
+
+        /// <summary>
+        /// Unregisters a specified service from this server.
+        /// </summary>
+        /// <param name="service">The service, which needs to be unregistered from this server.</param>
+        /// <remarks>
+        /// Once unregistered, the service object will become invalid and should not be used to access sevices or any children attribute's methods/members.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the BT/BTLE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the unregister service fails.</exception>
+        public void UnregisterGattService(BluetoothGattService service)
+        {
+            if (service.GetGattServer() != this)
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.InvalidParameter);
+            }
+
+            _impl.UnregisterGattService(service);
+        }
+
+        /// <summary>
+        /// Unregisters all services from this server.
+        /// </summary>
+        /// <remarks>
+        /// Once unregistered, servicees will become invalid and should not be used to access sevices or any children attribute's methods/members.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the BT/BTLE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the unregister all services fail.</exception>
+        public void UnregisterGattServices()
+        {
+            _impl.UnregisterAllGattServices(this);
+        }
+
+        /// <summary>
+        /// Gets service with given UUID that belongs to this server.
+        /// </summary>
+        /// <param name="uuid">The UUID for the service to get.</param>
+        /// <returns>The Service with the given UUID if it exists, null otherwise.</returns>
+        public BluetoothGattService GetService(string uuid)
+        {
+            return _impl.GetService(this, uuid);
+        }
+
+        /// <summary>
+        /// Gets the list of services that belongs to this server.
+        /// </summary>
+        /// <returns>The list of services that belongs to this server.</returns>
+        public IEnumerable<BluetoothGattService> GetServices()
+        {
+            return _impl.GetServices(this);
+        }
+
+        /// <summary>
+        /// Sends indication for the value change of the characteristic to the remote devices.
+        /// </summary>
+        /// <param name="characteristic">The characteristic whose the value is changed.</param>
+        /// <param name="clientAddress">The remote device address to send, notify, or indicate and if set to NULL, then notify/indicate all is enabled.</param>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the remote device is disconnected, or when service is not registered, or when the CCCD is not enabled.</exception>
+        public async Task<bool> SendIndicationAsync(BluetoothGattCharacteristic characteristic, string clientAddress)
+        {
+            return await _impl.SendIndicationAsync(this, characteristic, clientAddress);
+        }
+
+        /// <summary>
+        /// Sends the notification for the value change of the characteristic to the remote devices.
+        /// </summary>
+        /// <param name="characteristic">The characteristic, which has a changed value.</param>
+        /// <param name="clientAddress">The remote device address to send, notify, or indicate and if set to NULL, then notify/indicate all is enabled.</param>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the remote device is disconnected, or when service is not registered, or when the CCCD is not enabled.</exception>
+        public void SendNotification(BluetoothGattCharacteristic characteristic, string clientAddress)
+        {
+            _impl.SendNotification(characteristic, clientAddress);
+        }
+
+        /// <summary>
+        /// Sends a response to the remote device as a result of a read/write request.
+        /// </summary>
+        /// <param name="requestId">The identification of a read/write request.</param>
+        /// <param name="type">The request type for read/write.</param>
+        /// <param name="status">The error value in case of failure, 0 for success.</param>
+        /// <param name="value">The value to be sent.</param>
+        /// <param name="offset">The offset from where the value is read.</param>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the remote device is disconnected, or the send response procedure fails.</exception>
+        public void SendResponse(int requestId, BluetoothGattRequestType type, int status, byte[] value, int offset)
+        {
+            _impl.SendResponse(requestId, (int)type, status, value, offset);
+        }
+
+        internal bool IsValid()
+        {
+            return _impl.GetHandle().IsInvalid == false;
+        }
+    }
+
+    /// <summary>
+    /// The Bluetooth GATT client.
+    /// </summary>
+    public class BluetoothGattClient
+    {
+        private BluetoothGattClientImpl _impl;
+        private string _remoteAddress = string.Empty;
+
+        internal BluetoothGattClient(string remoteAddress)
+        {
+            _impl = new BluetoothGattClientImpl(remoteAddress);
+            _remoteAddress = remoteAddress;
+        }
+
+        internal static BluetoothGattClient CreateClient(string remoteAddress)
+        {
+            BluetoothGattClient client = new BluetoothGattClient(remoteAddress);
+            return client.Isvalid() ? client : null;
+        }
+
+        public void DestroyClient()
+        {
+            _impl.GetHandle().Dispose();
+        }
+
+        /// <summary>
+        /// The address of the remote device.
+        /// </summary>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the remote device is disconnected.</exception>
+        public string RemoteAddress
+        {
+            get
+            {
+                if (string.IsNullOrEmpty(_remoteAddress))
+                {
+                    _remoteAddress = _impl.GetRemoteAddress();
+                }
+                return _remoteAddress;
+            }
+        }
+
+        /// <summary>
+        /// Gets the service with the given UUID that belongs to the remote device.
+        /// </summary>
+        /// <param name="uuid">The UUID for the service to get.</param>
+        /// <returns>The service with the given UUID if it exists, null otherwise.</returns>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the remote device is disconnected, or when the get service fails.</exception>
+        public BluetoothGattService GetService(string uuid)
+        {
+            return _impl.GetService(this, uuid);
+        }
+
+        /// <summary>
+        /// Gets list of services that belongs to the remote device.
+        /// </summary>
+        /// <returns>The list of services that belongs to the remote device.</returns>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the remote device is disconnected, or when the get service fails.</exception>
+        public IEnumerable<BluetoothGattService> GetServices()
+        {
+            return _impl.GetServices(this);
+        }
+
+        /// <summary>
+        /// Reads the value of a given characteristic from the remote device asynchronously.
+        /// </summary>
+        /// <param name="characteristic">The characteristic to be read.</param>
+        /// <returns>true on success, false otherwise.</returns>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the remote device is disconnected, or when the read attribute value fails.</exception>
+        public async Task<bool> ReadValueAsync(BluetoothGattCharacteristic characteristic)
+        {
+            return await _impl.ReadValueAsyncTask(characteristic.GetHandle());
+        }
+
+        /// <summary>
+        /// Reads the value of the given descriptor from the remote device asynchronously.
+        /// </summary>
+        /// <param name="descriptor">The descriptor to be read.</param>
+        /// <returns>true on success, false otherwise.</returns>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the remote device is disconnected, or when the read attribute value fails.</exception>
+        public async Task<bool> ReadValueAsync(BluetoothGattDescriptor descriptor)
+        {
+            return await _impl.ReadValueAsyncTask(descriptor.GetHandle());
+        }
+
+        /// <summary>
+        /// Writes the value of a given characteristic to the remote device asynchronously.
+        /// </summary>
+        /// <param name="characteristic">The characteristic to be written.</param>
+        /// <returns>true on success, false otherwise.</returns>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the remote device is disconnected or when the write attribute value fails.</exception>
+        public async Task<bool> WriteValueAsync(BluetoothGattCharacteristic characteristic)
+        {
+            return await _impl.WriteValueAsyncTask(characteristic.GetHandle());
+        }
+
+        /// <summary>
+        /// Writes the value of the given descriptor to the remote device asynchronously.
+        /// </summary>
+        /// <param name="descriptor">The descriptor to be written.</param>
+        /// <returns>true on success, false otherwise.</returns>
+        /// <exception cref="System.InvalidOperationException">Thrown when the BT/BTLE is not enabled
+        /// or when the remote device is disconnected, or when the write attribute value fails.</exception>
+        public async Task<bool> WriteValueAsync(BluetoothGattDescriptor descriptor)
+        {
+            return await _impl.WriteValueAsyncTask(descriptor.GetHandle());
+        }
+
+        internal bool Isvalid()
+        {
+            return _impl.GetHandle().IsInvalid == false;
+        }
+    }
+
+    /// <summary>
+    /// The Bluetooth GATT service.
+    /// </summary>
+    public class BluetoothGattService
+    {
+        private BluetoothGattServiceImpl _impl;
+        private BluetoothGattClient _parentClient = null;
+        private BluetoothGattServer _parentServer = null;
+        private BluetoothGattService _parentService = null;
+
+        /// <summary>
+        /// The constructor.
+        /// </summary>
+        /// <param name="uuid">The UUID of the service.</param>
+        /// <param name="type">The type of service.</param>
+        /// <exception cref="System.InvalidOperationException">Thrown when the create GATT service procedure fails.</exception>
+        public BluetoothGattService(string uuid, BluetoothGattServiceType type)
+        {
+            Uuid = uuid;
+            _impl = new BluetoothGattServiceImpl(uuid, type);
+        }
+
+        internal BluetoothGattService(BluetoothGattServiceImpl impl, string uuid)
+        {
+            Uuid = uuid;
+            _impl = impl;
+        }
+
+        /// <summary>
+        /// Specification name from the UUID.
+        /// </summary>
+        public string Uuid { get; }
+
+        /// <summary>
+        /// Adds a characteristic to this service.
+        /// </summary>
+        /// <param name="characteristic">The characteristic to be added.</param>
+        /// <returns>true on success, false otherwise.</returns>
+        /// <exception cref="System.InvalidOperationException">Thrown when the add GATT characteristic procedure fails.</exception>
+        public void AddCharacteristic(BluetoothGattCharacteristic characteristic)
+        {
+            if (GetGattClient() != null)
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotSupported);
+            }
+
+            if (characteristic.GetService() != null)
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.InvalidParameter);
+            }
+
+            _impl.AddCharacteristic(characteristic);
+            characteristic.SetParent(this);
+        }
+
+        /// <summary>
+        /// Gets the characteristic with the given UUID that belongs to this service.
+        /// </summary>
+        /// <param name="uuid">The UUID for the characteristic to get.</param>
+        /// <returns>The characteristic with a given UUID if it exists, null otherwise.</returns>
+        public BluetoothGattCharacteristic GetCharacteristic(string uuid)
+        {
+            return _impl.GetCharacteristic(this, uuid);
+        }
+
+        /// <summary>
+        /// Gets list of the characteristic that belongs to this service.
+        /// </summary>
+        /// <returns>The list of the characteristic that belongs to this service.</returns>
+        public IEnumerable<BluetoothGattCharacteristic> GetCharacteristics()
+        {
+            return _impl.GetCharacteristics(this);
+        }
+
+        /// <summary>
+        /// Includes a service to this service.
+        /// </summary>
+        /// <param name="service">The service to be included.</param>
+        /// <returns>true on success, false otherwise</returns>
+        /// <exception cref="System.InvalidOperationException">Thrown when the add GATT service procedure fails.</exception>/// 
+        public void AddService(BluetoothGattService service)
+        {
+            if (GetGattClient() != null)
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotSupported);
+            }
+
+            if (service.IsRegistered())
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.InvalidParameter);
+            }
+
+            _impl.AddIncludeService(service);
+            service.SetParent(this);
+        }
+
+        /// <summary>
+        /// Gets the included service.
+        /// </summary>
+        /// <param name="uuid">The UUID for the service to get.</param>
+        /// <returns>The service with a given UUID if it exists, null otherwise.</returns>
+        public BluetoothGattService GetIncludeService(string uuid)
+        {
+            return _impl.GetIncludeService(this, uuid);
+        }
+
+        /// <summary>
+        /// Gets the included service list of this service.
+        /// </summary>
+        /// <returns>The included service list of this service.</returns>
+        public IEnumerable<BluetoothGattService> GetIncludeServices()
+        {
+            return _impl.GetIncludeServices(this);
+        }
+
+        /// <summary>
+        /// Gets the server instance which the specified service belongs to.
+        /// </summary>
+        /// <returns>The server instance which the specified service belongs to.</returns>
+        public BluetoothGattServer GetGattServer()
+        {
+            return _parentServer;
+        }
+
+        /// <summary>
+        /// Gets the client instance which the specified service belongs to.
+        /// </summary>
+        /// <returns>The client instance which the specified service belongs to.</returns>
+        public BluetoothGattClient GetGattClient()
+        {
+            return _parentClient;
+        }
+
+        internal BluetoothGattAttributeHandle GetHandle()
+        {
+            return _impl.GetHandle();
+        }
+
+        internal void SetParent(BluetoothGattService parent)
+        {
+            if (!IsRegistered())
+            {
+                _parentService = parent;
+                _impl.ReleaseHandleOwnership();
+            }
+        }
+
+        internal void SetParent(BluetoothGattClient parent)
+        {
+            if (!IsRegistered())
+            {
+                _parentClient = parent;
+                _impl.ReleaseHandleOwnership();
+            }
+        }
+
+        internal void SetParent(BluetoothGattServer parent)
+        {
+            if (!IsRegistered())
+            {
+                _parentServer = parent;
+                _impl.ReleaseHandleOwnership();
+            }
+        }
+
+        internal void UnregisterService()
+        {
+            _parentServer = null;
+            _parentClient = null;
+            _parentService = null;
+        }
+
+        internal bool IsRegistered()
+        {
+            return _parentClient != null || _parentServer != null || _parentService != null;
+        }
+    }
+
+    /// <summary>
+    /// The Bluetooth GATT characteristic.
+    /// </summary>
+    public class BluetoothGattCharacteristic : BluetoothGattAttribute
+    {
+        private BluetoothGattCharacteristicImpl _impl;
+        private BluetoothGattService _parent = null;
+
+        private Interop.Bluetooth.BtClientCharacteristicValueChangedCallback _characteristicValueChangedCallback;
+        private Interop.Bluetooth.BtGattServerNotificationStateChangeCallback _notificationStateChangedCallback;
+
+        private EventHandler<ValueChangedEventArgs> _characteristicValueChanged;
+        internal EventHandler<NotificationStateChangedEventArg> _notificationStateChanged;
+
+        /// <summary>
+        /// The constructor.
+        /// </summary>
+        /// <param name="uuid">The UUID of the characterstic.param>
+        /// <param name="permissions">Permissions for the characterstic.</param>
+        /// <param name="properties">Properties set for the characterstic.</param>
+        /// <param name="value">The value associated with the characterstic.</param>
+        /// <remarks>throws in case of internal error.</remarks>
+        /// <exception cref="System.InvalidOperationException">Thrown when the create GATT characteristics procedure fails.</exception>
+        public BluetoothGattCharacteristic(string uuid, BluetoothGattPermission permissions, BluetoothGattProperty properties, byte[] value) : base(uuid, permissions)
+        {
+            _impl = new BluetoothGattCharacteristicImpl(uuid, permissions, properties, value);
+        }
+
+        internal BluetoothGattCharacteristic(BluetoothGattCharacteristicImpl impl, string uuid, BluetoothGattPermission permission) : base(uuid, permission)
+        {
+            _impl = impl;
+        }
+
+        /// <summary>
+        /// The CharacteristicValueChanged event is raised when the server notifies for change in this characteristic value.
+        /// </summary>
+        /// <remarks>
+        /// Adding the event handle on characteristic on the server side will not have any effect.
+        /// </remarks>
+        public event EventHandler<ValueChangedEventArgs> ValueChanged
+        {
+            add
+            {
+                if (Client != null)
+                {
+                    if (_characteristicValueChanged == null)
+                    {
+                        _characteristicValueChangedCallback = (gattHandle, characteristicValue, len, userData) =>
+                        {
+                            _characteristicValueChanged?.Invoke(this, new ValueChangedEventArgs(characteristicValue));
+                        };
+
+                        _impl.SetCharacteristicValueChangedEvent(_characteristicValueChangedCallback);
+                    }
+                    _characteristicValueChanged = value;
+                }
+            }
+            remove
+            {
+                if (Client != null)
+                {
+                    _characteristicValueChanged = null;
+                    if (_characteristicValueChanged == null)
+                    {
+                        _impl.UnsetCharacteristicValueChangedEvent();
+                    }
+
+                }
+            }
+        }
+
+        /// <summary>
+        /// The NotificationStateChanged event is called when the client enables or disables the Notification/Indication for particular characteristics.
+        /// </summary>
+        /// <remarks>
+        /// Adding event handle on the characteristic on the client side will not have any effect.
+        /// </remarks>
+        public event EventHandler<NotificationStateChangedEventArg> NotificationStateChanged
+        {
+            add
+            {
+                if (Server != null)
+                {
+                    if (_notificationStateChangedCallback == null)
+                    {
+                        _notificationStateChangedCallback = (notify, serverHandle, characteristicHandle, userData) =>
+                        {
+                            _notificationStateChanged?.Invoke(this, new NotificationStateChangedEventArg(Server, notify));
+                        };
+
+                        _impl.SetNotificationStateChangedEvent(_notificationStateChangedCallback);
+                    }
+
+                    _notificationStateChanged = value;
+                }
+            }
+            remove
+            {
+                if (Server != null)
+                {
+                    _notificationStateChanged = null;
+                    // CAPI does not allow unsetting ReadValueRequestedEventCallback.
+                }
+            }
+        }
+
+        /// <summary>
+        /// The property for this characteristic.
+        /// </summary>
+        public BluetoothGattProperty Properties
+        {
+            get
+            {
+                return _impl.GetProperties();
+            }
+            set
+            {
+                if (Server != null)
+                {
+                    _impl.SetProperties(value);
+                }
+            }
+        }
+
+        /// <summary>
+        /// The write type to be used for write operations.
+        /// </summary>
+        public BluetoothGattWriteType WriteType
+        {
+            get
+            {
+                return _impl.GetWriteType();
+            }
+            set
+            {
+                _impl.SetWriteType(value);
+            }
+        }
+
+        internal override BluetoothGattClient Client
+        {
+            get
+            {
+                return _parent?.GetGattClient();
+            }
+        }
+
+        internal override BluetoothGattServer Server
+        {
+            get
+            {
+                return _parent?.GetGattServer();
+            }
+        }
+
+        internal override BluetoothGattAttributeImpl Impl
+        {
+            get
+            {
+                return _impl;
+            }
+        }
+
+        /// <summary>
+        /// Adds a descriptor to this characteristic.
+        /// </summary>
+        /// <param name="descriptor">The descriptor to be added.</param>
+        /// <returns>true on success, false otherwise.</returns>
+        /// <exception cref="System.InvalidOperationException">Thrown when the add GATT descriptor procedure fails.</exception>
+        public void AddDescriptor(BluetoothGattDescriptor descriptor)
+        {
+            if (Client != null)
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotSupported);
+            }
+
+            if (descriptor.GetCharacteristic() != null)
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.InvalidParameter);
+            }
+
+            _impl.AddDescriptor(descriptor);
+            descriptor.SetParent(this);
+        }
+
+        /// <summary>
+        /// Gets the descriptor with the given UUID that belongs to this characteristic.
+        /// </summary>
+        /// <param name="uuid">The UUID for the descriptor to get.</param>
+        /// <returns>The descriptor with a given UUID if it exists, null otherwise.</returns>
+        public BluetoothGattDescriptor GetDescriptor(string uuid)
+        {
+            return _impl.GetDescriptor(this, uuid);
+        }
+
+        /// <summary>
+        /// Gets the list of descriptors that belongs to this characteristic.
+        /// </summary>
+        /// <returns>The list of descriptors that belongs to this characteristic.</returns>
+        public IEnumerable<BluetoothGattDescriptor> GetDescriptors()
+        {
+            return _impl.GetDescriptors(this);
+        }
+
+        /// <summary>
+        /// Gets the service instance, which the specified characterstic belongs to.
+        /// </summary>
+        /// <returns>The characteristic instance, the specified characterstic belongs to.</returns>
+        public BluetoothGattService GetService()
+        {
+            return _parent;
+        }
+
+        internal void SetParent(BluetoothGattService parent)
+        {
+            if (_parent == null)
+            {
+                _parent = parent;
+                ReleaseHandleOwnership();
+            }
+         }
+    }
+
+    /// <summary>
+    /// The Bluetooth GATT descriptor.
+    /// </summary>
+    public class BluetoothGattDescriptor : BluetoothGattAttribute
+    {
+        private BluetoothGattCharacteristic _parent = null;
+        private BluetoothGattDescriptorImpl _impl;
+
+        /// <summary>
+        /// The constructor.
+        /// </summary>
+        /// <param name="uuid">The UUID of the descriptor.</param>
+        /// <param name="permisions">Permissions for the descriptor.</param>
+        /// <param name="value">The value associated with the descriptor.</param>
+        /// <remarks>throws in case of internal error.</remarks>
+        /// <exception cref="System.InvalidOperationException">Thrown when the create GATT descriptor procedure fails.</exception>
+        public BluetoothGattDescriptor(string uuid, BluetoothGattPermission permisions, byte[] value) : base (uuid, permisions)
+        {
+            _impl = new BluetoothGattDescriptorImpl(uuid, permisions, value);
+        }
+
+        internal BluetoothGattDescriptor(BluetoothGattDescriptorImpl impl, string uuid, BluetoothGattPermission permission) : base(uuid, permission)
+        {
+            _impl = impl;
+        }
+
+        internal override BluetoothGattClient Client
+        {
+            get
+            {
+                return _parent?.Client;
+            }
+        }
+
+        internal override BluetoothGattServer Server
+        {
+            get
+            {
+                return _parent?.Server;
+            }
+        }
+
+        internal override BluetoothGattAttributeImpl Impl
+        {
+            get
+            {
+                return _impl;
+            }
+        }
+
+        /// <summary>
+        /// Gets the characteristic instance, which the specified descriptor belongs to.
+        /// </summary>
+        /// <returns>The characteristic instance, the specified descriptor belongs to.</returns>
+        public BluetoothGattCharacteristic GetCharacteristic()
+        {
+            return _parent;
+        }
+
+        internal void SetParent(BluetoothGattCharacteristic parent)
+        {
+            if (_parent == null)
+            {
+                _parent = parent;
+                ReleaseHandleOwnership();
+            }
+        }
+    }
+
+    /// <summary>
+    /// The Bluetooth GATT attribute.
+    /// </summary>
+    public abstract class BluetoothGattAttribute
+    {
+        private Interop.Bluetooth.BtGattServerReadValueRequestedCallback _readValueRequestedCallback;
+        private Interop.Bluetooth.BtGattServerWriteValueRequestedCallback _writeValueRequestedCallback;
+
+        private EventHandler<ReadRequestedEventArgs> _readValueRequested;
+        private EventHandler<WriteRequestedEventArgs> _writeValueRequested;
+
+        public BluetoothGattAttribute(string uuid, BluetoothGattPermission permission)
+        {
+            Uuid = uuid;
+            Permissions = permission;
+        }
+
+        // Events
+
+        /// <summary>
+        /// This event is called when the client request to read the value of a characteristic or a descriptor.
+        /// </summary>
+        /// <exception cref="System.InvalidOperationException">Thrown when the set read value requested callback procedure fails.</exception>
+        public event EventHandler<ReadRequestedEventArgs> ReadRequested
+        {
+            add
+            {
+                if (Server == null) return;
+                if (_readValueRequestedCallback == null)
+                {
+                    _readValueRequestedCallback = (clientAddress, requestId, serverHandle, gattHandle, offset, userData) =>
+                    {
+                        _readValueRequested?.Invoke(this, new ReadRequestedEventArgs(Server, clientAddress, requestId, offset));
+                    };
+                    Impl.SetReadValueRequestedEventCallback(_readValueRequestedCallback);
+                }
+                _readValueRequested = value;
+            }
+            remove
+            {
+                if (Server == null) return;
+                _readValueRequested = null;
+                // CAPI does not allow unsetting ReadValueRequestedEventCallback.
+            }
+        }
+
+        /// <summary>
+        /// This event is called when a value of a characteristic or a descriptor has been changed by a client.
+        /// </summary>
+        /// <exception cref="System.InvalidOperationException">Thrown when the set write value requested callback procedure fails.</exception>
+        public event EventHandler<WriteRequestedEventArgs> WriteRequested
+        {
+            add
+            {
+                if (Server == null) return;
+                if (_writeValueRequested == null)
+                {
+                    _writeValueRequestedCallback = (clientAddress, requestId, serverHandle, gattHandle, offset, response_needed, valueToWrite, len, userData) =>
+                    {
+                        _writeValueRequested?.Invoke(this, new WriteRequestedEventArgs(Server, clientAddress, requestId, valueToWrite, offset, response_needed));
+                    };
+                    Impl.SetWriteValueRequestedEventCallback(_writeValueRequestedCallback);
+                }
+                _writeValueRequested = value;
+            }
+            remove
+            {
+                if (Server == null) return;
+                _writeValueRequested = null;
+                // CAPI does not allow unsetting ReadValueRequestedEventCallback.
+            }
+        }
+
+        /// <summary>
+        /// The attribute's UUID.
+        /// </summary>
+        public string Uuid { get; }
+
+        /// <summary>
+        /// Permissions for this attribute.
+        /// </summary>
+        public BluetoothGattPermission Permissions { get; }
+
+        /// <summary>
+        /// The value of this descriptor.
+        /// </summary>
+        public byte[] Value
+        {
+            get
+            {
+                return Impl.GetValue();
+            }
+            set
+            {
+                Impl.SetValue(value);
+            }
+        }
+
+        internal abstract BluetoothGattClient Client { get; }
+        internal abstract BluetoothGattServer Server { get; }
+        internal abstract BluetoothGattAttributeImpl Impl { get; }
+
+        /// <summary>
+        /// Returns a string value at the specified offset.
+        /// </summary>
+        /// <param name="offset"></param>
+        /// <returns>The string value at specified offset.</returns>
+        public string GetValue(int offset)
+        {
+            return Impl.GetValue(offset);
+        }
+
+        /// <summary>
+        /// Sets the string value as a specified offset.
+        /// </summary>
+        /// <param name="value">value to set</param>
+        /// <exception cref="InvalidOperationException">Throws exception if the value is null.</exception>
+        public void SetValue(string value)
+        {
+            if (string.IsNullOrEmpty(value))
+                GattUtil.ThrowForError((int)BluetoothError.InvalidParameter, "value should not be null");
+
+            byte[] val = Encoding.UTF8.GetBytes(value);
+            Impl.SetValue(val);
+        }
+
+        /// <summary>
+        /// Returns a value at specified offset as the int value of the specified type.
+        /// </summary>
+        /// <param name="type">The type of the int value.</param>
+        /// <param name="An offset">An offset in the attribute value buffer.</param>
+        /// <returns>The int value at given offset.</returns>
+        /// <exception cref="InvalidOperationException">Throws exception if (offset + size of int value) is greater than the length of the value buffer.</exception>
+        public int GetValue(IntDataType type, int offset)
+        {
+            return Impl.GetValue(type, offset);
+        }
+
+        /// <summary>
+        /// Updates a value at the specified offset by the int value of the specified type.
+        /// </summary>
+        /// <param name="type">The type of the int value.</param>
+        /// <param name="value">The value to set.</param>
+        /// <param name="offset">An offset in the attribute value buffer.</param>
+        /// <exception cref="InvalidOperationException">Throws exception if (offset + size of int value) is greater than the length of the value buffer.</exception>
+        public void SetValue(IntDataType type, int value, int offset)
+        {
+            Impl.SetValue(type, value, offset);
+        }
+
+        /// <summary>
+        /// Returns a value at the specified offset as the float value of the specified type.
+        /// </summary>
+        /// <param name="type">The type of the float value.</param>
+        /// <param name="offset">An offset in the attribute value buffer.</param>
+        /// <returns>The float value at given offset.</returns>
+        /// <exception cref="InvalidOperationException">Throws exception if (offset + size of float value) is greater than the length of the value buffer.</exception>
+        public float GetValue(FloatDataType type, int offset)
+        {
+            return Impl.GetValue(type, offset);
+        }
+
+        /// <summary>
+        /// Updates the value at the specified offset by the float value of the specified type.
+        /// </summary>
+        /// <param name="type">The type of the float value.</param>
+        /// <param name="mantissa">The mantissa of the float value.</param>
+        /// <param name="exponent">An exponent of the float value.</param>
+        /// <param name="offset">An offset in the attribute value buffer.</param>
+        /// <exception cref="InvalidOperationException">Throws exception if (offset + size of float value) is greater than the length of the value buffer.</exception>
+        public void SetValue(FloatDataType type, int mantissa, int exponent, int offset)
+        {
+            Impl.SetValue(type, mantissa, exponent, offset);
+        }
+
+        internal void ReleaseHandleOwnership()
+        {
+            Impl.ReleaseHandleOwnership();
+        }
+
+        internal BluetoothGattAttributeHandle GetHandle()
+        {
+            return Impl.GetHandle();
+        }
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGattImpl.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGattImpl.cs
new file mode 100644 (file)
index 0000000..39530db
--- /dev/null
@@ -0,0 +1,707 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tizen.Network.Bluetooth
+{
+    internal class BluetoothGattServerImpl
+    {
+        private BluetoothGattServerHandle _handle;
+        internal event EventHandler<NotificationSentEventArg> _notificationSent;
+
+        internal BluetoothGattServerImpl()
+        {
+            int err = Interop.Bluetooth.BtGattServerInitialize();
+            GattUtil.ThrowForError(err, "Failed to initialize server");
+
+            err = Interop.Bluetooth.BtGattServerCreate(out _handle);
+            GattUtil.ThrowForError(err, "Failed to create server");
+        }
+
+        internal void Start()
+        {
+            int err = Interop.Bluetooth.BtGattServerStart();
+            GattUtil.ThrowForError(err, "Failed to start server");
+        }
+
+        internal void RegisterGattService(BluetoothGattServer server, BluetoothGattService service)
+        {
+            int err = Interop.Bluetooth.BtGattServerRegisterService(_handle, service.GetHandle());
+            GattUtil.ThrowForError(err, "Failed to Register service");
+
+            service.SetParent(server);
+        }
+
+        internal void UnregisterGattService(BluetoothGattService service)
+        {
+            int err = Interop.Bluetooth.BtGattServerUnregisterService(_handle, service.GetHandle());
+            GattUtil.ThrowForError(err, "Failed to Unregister service");
+
+            service.UnregisterService();
+        }
+
+        internal void UnregisterAllGattServices(BluetoothGattServer server)
+        {
+            int err = Interop.Bluetooth.BtGattServerUnregisterAllServices(_handle);
+            GattUtil.ThrowForError(err, "Failed to Unregister all services");
+        }
+
+        internal BluetoothGattService GetService(BluetoothGattServer server, string uuid)
+        {
+            BluetoothGattAttributeHandle serviceHandle;
+            int err = Interop.Bluetooth.BtGattServerGetService(_handle, uuid, out serviceHandle);
+            if (err.IsFailed())
+            {
+                GattUtil.Error(err, string.Format("Failed to get service with UUID ({0})", uuid));
+                return null;
+            }
+
+            BluetoothGattService service = new BluetoothGattService(new BluetoothGattServiceImpl(serviceHandle), uuid); ;
+            service.SetParent(server);
+            return service;
+        }
+
+        internal IEnumerable<BluetoothGattService> GetServices(BluetoothGattServer server)
+        {
+            List<BluetoothGattService> attribututeList = new List<BluetoothGattService>();
+            Interop.Bluetooth.BtGattForeachCallback cb = (total, index, attributeHandle, userData) =>
+            {
+                BluetoothGattAttributeHandle handle = new BluetoothGattAttributeHandle(attributeHandle, false);
+                BluetoothGattService service = BluetoothGattServiceImpl.CreateBluetoothGattService(handle, ""); ;
+                if (service != null)
+                {
+                    service.SetParent(server);
+                    attribututeList.Add(service);
+                }
+                return true;
+            };
+
+            int err = Interop.Bluetooth.BtGattServerForeachServices(_handle, cb, IntPtr.Zero);
+            GattUtil.Error(err, "Failed to get all services");
+
+            return attribututeList;
+        }
+
+        internal void SendResponse(int requestId, int request_type, int status, byte[] value, int offset)
+        {
+            int err = Interop.Bluetooth.BtGattServerSendResponse(requestId, request_type, offset, status, value, value.Length);
+            GattUtil.ThrowForError(err, string.Format("Failed to send response for request Id {0}", requestId));
+        }
+
+        internal void SendNotification(BluetoothGattCharacteristic characteristic, string clientAddress)
+        {
+            int err = Interop.Bluetooth.BtGattServerNotify(characteristic.GetHandle(), null, clientAddress, IntPtr.Zero);
+            GattUtil.ThrowForError(err, string.Format("Failed to send value changed notification for characteristic uuid {0}", characteristic.Uuid));
+        }
+
+        internal Task<bool> SendIndicationAsync(BluetoothGattServer server, BluetoothGattCharacteristic characteristic, string clientAddress)
+        {
+            TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
+            Interop.Bluetooth.BtGattServerNotificationSentCallback cb = (result, address, serverHandle, characteristicHandle, completed, userData) =>
+            {
+                _notificationSent?.Invoke(characteristic, new NotificationSentEventArg(server, address, result, completed));
+                if (completed)
+                {
+                    tcs.SetResult(true);
+                }
+            };
+
+            int err = Interop.Bluetooth.BtGattServerNotify(characteristic.GetHandle(), cb, clientAddress, IntPtr.Zero);
+            GattUtil.ThrowForError(err, string.Format("Failed to send value changed indication for characteristic uuid {0}", characteristic.Uuid));
+
+            return tcs.Task;
+        }
+
+        internal BluetoothGattServerHandle GetHandle()
+        {
+            return _handle;
+        }
+    }
+
+    internal class BluetoothGattClientImpl
+    {
+        private BluetoothGattClientHandle _handle;
+
+        internal BluetoothGattClientImpl(string remoteAddress)
+        {
+            int err = Interop.Bluetooth.BtGattClientCreate(remoteAddress, out _handle);
+            GattUtil.ThrowForError(err, "Failed to get native client handle");
+        }
+
+        internal string GetRemoteAddress()
+        {
+            string remoteAddress;
+            int err = Interop.Bluetooth.BtGattClientGetRemoteAddress(_handle, out remoteAddress);
+            GattUtil.ThrowForError(err, "Failed to get remote address for this client");
+
+            return remoteAddress;
+        }
+
+        internal BluetoothGattService GetService(BluetoothGattClient client, string uuid)
+        {
+            BluetoothGattAttributeHandle serviceHandle;
+            int err = Interop.Bluetooth.BtGattClientGetService(_handle, uuid, out serviceHandle);
+            if (err.IsFailed())
+            {
+                GattUtil.Error(err, string.Format("Failed to get service with UUID ({0})", uuid));
+                return null;
+            }
+
+            BluetoothGattService service = new BluetoothGattService(new BluetoothGattServiceImpl(serviceHandle), uuid); ;
+            service.SetParent(client);
+            return service;
+        }
+
+        internal IEnumerable<BluetoothGattService> GetServices(BluetoothGattClient client)
+        {
+            List<BluetoothGattService> attribututeList = new List<BluetoothGattService>();
+            Interop.Bluetooth.BtGattForeachCallback cb = (total, index, attributeHandle, userData) =>
+            {
+                BluetoothGattAttributeHandle handle = new BluetoothGattAttributeHandle(attributeHandle, false);
+                BluetoothGattService service = BluetoothGattServiceImpl.CreateBluetoothGattService(handle, "");
+                if (service != null)
+                {
+                    service.SetParent(client);
+                    attribututeList.Add(service);
+                }
+                return true;
+            };
+
+            int err = Interop.Bluetooth.BtGattClientForeachServices(_handle, cb, IntPtr.Zero);
+            GattUtil.Error(err, "Failed to get all services");
+
+            return attribututeList;
+        }
+
+        internal Task<bool> ReadValueAsyncTask(BluetoothGattAttributeHandle handle)
+        {
+            TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
+            Interop.Bluetooth.BtGattClientRequestCompletedCallback cb = (result, requestHandle, userData) =>
+            {
+                if (result == (int)BluetoothError.None)
+                    tcs.SetResult(true);
+                else
+                    tcs.SetResult(false);
+            };
+
+            int err = Interop.Bluetooth.BtGattClientReadValue(handle, cb, IntPtr.Zero);
+            if (err.IsFailed())
+            {
+                GattUtil.Error(err, "Failed to read value from remote device");
+                tcs.SetResult(false);
+                BluetoothErrorFactory.ThrowBluetoothException(err);
+            }
+            return tcs.Task;
+        }
+
+        internal Task<bool> WriteValueAsyncTask(BluetoothGattAttributeHandle handle)
+        {
+            TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
+            Interop.Bluetooth.BtGattClientRequestCompletedCallback cb = (result, requestHandle, userData) =>
+            {
+                if (result == (int)BluetoothError.None)
+                    tcs.SetResult(true);
+                else
+                    tcs.SetResult(false);
+            };
+
+            int err = Interop.Bluetooth.BtGattClientWriteValue(handle, cb, IntPtr.Zero);
+            if (err.IsFailed())
+            {
+                GattUtil.Error(err, "Failed to write value to remote device");
+                tcs.SetResult(false);
+                BluetoothErrorFactory.ThrowBluetoothException(err);
+            }
+            return tcs.Task;
+        }
+
+        internal BluetoothGattClientHandle GetHandle()
+        {
+            return _handle;
+        }
+    }
+
+    internal class BluetoothGattServiceImpl : BluetoothGattAttributeImpl
+    {
+        internal BluetoothGattServiceImpl(string uuid, BluetoothGattServiceType type)
+        {
+            int err = Interop.Bluetooth.BtGattServiceCreate(uuid, (int)type, out _handle);
+            GattUtil.ThrowForError(err, "Failed to get native service handle");
+        }
+
+        internal BluetoothGattServiceImpl(BluetoothGattAttributeHandle handle)
+        {
+            _handle = handle;
+        }
+
+        internal static BluetoothGattService CreateBluetoothGattService(BluetoothGattAttributeHandle handle, string uuid)
+        {
+            if (uuid == "")
+            {
+                int err = Interop.Bluetooth.BtGattGetUuid(handle, out uuid);
+                GattUtil.ThrowForError(err, "Failed to get UUID");
+            }
+
+            BluetoothGattServiceImpl impl = new BluetoothGattServiceImpl(handle);
+            return new BluetoothGattService(impl, uuid);
+        }
+
+        internal void AddCharacteristic(BluetoothGattCharacteristic characteristic)
+        {
+            int err = Interop.Bluetooth.BtGattServiceAddCharacteristic(_handle, characteristic.GetHandle());
+            GattUtil.ThrowForError(err, string.Format("Failed to add characteristic with UUID ({0})", characteristic.Uuid));
+        }
+
+        internal BluetoothGattCharacteristic GetCharacteristic(BluetoothGattService service, string uuid)
+        {
+            BluetoothGattAttributeHandle attributeHandle;
+            int err = Interop.Bluetooth.BtGattServiceGetCharacteristic(_handle, uuid, out attributeHandle);
+            if (err.IsFailed())
+            {
+                GattUtil.Error(err, string.Format("Failed to get Characteristic with UUID ({0})", uuid));
+                return null;
+            }
+
+            BluetoothGattCharacteristic Characteristic = BluetoothGattCharacteristicImpl.CreateBluetoothGattGattCharacteristic(attributeHandle, uuid);
+            Characteristic.SetParent(service);
+            return Characteristic;
+        }
+
+        internal IEnumerable<BluetoothGattCharacteristic> GetCharacteristics(BluetoothGattService service)
+        {
+            List<BluetoothGattCharacteristic> attribututeList = new List<BluetoothGattCharacteristic>();
+            Interop.Bluetooth.BtGattForeachCallback cb = (total, index, attributeHandle, userData) =>
+            {
+                BluetoothGattAttributeHandle handle = new BluetoothGattAttributeHandle(attributeHandle, false);
+                BluetoothGattCharacteristic Characteristic = BluetoothGattCharacteristicImpl.CreateBluetoothGattGattCharacteristic(handle, "");
+                if (Characteristic != null)
+                {
+                    Characteristic.SetParent(service);
+                    attribututeList.Add(Characteristic);
+                }
+                return true;
+            };
+
+            int err = Interop.Bluetooth.BtGattServiceForeachCharacteristics(service.GetHandle(), cb, IntPtr.Zero);
+            GattUtil.Error(err, "Failed to get all Characteristic");
+
+            return attribututeList;
+        }
+
+        internal void AddIncludeService(BluetoothGattService includedService)
+        {
+            int err = Interop.Bluetooth.BtGattServiceAddIncludedService(_handle, includedService.GetHandle());
+            GattUtil.ThrowForError(err, string.Format("Failed to add service with UUID ({0})", includedService.Uuid));
+        }
+
+        internal BluetoothGattService GetIncludeService(BluetoothGattService parentService, string uuid)
+        {
+            BluetoothGattAttributeHandle attributeHandle;
+            int err = Interop.Bluetooth.BtGattServiceGetIncludedService(_handle, uuid, out attributeHandle);
+            if (err.IsFailed())
+            {
+                GattUtil.Error(err, string.Format("Failed to get included service with UUID ({0})", uuid));
+                return null;
+            }
+
+            BluetoothGattService service = new BluetoothGattService(new BluetoothGattServiceImpl(attributeHandle), uuid);
+            service.SetParent(parentService);
+            return service;
+        }
+
+        internal IEnumerable<BluetoothGattService> GetIncludeServices(BluetoothGattService parentService)
+        {
+            List<BluetoothGattService> attribututeList = new List<BluetoothGattService>();
+            Interop.Bluetooth.BtGattForeachCallback cb = (total, index, attributeHandle, userData) =>
+            {
+                BluetoothGattAttributeHandle handle = new BluetoothGattAttributeHandle(attributeHandle, false);
+                BluetoothGattService service = BluetoothGattServiceImpl.CreateBluetoothGattService(handle, "");
+                if (service != null)
+                {
+                    service.SetParent(parentService);
+                    attribututeList.Add(service);
+                }
+                return true;
+            };
+
+            int err = Interop.Bluetooth.BtGattServiceForeachIncludedServices(parentService.GetHandle(), cb, IntPtr.Zero);
+            GattUtil.Error(err, "Failed to get all services");
+
+            return attribututeList;
+        }
+    }
+
+    internal class BluetoothGattCharacteristicImpl : BluetoothGattAttributeImpl
+    {
+        internal BluetoothGattCharacteristicImpl(string uuid, BluetoothGattPermission permission, BluetoothGattProperty property, byte[] value)
+        {
+            int err = Interop.Bluetooth.BtGattCharacteristicCreate(uuid, (int)permission, (int)property, value, value.Length, out _handle);
+            GattUtil.ThrowForError(err, "Failed to get native characteristic handle");
+        }
+
+        internal BluetoothGattCharacteristicImpl(BluetoothGattAttributeHandle handle)
+        {
+            _handle = handle;
+        }
+
+        internal static BluetoothGattCharacteristic CreateBluetoothGattGattCharacteristic(BluetoothGattAttributeHandle handle, string uuid)
+        {
+            int permission;
+            int err = Interop.Bluetooth.BtGattCharacteristicGetPermissions(handle, out permission);
+            GattUtil.ThrowForError(err, "Failed to get permissions");
+
+            if (uuid == "")
+            {
+                err = Interop.Bluetooth.BtGattGetUuid(handle, out uuid);
+                GattUtil.ThrowForError(err, "Failed to get UUID");
+            }
+
+            BluetoothGattCharacteristicImpl impl = new BluetoothGattCharacteristicImpl(handle);
+            return new BluetoothGattCharacteristic(impl, uuid, (BluetoothGattPermission)permission);
+        }
+
+        internal void SetCharacteristicValueChangedEvent(Interop.Bluetooth.BtClientCharacteristicValueChangedCallback callback)
+        {
+            int err = Interop.Bluetooth.BtGattClientSetCharacteristicValueChangedCallback(_handle, callback, IntPtr.Zero);
+            GattUtil.Error(err, "Failed to set client characteristic value changed callback");
+        }
+
+        internal void UnsetCharacteristicValueChangedEvent()
+        {
+            int err = Interop.Bluetooth.BtGattClientUnsetCharacteristicValueChangedCallback(_handle);
+            GattUtil.Error(err, "Failed to unset client characteristic value changed callback");
+        }
+
+        internal void SetNotificationStateChangedEvent(Interop.Bluetooth.BtGattServerNotificationStateChangeCallback callback)
+        {
+            int err = Interop.Bluetooth.BtGattServeSetNotificationStateChangeCallback(_handle, callback, IntPtr.Zero);
+            GattUtil.Error(err, "Failed to set characteristic notification state changed callback");
+        }
+
+        internal BluetoothGattProperty GetProperties()
+        {
+            int properties = 0 ;
+            int err = Interop.Bluetooth.BtGattCharacteristicGetProperties(_handle, out properties);
+            GattUtil.Error(err, "Failed to get characteristic properties");
+            return (BluetoothGattProperty)properties;
+        }
+
+        internal void SetProperties(BluetoothGattProperty perperties)
+        {
+            int err = Interop.Bluetooth.BtGattCharacteristicSetProperties(_handle, (int)perperties);
+            GattUtil.Error(err, "Failed to set characteristic properties");
+        }
+
+        internal BluetoothGattWriteType GetWriteType()
+        {
+            int writeType;
+            int err = Interop.Bluetooth.BtGattCharacteristicGetWriteType(_handle, out writeType);
+            GattUtil.Error(err, "Failed to get characteristic writetype");
+            return (BluetoothGattWriteType) writeType;
+        }
+
+        internal void SetWriteType(BluetoothGattWriteType writeType)
+        {
+            int err = Interop.Bluetooth.BtGattCharacteristicSetWriteType(_handle, (int)writeType);
+            GattUtil.Error(err, "Failed to get characteristic writetype");
+        }
+
+        internal void AddDescriptor(BluetoothGattDescriptor descriptor)
+        {
+            int err = Interop.Bluetooth.BtGattCharacteristicAddDescriptor(_handle, descriptor.GetHandle());
+            GattUtil.ThrowForError(err, string.Format("Failed to add descriptor with UUID ({0})", descriptor.Uuid));
+        }
+
+        internal BluetoothGattDescriptor GetDescriptor(BluetoothGattCharacteristic characteristic, string uuid)
+        {
+            BluetoothGattAttributeHandle handle;
+            int err = Interop.Bluetooth.BtGattCharacteristicGetDescriptor(_handle, uuid, out handle);
+            if (err.IsFailed())
+            {
+                GattUtil.Error(err, string.Format("Failed to get descriptor with UUID ({0})", uuid));
+                return null;
+            }
+            BluetoothGattDescriptor descriptor = BluetoothGattDescriptorImpl.CreateBluetoothGattDescriptor(handle, uuid);
+            descriptor.SetParent(characteristic);
+            return descriptor;
+        }
+
+        internal IEnumerable<BluetoothGattDescriptor> GetDescriptors(BluetoothGattCharacteristic characteristic)
+        {
+            List<BluetoothGattDescriptor> attribututeList = new List<BluetoothGattDescriptor>();
+            Interop.Bluetooth.BtGattForeachCallback cb = (total, index, attributeHandle, userData) =>
+            {
+                BluetoothGattAttributeHandle handle = new BluetoothGattAttributeHandle(attributeHandle, false);
+                BluetoothGattDescriptor descriptor = BluetoothGattDescriptorImpl.CreateBluetoothGattDescriptor(handle, "");
+                if (descriptor != null)
+                {
+                    descriptor.SetParent(characteristic);
+                    attribututeList.Add(descriptor);
+                }
+                return true;
+            };
+
+            int err = Interop.Bluetooth.BtGattCharacteristicForeachDescriptors(characteristic.GetHandle(), cb, IntPtr.Zero);
+            GattUtil.Error(err, "Failed to get all descriptor");
+
+            return attribututeList;
+        }
+    }
+
+    internal class BluetoothGattDescriptorImpl : BluetoothGattAttributeImpl
+    {
+        internal BluetoothGattDescriptorImpl(string uuid, BluetoothGattPermission permission, byte[] value)
+        {
+            int err = Interop.Bluetooth.BtGattDescriptorCreate(uuid, (int)permission, value, value.Length, out _handle);
+            GattUtil.ThrowForError(err, "Failed to get native descriptor handle");
+        }
+
+        internal BluetoothGattDescriptorImpl(BluetoothGattAttributeHandle handle)
+        {
+            _handle = handle;
+        }
+
+        internal static BluetoothGattDescriptor CreateBluetoothGattDescriptor(BluetoothGattAttributeHandle handle, string uuid)
+        {
+            int permission;
+            int err = Interop.Bluetooth.BtGattDescriptorGetPermissions(handle, out permission);
+            GattUtil.ThrowForError(err, string.Format("Failed to get permissions with UUID ({0})", uuid));
+
+            if (uuid == "")
+            {
+                int ret = Interop.Bluetooth.BtGattGetUuid(handle, out uuid);
+                GattUtil.ThrowForError(ret, "Failed to get UUID");
+            }
+
+            BluetoothGattDescriptorImpl impl = new BluetoothGattDescriptorImpl(handle);
+            return new BluetoothGattDescriptor(impl, uuid, (BluetoothGattPermission)permission);
+        }
+    }
+
+    internal abstract class BluetoothGattAttributeImpl
+    {
+        protected BluetoothGattAttributeHandle _handle;
+
+        internal string GetUuid()
+        {
+            string uuid;
+            int err = Interop.Bluetooth.BtGattGetUuid(_handle, out uuid);
+            GattUtil.Error(err, "Failed to get attribute uuid");
+
+            return uuid;
+        }
+
+        internal byte[] GetValue()
+        {
+            IntPtr nativeValue;
+            int nativeValueLength;
+            int err = Interop.Bluetooth.BtGattGetValue(_handle, out nativeValue, out nativeValueLength);
+            GattUtil.Error(err, "Failed to get attribute value");
+
+            return GattUtil.IntPtrToByteArray(nativeValue, nativeValueLength);
+        }
+
+        internal void SetValue(byte[] value)
+        {
+            int err = Interop.Bluetooth.BtGattSetValue(_handle, value, value.Length);
+            GattUtil.ThrowForError(err, "Failed to set attribute value");
+        }
+
+        internal string GetValue(int offset)
+        {
+            byte[] value = GetValue();
+
+            int nullPos = value.Length - offset;
+            for (int i = offset; i < value.Length; ++i)
+            {
+                if (value[i] == '\0')
+                {
+                    nullPos = i;
+                    break;
+                }
+            }
+
+            string strValue = "";
+            strValue = Encoding.UTF8.GetString(value, offset, nullPos - offset);
+            return strValue;
+        }
+
+        internal int GetValue(IntDataType type, int offset)
+        {
+            int value;
+            int err = Interop.Bluetooth.BtGattGetIntValue(_handle, (int)type, offset, out value);
+            GattUtil.Error(err, "Failed to get attribute int value at offset");
+            return value;
+        }
+
+        internal void SetValue(IntDataType type, int value, int offset)
+        {
+            int err = Interop.Bluetooth.BtGattSetIntValue(_handle, (int)type, value, offset);
+            GattUtil.ThrowForError(err, "Failed to set attribute int value at offset");
+        }
+
+        internal float GetValue(FloatDataType type, int offset)
+        {
+            float value;
+            int err = Interop.Bluetooth.BtGattGetFloatValue(_handle, (int)type, offset, out value);
+            GattUtil.Error(err, "Failed to get attribute float value at offset");
+            return value;
+        }
+
+        internal void SetValue(FloatDataType type, int mantissa, int exponent, int offset)
+        {
+            int err = Interop.Bluetooth.BtGattSetFloatValue(_handle, (int)type, mantissa, exponent, offset);
+            GattUtil.ThrowForError(err, "Failed to set attribute float value at offset");
+        }
+
+        internal void SetReadValueRequestedEventCallback(Interop.Bluetooth.BtGattServerReadValueRequestedCallback callback)
+        {
+            int err = Interop.Bluetooth.BtGattServerSetReadValueRequestedCallback(_handle, callback, IntPtr.Zero);
+            GattUtil.ThrowForError(err, "Failed to set attribute read value requested callback");
+        }
+
+        internal void SetWriteValueRequestedEventCallback(Interop.Bluetooth.BtGattServerWriteValueRequestedCallback callback)
+        {
+            int err = Interop.Bluetooth.BtGattServerSetWriteValueRequestedCallback(_handle, callback, IntPtr.Zero);
+            GattUtil.ThrowForError(err, "Failed to set attribute write value requested callback");
+        }
+
+        internal BluetoothGattAttributeHandle GetHandle()
+        {
+            return _handle;
+        }
+
+        internal void ReleaseHandleOwnership()
+        {
+            _handle.ReleaseOwnership();
+        }
+    }
+
+
+    internal class BluetoothGattAttributeHandle : BluetoothGattHandle
+    {
+        public BluetoothGattAttributeHandle(IntPtr nativeHandle, bool hasOwnership) : base(nativeHandle, hasOwnership)
+        {
+        }
+
+        public BluetoothGattAttributeHandle()
+        {
+        }
+
+        protected override bool ReleaseHandle()
+        {
+            if (_hasOwnership == true)
+            {
+                Interop.Bluetooth.BtGattDestroy(handle);
+            }
+            SetHandle(IntPtr.Zero);
+            return true;
+        }
+    }
+
+    internal class BluetoothGattClientHandle : BluetoothGattHandle
+    {
+        protected override bool ReleaseHandle()
+        {
+            if (_hasOwnership == true)
+            {
+                Interop.Bluetooth.BtGattClientDestroy(handle);
+            }
+            SetHandle(IntPtr.Zero);
+            return true;
+        }
+    }
+
+    internal class BluetoothGattServerHandle : BluetoothGattHandle
+    {
+        protected override bool ReleaseHandle()
+        {
+            if (_hasOwnership == true)
+            {
+                Interop.Bluetooth.BtGattServerDeinitialize();
+                Interop.Bluetooth.BtGattServerDestroy(handle);
+            }
+            SetHandle(IntPtr.Zero);
+            return true;
+        }
+    }
+
+    internal abstract class BluetoothGattHandle : SafeHandle
+    {
+        protected bool _hasOwnership;
+
+        public BluetoothGattHandle() : base(IntPtr.Zero, true)
+        {
+            _hasOwnership = true;
+        }
+
+        public BluetoothGattHandle(IntPtr nativeHandle, bool hasOwnership) : base(nativeHandle, true)
+        {
+            _hasOwnership = hasOwnership;
+        }
+
+        public override bool IsInvalid
+        {
+            get { return handle == IntPtr.Zero; }
+        }
+
+        public void ReleaseOwnership()
+        {
+            _hasOwnership = false;
+        }
+    }
+
+    internal static class GattUtil
+    {
+        internal static byte[] IntPtrToByteArray(IntPtr nativeValue, int lenght)
+        {
+            byte[] value = new byte[lenght];
+            if (nativeValue != IntPtr.Zero)
+            {
+                Marshal.Copy(nativeValue, value, 0, lenght);
+            }
+            return value;
+        }
+
+        internal static void Error(int err, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
+        {
+            if (err.IsFailed())
+            {
+                Log.Error(Globals.LogTag, string.Format("{0}, err: {1}", message, (BluetoothError)err), file, func, line);
+            }
+        }
+
+        internal static void ThrowForError(int err, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
+        {
+            if (err.IsFailed())
+            {
+                Log.Error(Globals.LogTag, string.Format("{0}, err: {1}", message, (BluetoothError)err), file, func, line);
+                BluetoothErrorFactory.ThrowBluetoothException(err);
+            }
+        }
+
+        internal static bool IsFailed(this int err)
+        {
+            return err != (int)BluetoothError.None;
+        }
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothHid.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothHid.cs
new file mode 100644 (file)
index 0000000..c35a963
--- /dev/null
@@ -0,0 +1,79 @@
+using System;
+
+namespace Tizen.Network.Bluetooth
+{
+    /// <summary>
+    /// A class which is used to handle the connection to Bluetooth HID like keyboards and mouse.
+    /// </summary>
+    /// <privilege> http://tizen.org/privilege/bluetooth </privilege>
+    public class BluetoothHid : BluetoothProfile
+    {
+        internal BluetoothHid()
+        {
+        }
+
+        /// <summary>
+        /// The HidConnectionStateChanged event is called when the HID host connection state is changed.
+        /// </summary>
+        public event EventHandler<HidConnectionStateChangedEventArgs> HidConnectionStateChanged
+        {
+            add
+            {
+                BluetoothHidImpl.Instance.HidConnectionStateChanged += value;
+            }
+            remove
+            {
+                BluetoothHidImpl.Instance.HidConnectionStateChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// Connects the remote device with the HID service.
+        /// </summary>
+        /// <remarks>
+        /// The device must be bonded with the remote device by CreateBond().
+        /// If connection request succeeds, the HidConnectionStateChanged event will be invoked.
+        /// </remarks>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when the connection attempt to the remote device fails.</exception>
+        public void Connect()
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                int ret = BluetoothHidImpl.Instance.Connect(RemoteAddress);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to Connect - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        /// <summary>
+        /// Disconnects the remote device with the HID service.
+        /// </summary>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when the disconnection attempt to the remote device fails.</exception>
+        public void Disconnect()
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                int ret = BluetoothHidImpl.Instance.Disconnect(RemoteAddress);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to Disconnect - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+    }
+}
+
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothHidImpl.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothHidImpl.cs
new file mode 100644 (file)
index 0000000..6a1401e
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Network.Bluetooth
+{
+    internal class BluetoothHidImpl : IDisposable
+    {
+        private event EventHandler<HidConnectionStateChangedEventArgs> _hidConnectionChanged;
+        private Interop.Bluetooth.HidConnectionStateChangedCallback _hidConnectionChangedCallback;
+
+        private static readonly BluetoothHidImpl _instance = new BluetoothHidImpl();
+        private bool disposed = false;
+
+        internal event EventHandler<HidConnectionStateChangedEventArgs> HidConnectionStateChanged
+        {
+            add
+            {
+                _hidConnectionChanged += value;
+            }
+            remove
+            {
+                //nothing to be done
+            }
+        }
+
+        internal int Connect(string deviceAddress)
+        {
+            if (Globals.IsHidInitialize)
+            {
+                int ret = Interop.Bluetooth.Connect (deviceAddress);
+                if (ret != (int)BluetoothError.None) {
+                    Log.Error (Globals.LogTag, "Failed to connect device with the hid service, Error - " + (BluetoothError)ret);
+                }
+                return ret;
+            }
+            return (int)BluetoothError.NotInitialized;
+        }
+
+        internal int Disconnect(string deviceAddress)
+        {
+            if (Globals.IsHidInitialize)
+            {
+                int ret = Interop.Bluetooth.Disconnect (deviceAddress);
+                if (ret != (int)BluetoothError.None) {
+                    Log.Error (Globals.LogTag, "Failed to disconnect device with the hid service, Error - " + (BluetoothError)ret);
+                }
+                return ret;
+            }
+            return (int)BluetoothError.NotInitialized;
+        }
+
+        internal static BluetoothHidImpl Instance
+        {
+            get
+            {
+                return _instance;
+            }
+        }
+        private BluetoothHidImpl ()
+        {
+            initialize();
+        }
+        ~BluetoothHidImpl()
+        {
+            Dispose(false);
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            if (disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects.
+            }
+            //Free unmanaged objects
+            deinitialize();
+            disposed = true;
+        }
+
+        private void initialize()
+        {
+            if (Globals.IsInitialize)
+            {
+                _hidConnectionChangedCallback = (int result, bool connected, string deviceAddress, IntPtr userData) =>
+                {
+                    if (_hidConnectionChanged != null)
+                    {
+                        _hidConnectionChanged(null, new HidConnectionStateChangedEventArgs(result, connected, deviceAddress));
+                    }
+                };
+
+                int ret = Interop.Bluetooth.InitializeHid (_hidConnectionChangedCallback, IntPtr.Zero);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to initialize bluetooth hid, Error - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException (ret);
+                }
+                else
+                {
+                    Globals.IsHidInitialize = true;
+                }
+            }
+            else
+            {
+                Log.Error(Globals.LogTag, "Failed to initialize HID, BT not initialized");
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotInitialized);
+            }
+        }
+
+        private void deinitialize()
+        {
+            if (Globals.IsHidInitialize)
+            {
+                int ret = Interop.Bluetooth.DeinitializeHid ();
+                if (ret != (int)BluetoothError.None) {
+                    Log.Error (Globals.LogTag, "Failed to deinitialize bluetooth hid, Error - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException (ret);
+                } else {
+                    Globals.IsHidInitialize = false;
+                }
+            }
+        }
+    }
+}
+
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothLeAdapter.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothLeAdapter.cs
new file mode 100644 (file)
index 0000000..a700c44
--- /dev/null
@@ -0,0 +1,831 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Threading.Tasks;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Bluetooth {
+
+    /// <summary>
+    /// This is the BluetoothLeAdvertiser class. It handles the LE advertising operation amd callback.
+    /// </summary>
+    public class BluetoothLeAdvertiser
+    {
+        private static readonly BluetoothLeAdvertiser _instance = new BluetoothLeAdvertiser();
+
+        internal static BluetoothLeAdvertiser Instance
+        {
+            get
+            {
+                return _instance;
+            }
+        }
+
+        private BluetoothLeAdvertiser()
+        {
+        }
+
+        /// <summary>
+        /// This event is called when the LE advertising state changes.
+        /// </summary>
+        public event EventHandler<AdvertisingStateChangedEventArgs> AdvertisingStateChanged
+        {
+            add
+            {
+                BluetoothLeImplAdapter.Instance.AdapterLeAdvertisingStateChanged += value;
+            }
+            remove
+            {
+                BluetoothLeImplAdapter.Instance.AdapterLeAdvertisingStateChanged -= value;
+            }
+        }
+        /// <summary>
+        /// Starts advertising using the advertise data object.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <param name="advertiseData">The advertiser object carrying information of the advertising.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled.</exception>
+        public void StartAdvertising(BluetoothLeAdvertiseData advertiseData)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                int ret = BluetoothLeImplAdapter.Instance.StartAdvertising (advertiseData.GetHandle ());
+                if (ret != (int)BluetoothError.None) {
+                    Log.Error (Globals.LogTag, "Failed to start advertising- " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        /// <summary>
+        /// Stops the advertising.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <param name="advertiseData">The advertiser object carrying information of the advertising.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled.</exception>
+        public void StopAdvertising(BluetoothLeAdvertiseData advertiseData)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                int ret = BluetoothLeImplAdapter.Instance.StopAdvertising (advertiseData.GetHandle ());
+                if (ret != (int)BluetoothError.None) {
+                    Log.Error (Globals.LogTag, "Failed to stop advertising operation- " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+    }
+
+    /// <summary>
+    /// This is the BluetoothLeDevice class.
+    /// It handles the LE device operations like getting data from the scan result information.
+    /// </summary>
+    public class BluetoothLeDevice
+    {
+        //properties of Bluetoothlesacandata
+        private string _remoteAddress;
+        private BluetoothLeDeviceAddressType _addressType;
+        private int _rssi;
+        private byte[] _advDataValue;
+        private byte[] _scanDataValue;
+        private BluetoothLePacketType _packetType;
+        private BluetoothLeScanData _scanData;
+
+        /// <summary>
+        /// This event is called when the GATT client connects/disconnects with the server.
+        /// </summary>
+        public event EventHandler<GattConnectionStateChangedEventArgs> GattConnectionStateChanged
+        {
+            add
+            {
+                BluetoothLeImplAdapter.Instance.LeGattConnectionStateChanged += value;
+            }
+            remove
+            {
+                BluetoothLeImplAdapter.Instance.LeGattConnectionStateChanged -= value;
+            }
+        }
+
+        internal BluetoothLeDevice(BluetoothLeScanData scanData)
+        {
+            _scanData = new BluetoothLeScanData ();
+            _scanData = scanData;
+
+            Log.Info (Globals.LogTag, "Rssi" + _scanData.Rssi);
+            _rssi = scanData.Rssi;
+            Log.Info (Globals.LogTag, "RemoteAddress" + _scanData.RemoteAddress);
+            if (scanData.RemoteAddress != null)
+                _remoteAddress = scanData.RemoteAddress;
+            Log.Info (Globals.LogTag, "AddressType" + _scanData.AddressType);
+            _addressType = scanData.AddressType;
+
+            Log.Info (Globals.LogTag, "AdvDataLength" + _scanData.AdvDataLength);
+            if (_scanData.AdvDataLength > 0)
+            {
+                _advDataValue = new byte[_scanData.AdvDataLength];
+                scanData.AdvData.CopyTo(_advDataValue, 0);
+            }
+
+            Log.Info(Globals.LogTag, "ScanDataLength" + _scanData.ScanDataLength);
+            //  Check length before copying
+            if (_scanData.ScanDataLength > 0)
+            {
+                _scanDataValue = new byte[_scanData.ScanDataLength];
+                scanData.ScanData.CopyTo(_scanDataValue, 0);
+            }
+        }
+
+        ~BluetoothLeDevice()
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                BluetoothLeImplAdapter.Instance.FreeServiceDataList();
+            }
+        }
+
+        /// <summary>
+        /// The remote address.
+        /// </summary>
+        public string RemoteAddress
+        {
+            get
+            {
+                return _remoteAddress;
+            }
+        }
+
+        /// <summary>
+        /// The type of the address.
+        /// </summary>
+        public BluetoothLeDeviceAddressType AddressType
+        {
+            get
+            {
+                return _addressType;
+            }
+        }
+
+        /// <summary>
+        /// The rssi value.
+        /// </summary>
+        public int Rssi
+        {
+            get
+            {
+                return _rssi;
+            }
+        }
+
+        /// <summary>
+        /// The advertsing data information.
+        /// </summary>
+        public byte[] AdvertsingDataInformation
+        {
+            get
+            {
+                return _advDataValue;
+            }
+        }
+
+        /// <summary>
+        /// The scan data information.
+        /// </summary>
+        public byte[] ScanDataInformation
+        {
+            get
+            {
+                return _scanDataValue;
+            }
+        }
+
+        /// <summary>
+        /// The type of the packet.
+        /// </summary>
+        public BluetoothLePacketType PacketType
+        {
+            get
+            {
+                return _packetType;
+            }
+            set
+            {
+                _packetType = value;
+            }
+        }
+
+        /// <summary>
+        /// Gets the service UUIDs list from the LE scan result information.
+        /// </summary>
+        /// <value> Gets the list of the string service UUIDs.</value>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled.</exception>
+        public IEnumerable<string> ServiceUuid
+        {
+            get
+            {
+                if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+                {
+                    Log.Info(Globals.LogTag, "Retrieving Service uuid- ");
+                    return BluetoothLeImplAdapter.Instance.GetLeScanResultServiceUuids(_scanData, _packetType);
+                }
+                return null;
+            }
+        }
+
+        /// <summary>
+        /// Gets the device name from the LE scan result information.
+        /// </summary>
+        /// <value> Gets the device name.</value>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled.</exception>
+        public string DeviceName
+        {
+            get
+            {
+                Log.Info(Globals.LogTag, "Retrieving device name- ");
+                if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+                {
+                    return BluetoothLeImplAdapter.Instance.GetLeScanResultDeviceName(_scanData, _packetType);
+                }
+                return null;
+            }
+        }
+        /// <summary>
+        /// Gets the transmission power level from the LE scan result information.
+        /// </summary>
+        /// <value> Gets the transmission power level in dB.</value>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled.</exception>
+        public int TxPowerLevel
+        {
+            get
+            {
+                if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+                {
+                    return BluetoothLeImplAdapter.Instance.GetScanResultTxPowerLevel(_scanData, _packetType);
+                }
+                return -1;
+            }
+        }
+
+        /// <summary>
+        /// Gets the service solicitation UUID list from the scan result information.
+        /// </summary>
+        /// <value> Gets the list of the service solicitation UUIDs.</value>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled.</exception>
+        public IEnumerable<string> ServiceSolictationUuid
+        {
+            get
+            {
+                if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+                {
+                    return BluetoothLeImplAdapter.Instance.GetScanResultSvcSolicitationUuids(_scanData, _packetType);
+                }
+                return null;
+            }
+        }
+        /// <summary>
+        /// Gets the manufacturer data from the scan result information.
+        /// </summary>
+        /// <value> Gets the appearance value.</value>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled.</exception>
+        public int Appearance
+        {
+            get
+            {
+                if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+                {
+                    return BluetoothLeImplAdapter.Instance.GetScanResultAppearance(_scanData, _packetType);
+                }
+                return -1;
+            }
+        }
+        /// <summary>
+        /// Gets the manufacturer data from the scan result information.
+        /// </summary>
+        /// <value> Gets the manufacturer data containing the manucturer data and ID information.</value>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled.</exception>/// 
+        public ManufacturerData ManufacturerData
+        {
+            get
+            {
+                if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+                {
+                    return BluetoothLeImplAdapter.Instance.GetScanResultManufacturerData(_scanData, _packetType);
+                }
+                return null;
+            }
+        }
+
+        /// <summary>
+        /// Gets the service data list from the scan result information.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <returns> Returns the service data list.</returns>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled.</exception>
+        public IEnumerable<BluetoothLeServiceData> GetServiceDataList()
+        {
+            int serviceCount = 0;
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                return BluetoothLeImplAdapter.Instance.GetScanResultServiceDataList(_scanData,
+                                            _packetType, out serviceCount);
+            }
+            return null;
+        }
+
+
+        /// <summary>
+        /// Creates a GATT connection with the remote device.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <param name="autoConnect"> The auto connect flag.</param>
+        /// <returns>client instance</returns>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// or when the gatt connection attempt to remote device fails.</exception>
+        public BluetoothGattClient GattConnect(bool autoConnect)
+        {
+            BluetoothGattClient client = null;
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                int ret = BluetoothLeImplAdapter.Instance.GattConnect (_remoteAddress, autoConnect);
+                if (ret != (int)BluetoothError.None) {
+                    Log.Error (Globals.LogTag, "Failed to create GATT Connection with remote device- " + (BluetoothError)ret);
+                }
+                else
+                {
+                    client = BluetoothGattClient.CreateClient(_remoteAddress);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+            return client;
+        }
+
+        /// <summary>
+        /// Disconnects a GATT connection with the remote device.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// or when the GATT disconnection attempt to remote device fails.</exception>
+        public void GattDisconnect()
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                int ret = BluetoothLeImplAdapter.Instance.GattDisconnect (_remoteAddress);
+                if (ret != (int)BluetoothError.None) {
+                    Log.Error (Globals.LogTag, "Failed to disconnect GATT connection with remote device- " + (BluetoothError)ret);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+    }
+
+    /// <summary>
+    /// Bluetooth LE advertise data. Handles the data advertising.
+    /// </summary>
+    public class BluetoothLeAdvertiseData:IDisposable
+    {
+        private IntPtr _handle = IntPtr.Zero;
+        private BluetoothLeAdvertisingMode _mode;
+        private bool _advertisingConnectable;
+        private BluetoothLePacketType _packetType;
+        private int _appearance;
+        private bool _includePowerLevel;
+        private bool _includeDeviceName;
+
+        /// <summary>
+        /// The default constructor initializes an object of the BluetoothLeAdvertiseData.
+        /// </summary>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// or when create advertiser fails.</exception>
+        public BluetoothLeAdvertiseData()
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                Log.Debug(Globals.LogTag, " Creating LeAdvertiser()");
+                int ret = Interop.Bluetooth.CreateAdvertiser(out _handle);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to create advertiser object- " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        ~BluetoothLeAdvertiseData()
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                //clean-up
+                ClearAdvertisingData (BluetoothLePacketType.BluetoothLeAdvertisingPacket);
+                ClearAdvertisingData (BluetoothLePacketType.BluetoothLeScanResponsePacket);
+                BluetoothLeImplAdapter.Instance.DestroyAdvertiser (_handle);
+            }
+            Dispose(false);
+        }
+
+        internal IntPtr GetHandle()
+        {
+            return _handle;
+        }
+
+        /// <summary>
+        /// The advertising mode to control the advertising power and latency.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// or when the set advertising mode fails.</exception>
+        public BluetoothLeAdvertisingMode AdvertisingMode
+        {
+            get
+            {
+                return _mode;
+            }
+            set
+            {
+                if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+                {
+                    _mode = value;
+                    int ret = Interop.Bluetooth.SetAdvertisingMode (GetHandle (), _mode);
+                    if (ret != (int)BluetoothError.None) {
+                        Log.Error (Globals.LogTag, "Failed to set advertising mode- " + (BluetoothError)ret);
+                        BluetoothErrorFactory.ThrowBluetoothException (ret);
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// The advertising connectable type.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// or when the set advertising connectable mode fails.</exception>
+        public bool AdvertisingConnectable
+        {
+            get
+            {
+                return _advertisingConnectable;
+            }
+            set
+            {
+                if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+                {
+                    _advertisingConnectable = value;
+                    int ret = Interop.Bluetooth.SetAdvertisingConnectable (GetHandle (), _advertisingConnectable);
+                    if (ret != (int)BluetoothError.None) {
+                        Log.Error (Globals.LogTag, "Failed to set advertising connectable value- " + (BluetoothError)ret);
+                        BluetoothErrorFactory.ThrowBluetoothException (ret);
+                    }
+                }
+            }
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            //todo...
+        }
+
+        /// <summary>
+        /// The type of the packet.
+        /// </summary>
+        public BluetoothLePacketType PacketType
+        {
+            get
+            {
+                return _packetType;
+            }
+            set
+            {
+                _packetType = value;
+            }
+        }
+        /// <summary>
+        /// Sets the external appearance of this device to the advertise or the scan response data.
+        /// Please refer to the adopted Bluetooth specification for the appearance.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// or when the set appearance fails.</exception>
+        public int Appearance
+        {
+            get
+            {
+                return _appearance;
+            }
+            set
+            {
+                _appearance = value;
+                if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) {
+                    int ret = Interop.Bluetooth.SetAdvertisingAppearance (GetHandle (), _packetType, _appearance);
+                    if (ret != (int)BluetoothError.None) {
+                        Log.Error (Globals.LogTag, "Failed to add appearance value to advertising data- " + (BluetoothError)ret);
+                        BluetoothErrorFactory.ThrowBluetoothException(ret);
+                    }
+                }
+            }
+        }
+        /// <summary>
+        /// Sets whether the device name has to be included in the advertise or the scan response data.
+        /// The maximum advertised or responded data size is 31 bytes including the data type and the system wide data.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// or when the set advertising device name fails.</exception>
+        public bool IncludeDeviceName
+        {
+            get
+            {
+                return _includeDeviceName;
+            }
+            set
+            {
+                _includeDeviceName = value;
+                if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+                {
+                    int ret = Interop.Bluetooth.SetAdvertisingDeviceName(GetHandle(), _packetType, _includeDeviceName);
+                    if (ret != (int)BluetoothError.None) {
+                        Log.Error (Globals.LogTag, "Failed to add device name to advertising data- " + (BluetoothError)ret);
+                        BluetoothErrorFactory.ThrowBluetoothException(ret);
+                    }
+                }
+            }
+        }
+
+
+        /// <summary>
+        /// Sets whether the transmission power level should be included in the advertise or the scan response data.
+        /// The maximum advertised or responded data size is 31 bytes including the data type and the system wide data.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// or when the set advertising TC power level fails.</exception>
+        public bool IncludeTxPowerLevel
+        {
+            get
+            {
+                return _includePowerLevel;
+            }
+            set
+            {
+                _includePowerLevel = value;
+                if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+                {
+                    int ret = Interop.Bluetooth.SetAdvertisingTxPowerLevel(GetHandle(), _packetType, _includePowerLevel);
+                    if (ret != (int)BluetoothError.None)
+                    {
+                        Log.Error(Globals.LogTag, "Failed to add advertising service solicitation uuid- " + (BluetoothError)ret);
+                    }
+                }
+            }
+        }
+        /// <summary>
+        /// Adds a service UUID to the advertise or the scan response data.
+        /// The maximum advertised or responded data size is 31 bytes
+        /// including the data type and the system wide data.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <param name="packetType">The packet type.</param>
+        /// <param name="serviceUuid"> The service UUID to add to advertise data.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// or when the add advertising service UUID procedure fails.</exception>
+        public void AddAdvertisingServiceUuid(BluetoothLePacketType packetType, string serviceUuid)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                int ret = Interop.Bluetooth.AddAdvertisingServiceUuid (GetHandle (), packetType, serviceUuid);
+                if (ret != (int)BluetoothError.None) {
+                    Log.Error (Globals.LogTag, "Failed to add service uuid to advertising data- " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException (ret);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        /// <summary>
+        /// Adds a service solicitation UUID to advertise or scan the response data.
+        /// The maximum advertised or responded data size is 31 bytes
+        /// including the data type and the system wide data.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <param name="packetType">The packet type.</param>
+        /// <param name="serviceSolicitationUuid"> The service solicitation UUID to add to advertise data.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// or when the add advertising service solicitation UUID procedure fails.</exception>
+        public void AddAdvertisingServiceSolicitationUuid(BluetoothLePacketType packetType,
+                                                        string serviceSolicitationUuid)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                int ret = Interop.Bluetooth.AddAdvertisingServiceSolicitationUuid(GetHandle(), packetType,
+                                                                serviceSolicitationUuid);
+                if (ret != (int)BluetoothError.None) {
+                    Log.Error (Globals.LogTag, "Failed to add service solicitation uuid to advertising data- " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        /// <summary>
+        /// Adds a service data to the advertise or the scan response data.
+        /// The maximum advertised or responded data size is 31 bytes
+        /// including data type and system wide data.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <param name="packetType">The packet type.</param>
+        /// <param name="data"> The service data to be added to advertising.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// or when the add advertising data procedure fails.</exception>
+        public void AddAdvertisingServiceData(BluetoothLePacketType packetType, BluetoothServiceData data)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                IntPtr serviceDataPtr;
+                serviceDataPtr = Marshal.AllocHGlobal(data.DataLength);
+                Marshal.Copy(data.Data, 0, serviceDataPtr, data.DataLength);
+
+                for (int i = 0; i < 3; i++)
+                    Log.Error (Globals.LogTag, " service data is  " + data.Data [i]);
+                int ret = Interop.Bluetooth.AddAdvertisingServiceData(GetHandle(), packetType,
+                    data.Uuid, serviceDataPtr, data.DataLength);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to add service data to advertising data- " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        /// <summary>
+        /// Adds the manufacturer specific data to the advertise or the scan response data.
+        /// Please refer to the adopted Bluetooth specification for the the appearance.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <param name="packetType">The packet type.</param>
+        /// <param name="manufacturerData"> The manufacturer specific data.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// or when the add advertising manufacturer data procedure fails.</exception>
+        public void AddAdvertisingManufacturerData(BluetoothLePacketType packetType,
+                                    ManufacturerData manufacturerData)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                IntPtr manufDataPtr;
+                manufDataPtr = Marshal.AllocHGlobal(manufacturerData.DataLength);
+                Marshal.Copy(manufacturerData.Data, 0, manufDataPtr, manufacturerData.DataLength);
+
+                int ret = Interop.Bluetooth.AddAdvertisingManufData(GetHandle(), packetType,
+                    manufacturerData.Id, manufDataPtr, manufacturerData.DataLength);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to add service solicitation uuid to advertising data- " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+
+        /// <summary>
+        /// Clears all data to be advertised or responded to the scan request from the LE scanning device.
+        /// </summary>
+        /// <remarks>
+        /// The Bluetooth must be enabled.
+        /// </remarks>
+        /// <param name="packetType">The packet type to be cleared.</param>
+        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// or when the clear advertising data procedure fails.</exception>
+        internal void ClearAdvertisingData(BluetoothLePacketType packetType)
+        {
+            if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
+            {
+                int ret = Interop.Bluetooth.ClearAdvertisingData (GetHandle (), packetType);
+                if (ret != (int)BluetoothError.None) {
+                    Log.Error (Globals.LogTag, "Failed to Clear Advertising Data- " + (BluetoothError)ret);
+                }
+            }
+            else
+            {
+                BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothLeAdapterImpl.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothLeAdapterImpl.cs
new file mode 100644 (file)
index 0000000..1fb02de
--- /dev/null
@@ -0,0 +1,452 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Threading.Tasks;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Bluetooth
+{
+    internal class BluetoothLeImplAdapter : IDisposable
+    {
+        private static readonly BluetoothLeImplAdapter _instance = new BluetoothLeImplAdapter();
+
+        private bool disposed = false;
+
+        private event EventHandler<AdapterLeScanResultChangedEventArgs> _adapterLeScanResultChanged = null;
+        private Interop.Bluetooth.AdapterLeScanResultChangedCallBack _adapterLeScanResultChangedCallback;
+
+        private event EventHandler<AdvertisingStateChangedEventArgs> _advertisingStateChanged = null;
+        private Interop.Bluetooth.AdvertisingStateChangedCallBack _advertisingStateChangedCallback;
+
+        private event EventHandler<GattConnectionStateChangedEventArgs> _gattConnectionStateChanged = null;
+        private Interop.Bluetooth.GattConnectionStateChangedCallBack _gattConnectionStateChangedCallback;
+
+        private int _serviceListCount = 0;
+        private IList<BluetoothLeServiceData> _list = new List<BluetoothLeServiceData>();
+        private bool _scanStarted;
+
+        internal static BluetoothLeImplAdapter Instance
+        {
+            get
+            {
+                return _instance;
+            }
+        }
+
+        private BluetoothLeImplAdapter()
+        {
+        }
+
+        ~BluetoothLeImplAdapter()
+        {
+            Dispose(false);
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            if (disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects.
+            }
+            //Free unmanaged objects
+            if (_gattConnectionStateChanged != null)
+            {
+                UnRegisterGattConnectionStateChangedEvent();
+            }
+
+            //stop scan operation in progress
+            StopScan ();
+
+            disposed = true;
+        }
+
+        internal event EventHandler<AdapterLeScanResultChangedEventArgs> AdapterLeScanResultChanged
+        {
+            add
+            {
+                _adapterLeScanResultChanged += value;
+            }
+            remove {
+                _adapterLeScanResultChanged -= value;
+            }
+        }
+
+        internal event EventHandler<AdvertisingStateChangedEventArgs> AdapterLeAdvertisingStateChanged
+        {
+            add
+            {
+                _advertisingStateChanged += value;
+            }
+            remove
+            {
+                _advertisingStateChanged -= value;
+            }
+        }
+
+        internal event EventHandler<GattConnectionStateChangedEventArgs> LeGattConnectionStateChanged
+        {
+            add
+            {
+                if (_gattConnectionStateChanged == null)
+                {
+                    RegisterGattConnectionStateChangedEvent();
+                }
+                _gattConnectionStateChanged += value;
+            }
+            remove
+            {
+                _gattConnectionStateChanged -= value;
+                if (_gattConnectionStateChanged == null)
+                {
+                    UnRegisterGattConnectionStateChangedEvent();
+                }
+            }
+        }
+
+        internal void RegisterGattConnectionStateChangedEvent()
+        {
+            _gattConnectionStateChangedCallback = (int result, bool connected,
+                                    string remoteDeviceAddress, IntPtr userData) =>
+            {
+                if (_gattConnectionStateChanged != null)
+                {
+                    Log.Info(Globals.LogTag, "Setting gatt connection state changed callback" );
+                    GattConnectionStateChangedEventArgs e = new GattConnectionStateChangedEventArgs (result,
+                        connected, remoteDeviceAddress);
+
+                    _gattConnectionStateChanged(null, e);
+                }
+            };
+
+            int ret = Interop.Bluetooth.SetGattConnectionStateChangedCallback(
+                                    _gattConnectionStateChangedCallback, IntPtr.Zero);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set gatt connection state changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        internal void UnRegisterGattConnectionStateChangedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetGattConnectionStateChangedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset gatt connection state changed callback, Error - " + (BluetoothError)ret);
+            }
+        }
+
+        internal int StartScan()
+        {
+            _adapterLeScanResultChangedCallback = (int result, ref BluetoothLeScanDataStruct scanData, IntPtr userData) =>
+            {
+                Log.Info(Globals.LogTag, "Inside Le scan callback " );
+                BluetoothLeScanData scanDataInfo = BluetoothUtils.ConvertStructToLeScanData(scanData);
+
+                BluetoothLeDevice device = new BluetoothLeDevice(scanDataInfo);
+                BluetoothError res = (BluetoothError)result;
+
+                AdapterLeScanResultChangedEventArgs e = new AdapterLeScanResultChangedEventArgs (res,
+                                                                    device);
+                _adapterLeScanResultChanged (null, e);
+            };
+
+            IntPtr data = IntPtr.Zero;
+            int ret = Interop.Bluetooth.StartScan(_adapterLeScanResultChangedCallback, data);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to start BLE scan - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+            _scanStarted = true;
+            return ret;
+        }
+
+        internal int StopScan()
+        {
+            int ret = (int)BluetoothError.None;
+
+            if (_scanStarted)
+            {
+                ret = Interop.Bluetooth.StopScan ();
+                if (ret != (int)BluetoothError.None) {
+                    Log.Error (Globals.LogTag, "Failed to stop BLE scan - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException (ret);
+                }
+            }
+            return ret;
+        }
+
+        internal IList<string> GetLeScanResultServiceUuids(BluetoothLeScanData scanData, BluetoothLePacketType packetType)
+        {
+            IntPtr uuidListArray = IntPtr.Zero;
+            int count = -1;
+
+            BluetoothLeScanDataStruct scanDataStruct = BluetoothUtils.ConvertLeScanDataToStruct(scanData);
+
+            int ret = Interop.Bluetooth.GetScanResultServiceUuid(ref scanDataStruct, packetType,
+                                                ref uuidListArray, ref count);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Info(Globals.LogTag, "Failed to service uuids list- " + (BluetoothError)ret);
+                return null;
+            }
+
+            Log.Info(Globals.LogTag, "count of uuids :  " + count);
+
+            IntPtr[] uuidList = new IntPtr[count];
+            Marshal.Copy(uuidListArray, uuidList, 0, count);
+            IList<string> list = new List<string>();
+            foreach(IntPtr uuids in uuidList)
+            {
+                list.Add(Marshal.PtrToStringAnsi(uuids));
+                Interop.Libc.Free(uuids);
+            }
+
+            Interop.Libc.Free(uuidListArray);
+            return list;
+        }
+
+        internal string GetLeScanResultDeviceName(BluetoothLeScanData scanData, BluetoothLePacketType packetType)
+        {
+            string deviceName;
+
+            BluetoothLeScanDataStruct scanDataStruct = BluetoothUtils.ConvertLeScanDataToStruct (scanData);
+
+            int ret = Interop.Bluetooth.GetLeScanResultDeviceName(ref scanDataStruct, packetType, out deviceName);
+            if (ret != (int)BluetoothError.None) {
+                Log.Error(Globals.LogTag, "Failed to get Device name- " + (BluetoothError)ret);
+                return null;
+            }
+            Log.Info (Globals.LogTag, "Device name " + deviceName);
+            return deviceName;
+        }
+
+        internal int GetScanResultTxPowerLevel(BluetoothLeScanData scanData, BluetoothLePacketType packetType)
+        {
+            int powerLevel = -1;
+            BluetoothLeScanDataStruct scanDataStruct = BluetoothUtils.ConvertLeScanDataToStruct (scanData);
+
+            int ret = Interop.Bluetooth.GetScanResultTxPowerLevel(ref scanDataStruct, packetType, out powerLevel);
+            if (ret != (int)BluetoothError.None) {
+                Log.Error(Globals.LogTag, "Failed to get tx power level- " + (BluetoothError)ret);
+            }
+            Log.Info (Globals.LogTag, "TxPowerLevel is --- " + powerLevel);
+            return powerLevel;
+        }
+
+        internal IList<string> GetScanResultSvcSolicitationUuids(BluetoothLeScanData scanData, BluetoothLePacketType packetType)
+        {
+            IntPtr uuidListArray;
+            int count;
+
+            BluetoothLeScanDataStruct scanDataStruct = BluetoothUtils.ConvertLeScanDataToStruct(scanData);
+
+            int ret = Interop.Bluetooth.GetScaResultSvcSolicitationUuids(ref scanDataStruct, packetType, out uuidListArray, out count);
+            if (ret != (int)BluetoothError.None) {
+                Log.Error(Globals.LogTag, "Failed to get service solicitation uuids " + (BluetoothError)ret);
+                return null;
+            }
+
+            IntPtr[] uuidList = new IntPtr[count];
+            Marshal.Copy(uuidListArray, uuidList, 0, count);
+            IList<string> list = new List<string>();
+            foreach(IntPtr uuids in uuidList)
+            {
+                list.Add(Marshal.PtrToStringAnsi(uuids));
+                Interop.Libc.Free(uuids);
+            }
+
+            Interop.Libc.Free(uuidListArray);
+            return list;
+        }
+
+        internal IList<BluetoothLeServiceData> GetScanResultServiceDataList(BluetoothLeScanData scanData,
+                            BluetoothLePacketType packetType, out int serviceCount)
+        {
+            int ret = 0;
+            IntPtr serviceListArray;
+            _serviceListCount = 0;
+
+            BluetoothLeScanDataStruct scanDataStruct = BluetoothUtils.ConvertLeScanDataToStruct (scanData);
+
+            ret = Interop.Bluetooth.GetScanResultServiceDataList(ref scanDataStruct, packetType, out serviceListArray, out _serviceListCount);
+            Log.Info(Globals.LogTag, "ServiceListCount :  " + _serviceListCount + " PacketType : " + packetType + " Error: " + (BluetoothError)ret);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Info(Globals.LogTag, "Failed to get Service Data List, Error - " + (BluetoothError)ret);
+                serviceCount = 0;
+                Marshal.FreeHGlobal(serviceListArray);
+                Marshal.FreeHGlobal(scanDataStruct.AdvData);
+                Marshal.FreeHGlobal(scanDataStruct.ScanData);
+                return null;
+            }
+
+            BluetoothLeServiceDataStruct[] svcList = new BluetoothLeServiceDataStruct[_serviceListCount];
+            int sizePointerToABC = Marshal.SizeOf(new BluetoothLeServiceDataStruct());
+            for (int i = 0; i < _serviceListCount; i++)
+            {
+                svcList[i] = (BluetoothLeServiceDataStruct)Marshal.PtrToStructure(new IntPtr(serviceListArray.ToInt32() + (i * sizePointerToABC)), typeof(BluetoothLeServiceDataStruct));
+                Log.Info(Globals.LogTag, " Uuid : " + svcList[i].ServiceUuid + "length :  " + svcList[i].ServiceDataLength);
+
+                _list.Add(BluetoothUtils.ConvertStructToLeServiceData(svcList[i]));
+            }
+
+            serviceCount = _serviceListCount;
+
+            Interop.Libc.Free(serviceListArray);
+            Marshal.FreeHGlobal(scanDataStruct.AdvData);
+            Marshal.FreeHGlobal(scanDataStruct.ScanData);
+            return _list;
+        }
+
+        internal int FreeServiceDataList()
+        {
+            if (_list.Count > 0)
+            {
+                int iServiceDataSize = Marshal.SizeOf(typeof(BluetoothLeServiceData));
+                IntPtr structServiceData = Marshal.AllocHGlobal(iServiceDataSize);
+                Marshal.StructureToPtr(_list, structServiceData, false);
+
+                int ret = Interop.Bluetooth.FreeServiceDataList(structServiceData, _serviceListCount);
+                if (ret != (int)BluetoothError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to free Service Data List, Error - " + (BluetoothError)ret);
+                    BluetoothErrorFactory.ThrowBluetoothException(ret);
+                }
+
+                Marshal.FreeHGlobal(structServiceData);
+            }
+            return 0;
+        }
+
+        internal int GetScanResultAppearance(BluetoothLeScanData scanData, BluetoothLePacketType packetType)
+        {
+            int appearance;
+
+            BluetoothLeScanDataStruct scanDataStruct = BluetoothUtils.ConvertLeScanDataToStruct (scanData);
+
+            int ret = Interop.Bluetooth.GetScanResultAppearance(ref scanDataStruct, packetType, out appearance);
+            if (ret != (int)BluetoothError.None) {
+                Log.Error(Globals.LogTag, "Failed to get Appearance value- " + (BluetoothError)ret);
+            }
+            return appearance;
+        }
+
+        internal ManufacturerData GetScanResultManufacturerData(BluetoothLeScanData scanData, BluetoothLePacketType packetType)
+        {
+            int dataId = 0;
+            int dataLength = 0;
+            IntPtr manufData;
+
+            BluetoothLeScanDataStruct scanDataStruct = BluetoothUtils.ConvertLeScanDataToStruct (scanData);
+            ManufacturerData data = new ManufacturerData();
+
+            int ret = Interop.Bluetooth.GetScanResultManufacturerData(ref scanDataStruct, packetType, out dataId,
+                out manufData, out dataLength);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to get Manufacturer data - " + (BluetoothError)ret);
+                return null;
+            }
+
+            data.Id = dataId;
+            data.DataLength = dataLength;
+            if (data.DataLength > 0)
+            {
+                data.Data = new byte[data.DataLength];
+                Marshal.Copy(manufData, data.Data, 0, data.DataLength);
+            }
+
+            return data;
+        }
+
+        internal int GattConnect(string remoteAddress, bool autoConnect)
+        {
+            int ret = Interop.Bluetooth.GattConnect (remoteAddress, autoConnect);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to establish GATT connection - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+            return ret;
+        }
+
+        internal int GattDisconnect(string remoteAddress)
+        {
+            int ret = Interop.Bluetooth.GattDisconnect (remoteAddress);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to disconnect GATT connection - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+            return ret;
+        }
+
+        internal int CreateAdvertiser(out IntPtr advertiserHandle)
+        {
+            return Interop.Bluetooth.CreateAdvertiser (out advertiserHandle);
+        }
+
+        internal int DestroyAdvertiser(IntPtr advertiserHandle)
+        {
+            int ret =  Interop.Bluetooth.DestroyAdvertiser (advertiserHandle);
+            if (ret != (int)BluetoothError.None) {
+                Log.Error(Globals.LogTag, "Failed to destroy the Advertiser- " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+            return ret;
+        }
+
+        internal int StartAdvertising(IntPtr advertisingHandle)
+        {
+            _advertisingStateChangedCallback = (int result, IntPtr advertiserHandle,
+                            BluetoothLeAdvertisingState state, IntPtr userData) =>
+            {
+                Log.Info(Globals.LogTag, "Setting advertising state changed callback !! " );
+                AdvertisingStateChangedEventArgs e = new AdvertisingStateChangedEventArgs(result, advertiserHandle, state);
+                _advertisingStateChanged(null, e);
+            };
+
+            IntPtr uData = IntPtr.Zero;
+            int ret = Interop.Bluetooth.BluetoothLeStartAdvertising (advertisingHandle,
+                                   _advertisingStateChangedCallback, uData );
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to start BLE advertising - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+            return ret;
+        }
+
+
+        internal int StopAdvertising(IntPtr advertisingHandle)
+        {
+            return Interop.Bluetooth.BluetoothLeStopAdvertising (advertisingHandle);
+        }
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothProfile.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothProfile.cs
new file mode 100644 (file)
index 0000000..6be950a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Network.Bluetooth
+{
+    /// <summary>
+    /// This generic class represents all Bluetooth profiles.<br>
+    /// Any common properties/functions can be added in this class in future.
+    /// </summary>
+    /// <privilege> http://tizen.org/privilege/bluetooth </privilege>
+    public abstract class BluetoothProfile
+    {
+        internal string RemoteAddress { get; set; }
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothServerSocket.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothServerSocket.cs
new file mode 100644 (file)
index 0000000..3d4509b
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Bluetooth
+{
+    /// <summary>
+    /// The BluetoothSocket provides functions for managing connections to other devices and exchanging data.
+    /// </summary>
+    public class BluetoothServerSocket : IDisposable
+    {
+        private event EventHandler<AcceptStateChangedEventArgs> _acceptStateChanged;
+        private Interop.Bluetooth.SocketConnectionStateChangedCallback _connectionStateChangedCallback;
+        internal int socketFd;
+        private bool disposed = false;
+
+        /// <summary>
+        /// The AcceptStateChanged event is raised when the socket connection state is changed.
+        /// </summary>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when the register accpet state changed callback fails.</exception>
+        public event EventHandler<AcceptStateChangedEventArgs> AcceptStateChanged
+        {
+            add
+            {
+                if (_acceptStateChanged == null)
+                {
+                    RegisterAcceptStateChangedEvent();
+                }
+                _acceptStateChanged += value;
+            }
+            remove
+            {
+                _acceptStateChanged -= value;
+                if (_acceptStateChanged == null)
+                {
+                    UnregisterAcceptStateChangedEvent();
+                }
+            }
+        }
+
+        private void RegisterAcceptStateChangedEvent()
+        {
+            _connectionStateChangedCallback = (int result, BluetoothSocketState connectionState, ref SocketConnectionStruct socketConnection, IntPtr userData) =>
+            {
+                Log.Info(Globals.LogTag, "AcceptStateChanged cb is called");
+                if (_acceptStateChanged != null)
+                {
+                    BluetoothSocket socket = new BluetoothSocket();
+                    socket.connectedSocket = socketConnection.SocketFd;
+                    GCHandle handle2 = (GCHandle) userData;
+                    _acceptStateChanged(handle2.Target as BluetoothServerSocket, new AcceptStateChangedEventArgs((BluetoothError)result, connectionState, BluetoothUtils.ConvertStructToSocketConnection(socketConnection), socket));
+                }
+            };
+            GCHandle handle1 = GCHandle.Alloc(this);
+            IntPtr data = (IntPtr) handle1;
+            int ret = Interop.Bluetooth.SetConnectionStateChangedCallback(_connectionStateChangedCallback, data);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set accept state changed callback, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        private void UnregisterAcceptStateChangedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetSocketConnectionStateChangedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset accept state changed callback, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        internal BluetoothServerSocket(int socketFd)
+        {
+            Log.Info (Globals.LogTag, "Constructing server socket");
+            this.socketFd = socketFd;
+        }
+
+        /// <summary>
+        /// Starts listening on the passed RFCOMM socket and accepts connection requests.
+        /// </summary>
+        /// <remarks>
+        /// The socket must be created with CreateServerSocket(). This API invokes the ConnectionStateChanged event.
+        /// </remarks>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when the listen on socket procedure fails.</exception>
+        public void Listen()
+        {
+            int ret = Interop.Bluetooth.Listen(socketFd, 1);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to accept connection, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        ~BluetoothServerSocket()
+        {
+            Dispose(false);
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            if (disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects.
+            }
+            //Free unmanaged objects
+            RemoveRegisteredEvents();
+            disposed = true;
+        }
+
+        private void RemoveRegisteredEvents()
+        {
+            //unregister all remaining events when this object is released.
+            if (_acceptStateChanged != null)
+            {
+                UnregisterAcceptStateChangedEvent();
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothSocket.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothSocket.cs
new file mode 100644 (file)
index 0000000..5639cc2
--- /dev/null
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Bluetooth
+{
+    /// <summary>
+    /// The IBluetoothServerSocket interface handles the server socket operations.
+    /// </summary>
+    public interface IBluetoothServerSocket
+    {
+        event EventHandler<SocketDataReceivedEventArgs> DataReceived;
+        event EventHandler<SocketConnectionStateChangedEventArgs> ConnectionStateChanged;
+        int SendData(string data);
+    }
+
+    /// <summary>
+    /// The IBluetoothClientSocket interface handles the client socket operations.
+    /// </summary>
+    public interface IBluetoothClientSocket : IBluetoothServerSocket
+    {
+        void Connect();
+        void Disconnect();
+    }
+
+    internal class BluetoothSocket : IBluetoothClientSocket, IDisposable
+    {
+        private event EventHandler<SocketDataReceivedEventArgs> _dataReceived;
+        private event EventHandler<SocketConnectionStateChangedEventArgs> _connectionStateChanged;
+        private Interop.Bluetooth.DataReceivedCallback _dataReceivedCallback;
+        private Interop.Bluetooth.SocketConnectionStateChangedCallback _connectionStateChangedCallback;
+        private bool disposed = false;
+        internal int connectedSocket;
+        internal string remoteAddress;
+        internal string serviceUuid;
+
+        /// <summary>
+        /// This event occurs when the socket server receives data from the client.
+        /// </summary>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when the register data received callback fails.</exception>
+        public event EventHandler<SocketDataReceivedEventArgs> DataReceived
+        {
+            add
+            {
+                if (_dataReceived == null)
+                {
+                    RegisterDataReceivedEvent();
+                }
+                _dataReceived += value;
+            }
+            remove
+            {
+                _dataReceived -= value;
+                if (_dataReceived == null)
+                {
+                    UnregisterDataReceivedEvent();
+                }
+            }
+        }
+
+        /// <summary>
+        /// This event occurs when the connection state between two devices is changed.
+        /// </summary>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when the register connection changed callback fails.</exception>
+        public event EventHandler<SocketConnectionStateChangedEventArgs> ConnectionStateChanged
+        {
+            add
+            {
+                if (_connectionStateChanged == null)
+                {
+                    RegisterConnectionStateChangedEvent();
+                }
+                _connectionStateChanged += value;
+            }
+            remove
+            {
+                _connectionStateChanged -= value;
+                if (_connectionStateChanged == null)
+                {
+                    UnregisterConnectionStateChangedEvent();
+                }
+            }
+        }
+
+        private void RegisterDataReceivedEvent()
+        {
+            _dataReceivedCallback = (ref SocketDataStruct socketData, IntPtr userData) =>
+            {
+                Log.Info(Globals.LogTag, "DataReceivedCallback is called");
+                if (_dataReceived != null)
+                {
+                    GCHandle handle2 = (GCHandle) userData;
+                    _dataReceived(handle2.Target as IBluetoothServerSocket, new SocketDataReceivedEventArgs(BluetoothUtils.ConvertStructToSocketData(socketData)));
+                }
+            };
+            GCHandle handle1 = GCHandle.Alloc (this);
+            IntPtr uData = (IntPtr) handle1;
+            int ret = Interop.Bluetooth.SetDataReceivedCallback(_dataReceivedCallback, uData);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set data received callback, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        private void UnregisterDataReceivedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetDataReceivedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset data received callback, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        private void RegisterConnectionStateChangedEvent()
+        {
+            _connectionStateChangedCallback = (int result, BluetoothSocketState connectionState, ref SocketConnectionStruct socketConnection, IntPtr userData) =>
+            {
+                Log.Info(Globals.LogTag, "ConnectionStateChangedCallback is called");
+                if (_connectionStateChanged != null)
+                {
+                    connectedSocket = socketConnection.SocketFd;
+                    GCHandle handle2 = (GCHandle) userData;
+                    _connectionStateChanged(handle2.Target as IBluetoothServerSocket, new SocketConnectionStateChangedEventArgs((BluetoothError)result, connectionState, BluetoothUtils.ConvertStructToSocketConnection(socketConnection)));
+                }
+            };
+            GCHandle handle1 = GCHandle.Alloc(this);
+            IntPtr data = (IntPtr) handle1;
+            int ret = Interop.Bluetooth.SetConnectionStateChangedCallback(_connectionStateChangedCallback, data);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set connection state changed callback, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        private void UnregisterConnectionStateChangedEvent()
+        {
+            int ret = Interop.Bluetooth.UnsetSocketConnectionStateChangedCallback();
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset connection state changed callback, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Connects to a specific RFCOMM based service on a remote Bluetooth device UUID.
+        /// </summary>
+        /// <remarks>
+        /// The bluetooth must be enabled, discoverable with StartDiscovery(), and bonded with the remote device using CreateBond(). The ConnectionStateChanged event is raised once this API is called.
+        /// </remarks>
+        /// <param name="address">The address of the remote Bluetooth device.</param>
+        /// <param name="serviceUuid">The UUID of the service provided by the remote Bluetooth device.</param>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when the connect socket attempt to remote device fails, or when the service UUID is not supported by the remote device.</exception>
+        void IBluetoothClientSocket.Connect()
+        {
+            int ret = Interop.Bluetooth.ConnectSocket(remoteAddress, serviceUuid);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to connect to socket, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Disconnects the RFCOMM connection with the given file descriptor of the conneted socket.
+        /// </summary>
+        /// <remarks>
+        /// The connection must be established.
+        /// </remarks>
+        /// <param name="socketFd">The file descriptor of the socket to close.</param>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when the socket disconnect to remote device fails.</exception>
+        void IBluetoothClientSocket.Disconnect()
+        {
+            int ret = Interop.Bluetooth.DisconnectSocket(connectedSocket);
+            if (ret != (int)BluetoothError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to disconnect socket, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Sends data to the connected device.
+        /// </summary>
+        /// <returns>The number of bytes written (zero indicates nothing was written).</returns>
+        /// <remarks>
+        /// The connection must be established.
+        /// </remarks>
+        /// <param name="socketFd">The file descriptor of the connected socket.</param>
+        /// <param name="data">The data to be sent.</param>
+        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// or when the remote device is not connected, or the send data procedure fails.</exception>
+        public int SendData(string data)
+        {
+            int ret = Interop.Bluetooth.SendData(connectedSocket, data, data.Length);
+            if (ret < 0)
+            {
+                Log.Error(Globals.LogTag, "Failed to send data, Error - " + (BluetoothError)ret);
+                BluetoothErrorFactory.ThrowBluetoothException(ret);
+            }
+            return ret;
+        }
+
+        ~BluetoothSocket()
+        {
+            Dispose(false);
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            if (disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects.
+            }
+            //Free unmanaged objects
+            RemoveRegisteredEvents();
+            disposed = true;
+        }
+
+        private void RemoveRegisteredEvents()
+        {
+            //unregister all remaining events when this object is released.
+            if (_dataReceived != null)
+            {
+                UnregisterDataReceivedEvent();
+            }
+            if (_connectionStateChanged != null)
+            {
+                UnregisterConnectionStateChangedEvent();
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothStructs.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothStructs.cs
new file mode 100644 (file)
index 0000000..dcd53a2
--- /dev/null
@@ -0,0 +1,390 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Reflection;
+using System.Linq;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Bluetooth
+{
+    /// <summary>
+    /// The structure of the device class type and service.
+    /// </summary>
+    [StructLayout(LayoutKind.Sequential)]
+    internal struct BluetoothClassStruct
+    {
+        /// <summary>
+        /// The type of the major device class.
+        /// </summary>
+        internal BluetoothMajorDeviceClassType MajorDeviceClassType;
+        /// <summary>
+        /// The type of the minor device class.
+        /// </summary>
+        internal BluetoothMinorDeviceClassType MinorDeviceClassType;
+        /// <summary>
+        /// The major service class mask.
+        /// </summary>
+        internal int MajorServiceClassMask;
+    }
+
+    /// <summary>
+    /// This structure contains the information of the Bluetooth device.
+    /// </summary>
+    [StructLayout(LayoutKind.Sequential)]
+    internal struct BluetoothDeviceStruct
+    {
+        /// <summary>
+        /// The address of the device.
+        /// </summary>
+        [MarshalAsAttribute(UnmanagedType.LPStr)]
+        internal string Address;
+
+        /// <summary>
+        /// The name of the device.
+        /// </summary>
+        [MarshalAsAttribute(UnmanagedType.LPStr)]
+        internal string Name;
+
+        /// <summary>
+        /// The class of the device.
+        /// </summary>
+        internal BluetoothClassStruct Class;
+
+        /// <summary>
+        /// The service UUID list of the device.
+        /// </summary>
+        internal IntPtr ServiceUuidList;
+
+        /// <summary>
+        /// The service count of the device.
+        /// </summary>
+        internal int ServiceCount;
+
+        /// <summary>
+        /// The paired state of the device.
+        /// </summary>
+        [MarshalAsAttribute(UnmanagedType.I1)]
+        internal bool IsPaired;
+
+        /// <summary>
+        /// The connection state of the device.
+        /// </summary>
+        [MarshalAsAttribute(UnmanagedType.I1)]
+        internal bool IsConnected;
+
+        /// <summary>
+        /// The authorization state of the device.
+        /// </summary>
+        [MarshalAsAttribute(UnmanagedType.I1)]
+        internal bool IsAuthorized;
+
+        /// <summary>
+        /// The length of the manufacturer the data.
+        /// </summary>
+        internal int ManufacturerDataLength;
+
+        /// <summary>
+        /// The manufacturer data.
+        /// </summary>
+        [MarshalAsAttribute(UnmanagedType.LPStr)]
+        internal string ManufacturerData;
+    }
+
+    [StructLayout(LayoutKind.Sequential)]
+    internal struct BluetoothDiscoveredDeviceStruct
+    {
+        [MarshalAsAttribute(UnmanagedType.LPStr)]
+        internal string Address;
+
+        [MarshalAsAttribute(UnmanagedType.LPStr)]
+        internal string Name;
+
+        internal BluetoothClassStruct Class;
+
+        internal int Rssi;
+
+        [MarshalAsAttribute(UnmanagedType.I1)]
+        internal bool IsPaired;
+
+        internal IntPtr ServiceUuidList;
+
+        internal int ServiceCount;
+
+        internal BluetoothAppearanceType AppearanceType;
+
+        internal int ManufacturerDataLength;
+
+        [MarshalAsAttribute(UnmanagedType.LPStr)]
+        internal string ManufacturerData;
+    }
+
+    internal struct BluetoothDeviceSdpStruct
+    {
+        [MarshalAsAttribute(UnmanagedType.LPStr)]
+        internal string DeviceAddress;
+        internal IntPtr ServiceUuid;
+        internal int ServiceCount;
+    }
+
+    internal struct BluetoothDeviceConnectionStruct
+    {
+        internal string Address;
+        internal BluetoothConnectionLinkType LinkType;
+        internal BluetoothDisconnectReason DisconnectReason;
+    }
+
+    internal struct SocketDataStruct
+    {
+        internal int SocketFd;
+        internal int DataSize;
+        internal IntPtr Data;
+    }
+
+    internal struct SocketConnectionStruct
+    {
+        internal int SocketFd;
+        internal int ServerFd;
+        internal BluetoothSocketRole LocalRole;
+        internal string Address;
+        internal string ServiceUuid;
+    }
+
+    /// </summary>
+    [StructLayout(LayoutKind.Sequential)]
+    internal struct BluetoothLeScanDataStruct
+    {
+        [MarshalAsAttribute(UnmanagedType.LPStr)]
+        internal string RemoteAddress;
+
+        internal BluetoothLeDeviceAddressType AddressType;
+
+        internal int Rssi;
+
+        internal int AdvDataLength;
+
+        internal IntPtr AdvData;
+
+        internal int ScanDataLength;
+
+        internal IntPtr ScanData;
+    }
+
+    [StructLayout(LayoutKind.Sequential)]
+    internal struct BluetoothLeServiceDataStruct
+    {
+        /// <summary>
+        /// The Bluetooth LE service UUID.
+        /// </summary>
+        [MarshalAs(UnmanagedType.LPStr)]
+        internal string ServiceUuid;
+        /// <summary>
+        /// The Bluetooth LE service data.
+        /// </summary>
+        internal IntPtr ServiceData;
+
+        internal int ServiceDataLength;
+    }
+
+    internal static class BluetoothUtils
+    {
+        internal static BluetoothDevice ConvertStructToDeviceClass(BluetoothDeviceStruct device)
+        {
+            BluetoothDevice resultDevice = new BluetoothDevice();
+            Collection<string> uuidList = null;
+
+            if (device.ServiceCount > 0)
+            {
+                IntPtr[] extensionList = new IntPtr[device.ServiceCount];
+                Marshal.Copy (device.ServiceUuidList, extensionList, 0, device.ServiceCount);
+                uuidList = new Collection<string> ();
+                foreach (IntPtr extension in extensionList) {
+                    string uuid = Marshal.PtrToStringAnsi (extension);
+                    uuidList.Add (uuid);
+                }
+            }
+
+            resultDevice.RemoteDeviceAddress = device.Address;
+            resultDevice.RemoteDeviceName = device.Name;
+            resultDevice.RemoteDeviceClass = new BluetoothClass();
+            resultDevice.Class.MajorType = device.Class.MajorDeviceClassType;
+            resultDevice.Class.MinorType = device.Class.MinorDeviceClassType;
+            resultDevice.Class.Mask = device.Class.MajorServiceClassMask;
+            resultDevice.RemotePaired = device.IsPaired;
+            resultDevice.RemoteConnected = device.IsConnected;
+            resultDevice.RemoteAuthorized = device.IsAuthorized;
+            resultDevice.RemoteDeviceService = uuidList;
+            resultDevice.RemoteDeviceCount = device.ServiceCount;
+            resultDevice.RemoteManufLength = device.ManufacturerDataLength;
+            resultDevice.RemoteManufData = device.ManufacturerData;
+
+            return resultDevice;
+        }
+
+        internal static BluetoothDevice ConvertStructToDiscoveredDevice(BluetoothDiscoveredDeviceStruct structDevice)
+        {
+            BluetoothDevice resultDevice = new BluetoothDevice();
+            Collection<string> uuidList = null;
+
+            if (structDevice.ServiceCount > 0) {
+                IntPtr[] extensionList = new IntPtr[structDevice.ServiceCount];
+                Marshal.Copy (structDevice.ServiceUuidList, extensionList, 0, structDevice.ServiceCount);
+                uuidList = new Collection<string> ();
+                foreach (IntPtr extension in extensionList) {
+                    string uuid = Marshal.PtrToStringAnsi (extension);
+                    uuidList.Add (uuid);
+                }
+            }
+
+            resultDevice.RemoteDeviceAddress = structDevice.Address;
+            resultDevice.RemoteDeviceName = structDevice.Name;
+
+            resultDevice.RemoteDeviceClass = new BluetoothClass();
+            resultDevice.Class.MajorType = structDevice.Class.MajorDeviceClassType;
+            resultDevice.Class.MinorType = structDevice.Class.MinorDeviceClassType;
+            resultDevice.Class.Mask = structDevice.Class.MajorServiceClassMask;
+
+            resultDevice.RemoteDeviceRssi = structDevice.Rssi;
+            resultDevice.RemoteAppearance = structDevice.AppearanceType;
+
+            if (structDevice.ServiceCount > 0) {
+                resultDevice.RemoteDeviceService = uuidList;
+                resultDevice.RemoteDeviceCount = structDevice.ServiceCount;
+            }
+
+            resultDevice.RemotePaired = structDevice.IsPaired;
+            resultDevice.RemoteManufData = structDevice.ManufacturerData;
+            resultDevice.RemoteManufLength = structDevice.ManufacturerDataLength;
+            return resultDevice;
+        }
+
+        internal static BluetoothDeviceSdpData ConvertStructToSdpData(BluetoothDeviceSdpStruct structData)
+        {
+            BluetoothDeviceSdpData resultData = new BluetoothDeviceSdpData();
+            Collection<string> uuidList = null;
+
+            if (structData.ServiceCount > 0) {
+                IntPtr[] extensionList = new IntPtr[structData.ServiceCount];
+                Marshal.Copy (structData.ServiceUuid, extensionList, 0, structData.ServiceCount);
+                uuidList = new Collection<string> ();
+                foreach (IntPtr extension in extensionList) {
+                    string uuid = Marshal.PtrToStringAnsi (extension);
+                    uuidList.Add (uuid);
+                }
+            }
+
+            resultData.Uuid = uuidList;
+            resultData.Address = structData.DeviceAddress;
+
+            return resultData;
+        }
+
+        internal static BluetoothDeviceConnectionData ConvertStructToConnectionData(BluetoothDeviceConnectionStruct structInfo)
+        {
+            BluetoothDeviceConnectionData resultData = new BluetoothDeviceConnectionData();
+            resultData.RemoteAddress = structInfo.Address;
+            resultData.Link = structInfo.LinkType;
+            resultData.Reason = structInfo.DisconnectReason;
+            return resultData;
+        }
+
+        internal static BluetoothLeScanData ConvertStructToLeScanData(BluetoothLeScanDataStruct structScanData)
+        {
+            BluetoothLeScanData scanData = new BluetoothLeScanData();
+
+            scanData.RemoteAddress = structScanData.RemoteAddress;
+            scanData.AddressType = structScanData.AddressType;
+            scanData.Rssi = structScanData.Rssi;
+
+            if (structScanData.AdvDataLength > 0)
+            {
+                scanData.AdvDataLength = structScanData.AdvDataLength;
+                scanData.AdvData = new byte[scanData.AdvDataLength];
+                Marshal.Copy (structScanData.AdvData, scanData.AdvData, 0, scanData.AdvDataLength);
+            }
+
+            if (structScanData.ScanDataLength > 0)
+            {
+                scanData.ScanDataLength = structScanData.ScanDataLength;
+                scanData.ScanData = new byte[scanData.ScanDataLength];
+                Marshal.Copy (structScanData.ScanData, scanData.ScanData, 0, scanData.ScanDataLength);
+            }
+            return scanData;
+        }
+
+        internal static BluetoothLeScanDataStruct ConvertLeScanDataToStruct(BluetoothLeScanData scanData)
+        {
+            BluetoothLeScanDataStruct scanDataStruct = new BluetoothLeScanDataStruct();
+
+            scanDataStruct.RemoteAddress = scanData.RemoteAddress;
+            scanDataStruct.AddressType = scanData.AddressType;
+            scanDataStruct.Rssi = scanData.Rssi;
+
+            if (scanData.AdvDataLength > 0)
+            {
+                scanDataStruct.AdvDataLength = scanData.AdvDataLength;
+                scanDataStruct.AdvData = Marshal.AllocHGlobal(scanData.AdvDataLength);
+                Marshal.Copy (scanData.AdvData, 0, scanDataStruct.AdvData, scanData.AdvDataLength);
+            }
+
+            if (scanData.ScanDataLength > 0)
+            {
+                scanDataStruct.ScanDataLength = scanData.ScanDataLength;
+                scanDataStruct.ScanData = Marshal.AllocHGlobal(scanData.ScanDataLength);
+                Marshal.Copy (scanData.ScanData, 0, scanDataStruct.ScanData, scanData.ScanDataLength);
+            }
+
+            return scanDataStruct;
+        }
+
+        internal static BluetoothLeServiceData ConvertStructToLeServiceData(BluetoothLeServiceDataStruct structServiceData)
+        {
+            BluetoothLeServiceData serviceData = new BluetoothLeServiceData();
+            Log.Info(Globals.LogTag, "ServiceDataLength" + structServiceData.ServiceDataLength);
+
+            if (structServiceData.ServiceDataLength > 0)
+            {
+                serviceData.Uuid = structServiceData.ServiceUuid;
+                serviceData.Length = structServiceData.ServiceDataLength;
+                serviceData.Data = new byte[serviceData.Length];
+                Marshal.Copy(structServiceData.ServiceData, serviceData.Data, 0, serviceData.Length);
+            }
+            return serviceData;
+        }
+
+        internal static SocketData ConvertStructToSocketData(SocketDataStruct structInfo)
+        {
+            SocketData data = new SocketData();
+            data.Fd = structInfo.SocketFd;
+            data.Size = structInfo.DataSize;
+            data.RecvData = Marshal.PtrToStringAnsi(structInfo.Data);
+            return data;
+        }
+
+        internal static SocketConnection ConvertStructToSocketConnection(SocketConnectionStruct structInfo)
+        {
+            SocketConnection connectionInfo = new SocketConnection();
+            connectionInfo.Fd = structInfo.SocketFd;
+            connectionInfo.RemoteAddress = structInfo.Address;
+            connectionInfo.Uuid = structInfo.ServiceUuid;
+            return connectionInfo;
+        }
+    }
+}
+
diff --git a/src/Tizen.Network.Connection/Interop/Interop.Connection.cs b/src/Tizen.Network.Connection/Interop/Interop.Connection.cs
new file mode 100755 (executable)
index 0000000..89011c8
--- /dev/null
@@ -0,0 +1,337 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Network.Connection;
+
+internal static partial class Interop
+{
+    internal static partial class Connection
+    {
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate void ConnectionTypeChangedCallback(ConnectionType type, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate void EthernetCableStateChangedCallback(EthernetCableState state, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate void ConnectionAddressChangedCallback(IntPtr ipv4, IntPtr ipv6, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate void ConnectionCallback(ConnectionError result, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate bool IPv6AddressCallback(IntPtr ipv6, IntPtr userData);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_create")]
+        public static extern int Create(out IntPtr handle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_destroy")]
+        public static extern int Destroy(IntPtr handle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_get_type")]
+        public static extern int GetType(IntPtr handle, out int type);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_get_ip_address")]
+        public static extern int GetIPAddress(IntPtr handle, int family, out IntPtr address);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_foreach_ipv6_address")]
+        public static extern int GetAllIPv6Addresses(IntPtr handle, int type, IPv6AddressCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_get_proxy")]
+        public static extern int GetProxy(IntPtr handle, int family, out IntPtr address);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_get_mac_address")]
+        public static extern int GetMacAddress(IntPtr handle, int family, out IntPtr address);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_get_wifi_state")]
+        public static extern int GetWiFiState(IntPtr handle, out int state);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_get_cellular_state")]
+        public static extern int GetCellularState(IntPtr handle, out int state);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_get_ethernet_state")]
+        public static extern int GetEthernetState(IntPtr handle, out int state);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_get_ethernet_cable_state")]
+        public static extern int GetEthernetCableState(IntPtr handle, out int state);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_get_bt_state")]
+        public static extern int GetBtState(IntPtr handle, out int state);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_get_statistics")]
+        public static extern int GetStatistics(IntPtr handle, int connectionType, int statisticsType, out long size);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_reset_statistics")]
+        public static extern int ResetStatistics(IntPtr handle, int connectionType, int statisticsType);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_add_route_entry")]
+        public static extern int AddRoute(IntPtr handle, AddressFamily family, string interfaceName, string address, string gateway);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_remove_route_entry")]
+        public static extern int RemoveRoute(IntPtr handle, AddressFamily family, string interfaceName, string address, string gateway);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_set_type_changed_cb")]
+        public static extern int SetTypeChangedCallback(IntPtr handle, ConnectionTypeChangedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_set_ip_address_changed_cb")]
+        public static extern int SetIPAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_set_ethernet_cable_state_chaged_cb")]
+        public static extern int SetEthernetCableStateChagedCallback(IntPtr handle, EthernetCableStateChangedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_set_proxy_address_changed_cb")]
+        public static extern int SetProxyAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_unset_type_changed_cb")]
+        public static extern int UnsetTypeChangedCallback(IntPtr handle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ip_address_changed_cb")]
+        public static extern int UnsetIPAddressChangedCallback(IntPtr handle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ethernet_cable_state_chaged_cb")]
+        public static extern int UnsetEthernetCableStateChagedCallback(IntPtr handle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_unset_proxy_address_changed_cb")]
+        public static extern int UnsetProxyAddressChangedCallback(IntPtr handle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_add_profile")]
+        public static extern int AddProfile(IntPtr handle, IntPtr profileHandle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_remove_profile")]
+        public static extern int RemoveProfile(IntPtr handle, IntPtr profileHandle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_update_profile")]
+        public static extern int UpdateProfile(IntPtr handle, IntPtr profileHandle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_get_default_cellular_service_profile")]
+        public static extern int GetDefaultCellularServiceProfile(IntPtr handle, int type, out IntPtr profileHandle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_get_current_profile")]
+        public static extern int GetCurrentProfile(IntPtr handle, out IntPtr profileHandle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_open_profile")]
+        public static extern int OpenProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_close_profile")]
+        public static extern int CloseProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_reset_profile")]
+        public static extern int ResetProfile(IntPtr handle, int Option, int Id, ConnectionCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_set_default_cellular_service_profile_async")]
+        public static extern int SetDefaultCellularServiceProfileAsync(IntPtr handle, int Type, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_get_profile_iterator")]
+        public static extern int GetProfileIterator(IntPtr handle, int type, out IntPtr iterHandle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_next")]
+        public static extern int GetNextProfileIterator(IntPtr iterHandle, out IntPtr profileHandle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_has_next")]
+        public static extern bool HasNextProfileIterator(IntPtr iterHandle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_destroy_profile_iterator")]
+        public static extern int DestroyProfileIterator(IntPtr iterHandle);
+    }
+
+    internal static partial class ConnectionProfile
+    {
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate void ProfileStateChangedCallback(ProfileState type, IntPtr userData);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_create")]
+        public static extern int Create(int ProfileType, string Keyword, out IntPtr profileHandle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_clone")]
+        public static extern int Clone(out IntPtr cloneHandle, IntPtr profileHandle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_destroy")]
+        public static extern int Destroy(IntPtr profileHandle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_id")]
+        public static extern int GetId(IntPtr profileHandle, out IntPtr profileId);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_name")]
+        public static extern int GetName(IntPtr profileHandle, out IntPtr name);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_type")]
+        public static extern int GetType(IntPtr profileHandle, out int type);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_network_interface_name")]
+        public static extern int GetNetworkInterfaceName(IntPtr profileHandle, out IntPtr interfaceName);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_state")]
+        public static extern int GetState(IntPtr profileHandle, out int type);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ipv6_state")]
+        public static extern int GetIPv6State(IntPtr profileHandle, out int type);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_config_type")]
+        public static extern int GetIPConfigType(IntPtr profileHandle, int family, out int type);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_type")]
+        public static extern int GetProxyType(IntPtr profileHandle, out int type);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_address")]
+        public static extern int GetIPAddress(IntPtr profileHandle, int family, out IntPtr address);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_subnet_mask")]
+        public static extern int GetSubnetMask(IntPtr profileHandle, int family, out IntPtr address);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_gateway_address")]
+        public static extern int GetGatewayAddress(IntPtr profileHandle, int family, out IntPtr address);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_dns_address")]
+        public static extern int GetDnsAddress(IntPtr profileHandle, int order, int Family, out IntPtr address);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_address")]
+        public static extern int GetProxyAddress(IntPtr profileHandle, int family, out IntPtr address);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_prefix_length")]
+        public static extern int GetPrefixLength(IntPtr profileHandle, int family, out int length);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_dns_config_type")]
+        public static extern int GetDnsConfigType(IntPtr profileHandle, int family, out int type);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_dhcp_server_address")]
+        public static extern int GetDhcpServerAddress(IntPtr profileHandle, AddressFamily family, out string dhcpServerAddress);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_refresh")]
+        public static extern int Refresh(IntPtr profileHandle);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_config_type")]
+        public static extern int SetIPConfigType(IntPtr profileHandle, int family, int type);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_type")]
+        public static extern int SetProxyType(IntPtr profileHandle, int type);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_address")]
+        public static extern int SetIPAddress(IntPtr profileHandle, int family, string address);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_subnet_mask")]
+        public static extern int SetSubnetMask(IntPtr profileHandle, int family, string address);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_gateway_address")]
+        public static extern int SetGatewayAddress(IntPtr profileHandle, int family, string address);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_dns_address")]
+        public static extern int SetDnsAddress(IntPtr profileHandle, int order, int family, string address);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_address")]
+        public static extern int SetProxyAddress(IntPtr profileHandle, int family, string address);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_prefix_length")]
+        public static extern int SetPrefixLength(IntPtr profileHandle, int family, int length);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_dns_config_type")]
+        public static extern int SetDnsConfigType(IntPtr profileHandle, int family, int type);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_state_changed_cb")]
+        public static extern int SetStateChangeCallback(IntPtr profileHandle, ProfileStateChangedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_unset_state_changed_cb")]
+        public static extern int UnsetStateChangeCallback(IntPtr profileHandle);
+    }
+
+    internal static partial class ConnectionCellularProfile
+    {
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_service_type")]
+        public static extern int GetServiceType(IntPtr profileHandle, out int type);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_apn")]
+        public static extern int GetApn(IntPtr profileHandle, out IntPtr apn);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_auth_info")]
+        public static extern int GetAuthInfo(IntPtr profileHandle, out int authType, out string name, out string password);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_home_url")]
+        public static extern int GetHomeUrl(IntPtr profileHandle, out IntPtr homeUrl);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_pdn_type")]
+        public static extern int GetPdnType(IntPtr profileHandle, out int pdnType);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_roam_pdn_type")]
+        public static extern int GetRoamingPdnType(IntPtr profileHandle, out int roamPdnType);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_roaming")]
+        public static extern int IsRoaming(IntPtr profileHandle, out bool roaming);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_hidden")]
+        public static extern int IsHidden(IntPtr profileHandle, out bool hidden);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_editable")]
+        public static extern int IsEditable(IntPtr profileHandle, out bool editable);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_default")]
+        public static extern int IsDefault(IntPtr profileHandle, out bool isDefault);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_service_type")]
+        public static extern int SetServiceType(IntPtr profileHandle, int type);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_apn")]
+        public static extern int SetApn(IntPtr profileHandle, string apn);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_auth_info")]
+        public static extern int SetAuthInfo(IntPtr profileHandle, int authType, string name, string password);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_home_url")]
+        public static extern int SetHomeUrl(IntPtr profileHandle, string homeUrl);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_pdn_type")]
+        public static extern int SetPdnType(IntPtr profileHandle, int pdnType);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_roam_pdn_type")]
+        public static extern int SetRoamingPdnType(IntPtr profileHandle, int roamPdnType);
+    }
+
+    internal static partial class ConnectionWiFiProfile
+    {
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_essid")]
+        public static extern int GetEssid(IntPtr profileHandle, out IntPtr essid);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_bssid")]
+        public static extern int GetBssid(IntPtr profileHandle, out IntPtr bssid);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_rssi")]
+        public static extern int GetRssi(IntPtr profileHandle, out int rssi);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_frequency")]
+        public static extern int GetFrequency(IntPtr profileHandle, out int frequency);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_max_speed")]
+        public static extern int GetMaxSpeed(IntPtr profileHandle, out int maxSpeed);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_security_type")]
+        public static extern int GetSecurityType(IntPtr profileHandle, out int type);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_encryption_type")]
+        public static extern int GetEncryptionType(IntPtr profileHandle, out int type);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_passphrase_required")]
+        public static extern int IsRequiredPassphrase(IntPtr profileHandle, out bool required);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_wifi_passphrase")]
+        public static extern int SetPassphrase(IntPtr profileHandle, string passphrase);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_wps_supported")]
+        public static extern int IsSupportedWps(IntPtr profileHandle, out bool supported);
+    }
+       
+    internal static partial class Libc
+    {
+        [DllImport(Libraries.Libc, EntryPoint = "free")]
+        public static extern void Free(IntPtr userData);
+
+    }
+}
diff --git a/src/Tizen.Network.Connection/Interop/Interop.Libraries.cs b/src/Tizen.Network.Connection/Interop/Interop.Libraries.cs
new file mode 100644 (file)
index 0000000..03ee0cd
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string Connection = "libcapi-network-connection.so.1";
+        public const string WiFi = "libcapi-network-wifi.so.1";
+        public const string Bluetooth = "libcapi-network-bluetooth.so.0";
+        public const string Smartcard = "libcapi-network-smartcard.so.0";
+        public const string Nfc = "libcapi-network-nfc.so.0";
+        public const string WiFiDirect = "libwifi-direct.so.1";
+        public const string Glib = "libglib-2.0.so.0";
+        public const string Libc = "libc.so.6";
+    }
+}
diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection.csproj b/src/Tizen.Network.Connection/Tizen.Network.Connection.csproj
new file mode 100644 (file)
index 0000000..e7d758b
--- /dev/null
@@ -0,0 +1,25 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <Version>1.0.20</Version>
+    <Authors>Samsung Electronics</Authors>
+    <Copyright>© Samsung Electronics Co., Ltd All Rights Reserved</Copyright>
+    <Description>Provides the Connection APIs for Tizen .NET</Description>
+    <PackageProjectUrl>https://www.tizen.org/</PackageProjectUrl>
+    <PackageLicenseUrl>https://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
+    <PackageIconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</PackageIconUrl>
+  </PropertyGroup>
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.3</TargetFramework>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Network.Connection.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Tizen" Version="1.0.5" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection.snk b/src/Tizen.Network.Connection/Tizen.Network.Connection.snk
new file mode 100644 (file)
index 0000000..c2e0c4c
Binary files /dev/null and b/src/Tizen.Network.Connection/Tizen.Network.Connection.snk differ
diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs
new file mode 100755 (executable)
index 0000000..86658a2
--- /dev/null
@@ -0,0 +1,402 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Connection
+{
+    /// <summary>
+    /// This Class is CellularProfile. It provides functions to manage the cellular profile.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public class CellularProfile : ConnectionProfile
+    {
+        internal CellularProfile(IntPtr handle): base(handle)
+        {
+        }
+
+        private CellularAuthInformation _cellularAuthInfo = null;
+
+        ~CellularProfile()
+        {
+        }
+
+        /// <summary>
+        /// The APN (access point name).
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Cellular access point name.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown during set when value is null.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
+        public string Apn
+        {
+            get
+            {
+                Log.Debug(Globals.LogTag, "Get Apn");
+                IntPtr Value;
+                int ret = Interop.ConnectionCellularProfile.GetApn(ProfileHandle, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get apn, " + (ConnectionError)ret);
+                }
+                string result = Marshal.PtrToStringAnsi(Value);
+                Interop.Libc.Free(Value);
+                return result;
+            }
+
+            set
+            {
+                Log.Debug(Globals.LogTag, "Set Apn");
+                CheckDisposed();
+                if (value != null)
+                {
+                    int ret = Interop.ConnectionCellularProfile.SetApn(ProfileHandle, value);
+                    if ((ConnectionError)ret != ConnectionError.None)
+                    {
+                        Log.Error(Globals.LogTag, "It failed to set apn, " + (ConnectionError)ret);
+                        ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+                        ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                        ConnectionErrorFactory.ThrowConnectionException(ret);
+                    }
+                }
+
+                else
+                {
+                    throw new ArgumentNullException("Value of Apn is null");
+                }
+            }
+        }
+
+        /// <summary>
+        /// The home URL.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Cellular home URL.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown during set when value is null.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
+        public string HomeUri
+        {
+            get
+            {
+                Log.Debug(Globals.LogTag, "Get HomeUri");
+                IntPtr Value;
+                int ret = Interop.ConnectionCellularProfile.GetHomeUrl(ProfileHandle, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get home url, " + (ConnectionError)ret);
+                }
+                string result = Marshal.PtrToStringAnsi(Value);
+                Interop.Libc.Free(Value);
+                return result;
+            }
+
+            set
+            {
+                Log.Debug(Globals.LogTag, "Set HomeUri");
+                CheckDisposed();
+                if (value != null)
+                {
+                    int ret = Interop.ConnectionCellularProfile.SetHomeUrl(ProfileHandle, value);
+                    if ((ConnectionError)ret != ConnectionError.None)
+                    {
+                        Log.Error(Globals.LogTag, "It failed to set home url, " + (ConnectionError)ret);
+                        ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+                        ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                        ConnectionErrorFactory.ThrowConnectionException(ret);
+                    }
+                }
+
+                else
+                {
+                    throw new ArgumentNullException("Value of HomeUri is null");
+                }
+            }
+        }
+
+        /// <summary>
+        /// The service type.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Cellular service type.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
+        public CellularServiceType ServiceType
+        {
+            get
+            {
+                Log.Debug(Globals.LogTag, "Get ServiceType");
+                int value;
+                int ret = Interop.ConnectionCellularProfile.GetServiceType(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get service type, " + (ConnectionError)ret);
+                }
+                return (CellularServiceType)value;
+            }
+
+            set
+            {
+                Log.Debug(Globals.LogTag, "Set ServiceType");
+                CheckDisposed();
+                int ret = Interop.ConnectionCellularProfile.SetServiceType(ProfileHandle, (int)value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set service type, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// The cellular pdn type.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Cellular pdn type.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
+        public CellularPdnType PdnType
+        {
+            get
+            {
+                Log.Debug(Globals.LogTag, "Get PdnType");
+                int value;
+                int ret = Interop.ConnectionCellularProfile.GetPdnType(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get pdn type, " + (ConnectionError)ret);
+                }
+                return (CellularPdnType)value;
+            }
+
+            set
+            {
+                Log.Debug(Globals.LogTag, "Set PdnType");
+                CheckDisposed();
+                int ret = Interop.ConnectionCellularProfile.SetPdnType(ProfileHandle, (int)value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set pdn type, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// The cellular roaming pdn type.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Cellular roaming pdn type.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
+        public CellularPdnType RoamingPdnType
+        {
+            get
+            {
+                Log.Debug(Globals.LogTag, "Get RoamingPdnType");
+                int value;
+                int ret = Interop.ConnectionCellularProfile.GetRoamingPdnType(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get roam pdn type, " + (ConnectionError)ret);
+                }
+                return (CellularPdnType)value;
+            }
+
+            set
+            {
+                Log.Debug(Globals.LogTag, "Set RoamingPdnType");
+                CheckDisposed();
+                int ret = Interop.ConnectionCellularProfile.SetRoamingPdnType(ProfileHandle, (int)value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set roam pdn type, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Cellular Authentication Information.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Instance of CellularAuthInformation.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown during set when value is null.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
+        public CellularAuthInformation CellularAuthInfo
+        {
+            get
+            {
+                int type;
+                string name;
+                string password;
+                int ret = Interop.ConnectionCellularProfile.GetAuthInfo(ProfileHandle, out type, out name, out password);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get cellular authentication information, " + (ConnectionError)ret);
+                    return null;
+                }
+
+                if (_cellularAuthInfo == null)
+                    _cellularAuthInfo = new CellularAuthInformation();
+                _cellularAuthInfo.AuthType = (CellularAuthType)type;
+                _cellularAuthInfo.UserName = name;
+                _cellularAuthInfo.Password = password;
+                return _cellularAuthInfo;
+            }
+
+            set
+            {
+                CheckDisposed();
+                if (value != null)
+                {
+                    _cellularAuthInfo = value;
+                    int type = (int)_cellularAuthInfo.AuthType;
+                    string name = _cellularAuthInfo.UserName;
+                    string password = _cellularAuthInfo.Password;
+                    int ret = Interop.ConnectionCellularProfile.SetAuthInfo(ProfileHandle, type, name, password);
+                    if ((ConnectionError)ret != ConnectionError.None)
+                    {
+                        Log.Error(Globals.LogTag, "It failed to set auth information, " + (ConnectionError)ret);
+                        ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+                        ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                        ConnectionErrorFactory.ThrowConnectionException(ret);
+                    }
+                }
+
+                else
+                {
+                    throw new ArgumentNullException("CellularAuthInformation value is null");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Checks whether the profile is hidden.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>True if the cellular profile is hidden, otherwise false.</value>
+        public bool Hidden
+        {
+            get
+            {
+                bool value;
+                int ret = Interop.ConnectionCellularProfile.IsHidden(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get hidden value, " + (ConnectionError)ret);
+                }
+                return value;
+            }
+        }
+
+        /// <summary>
+        /// Checks whether the profile is editable.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>True if the cellular profile is editable, otherwise false.</value>
+        public bool Editable
+        {
+            get
+            {
+                bool value;
+                int ret = Interop.ConnectionCellularProfile.IsEditable(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get editable value, " + (ConnectionError)ret);
+                }
+                return value;
+            }
+        }
+
+        /// <summary>
+        /// Checks whether the profile is default.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>True if the cellular profile is default, otherwise false.</value>
+        public bool IsDefault
+        {
+            get
+            {
+                bool value;
+                int ret = Interop.ConnectionCellularProfile.IsDefault(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get IsDefault value, " + (ConnectionError)ret);
+                }
+                return value;
+            }
+        }
+    }
+
+    /// <summary>
+    /// This Class is CellularAuthInformation. It provides the properties to get and set the cellular authentication information.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public class CellularAuthInformation
+    {
+        /// <summary>
+        /// Default Constructor.Initializes an object of CellularAuthInformation.
+        /// </summary>
+        public CellularAuthInformation()
+        {
+        }
+
+        /// <summary>
+        /// The user name.
+        /// <since_tizen> 3 </since_tizen>
+        /// </summary>
+        /// <value>Cellular user name.</value>
+        public string UserName { get; set;}
+        /// <summary>
+        /// The password
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Cellular password.</value>
+        public string Password { get; set; }
+
+        /// <summary>
+        /// The authentication type
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Cellular authentication type.</value>
+        public CellularAuthType AuthType { get; set; }
+    }
+}
diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionError.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionError.cs
new file mode 100755 (executable)
index 0000000..9e8d587
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tizen.Network.Connection
+{
+    internal static class ConnectionErrorFactory
+    {
+        internal static void CheckFeatureUnsupportedException(int err, string message)
+        {
+            if ((ConnectionError)err == ConnectionError.NotSupported)
+            {
+                ThrowConnectionException(err, message);
+            }
+        }
+
+        internal static void CheckPermissionDeniedException(int err, string message)
+        {
+            if ((ConnectionError)err == ConnectionError.PermissionDenied)
+            {
+                ThrowConnectionException(err, message);
+            }
+        }
+
+        internal static void CheckHandleNullException(int err, bool isHandleInvalid, string message)
+        {
+            if ((ConnectionError)err == ConnectionError.InvalidParameter)
+            {
+                if (isHandleInvalid)
+                {
+                    ThrowConnectionException((int)ConnectionError.InvalidOperation, message);
+                }
+            }
+        }
+
+        internal static void ThrowConnectionException(int errno , string message = "")
+        {
+            ConnectionError _error = (ConnectionError)errno;
+            Log.Debug(Globals.LogTag, "ThrowConnectionException " + _error);
+            switch (_error)
+            {
+                case ConnectionError.AddressFamilyNotSupported:
+                    throw new InvalidOperationException("Address Family Not Supported");
+                case ConnectionError.AlreadyExists:
+                    throw new InvalidOperationException("Already Exists");
+                case ConnectionError.DhcpFailed:
+                    throw new InvalidOperationException("DHCP Failed");
+                case ConnectionError.EndOfIteration:
+                    throw new InvalidOperationException("End Of Iteration");
+                case ConnectionError.InvalidKey:
+                    throw new InvalidOperationException("Invalid Key");
+                case ConnectionError.InvalidOperation:
+                    throw new InvalidOperationException("Invalid Operation " + message);
+                case ConnectionError.InvalidParameter:
+                    throw new ArgumentException("Invalid Parameter");
+                case ConnectionError.NoConnection:
+                    throw new InvalidOperationException("No Connection");
+                case ConnectionError.NoReply:
+                    throw new InvalidOperationException("No Reply");
+                case ConnectionError.NotSupported:
+                    throw new NotSupportedException("Unsupported feature " + message);
+                case ConnectionError.NowInProgress:
+                    throw new InvalidOperationException("Now In Progress");
+                case ConnectionError.OperationAborted:
+                    throw new InvalidOperationException("Operation Aborted");
+                case ConnectionError.OperationFailed:
+                    throw new InvalidOperationException("Operation Failed");
+                case ConnectionError.OutOfMemoryError:
+                    throw new OutOfMemoryException("Out Of Memory Error");
+                case ConnectionError.PermissionDenied:
+                    throw new UnauthorizedAccessException("Permission Denied " + message);
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs
new file mode 100755 (executable)
index 0000000..cad51a7
--- /dev/null
@@ -0,0 +1,945 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Runtime.InteropServices;
+using System.Collections;
+using System.Threading;
+
+namespace Tizen.Network.Connection
+{
+    class HandleHolder : IDisposable
+    {
+        private IntPtr Handle;
+        private bool disposed = false;
+
+        public HandleHolder()
+        {
+            Log.Debug(Globals.LogTag, "Handle: " + Handle);
+            int ret = Interop.Connection.Create(out Handle);
+            if(ret != (int)ConnectionError.None)
+            {
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+        }
+
+        ~HandleHolder()
+        {
+            Dispose(false);
+        }
+
+        internal IntPtr GetHandle()
+        {
+            Log.Debug(Globals.LogTag, "handleholder handle = " + Handle);
+            return Handle;
+        }
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            Log.Debug(Globals.LogTag, ">>> HandleHolder Dispose with " + disposing);
+            Log.Debug(Globals.LogTag, ">>> Handle: " + Handle);
+            if (disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects.
+                Destroy();
+            }
+            disposed = true;
+        }
+
+        private void Destroy()
+        {
+            Interop.Connection.Destroy(Handle);
+            if (Handle != IntPtr.Zero)
+            {
+                Handle = IntPtr.Zero;
+            }
+        }
+    }
+
+    internal class ConnectionInternalManager
+    {
+        private bool disposed = false;
+        private static ConnectionInternalManager s_instance = null;
+
+        private EventHandler _ConnectionTypeChanged = null;
+        private EventHandler _IPAddressChanged = null;
+        private EventHandler _EthernetCableStateChanged = null;
+        private EventHandler _ProxyAddressChanged = null;
+
+        private Interop.Connection.ConnectionAddressChangedCallback _connectionAddressChangedCallback;
+        private Interop.Connection.ConnectionTypeChangedCallback _connectionTypeChangedCallback;
+        private Interop.Connection.ConnectionAddressChangedCallback _proxyAddressChangedCallback;
+
+        internal static ConnectionInternalManager Instance
+        {
+            get
+            {
+                if (s_instance == null)
+                {
+                    s_instance = new ConnectionInternalManager();
+                }
+
+                return s_instance;
+            }
+        }
+
+        private static ThreadLocal<HandleHolder> s_threadName = new ThreadLocal<HandleHolder>(() =>
+        {
+            Log.Info(Globals.LogTag, "In threadlocal delegate");
+            return new HandleHolder();
+        });
+
+        private ConnectionInternalManager()
+        {
+
+        }
+
+        ~ConnectionInternalManager()
+        {
+            Dispose(false);
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            Log.Debug(Globals.LogTag, ">>> ConnectionInternalManager Dispose with disposing " + disposing + ", disposed " + disposed);
+            Log.Debug(Globals.LogTag, ">>> Handle: " + GetHandle());
+            if (disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects.
+            }
+
+            UnregisterEvents();
+            disposed = true;
+        }
+
+        internal IntPtr GetHandle()
+        {
+            return s_threadName.Value.GetHandle();
+        }
+
+        internal event EventHandler ConnectionTypeChanged
+        {
+            add
+            {
+                if (_ConnectionTypeChanged == null)
+                {
+                    ConnectionTypeChangedStart();
+                }
+
+                _ConnectionTypeChanged += value;
+            }
+            remove
+            {
+                _ConnectionTypeChanged -= value;
+                if (_ConnectionTypeChanged == null)
+                {
+                    ConnectionTypeChangedStop();
+                }
+            }
+        }
+
+        private void ConnectionTypeChangedStart()
+        {
+            _connectionTypeChangedCallback = (ConnectionType type, IntPtr user_data) =>
+            {
+                if (_ConnectionTypeChanged != null)
+                {
+                    _ConnectionTypeChanged(null, new ConnectionTypeEventArgs(type));
+                }
+            };
+
+            int ret = Interop.Connection.SetTypeChangedCallback(GetHandle(), _connectionTypeChangedCallback, IntPtr.Zero);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to register connection type changed callback, " + (ConnectionError)ret);
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+        }
+
+        private void ConnectionTypeChangedStop()
+        {
+            int ret = Interop.Connection.UnsetTypeChangedCallback(GetHandle());
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to unregister connection type changed callback, " + (ConnectionError)ret);
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+        }
+
+        internal event EventHandler EthernetCableStateChanged
+        {
+            add
+            {
+                if (_EthernetCableStateChanged == null)
+                {
+                    EthernetCableStateChangedStart();
+                }
+                _EthernetCableStateChanged += value;
+            }
+            remove
+            {
+                _EthernetCableStateChanged -= value;
+                if (_EthernetCableStateChanged == null)
+                {
+                    EthernetCableStateChangedStop();
+                }
+            }
+        }
+
+        private void EthernetCableStateChangedStart()
+        {
+            int ret = Interop.Connection.SetEthernetCableStateChagedCallback(GetHandle(), EthernetCableStateChangedCallback, IntPtr.Zero);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to register ethernet cable state changed callback, " + (ConnectionError)ret);
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+        }
+
+        private void EthernetCableStateChangedStop()
+        {
+            int ret = Interop.Connection.UnsetEthernetCableStateChagedCallback(GetHandle());
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to unregister ethernet cable state changed callback, " + (ConnectionError)ret);
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+        }
+
+        private void EthernetCableStateChangedCallback(EthernetCableState state, IntPtr user_data)
+        {
+            if (_EthernetCableStateChanged != null)
+            {
+                _EthernetCableStateChanged(null, new EthernetCableStateEventArgs(state));
+            }
+        }
+
+        internal event EventHandler IPAddressChanged
+        {
+            add
+            {
+                if (_IPAddressChanged == null)
+                {
+                    IPAddressChangedStart();
+                }
+                _IPAddressChanged += value;
+            }
+
+            remove
+            {
+                _IPAddressChanged -= value;
+                if (_IPAddressChanged == null)
+                {
+                    IPAddressChangedStop();
+                }
+            }
+        }
+
+        private void IPAddressChangedStart()
+        {
+            _connectionAddressChangedCallback = (IntPtr IPv4, IntPtr IPv6, IntPtr UserData) =>
+            {
+                if (_IPAddressChanged != null)
+                {
+                    string ipv4 = Marshal.PtrToStringAnsi(IPv4);
+                    string ipv6 = Marshal.PtrToStringAnsi(IPv6);
+
+                    if ((string.IsNullOrEmpty(ipv4) == false) || (string.IsNullOrEmpty(ipv6) == false))
+                    {
+                        _IPAddressChanged(null, new AddressEventArgs(ipv4, ipv6));
+                    }
+                }
+            };
+
+            int ret = Interop.Connection.SetIPAddressChangedCallback(GetHandle(), _connectionAddressChangedCallback, IntPtr.Zero);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to register callback for changing IP address, " + (ConnectionError)ret);
+            }
+        }
+
+        private void IPAddressChangedStop()
+        {
+            int ret = Interop.Connection.UnsetIPAddressChangedCallback(GetHandle());
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to unregister callback for changing IP address, " + (ConnectionError)ret);
+            }
+        }
+
+        internal event EventHandler ProxyAddressChanged
+        {
+            add
+            {
+                //Console.WriteLine("ProxyAddressChanged Add **");
+                if (_ProxyAddressChanged == null)
+                {
+                    ProxyAddressChangedStart();
+                }
+
+                _ProxyAddressChanged += value;
+            }
+            remove
+            {
+                //Console.WriteLine("ProxyAddressChanged Remove");
+                _ProxyAddressChanged -= value;
+                if (_ProxyAddressChanged == null)
+                {
+                    ProxyAddressChangedStop();
+                }
+            }
+        }
+
+        private void ProxyAddressChangedStart()
+        {
+            _proxyAddressChangedCallback = (IntPtr IPv4, IntPtr IPv6, IntPtr UserData) =>
+            {
+                if (_ProxyAddressChanged != null)
+                {
+                    string ipv4 = Marshal.PtrToStringAnsi(IPv4);
+                    string ipv6 = Marshal.PtrToStringAnsi(IPv6);
+
+                    if ((string.IsNullOrEmpty(ipv4) == false) || (string.IsNullOrEmpty(ipv6) == false))
+                    {
+                        _ProxyAddressChanged(null, new AddressEventArgs(ipv4, ipv6));
+                    }
+                }
+            };
+
+            int ret = Interop.Connection.SetProxyAddressChangedCallback(GetHandle(), _proxyAddressChangedCallback, IntPtr.Zero);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to register callback for changing proxy address, " + (ConnectionError)ret);
+            }
+        }
+
+        private void ProxyAddressChangedStop()
+        {
+            int ret = Interop.Connection.UnsetProxyAddressChangedCallback(GetHandle());
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to unregister callback for changing proxy address, " + (ConnectionError)ret);
+            }
+        }
+
+        private void UnregisterEvents()
+        {
+            if (_ConnectionTypeChanged != null)
+            {
+                ConnectionTypeChangedStop();
+            }
+            if (_IPAddressChanged != null)
+            {
+                IPAddressChangedStop();
+            }
+            if (_EthernetCableStateChanged != null)
+            {
+                EthernetCableStateChangedStop();
+            }
+            if (_ProxyAddressChanged != null)
+            {
+                ProxyAddressChangedStop();
+            }
+        }
+
+        internal int GetProfileIterator(ProfileListType type, out IntPtr iterator)
+        {
+            return Interop.Connection.GetProfileIterator(GetHandle(), (int)type, out iterator);
+        }
+
+        internal bool HasNext(IntPtr iterator)
+        {
+            return Interop.Connection.HasNextProfileIterator(iterator);
+        }
+
+        internal int NextProfileIterator(IntPtr iterator, out IntPtr profileHandle)
+        {
+            return Interop.Connection.GetNextProfileIterator(iterator, out profileHandle);
+        }
+
+        internal int DestoryProfileIterator(IntPtr iterator)
+        {
+            return Interop.Connection.DestroyProfileIterator(iterator);
+        }
+
+        internal System.Net.IPAddress GetIPAddress(AddressFamily family)
+        {
+            Log.Debug(Globals.LogTag, "GetIPAddress " + family);
+            IntPtr ip;
+            int ret = Interop.Connection.GetIPAddress(GetHandle(), (int)family, out ip);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to get IP address, " + (ConnectionError)ret);
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+
+            string result = Marshal.PtrToStringAnsi(ip);
+            Interop.Libc.Free(ip);
+            return System.Net.IPAddress.Parse(result);;
+        }
+
+        internal IEnumerable<System.Net.IPAddress> GetAllIPv6Addresses(ConnectionType type)
+        {
+            Log.Debug(Globals.LogTag, "GetAllIPv6Addresses");
+            List<System.Net.IPAddress> ipList = new List<System.Net.IPAddress>();
+            Interop.Connection.IPv6AddressCallback callback = (IntPtr ipv6Address, IntPtr userData) =>
+            {
+                if (ipv6Address != IntPtr.Zero)
+                {
+                    string ipv6 = Marshal.PtrToStringAnsi(ipv6Address);
+                    ipList.Add(System.Net.IPAddress.Parse(ipv6));
+                    return true;
+                }
+                return false;
+            };
+
+            int ret = Interop.Connection.GetAllIPv6Addresses(GetHandle(), (int)type, callback, IntPtr.Zero);
+            if (ret != (int)ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to get all IPv6 addresses, Error - " + (ConnectionError)ret);
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+
+            return ipList;
+        }
+
+        internal string GetProxy(AddressFamily family)
+        {
+            Log.Debug(Globals.LogTag, "GetProxy " + family);
+            IntPtr ip;
+            int ret = Interop.Connection.GetProxy(GetHandle(), (int)family, out ip);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to get proxy, " + (ConnectionError)ret);
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+
+            string result = Marshal.PtrToStringAnsi(ip);
+            Interop.Libc.Free(ip);
+            return result;
+        }
+
+        internal string GetMacAddress(ConnectionType type)
+        {
+            Log.Debug(Globals.LogTag, "GetMacAddress " + type);
+            IntPtr mac;
+            int ret = Interop.Connection.GetMacAddress(GetHandle(), (int)type, out mac);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to get mac address, " + (ConnectionError)ret);
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.ethernet");
+                ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+
+            string result = Marshal.PtrToStringAnsi(mac);
+            Interop.Libc.Free(mac);
+            return result;
+        }
+
+        internal long GetStatistics(ConnectionType connectionType, StatisticsType statisticsType)
+        {
+            Log.Debug(Globals.LogTag, "GetStatistics " + connectionType + ", " + statisticsType);
+            long size;
+            int ret = Interop.Connection.GetStatistics(GetHandle(), (int)connectionType,
+                    (int)statisticsType, out size);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to get statistics, " + (ConnectionError)ret);
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.telephony");
+                ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)");
+                ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+            return size;
+        }
+
+        internal void ResetStatistics(ConnectionType connectionType, StatisticsType statisticsType)
+        {
+            Log.Debug(Globals.LogTag, "ResetStatistics " + connectionType + ", " + statisticsType);
+            int ret = Interop.Connection.ResetStatistics(GetHandle(), (int)connectionType,
+                    (int)statisticsType);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to reset statistics, " + (ConnectionError)ret);
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.telephony");
+                ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.set)");
+                ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+        }
+
+        internal void AddRoute(AddressFamily family, string interfaceName, System.Net.IPAddress address, System.Net.IPAddress gateway)
+        {
+            if (interfaceName != null && address != null && gateway != null)
+            {
+                Log.Debug(Globals.LogTag, "AddRoute " + family + ", " + interfaceName + ", " + address + ", " + gateway);
+                int ret = Interop.Connection.AddRoute(GetHandle(), family, interfaceName, address.ToString(), gateway.ToString());
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to add route to the routing table, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                    ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.set)");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+
+            else
+            {
+                throw new ArgumentNullException("Arguments are null");
+            }
+        }
+
+        internal void RemoveRoute(AddressFamily family, string interfaceName, System.Net.IPAddress address, System.Net.IPAddress gateway)
+        {
+            if (interfaceName != null && address != null && gateway != null)
+            {
+                Log.Debug(Globals.LogTag, "RemoveRoute " + family + ", " + interfaceName + ", " + address + ", " + gateway);
+                int ret = Interop.Connection.RemoveRoute(GetHandle(), family, interfaceName, address.ToString(), gateway.ToString());
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to remove route from the routing table, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                    ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.set)");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+
+            else
+            {
+                throw new ArgumentNullException("Arguments are null");
+            }
+        }
+
+        internal ConnectionType ConnectionType
+        {
+            get
+            {
+                Log.Debug(Globals.LogTag, "get ConnectionType");
+                int type = 0;
+                int ret = Interop.Connection.GetType(GetHandle(), out type);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get connection type, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+                return (ConnectionType)type;
+            }
+        }
+
+        internal CellularState CellularState
+        {
+            get
+            {
+                Log.Debug(Globals.LogTag, "get CellularState");
+                int type = 0;
+                int ret = Interop.Connection.GetCellularState(GetHandle(), out type);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get cellular state, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+                return (CellularState)type;
+            }
+        }
+
+        internal ConnectionState WiFiState
+        {
+            get
+            {
+                Log.Debug(Globals.LogTag, "get WiFiState");
+                int type = 0;
+                int ret = Interop.Connection.GetWiFiState(GetHandle(), out type);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get wifi state, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+                return (ConnectionState)type;
+            }
+        }
+
+        internal ConnectionState BluetoothState
+        {
+            get
+            {
+                Log.Debug(Globals.LogTag, "get BluetoothState");
+                int type = 0;
+                int ret = Interop.Connection.GetBtState(GetHandle(), out type);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get bluetooth state, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+                return (ConnectionState)type;
+            }
+        }
+
+        internal ConnectionState EthernetState
+        {
+            get
+            {
+                Log.Debug(Globals.LogTag, "get ConnectionType");
+                int type = 0;
+                int ret = Interop.Connection.GetEthernetState(GetHandle(), out type);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get ethernet state, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+                return (ConnectionState)type;
+            }
+        }
+
+        internal EthernetCableState EthernetCableState
+        {
+            get
+            {
+                Log.Debug(Globals.LogTag, "get EthernetCableState");
+                int type = 0;
+                int ret = Interop.Connection.GetEthernetCableState(GetHandle(), out type);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get ethernet cable state, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+                return (EthernetCableState)type;
+            }
+        }
+
+        internal IntPtr CreateCellularProfile(ConnectionProfileType type, string keyword)
+        {
+            Log.Debug(Globals.LogTag, "CreateCellularProfile, " + type + ", " + keyword);
+            if (keyword != null)
+            {
+                IntPtr handle = IntPtr.Zero;
+                int ret = Interop.ConnectionProfile.Create((int)type, keyword, out handle);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to Create profile, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.telephony");
+                    ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+
+                return handle;
+            }
+
+            else
+            {
+                throw new ArgumentNullException("Keyword is null");
+            }
+        }
+
+        internal void AddCellularProfile(CellularProfile profile)
+        {
+
+            Log.Debug(Globals.LogTag, "AddCellularProfile");
+            if (profile != null)
+            {
+                if (profile.Type == ConnectionProfileType.Cellular)
+                {
+                    int ret = Interop.Connection.AddProfile(GetHandle(), profile.ProfileHandle);
+                    if ((ConnectionError)ret != ConnectionError.None)
+                    {
+                        Log.Error(Globals.LogTag, "Failed to add cellular profile, " + (ConnectionError)ret);
+                        ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+                        ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.profile)");
+                        ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released");
+                        ConnectionErrorFactory.ThrowConnectionException(ret);
+                    }
+                }
+
+                else
+                {
+                    throw new ArgumentException("Profile type is not cellular");
+                }
+            }
+
+            else
+            {
+                throw new ArgumentNullException("Profile is null");
+            }
+        }
+
+        internal void RemoveProfile(ConnectionProfile profile)
+        {
+            Log.Debug(Globals.LogTag, "RemoveProfile");
+            if (profile != null)
+            {
+                int ret = Interop.Connection.RemoveProfile(GetHandle(), profile.ProfileHandle);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to remove profile, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.telephony");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+
+            else
+            {
+                throw new ArgumentNullException("Profile is null");
+            }
+        }
+
+        internal void UpdateProfile(ConnectionProfile profile)
+        {
+            Log.Debug(Globals.LogTag, "UpdateProfile");
+            if (profile != null)
+            {
+                int ret = Interop.Connection.UpdateProfile(GetHandle(), profile.ProfileHandle);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to update profile, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.ethernet");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+
+            else
+            {
+                throw new ArgumentNullException("Profile is null");
+            }
+        }
+
+        internal ConnectionProfile GetCurrentProfile()
+        {
+            Log.Debug(Globals.LogTag, "GetCurrentProfile");
+            IntPtr ProfileHandle;
+            int ret = Interop.Connection.GetCurrentProfile(GetHandle(), out ProfileHandle);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to get current profile, " + (ConnectionError)ret);
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)");
+                ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+
+            ConnectionProfile Profile = new ConnectionProfile(ProfileHandle);
+            return Profile;
+        }
+
+        internal ConnectionProfile GetDefaultCellularProfile(CellularServiceType type)
+        {
+            Log.Debug(Globals.LogTag, "GetDefaultCellularProfile");
+            IntPtr ProfileHandle;
+            int ret = Interop.Connection.GetDefaultCellularServiceProfile(GetHandle(), (int)type, out ProfileHandle);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "Error: " + ret);
+                Log.Error(Globals.LogTag, "It failed to get default cellular profile, " + (ConnectionError)ret);
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+                ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)");
+                ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+
+            CellularProfile Profile = new CellularProfile(ProfileHandle);
+            return Profile;
+        }
+
+        internal Task SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile)
+        {
+            Log.Debug(Globals.LogTag, "SetDefaultCellularProfile");
+            if (profile != null)
+            {
+                TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+                Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) =>
+                {
+                    if (Result != ConnectionError.None)
+                    {
+                        Log.Error(Globals.LogTag, "Error occurs during set default cellular profile, " + Result);
+                        task.SetException(new InvalidOperationException("Error occurs during set default cellular profile, " + Result));
+                    }
+
+                    task.SetResult(true);
+                };
+
+                int ret = Interop.Connection.SetDefaultCellularServiceProfileAsync(GetHandle(), (int)type, profile.ProfileHandle, Callback, (IntPtr)0);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set default cellular profile, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+
+                return task.Task;
+            }
+
+            else
+            {
+                throw new ArgumentNullException("Profile is null");
+            }
+        }
+
+
+        internal Task<IEnumerable<ConnectionProfile>> GetProfileListAsync(ProfileListType type)
+        {
+            Log.Debug(Globals.LogTag, "GetProfileListAsync");
+            var task = new TaskCompletionSource<IEnumerable<ConnectionProfile>>();
+
+            List<ConnectionProfile> Result = new List<ConnectionProfile>();
+            IntPtr iterator;
+            int ret = Interop.Connection.GetProfileIterator(GetHandle(), (int)type, out iterator);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to get profile iterator, " + (ConnectionError)ret);
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)");
+                ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+
+            while (Interop.Connection.HasNextProfileIterator(iterator))
+            {
+                IntPtr nextH;
+                IntPtr profileH;
+                Interop.Connection.GetNextProfileIterator(iterator, out nextH);
+                Interop.ConnectionProfile.Clone(out profileH, nextH);
+
+                int profileType;
+                Interop.ConnectionProfile.GetType(profileH, out profileType);
+
+                if ((ConnectionProfileType)profileType == ConnectionProfileType.WiFi)
+                {
+                    WiFiProfile cur = new WiFiProfile(profileH);
+                    Result.Add(cur);
+                }
+                else if ((ConnectionProfileType)profileType == ConnectionProfileType.Cellular)
+                {
+                    CellularProfile cur = new CellularProfile(profileH);
+                    Result.Add(cur);
+                }
+                else {
+                    ConnectionProfile cur = new ConnectionProfile(profileH);
+                    Result.Add(cur);
+                }
+            }
+            Interop.Connection.DestroyProfileIterator(iterator);
+            task.SetResult(Result);
+            return task.Task;
+        }
+
+        internal Task OpenProfileAsync(ConnectionProfile profile)
+        {
+            Log.Debug(Globals.LogTag, "OpenProfileAsync");
+            if (profile != null)
+            {
+                Log.Debug(Globals.LogTag, "OpenProfileAsync " + profile.Name);
+                TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+                Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) =>
+                {
+                    Log.Debug(Globals.LogTag, "Connected " + profile.Name);
+                    if (Result != ConnectionError.None)
+                    {
+                        Log.Error(Globals.LogTag, "Error occurs during connecting profile, " + Result);
+                        task.SetException(new InvalidOperationException("Error occurs during connecting profile, " + Result));
+                    }
+
+                    task.SetResult(true);
+                };
+
+                int ret = Interop.Connection.OpenProfile(GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to connect profile, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+
+                return task.Task;
+            }
+
+            else
+            {
+                throw new ArgumentNullException("Profile is null");
+            }
+        }
+
+        internal Task CloseProfileAsync(ConnectionProfile profile)
+        {
+            Log.Debug(Globals.LogTag, "CloseProfileAsync");
+            if (profile != null)
+            {
+                Log.Debug(Globals.LogTag, "CloseProfileAsync " + profile.Name);
+                TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+                Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) =>
+                {
+                    if (Result != ConnectionError.None)
+                    {
+                        Log.Error(Globals.LogTag, "Error occurs during disconnecting profile, " + Result);
+                        task.SetException(new InvalidOperationException("Error occurs during disconnecting profile, " + Result));
+                    }
+
+                    task.SetResult(true);
+                };
+
+                int ret = Interop.Connection.CloseProfile(GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to disconnect profile, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth");
+                    ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.set)");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+
+                return task.Task;
+            }
+
+            else
+            {
+                throw new ArgumentNullException("Profile is null");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionManager.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionManager.cs
new file mode 100755 (executable)
index 0000000..0b574b5
--- /dev/null
@@ -0,0 +1,628 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// The Connection API provides functions, enumerations to get the status of network and current profile and manage profiles.
+/// </summary>
+namespace Tizen.Network.Connection
+{
+    /// <summary>
+    /// This class manages the connection handle resources.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public sealed class SafeConnectionHandle : SafeHandle
+    {
+        internal SafeConnectionHandle(IntPtr handle) : base(handle, true)
+        {
+        }
+
+        /// <summary>
+        /// Checks whether the handle value is valid or not.
+        /// </summary>
+        /// <value>True if the handle is invalid, otherwise false.</value>
+        public override bool IsInvalid
+        {
+            get
+            {
+                return this.handle == IntPtr.Zero;
+            }
+        }
+
+        /// <summary>
+        /// Frees the handle.
+        /// </summary>
+        /// <returns>True if the handle is released successfully, otherwise false.</returns>
+        protected override bool ReleaseHandle()
+        {
+            this.SetHandle(IntPtr.Zero);
+            return true;
+        }
+    }
+
+    /// <summary>
+    /// This class is ConnectionManager. It provides functions to manage data connections.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public static class ConnectionManager
+    {
+        private static ConnectionItem _currentConnection = null;
+
+        /// <summary>
+        /// Event that is called when the type of the current connection is changed.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        public static event EventHandler ConnectionTypeChanged
+        {
+            add
+            {
+                ConnectionInternalManager.Instance.ConnectionTypeChanged += value;
+            }
+
+            remove
+            {
+                ConnectionInternalManager.Instance.ConnectionTypeChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// Event for ethernet cable is plugged [in/out] event.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        public static event EventHandler EthernetCableStateChanged
+        {
+            add
+            {
+                ConnectionInternalManager.Instance.EthernetCableStateChanged += value;
+            }
+
+            remove
+            {
+                ConnectionInternalManager.Instance.EthernetCableStateChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// Event that is called when the IP address is changed.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        public static event EventHandler IPAddressChanged
+        {
+            add
+            {
+                ConnectionInternalManager.Instance.IPAddressChanged += value;
+            }
+
+            remove
+            {
+                ConnectionInternalManager.Instance.IPAddressChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// Event that is called when the proxy address is changed.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        public static event EventHandler ProxyAddressChanged
+        {
+            add
+            {
+                ConnectionInternalManager.Instance.ProxyAddressChanged += value;
+            }
+
+            remove
+            {
+                ConnectionInternalManager.Instance.ProxyAddressChanged -= value;
+            }
+        }
+
+        /// <summary>
+        /// Gets the connection handle.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <returns>Instance of SafeConnectionHandle</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static SafeConnectionHandle GetConnectionHandle()
+        {
+            IntPtr handle = ConnectionInternalManager.Instance.GetHandle();
+            return new SafeConnectionHandle(handle);
+        }
+
+        /// <summary>
+        /// Gets the IP address of the current connection.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="family">The address family</param>
+        /// <returns>IP address of the connection (global address in case of IPv6).</returns>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation.</exception>
+        public static System.Net.IPAddress GetIPAddress(AddressFamily family)
+        {
+            return ConnectionInternalManager.Instance.GetIPAddress(family);
+        }
+
+        /// <summary>
+        /// Gets the all IPv6 addresses of the current connection.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="type">The type of current network connection</param>
+        /// <returns>A list of IPv6 addresses of the connection.</returns>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation.</exception>
+        public static IEnumerable<System.Net.IPAddress> GetAllIPv6Addresses(ConnectionType type)
+        {
+            return ConnectionInternalManager.Instance.GetAllIPv6Addresses(type);
+        }
+
+        /// <summary>
+        /// Gets the proxy address of the current connection.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="family">The address family</param>
+        /// <returns>Proxy address of the connection.</returns>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation.</exception>
+        public static string GetProxy(AddressFamily family)
+        {
+            return ConnectionInternalManager.Instance.GetProxy(family);
+        }
+
+        /// <summary>
+        /// Gets the MAC address of the Wi-Fi or ethernet.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="type">The type of current network connection</param>
+        /// <returns>MAC address of the Wi-Fi or ethernet.</returns>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation.</exception>
+        public static string GetMacAddress(ConnectionType type)
+        {
+            return ConnectionInternalManager.Instance.GetMacAddress(type);
+        }
+
+        /// <summary>
+        /// Gets the statistics information.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="connectionType">The type of connection (only WiFi and Cellular are supported)</param>
+        /// <param name="statisticsType">The type of statistics</param>
+        /// <returns>The statistics information associated with statisticsType</returns>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation.</exception>
+        public static long GetStatistics(ConnectionType connectionType, StatisticsType statisticsType)
+        {
+            return ConnectionInternalManager.Instance.GetStatistics(connectionType, statisticsType);
+        }
+
+        /// <summary>
+        /// Resets the statistics information.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="connectionType">The type of connection (only WiFi and Cellular are supported)</param>
+        /// <param name="statisticsType">The type of statistics</param>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <privilege>http://tizen.org/privilege/network.set</privilege>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation.</exception>
+        public static void ResetStatistics(ConnectionType connectionType, StatisticsType statisticsType)
+        {
+            ConnectionInternalManager.Instance.ResetStatistics(connectionType, statisticsType);
+        }
+
+        /// <summary>
+        /// Adds a route to the routing table.
+        /// </summary>
+        /// <param name="family">The address family</param>
+        /// <param name="interfaceName">The name of network interface</param>
+        /// <param name="hostAddress">The IP address of the host</param>
+        /// <param name="gateway">The gateway address</param>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <privilege>http://tizen.org/privilege/network.set</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown when interfaceName or hostAddress or gateway is null.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation.</exception>
+        public static void AddRoute(AddressFamily family, string interfaceName, System.Net.IPAddress hostAddress, System.Net.IPAddress gateway)
+        {
+            ConnectionInternalManager.Instance.AddRoute(family, interfaceName, hostAddress, gateway);
+        }
+
+        /// <summary>
+        /// Removes a route from the routing table.
+        /// </summary>
+        /// <param name="family">The address family</param>
+        /// <param name="interfaceName">The name of network interface</param>
+        /// <param name="hostAddress">The IP address of the host</param>
+        /// <param name="gateway">The gateway address</param>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <privilege>http://tizen.org/privilege/network.set</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown when interfaceName or hostAddress or gateway is null.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation.</exception>
+        public static void RemoveRoute(AddressFamily family, string interfaceName, System.Net.IPAddress hostAddress, System.Net.IPAddress gateway)
+        {
+            ConnectionInternalManager.Instance.RemoveRoute(family, interfaceName, hostAddress, gateway);
+        }
+
+        /// <summary>
+        /// Type and state of the current profile for data connection
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Instance of ConnectionItem</value>
+        public static ConnectionItem CurrentConnection
+        {
+            get
+            {
+                if (_currentConnection == null)
+                {
+                    _currentConnection = new ConnectionItem();
+                }
+
+                return _currentConnection;
+            }
+        }
+
+        /// <summary>
+        /// Creates a cellular profile handle.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="type">The type of profile. Cellular profile type is supported.</param>
+        /// <param name="keyword">The keyword included in profile name.</param>
+        /// <returns>CellularProfile object</returns>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown when keyword value is null.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
+        public static CellularProfile CreateCellularProfile(ConnectionProfileType type, string keyword)
+        {
+            IntPtr profileHandle = IntPtr.Zero;
+            if (type == ConnectionProfileType.Cellular)
+            {
+                profileHandle = ConnectionInternalManager.Instance.CreateCellularProfile(type, keyword);
+            }
+
+            else
+            {
+                Log.Error(Globals.LogTag, "ConnectionProfile Type is not supported");
+                ConnectionErrorFactory.ThrowConnectionException((int)ConnectionError.InvalidParameter);
+            }
+
+            return new CellularProfile(profileHandle);
+        }
+
+        /// <summary>
+        /// The state of cellular connection.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Cellular network state.</value>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        public static CellularState CellularState
+        {
+            get
+            {
+                return ConnectionInternalManager.Instance.CellularState;
+            }
+        }
+
+        /// <summary>
+        /// The state of the Wi-Fi.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>WiFi connection state.</value>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        public static ConnectionState WiFiState
+        {
+            get
+            {
+                return ConnectionInternalManager.Instance.WiFiState;
+            }
+        }
+
+        /// <summary>
+        /// The state of the Bluetooth.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Bluetooth connection state.</value>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        public static ConnectionState BluetoothState
+        {
+            get
+            {
+                return ConnectionInternalManager.Instance.BluetoothState;
+            }
+        }
+
+        /// <summary>
+        /// The Ethernet connection state.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Ethernet connection state.</value>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        public static ConnectionState EthernetState
+        {
+            get
+            {
+                return ConnectionInternalManager.Instance.EthernetState;
+            }
+        }
+
+        /// <summary>
+        /// Checks for ethernet cable is attached or not.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Ethernet cable state.</value>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        public static EthernetCableState EthernetCableState
+        {
+            get
+            {
+                return ConnectionInternalManager.Instance.EthernetCableState;
+            }
+        }
+
+    } // class ConnectionManager
+
+    /// <summary>
+    /// This class contains connection information such as connection type and state.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public class ConnectionItem
+    {
+        internal ConnectionItem()
+        {
+        }
+
+        /// <summary>
+        /// The type of the current profile for data connection.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Data connection current profile.</value>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        public ConnectionType Type
+        {
+            get
+            {
+                return ConnectionInternalManager.Instance.ConnectionType;
+            }
+        }
+
+        /// <summary>
+        /// The state of the current profile for data connection.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Connection state of the current connection type.</value>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        public ConnectionState State
+        {
+            get
+            {
+                if (ConnectionInternalManager.Instance.ConnectionType == ConnectionType.Cellular)
+                {
+                    if (ConnectionInternalManager.Instance.CellularState == CellularState.Connected)
+                    {
+                        return ConnectionState.Connected;
+                    }
+                    else if (ConnectionInternalManager.Instance.CellularState == CellularState.Available)
+                    {
+                        return ConnectionState.Disconnected;
+                    }
+                    else {
+                        return ConnectionState.Deactivated;
+                    }
+                }
+                else if (ConnectionInternalManager.Instance.ConnectionType == ConnectionType.Bluetooth)
+                {
+                    return ConnectionInternalManager.Instance.BluetoothState;
+                }
+                else if (ConnectionInternalManager.Instance.ConnectionType == ConnectionType.WiFi)
+                {
+                    return ConnectionInternalManager.Instance.WiFiState;
+                }
+                else if (ConnectionInternalManager.Instance.ConnectionType == ConnectionType.Ethernet)
+                {
+                    return ConnectionInternalManager.Instance.EthernetState;
+                }
+                else { // TO DO : Add Net Proxy
+                    return ConnectionState.Disconnected;
+                }
+            }
+        }
+    } // class ConnectionItem
+
+    /// <summary>
+    /// An extended EventArgs class which contains changed connection type.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public class ConnectionTypeEventArgs : EventArgs
+    {
+        private ConnectionType Type = ConnectionType.Disconnected;
+
+        internal ConnectionTypeEventArgs(ConnectionType type)
+        {
+            Type = type;
+        }
+
+        /// <summary>
+        /// The connection type.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Type of the connection.</value>
+        public ConnectionType ConnectionType
+        {
+            get
+            {
+                return Type;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class which contains changed ethernet cable state.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public class EthernetCableStateEventArgs : EventArgs
+    {
+        private EthernetCableState State;
+
+        internal EthernetCableStateEventArgs(EthernetCableState state)
+        {
+            State = state;
+        }
+
+        /// <summary>
+        /// The ethernet cable state.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Attached or detached state of the ethernet cable.</value>
+        public EthernetCableState EthernetCableState
+        {
+            get
+            {
+                return State;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class which contains changed address.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public class AddressEventArgs : EventArgs
+    {
+        private string IPv4 = "";
+        private string IPv6 = "";
+
+        internal AddressEventArgs(string ipv4, string ipv6)
+        {
+            IPv4 = ipv4;
+            IPv6 = ipv6;
+        }
+
+        /// <summary>
+        /// The  IPV4 address.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>IP address in the format of IPV4 syntax.</value>
+        public string IPv4Address
+        {
+            get
+            {
+                return IPv4;
+            }
+        }
+
+        /// <summary>
+        /// The  IPV6 address.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>IP address in the format of IPV6 syntax.</value>
+        public string IPv6Address
+        {
+            get
+            {
+                return IPv6;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs
new file mode 100755 (executable)
index 0000000..87fc8a2
--- /dev/null
@@ -0,0 +1,450 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Connection
+{
+    /// <summary>
+    /// This Class is ConnectionProfile. It provides event and propeties of the connection profile.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public class ConnectionProfile : IDisposable
+    {
+        internal IntPtr ProfileHandle = IntPtr.Zero;
+        private IAddressInformation IPv4;
+        private IAddressInformation IPv6;
+        private bool disposed = false;
+        private EventHandler _ProfileStateChanged = null;
+
+        private Interop.ConnectionProfile.ProfileStateChangedCallback _profileChangedCallback;
+
+        internal IntPtr GetHandle()
+        {
+            return ProfileHandle;
+        }
+
+        /// <summary>
+        /// The event that is called when the state of profile is changed.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        public event EventHandler ProfileStateChanged
+        {
+            add
+            {
+                Log.Debug(Globals.LogTag, "ProfileStateChanged add");
+                if (_ProfileStateChanged == null)
+                {
+                    ProfileStateChangedStart();
+                }
+                _ProfileStateChanged += value;
+            }
+            remove
+            {
+                Log.Debug(Globals.LogTag, "ProfileStateChanged remove");
+                _ProfileStateChanged -= value;
+                if (_ProfileStateChanged == null)
+                {
+                    ProfileStateChangedStop();
+                }
+            }
+        }
+
+        private void ProfileStateChangedStart()
+        {
+            _profileChangedCallback = (ProfileState state, IntPtr userData) =>
+            {
+                if (_ProfileStateChanged != null)
+                {
+                    _ProfileStateChanged(null, new ProfileStateEventArgs(state));
+                }
+            };
+
+            Log.Debug(Globals.LogTag, "ProfileStateChangedStart");
+            int ret = Interop.ConnectionProfile.SetStateChangeCallback(ProfileHandle, _profileChangedCallback, IntPtr.Zero);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to register callback for changing profile state, " + (ConnectionError)ret);
+            }
+        }
+
+        private void ProfileStateChangedStop()
+        {
+            Log.Debug(Globals.LogTag, "ProfileStateChangedStop");
+            int ret = Interop.ConnectionProfile.UnsetStateChangeCallback(ProfileHandle);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to unregister callback for changing profile state, " + (ConnectionError)ret);
+            }
+        }
+
+        internal ConnectionProfile(IntPtr handle)
+        {
+            ProfileHandle = handle;
+            IPv4 = new ConnectionAddressInformation(ProfileHandle, AddressFamily.IPv4);
+            IPv6 = new ConnectionAddressInformation(ProfileHandle, AddressFamily.IPv6);
+        }
+
+        ~ConnectionProfile()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// Disposes the memory allocated to unmanaged resources.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            Log.Debug(Globals.LogTag, ">>> ConnectionProfile Dispose with " + disposing);
+            if (disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects.
+                UnregisterEvents();
+                Destroy();
+            }
+            disposed = true;
+        }
+
+        private void UnregisterEvents()
+        {
+            if (_ProfileStateChanged != null)
+            {
+                ProfileStateChangedStop();
+            }
+        }
+
+        private void Destroy()
+        {
+            Interop.ConnectionProfile.Destroy(ProfileHandle);
+            ProfileHandle = IntPtr.Zero;
+        }
+
+        internal void CheckDisposed()
+        {
+            if (disposed)
+            {
+                throw new ObjectDisposedException(GetType().FullName);
+            }
+        }
+
+        /// <summary>
+        /// The profile ID.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Unique ID of the profile.</value>
+        public string Id
+        {
+            get
+            {
+                IntPtr Value;
+                int ret = Interop.ConnectionProfile.GetId(ProfileHandle, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get id of connection profile, " + (ConnectionError)ret);
+                }
+                string result = Marshal.PtrToStringAnsi(Value);
+                Interop.Libc.Free(Value);
+                return result;
+            }
+        }
+
+        /// <summary>
+        /// The profile name.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>User friendly name of the profile.</value>
+        public string Name
+        {
+            get
+            {
+                IntPtr Value;
+                int ret = Interop.ConnectionProfile.GetName(ProfileHandle, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get name of connection profile, " + (ConnectionError)ret);
+                }
+                string result = Marshal.PtrToStringAnsi(Value);
+                Interop.Libc.Free(Value);
+                return result;
+            }
+        }
+
+        /// <summary>
+        /// The network type.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Profile type of the network connection.</value>
+        public ConnectionProfileType Type
+        {
+            get
+            {
+                int Value;
+                int ret = Interop.ConnectionProfile.GetType(ProfileHandle, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get type of connection profile, " + (ConnectionError)ret);
+                }
+                return (ConnectionProfileType)Value;
+            }
+        }
+
+        /// <summary>
+        /// The name of the network interface.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Network interface name, e.g. eth0 and pdp0.</value>
+        public string InterfaceName
+        {
+            get
+            {
+                IntPtr Value;
+                int ret = Interop.ConnectionProfile.GetNetworkInterfaceName(ProfileHandle, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get network interface name, " + (ConnectionError)ret);
+                }
+                string result = Marshal.PtrToStringAnsi(Value);
+                Interop.Libc.Free(Value);
+                return result;
+            }
+        }
+
+        /// <summary>
+        /// Refreshes the profile information.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when profile instance is invalid or when method failed due to invalid operation</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
+        public void Refresh()
+        {
+            CheckDisposed();
+            int ret = Interop.ConnectionProfile.Refresh(ProfileHandle);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to get network interface name, " + (ConnectionError)ret);
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)");
+                ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Get the network state.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="family">The address family</param>
+        /// <returns>The network state.</returns>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when profile instance is invalid or when method failed due to invalid operation</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
+        public ProfileState GetState(AddressFamily family)
+        {
+            CheckDisposed();
+            int Value;
+            int ret = (int)ConnectionError.None;
+            if (family == AddressFamily.IPv4)
+            {
+                ret = Interop.ConnectionProfile.GetState(ProfileHandle, out Value);
+            }
+
+            else
+            {
+                ret = Interop.ConnectionProfile.GetIPv6State(ProfileHandle, out Value);
+            }
+
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to get profile state, " + (ConnectionError)ret);
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+
+            return (ProfileState)Value;
+        }
+
+        /// <summary>
+        /// The Proxy type.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Proxy type of the connection.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown during set when operation is performed on a disposed object.</exception>
+        public ProxyType ProxyType
+        {
+            get
+            {
+                int Value;
+                int ret = Interop.ConnectionProfile.GetProxyType(ProfileHandle, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get proxy type, " + (ConnectionError)ret);
+                }
+                return (ProxyType)Value;
+
+            }
+
+            set
+            {
+                CheckDisposed();
+                int ret = Interop.ConnectionProfile.SetProxyType(ProfileHandle, (int)value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set proxy type, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// The proxy address.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Proxy address of the connection.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown during set when value is null.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
+        public string ProxyAddress
+        {
+            get
+            {
+                IntPtr Value;
+                int ret = Interop.ConnectionProfile.GetProxyAddress(ProfileHandle, (int)AddressFamily.IPv4, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get proxy address, " + (ConnectionError)ret);
+                }
+                string result = Marshal.PtrToStringAnsi(Value);
+                Interop.Libc.Free(Value);
+                return result;
+
+            }
+
+            set
+            {
+                CheckDisposed();
+                if (value != null)
+                {
+                    int ret = Interop.ConnectionProfile.SetProxyAddress(ProfileHandle, (int)AddressFamily.IPv4, value);
+                    if ((ConnectionError)ret != ConnectionError.None)
+                    {
+                        Log.Error(Globals.LogTag, "It failed to set proxy address, " + (ConnectionError)ret);
+                        ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                        ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                        ConnectionErrorFactory.ThrowConnectionException(ret);
+                    }
+                }
+
+                else
+                {
+                    throw new ArgumentNullException("ProxyAddress is null");
+                }
+            }
+        }
+
+        /// <summary>
+        /// The address information (IPv4)
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Instance of IAddressInformation with IPV4 address.</value>
+        public IAddressInformation IPv4Settings
+        {
+            get
+            {
+                return IPv4;
+
+            }
+        }
+
+        /// <summary>
+        /// The address information (IPv6)
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Instance of IAddressInformation with IPV6 address.</value>
+        public IAddressInformation IPv6Settings
+        {
+            get
+            {
+                return IPv6;
+            }
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class which contains changed profile state.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public class ProfileStateEventArgs : EventArgs
+    {
+        private ProfileState _State = ProfileState.Disconnected;
+
+        internal ProfileStateEventArgs(ProfileState state)
+        {
+            _State = state;
+        }
+
+        /// <summary>
+        /// The profile state.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>State type of the connection profile.</value>
+        public ProfileState State
+        {
+            get
+            {
+                return _State;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfileManager.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfileManager.cs
new file mode 100755 (executable)
index 0000000..5049686
--- /dev/null
@@ -0,0 +1,268 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Collections;
+
+namespace Tizen.Network.Connection
+{
+    /// <summary>
+    /// This class is ConnectionProfileManager. It provides functions to add, get, connect or modify the connection profile.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public static class ConnectionProfileManager
+    {
+        /// <summary>
+        /// Adds a new profile
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="profile">The cellular profile object</param>
+        /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
+        public static void AddCellularProfile(CellularProfile profile)
+        {
+            Log.Debug(Globals.LogTag, "AddCellularProfile");
+            ConnectionInternalManager.Instance.AddCellularProfile(profile);
+        }
+
+        /// <summary>
+        /// Gets the list of profile with profile list type
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="type">The type of profile</param>
+        /// <returns>List of connection profile objects.</returns>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection instance has been disposed.</exception>
+        public static Task<IEnumerable<ConnectionProfile>> GetProfileListAsync(ProfileListType type)
+        {
+            Log.Debug(Globals.LogTag, "GetProfileListAsync");
+            return ConnectionInternalManager.Instance.GetProfileListAsync(type);
+        }
+
+        /// <summary>
+        /// Opens a connection of profile, asynchronously.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="profile">The connection profile object</param>
+        /// <returns>A task indicates whether the ConnectProfileAsync method is done successfully or not.</returns>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <privilege>http://tizen.org/privilege/network.set</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
+        public static Task ConnectProfileAsync(ConnectionProfile profile)
+        {
+            Log.Debug(Globals.LogTag, "ConnectProfile");
+            return ConnectionInternalManager.Instance.OpenProfileAsync(profile);
+        }
+
+        /// <summary>
+        /// Closes a connection of profile.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="profile">The connection profile object</param>
+        /// <returns>A task indicates whether the DisconnectProfileAsync method is done successfully or not.</returns>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <privilege>http://tizen.org/privilege/network.set</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
+        public static Task DisconnectProfileAsync(ConnectionProfile profile)
+        {
+            Log.Debug(Globals.LogTag, "DisconnectProfileAsync");
+            return ConnectionInternalManager.Instance.CloseProfileAsync(profile);
+        }
+
+        /// <summary>
+        /// Removes an existing profile.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="profile">The connection profile object</param>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
+        public static void RemoveProfile(ConnectionProfile profile)
+        {
+            Log.Debug(Globals.LogTag, "RemoveProfile. Id: " + profile.Id + ", Name: " + profile.Name + ", Type: " + profile.Type);
+            ConnectionInternalManager.Instance.RemoveProfile(profile);
+        }
+
+        /// <summary>
+        /// Updates an existing profile.
+        /// When a profile is changed, these changes will be not applied to the ConnectionProfileManager immediately.
+        /// When you call this function, your changes affect the ConnectionProfileManager and the existing profile is updated.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="profile">The connection profile object</param>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
+        public static void UpdateProfile(ConnectionProfile profile)
+        {
+            Log.Debug(Globals.LogTag, "UpdateProfile");
+            ConnectionInternalManager.Instance.UpdateProfile(profile);
+        }
+
+        /// <summary>
+        /// Gets the name of the default profile.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <returns>Connection profile object.</returns>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation</exception>
+        public static ConnectionProfile GetCurrentProfile()
+        {
+            Log.Debug(Globals.LogTag, "GetCurrentProfile");
+            return ConnectionInternalManager.Instance.GetCurrentProfile();
+        }
+
+        /// <summary>
+        /// Gets the default profile which provides the given cellular service.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="type">The cellular service type</param>
+        /// <returns>Connection profile object.</returns>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation</exception>
+        public static ConnectionProfile GetDefaultCellularProfile(CellularServiceType type)
+        {
+            Log.Debug(Globals.LogTag, "GetDefaultCurrentProfile");
+            return ConnectionInternalManager.Instance.GetDefaultCellularProfile(type);
+        }
+
+        /// <summary>
+        /// Sets the default profile which provides the given cellular service.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="type">The cellular service type</param>
+        /// <param name="profile">The connection profile object</param>
+        /// <returns>A task indicates whether the SetDefaultCellularProfile method is done successfully or not.</returns>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
+        public static Task SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile)
+        {
+            Log.Debug(Globals.LogTag, "SetDefaultCellularProfile");
+            return ConnectionInternalManager.Instance.SetDefaultCellularProfile(type, profile);
+        }
+    }
+
+    /// <summary>
+    /// An extended EventArgs class which contains the state of changed connection profile.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public class ConnectionProfileStateEventArgs : EventArgs
+    {
+        private  ConnectionProfileState State;
+
+        internal ConnectionProfileStateEventArgs(ConnectionProfileState state)
+        {
+            State = state;
+        }
+
+        /// <summary>
+        /// The connection profile state.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>State of the connection profile.</value>
+        public ConnectionProfileState ConnectionProfileState
+        {
+            get
+            {
+                return State;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionTypes.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionTypes.cs
new file mode 100755 (executable)
index 0000000..6c206ff
--- /dev/null
@@ -0,0 +1,284 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Tizen.Internals.Errors;
+
+
+namespace Tizen.Network.Connection
+{
+    /// <summary>
+    /// Enumeration for connection type.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum ConnectionType
+    {
+        Disconnected = 0,  /**< Disconnected */
+        WiFi = 1,          /**< Wi-Fi type */
+        Cellular = 2,      /**< Cellular type */
+        Ethernet = 3,      /**< Ethernet type */
+        Bluetooth = 4,     /**< Bluetooth type */
+        NetProxy = 5       /**< Proxy type for internet connection */
+    }
+
+    /// <summary>
+    /// Enumeration for address family.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum AddressFamily
+    {
+        IPv4 = 0,   /**< IPv4 Address */
+        IPv6 = 1    /**< IPv6 Address */
+    }
+
+    /// <summary>
+    /// Enumeration for cellular network state.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum CellularState
+    {
+        OutOfService = 0,  /**< Out of service */
+        FlightMode = 1,    /**< Flight mode */
+        RoamingOff = 2,    /**< Roaming is turned off */
+        CallOnlyAvailable = 3,  /**< Call is only available */
+        Available = 4,     /**< Available but not connected yet */
+        Connected = 5,     /**< Connected */
+    }
+
+    /// <summary>
+    /// Enumeration for connection state.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum ConnectionState
+    {
+        Deactivated = 0,   /**< Deactivated */
+        Disconnected = 1,  /**< Disconnected */
+        Connected = 2,     /**< Connected */
+    }
+
+    /// <summary>
+    /// This enumeration defines the attached or detached state of ethernet cable.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum EthernetCableState
+    {
+        Detached = 0,  /**< Ethernet cable is detached */
+        Attached = 1,  /**< Ethernet cable is attached */
+    }
+
+    /// <summary>
+    /// Enumeration for statistics type.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum StatisticsType
+    {
+        LastReceivedData = 0,  /**< Last received data */
+        LastSentData = 1,  /**< Last sent data */
+        TotalReceivedData = 2,  /**< Total received data */
+        TotalSentData = 3,  /**< Total sent data */
+    }
+
+    /// <summary>
+    /// Enumeration for network connection type.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum ConnectionProfileType
+    {
+        Cellular = 0,  /**< Cellular type */
+        WiFi = 1,      /**< Wi-Fi type */
+        Ethernet = 2,  /**< Ethernet type */
+        Bt = 3,        /**< Bluetooth type */
+    }
+
+    /// <summary>
+    /// Enumeration for profile state type.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum ProfileState
+    {
+        Disconnected = 0,  /**< Disconnected state */
+        Association = 1,  /**< Association state */
+        Configuration = 2,  /**< Configuration state */
+        Connected = 3,  /**< Connected state */
+    }
+
+    /// <summary>
+    /// Enumeration for proxy method type.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum ProxyType
+    {
+        Direct = 0,  /**< Direct connection */
+        Auto = 1,    /**< Auto configuration(Use PAC file). If URL property is not set, DHCP/WPAD auto-discover will be tried */
+        Manual = 2,  /**< Manual configuration */
+    }
+
+    /// <summary>
+    /// Enumeration for IP configuration type.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum IPConfigType
+    {
+        None = 0,  /**< Not defined */
+        Static = 1,  /**< Manual IP configuration */
+        Dynamic = 2,  /**< Config IP using DHCP client*/
+        Auto = 3,  /**< Config IP from Auto IP pool (169.254/16). Later with DHCP client, if available */
+        Fixed = 4,  /**< Indicates an IP address that can not be modified */
+    }
+
+    /// <summary>
+    /// Enumeration for cellular service type.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum CellularServiceType
+    {
+        Unknown = 0,  /**< Unknown */
+        Internet = 1,  /**< Internet */
+        MMS = 2,  /**< MMS */
+        PrepaidInternet = 3,  /**< Prepaid internet */
+        PrepaidMMS = 4,  /**< Prepaid MMS */
+        Tethering = 5,  /**< Tethering */
+        Application = 6,  /**< Specific application */
+    }
+
+    /// <summary>
+    /// Enumeration for cellular pdn type.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum CellularPdnType
+    {
+        Unknown = 0,  /**< Unknown */
+        IPv4 = 1,  /**< IPv4 */
+        IPv6 = 2,  /**< IPv6 */
+        IPv4_IPv6 = 3,  /**< Both IPv4 and IPv6 */
+    }
+
+    /// <summary>
+    /// Enumeration for DNS configuration type.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum DnsConfigType
+    {
+        None = 0,  /**< Not defined */
+        Static = 1,  /**< Manual DNS configuration */
+        Dynamic = 2,  /**< Config DNS using DHCP client */
+    }
+
+    static internal class ConnectionErrorValue
+    {
+        internal const int Base = -0x01C10000;
+    }
+
+
+    /// <summary>
+    /// Enumeration for connection errors.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    // To do : have to assign valid error code
+    public enum ConnectionError
+    {
+        None = ErrorCode.None,         /**< Successful */
+        InvalidParameter = ErrorCode.InvalidParameter, /**< Invalid parameter */
+        OutOfMemoryError = ErrorCode.OutOfMemory, /**< Out of memory error */
+        InvalidOperation = ErrorCode.InvalidOperation, /**< Invalid Operation */
+        AddressFamilyNotSupported = ErrorCode.AddressFamilyNotSupported, /**< Address family not supported */
+        OperationFailed = ConnectionErrorValue.Base | 0x0401,  /**< Operation failed */
+        EndOfIteration = ConnectionErrorValue.Base | 0x0402,   /**< End of iteration */
+        NoConnection = ConnectionErrorValue.Base | 0x0403,     /**< There is no connection */
+        NowInProgress = ErrorCode.NowInProgress,    /** Now in progress */
+        AlreadyExists = ConnectionErrorValue.Base | 0x0404, /**< Already exists */
+        OperationAborted = ConnectionErrorValue.Base | 0x0405, /**< Operation is aborted */
+        DhcpFailed = ConnectionErrorValue.Base | 0x0406, /**< DHCP failed  */
+        InvalidKey = ConnectionErrorValue.Base | 0x0407, /**< Invalid key  */
+        NoReply = ConnectionErrorValue.Base | 0x0408, /**< No reply */
+        PermissionDenied = ErrorCode.PermissionDenied, /**< Permission denied */
+        NotSupported = ErrorCode.NotSupported    /**< Not Supported */
+    }
+
+    /// <summary>
+    /// Enumeration for profile list type.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum ProfileListType
+    {
+        Registered = 0,  /**< The iterator of the registered profile  */
+        Connected = 1,   /**< The iterator of the connected profile  */
+        Default = 2,      /**< The iterator of the default profile  */
+    }
+
+    /// <summary>
+    /// Enumeration for security type of Wi-Fi.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum WiFiSecurityType
+    {
+        None  =  0,       /**< Security disabled */
+        Wep = 1,          /**< WEP */
+        WpaPsk = 2,    /**< WPA-PSK */
+        Wpa2Psk = 3,  /**< WPA2-PSK */
+        Eap = 4,            /**< EAP */
+    }
+
+    /// <summary>
+    /// Enumeration for encryption modes.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum WiFiEncryptionType
+    {
+        None = 0,  /**< Encryption disabled */
+        Wep = 1,  /**< WEP */
+        Tkip = 2,  /**< TKIP */
+        Aes = 3,  /**< AES */
+        TkipAesMixed = 4,  /**< TKIP and AES are both supported */
+    }
+
+    /// <summary>
+    /// Enumeration for connection profile state.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum ConnectionProfileState
+    {
+        Disconnected = 0,  /**< Disconnected state */
+        Association = 1,  /**< Association state */
+        Configuration = 2,  /**< Configuration state */
+        Connected = 3,   /**< Connected state */
+    }
+
+    /// <summary>
+    /// Enumeration for cellular authentication type.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public enum CellularAuthType
+    {
+        None = 0,  /**< No authentication */
+        Pap = 1,  /**< PAP authentication */
+        Chap = 2,  /**< CHAP authentication */
+    }
+
+    public enum AddressInformationType
+    {
+        Connection = 0,
+        WiFi = 1
+    }
+
+    static internal class Globals
+    {
+        internal const string LogTag = "Tizen.Network.Connection";
+    }
+}
diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs
new file mode 100755 (executable)
index 0000000..5185186
--- /dev/null
@@ -0,0 +1,383 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Collections;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Connection
+{
+    /// <summary>
+    /// This interface provides properties to manage address information of the connection.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public interface IAddressInformation
+    {
+        /// <summary>
+        /// The DNS address.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>First DNS address of the connection.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        System.Net.IPAddress Dns1 { get; set; }
+
+        /// <summary>
+        /// The DNS address.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Second DNS address of the connection.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        System.Net.IPAddress Dns2 { get; set; }
+
+        /// <summary>
+        /// The gateway address.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Gateway address of the connection.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        System.Net.IPAddress Gateway { get; set; }
+
+        /// <summary>
+        /// The subnet mask address.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Subnet mask of the connection.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        System.Net.IPAddress SubnetMask { get; set; }
+
+        /// <summary>
+        /// The IP address.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>IP address of the connection.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        System.Net.IPAddress IP { get; set; }
+
+        /// <summary>
+        /// The type of IP config.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>IP config type of the connection.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        IPConfigType IPConfigType { get; set; }
+
+        /// <summary>
+        /// The prefix length.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Prefix length of the connection.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        int PrefixLength { get; set; }
+
+        /// <summary>
+        /// The DNS config type.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Config type of the DNS.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        DnsConfigType DnsConfigType { get; set; }
+
+        /// <summary>
+        /// The DHCP server address. It is only supported for IPV4 address family.
+        /// </summary>
+        /// <value>Server address of the DHCP.</value>
+        System.Net.IPAddress DhcpServerAddress { get; }
+    }
+
+    internal class ConnectionAddressInformation : IAddressInformation
+    {
+        private IntPtr _profileHandle;
+        private AddressFamily _family;
+
+        internal ConnectionAddressInformation(IntPtr handle, AddressFamily family)
+        {
+            _profileHandle = handle;
+            _family = family;
+        }
+
+        public System.Net.IPAddress Dns1
+        {
+            get
+            {
+                IntPtr Value;
+                int ret = Interop.ConnectionProfile.GetDnsAddress(_profileHandle, 1, (int)_family, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get dns1 address, " + (ConnectionError)ret);
+                }
+                string result = Marshal.PtrToStringAnsi(Value);
+                Interop.Libc.Free(Value);
+                if (result == null)
+                    return System.Net.IPAddress.Parse("0.0.0.0");
+                return System.Net.IPAddress.Parse(result);
+            }
+
+            set
+            {
+                int ret = Interop.ConnectionProfile.SetDnsAddress(_profileHandle, 1, (int)_family, value.ToString());
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set dns1 address, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
+        public System.Net.IPAddress Dns2
+        {
+            get
+            {
+                IntPtr Value;
+                int ret = Interop.ConnectionProfile.GetDnsAddress(_profileHandle, 2, (int)_family, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get dns2 address, " + (ConnectionError)ret);
+                }
+                string result = Marshal.PtrToStringAnsi(Value);
+                Interop.Libc.Free(Value);
+                if (result == null)
+                    return System.Net.IPAddress.Parse("0.0.0.0");
+                return System.Net.IPAddress.Parse(result);
+            }
+
+            set
+            {
+                int ret = Interop.ConnectionProfile.SetDnsAddress(_profileHandle, 2, (int)_family, value.ToString());
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set dns2 address, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
+
+        public System.Net.IPAddress Gateway
+        {
+            get
+            {
+                IntPtr Value;
+                int ret = Interop.ConnectionProfile.GetGatewayAddress(_profileHandle, (int)_family, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get gateway, " + (ConnectionError)ret);
+                }
+                string result = Marshal.PtrToStringAnsi(Value);
+                Interop.Libc.Free(Value);
+                if (result == null)
+                    return System.Net.IPAddress.Parse("0.0.0.0");
+                return System.Net.IPAddress.Parse(result);
+            }
+
+            set
+            {
+                int ret = Interop.ConnectionProfile.SetGatewayAddress(_profileHandle, (int)_family, value.ToString());
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set gateway, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
+
+
+        public System.Net.IPAddress SubnetMask
+        {
+            get
+            {
+                IntPtr Value;
+                int ret = Interop.ConnectionProfile.GetSubnetMask(_profileHandle, (int)_family, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get subnet mask, " + (ConnectionError)ret);
+                }
+                string result = Marshal.PtrToStringAnsi(Value);
+                Interop.Libc.Free(Value);
+                if (result == null)
+                    return System.Net.IPAddress.Parse("0.0.0.0");
+                return System.Net.IPAddress.Parse(result);
+            }
+
+            set
+            {
+                int ret = Interop.ConnectionProfile.SetSubnetMask(_profileHandle, (int)_family, value.ToString());
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set subnet mask, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
+
+
+        public System.Net.IPAddress IP
+        {
+            get
+            {
+                IntPtr Value;
+                int ret = Interop.ConnectionProfile.GetIPAddress(_profileHandle, (int)_family, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get ip, " + (ConnectionError)ret);
+                }
+                string result = Marshal.PtrToStringAnsi(Value);
+                Interop.Libc.Free(Value);
+                if (result == null)
+                    return System.Net.IPAddress.Parse("0.0.0.0");
+                return System.Net.IPAddress.Parse(result);
+            }
+
+            set
+            {
+                int ret = Interop.ConnectionProfile.SetIPAddress(_profileHandle, (int)_family, value.ToString());
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set ip, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
+
+        public IPConfigType IPConfigType
+        {
+            get
+            {
+                int Value;
+                int ret = Interop.ConnectionProfile.GetIPConfigType(_profileHandle, (int)_family, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get ip config type, " + (ConnectionError)ret);
+                }
+                return (IPConfigType)Value;
+            }
+
+            set
+            {
+                int ret = Interop.ConnectionProfile.SetIPConfigType(_profileHandle, (int)_family, (int)value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set ip config type, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
+
+        public int PrefixLength
+        {
+            get
+            {
+                int Value;
+                int ret = Interop.ConnectionProfile.GetPrefixLength(_profileHandle, (int)_family, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get prefix length, " + (ConnectionError)ret);
+                }
+                return Value;
+            }
+
+            set
+            {
+                int ret = Interop.ConnectionProfile.SetPrefixLength(_profileHandle, (int)_family, value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set prefix length, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
+
+        public DnsConfigType DnsConfigType
+        {
+            get
+            {
+                int Value;
+                int ret = Interop.ConnectionProfile.GetDnsConfigType(_profileHandle, (int)_family, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get DNS config type, " + (ConnectionError)ret);
+                }
+                return (DnsConfigType)Value;
+            }
+
+            set
+            {
+                int ret = Interop.ConnectionProfile.SetDnsConfigType(_profileHandle, (int)_family, (int)value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set DNS config type, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
+
+        public System.Net.IPAddress DhcpServerAddress
+        {
+            get
+            {
+                string dhcpServer;
+                int ret = Interop.ConnectionProfile.GetDhcpServerAddress(_profileHandle, _family, out dhcpServer);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get the DHCP server address, " + (ConnectionError)ret);
+                }
+
+                if (dhcpServer == null)
+                {
+                    return System.Net.IPAddress.Parse("0.0.0.0");
+                }
+
+                else
+                {
+                    return System.Net.IPAddress.Parse(dhcpServer);
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs
new file mode 100755 (executable)
index 0000000..8ac6234
--- /dev/null
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.Connection
+{
+    /// <summary>
+    /// This Class is WiFiProfile. It provides functions to manage the WiFi profile.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public class WiFiProfile : ConnectionProfile
+    {
+        internal WiFiProfile(IntPtr Handle) : base(Handle)
+        {
+        }
+
+        ~WiFiProfile()
+        {
+        }
+
+        /// <summary>
+        /// The ESSID (Extended Service Set Identifier).
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>ESSID of the WiFi.</value>
+        public string Essid
+        {
+            get
+            {
+                IntPtr value;
+                int ret = Interop.ConnectionWiFiProfile.GetEssid(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to create profile handle, " + (ConnectionError)ret);
+                }
+                string result = Marshal.PtrToStringAnsi(value);
+                Interop.Libc.Free(value);
+                return result;
+            }
+        }
+
+        /// <summary>
+        /// The BSSID (Basic Service Set Identifier).
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>BSSID of the WiFi.</value>
+        public string Bssid
+        {
+            get
+            {
+                IntPtr value;
+                int ret = Interop.ConnectionWiFiProfile.GetBssid(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get bssid, " + (ConnectionError)ret);
+                }
+                string result = Marshal.PtrToStringAnsi(value);
+                Interop.Libc.Free(value);
+                return result;
+            }
+        }
+
+        /// <summary>
+        /// The RSSI.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>RSSI of the WiFi.</value>
+        public int Rssi
+        {
+            get
+            {
+                int value;
+                int ret = Interop.ConnectionWiFiProfile.GetRssi(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get rssi, " + (ConnectionError)ret);
+                }
+                return value;
+            }
+        }
+
+        /// <summary>
+        /// The frequency (MHz).
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Frequency of the WiFi.</value>
+        public int Frequency
+        {
+            get
+            {
+                int value;
+                int ret = Interop.ConnectionWiFiProfile.GetFrequency(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get frequency, " + (ConnectionError)ret);
+                }
+                return value;
+            }
+        }
+
+        /// <summary>
+        /// The max speed (Mbps).
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Maximum speed of the WiFi.</value>
+        public int MaxSpeed
+        {
+            get
+            {
+                int value;
+                int ret = Interop.ConnectionWiFiProfile.GetMaxSpeed(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get max speed, " + (ConnectionError)ret);
+                }
+                return value;
+            }
+        }
+
+        /// <summary>
+        /// The security type of WiFi.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Security type of the WiFi.</value>
+        public WiFiSecurityType SecurityType
+        {
+            get
+            {
+                int value;
+                int ret = Interop.ConnectionWiFiProfile.GetSecurityType(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get security type, " + (ConnectionError)ret);
+                }
+                return (WiFiSecurityType)value;
+            }
+        }
+
+        /// <summary>
+        /// The encryption type of WiFi.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Encryption mode of the WiFi.</value>
+        public WiFiEncryptionType EncryptionType
+        {
+            get
+            {
+                int value;
+                int ret = Interop.ConnectionWiFiProfile.GetEncryptionType(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get encryption type, " + (ConnectionError)ret);
+                }
+                return (WiFiEncryptionType)value;
+            }
+        }
+
+        /// <summary>
+        /// Checks whether passphrase is required.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>True if a passphrase is required, otherwise false.</value>
+        /// <remarks>This property is not valid if <c>WiFiSecurityType</c> is <c>Eap</c>.</remarks>
+        public bool PassphraseRequired
+        {
+            get
+            {
+                bool value;
+                int ret = Interop.ConnectionWiFiProfile.IsRequiredPassphrase(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get PassphraseRequired, " + (ConnectionError)ret);
+                }
+                return value;
+            }
+        }
+
+        /// <summary>
+        /// Checks whether the WPS (Wi-Fi Protected Setup) is supported.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>True if WPS is supported, otherwise false.</value>
+        public bool WpsSupported
+        {
+            get
+            {
+                bool value;
+                int ret = Interop.ConnectionWiFiProfile.IsSupportedWps(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get IsSupportedWps, " + (ConnectionError)ret);
+                }
+                return value;
+            }
+        }
+
+        /// <summary>
+        /// Sets the passphrase of the Wi-Fi WPA.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="passphrase">The passphrase of Wi-Fi security</param>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown when passphrase is null.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when profile instance is invalid or when method failed due to invalid operation.</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
+        public void SetPassphrase(string passphrase)
+        {
+            CheckDisposed();
+            if (passphrase != null)
+            {
+                int ret = Interop.ConnectionWiFiProfile.SetPassphrase(ProfileHandle, passphrase);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set passphrase, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.wifi");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+
+            else
+            {
+                throw new ArgumentNullException("Value of passphrase is null");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Database.cs b/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Database.cs
new file mode 100644 (file)
index 0000000..8183fe6
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Calendar
+    {
+        internal static partial class Database
+        {
+            [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+            internal delegate void DBChangedCallback(string uri, IntPtr userData);
+
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_insert_record")]
+            internal static extern int Insert(IntPtr recordHandle, out int recordId);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_get_record")]
+            internal static extern int Get(string uri, int recordId, out IntPtr recordHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_update_record")]
+            internal static extern int Update(IntPtr recordHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_delete_record")]
+            internal static extern int Delete(string uri, int recordId);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_get_all_records")]
+            internal static extern int GetAllRecords(string uri, int offset, int limit, out IntPtr recordListHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_get_records_with_query")]
+            internal static extern int GetRecords(IntPtr queryHandle, int offset, int limit, out IntPtr recordListHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_get_count")]
+            internal static extern int GetCount(string uri, out int count);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_get_count_with_query")]
+            internal static extern int GetCountWithQuery(IntPtr queryHandle, out int count);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_insert_records")]
+            internal static extern int InsertRecords(IntPtr recordListHandle, out IntPtr recordIds, out int count);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_update_records")]
+            internal static extern int UpdateRecords(IntPtr recordListHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_delete_records")]
+            internal static extern int DeleteRecords(string uri, int[] ids, int count);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_get_current_version")]
+            internal static extern int GetCurrentVersion(out int version);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_add_changed_cb")]
+            internal static extern int AddChangedCallback(string uri, DBChangedCallback callback, IntPtr userData);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_remove_changed_cb")]
+            internal static extern int RemoveChangedCallback(string uri, DBChangedCallback callback, IntPtr userData);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_get_changes_by_version")]
+            internal static extern int GetChangesByVersion(string uri, int bookId, int dbVersion, out IntPtr recordListHandle, out int currentDBVersion);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_insert_vcalendars")]
+            internal static extern int InsertVcalendars(string stream, out IntPtr recordIds, out int count);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_replace_vcalendars")]
+            internal static extern int ReplaceVcalendars(string stream, int[] ids, int count);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_replace_record")]
+            internal static extern int Replace(IntPtr recordHandle, int recordId);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_replace_records")]
+            internal static extern int ReplaceRecords(IntPtr recordListHandle, int[] ids, int count);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_get_last_change_version")]
+            internal static extern int GetLastChangeVersion(out int lastChangeVersion);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_get_changes_exception_by_version")]
+            internal static extern int GetChangesException(string uri, int eventId, int dbVersion, out IntPtr recordListHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_clean_after_sync")]
+            internal static extern int Clean(int bookId, int dbVersion);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_link_record")]
+            internal static extern int LinkRecord(int baseId, int recordId);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_unlink_record")]
+            internal static extern int UnlinkRecord(int recordId);
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Filter.cs b/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Filter.cs
new file mode 100644 (file)
index 0000000..43f9577
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Pims.Calendar;
+using static Tizen.Pims.Calendar.CalendarFilter;
+
+internal static partial class Interop
+{
+    internal static partial class Calendar
+    {
+        internal static partial class Filter
+        {
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_filter_create")]
+            internal static extern int Create(string uri, out IntPtr filterHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_filter_destroy")]
+            internal static extern int Destroy(IntPtr filterHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_filter_add_str")]
+            internal static extern int AddString(IntPtr filterHandle, uint propertyId, StringMatchType match, string value);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_filter_add_int")]
+            internal static extern int AddInteger(IntPtr filterHandle, uint propertyId, IntegerMatchType match, int value);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_filter_add_double")]
+            internal static extern int AddDouble(IntPtr filterHandle, uint propertyId, IntegerMatchType match, double value);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_filter_add_lli")]
+            internal static extern int AddLong(IntPtr filterHandle, uint propertyId, IntegerMatchType match, long value);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_filter_add_caltime")]
+            internal static extern int AddCalendarTime(IntPtr filterHandle, uint propertyId, IntegerMatchType match, Interop.Calendar.Record.DateTime value);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_filter_add_filter")]
+            internal static extern int AddFilter(IntPtr parentFilterHandle, IntPtr childFilterHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_filter_add_operator")]
+            internal static extern int AddOperator(IntPtr filterHandle, LogicalOperator type);
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Libraries.cs b/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Libraries.cs
new file mode 100644 (file)
index 0000000..ffb5218
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string Calendar = "libcalendar-service2.so.0";
+    }
+}
+
diff --git a/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.List.cs b/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.List.cs
new file mode 100644 (file)
index 0000000..31010c8
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Calendar
+    {
+        internal static partial class List
+        {
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_list_create")]
+            internal static extern int Create(out IntPtr listHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_list_destroy")]
+            internal static extern int Destroy(IntPtr listHandle, bool delete);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_list_get_count")]
+            internal static extern int GetCount(IntPtr listHandle, out int count);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_list_add")]
+            internal static extern int Add(IntPtr listHandle, IntPtr recordHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_list_remove")]
+            internal static extern int Remove(IntPtr listHandle, IntPtr recordHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_list_get_current_record_p")]
+            internal static extern int GetCurrentRecordP(IntPtr listHandle, out IntPtr recordHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_list_prev")]
+            internal static extern int Prev(IntPtr listHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_list_next")]
+            internal static extern int Next(IntPtr listHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_list_first")]
+            internal static extern int First(IntPtr listHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_list_last")]
+            internal static extern int Last(IntPtr listHandle);
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Query.cs b/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Query.cs
new file mode 100644 (file)
index 0000000..c570495
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Calendar
+    {
+        internal static partial class Query
+        {
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_query_create")]
+            internal static extern int Create(string uri, out IntPtr queryHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_query_destroy")]
+            internal static extern int Destroy(IntPtr queryHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_query_set_projection")]
+            internal static extern int SetProjection(IntPtr queryHandle, uint[] propertyIdArray, int count);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_query_set_distinct")]
+            internal static extern int SetDistinct(IntPtr queryHandle, bool set);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_query_set_filter")]
+            internal static extern int SetFilter(IntPtr queryHandle, IntPtr filterHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_query_set_sort")]
+            internal static extern int SetSort(IntPtr queryHandle, uint propertyId, bool isAscending);
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Record.cs b/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Record.cs
new file mode 100644 (file)
index 0000000..befe4d9
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Pims.Calendar;
+
+internal static partial class Interop
+{
+    internal static partial class Calendar
+    {
+        internal static partial class Record
+        {
+                       [StructLayout(LayoutKind.Sequential)]
+                       internal struct DateTime
+                       {
+                               internal int type;
+                               internal long utime;
+                               internal int year;
+                               internal int month;
+                               internal int mday;
+                               internal int hour;
+                               internal int minute;
+                               internal int second;
+                       };
+
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_create")]
+            internal static extern int Create(string uri, out IntPtr recordHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_destroy")]
+            internal static extern int Destroy(IntPtr recordHandle, bool isDeleteChild);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_clone")]
+            internal static extern int Clone(IntPtr recordHandle, out IntPtr cloneHandle);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_get_uri_p")]
+            internal static extern int GetUriPointer(IntPtr recordHandle, out IntPtr uri);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_get_str")]
+            internal static extern int GetString(IntPtr recordHandle, uint propertyId, out string str);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_get_str_p")]
+            internal static extern int GetStringPointer(IntPtr recordHandle, uint propertyId, out string str);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_get_int")]
+            internal static extern int GetInteger(IntPtr recordHandle, uint propertyId, out int value);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_get_double")]
+            internal static extern int GetDouble(IntPtr recordHandle, uint propertyId, out double value);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_get_lli")]
+            internal static extern int GetLli(IntPtr recordHandle, uint propertyId, out long value);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_get_caltime")]
+            internal static extern int GetCalendarTime(IntPtr recordHandle, uint propertyId, out DateTime value);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_set_str")]
+            internal static extern int SetString(IntPtr recordHandle, uint propertyId, string str);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_set_int")]
+            internal static extern int SetInteger(IntPtr recordHandle, uint propertyId, int value);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_set_double")]
+            internal static extern int SetDouble(IntPtr recordHandle, uint propertyId, double value);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_set_lli")]
+            internal static extern int SetLli(IntPtr recordHandle, uint propertyId, long value);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_set_caltime")]
+            internal static extern int SetCalendarTime(IntPtr recordHandle, uint propertyId, DateTime value);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_add_child_record")]
+            internal static extern int AddChildRecord(IntPtr recordHandle, uint propertyId, IntPtr childHandle);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_remove_child_record")]
+            internal static extern int RemoveChildRecord(IntPtr recordHandle, uint propertyId, IntPtr childHandle);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_get_child_record_count")]
+            internal static extern int GetChildRecordCount(IntPtr recordHandle, uint propertyId, out int count);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_get_child_record_at_p")]
+            internal static extern int GetChildRecordPointer(IntPtr recordHandle, uint propertyId, int index, out IntPtr childHandle);
+                       [DllImport(Libraries.Calendar, EntryPoint = "calendar_record_clone_child_record_list")]
+            internal static extern int CloneChildRecordList(IntPtr childRecordHandle, uint propertyId, out IntPtr listHandle);
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Reminder.cs b/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Reminder.cs
new file mode 100644 (file)
index 0000000..a737208
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Calendar
+    {
+        internal static partial class Reminder
+        {
+            [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+            internal delegate void ReminderAlertedCallback(string param, IntPtr userData);
+
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_reminder_add_cb")]
+            internal static extern int Add(ReminderAlertedCallback callback, IntPtr userData);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_db_remove_changed_cb")]
+            internal static extern int Remove(ReminderAlertedCallback callback, IntPtr userData);
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Service.cs b/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Service.cs
new file mode 100644 (file)
index 0000000..adb132b
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Calendar
+    {
+        internal static partial class Service
+        {
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_connect")]
+            internal static extern int Connect();
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_disconnect")]
+            internal static extern int Disconnect();
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_connect_on_thread")]
+            internal static extern int ConnectOnThread();
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_disconnect_on_thread")]
+            internal static extern int DisconnectOnThread();
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_connect_with_flags")]
+            internal static extern int ConnectWithFlags(uint flags);
+        }
+    }
+}
+
diff --git a/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Vcalendar.cs b/src/Tizen.Pims.Calendar/Interop/Interop.Calendar.Vcalendar.cs
new file mode 100644 (file)
index 0000000..0b0d6a4
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Calendar
+    {
+        internal static partial class Vcalendar
+        {
+            [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+            internal delegate bool ParseCallback(IntPtr recordHandle, IntPtr userData);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_vcalendar_make_from_records")]
+            internal static extern int Compose(IntPtr listHandle, out string stream);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_vcalendar_parse_to_calendar")]
+            internal static extern int Parse(string stream, out IntPtr listHandle);
+            [DllImport(Libraries.Calendar, EntryPoint = "calendar_vcalendar_parse_to_calendar_foreach")]
+            internal static extern int ParseForEach(string filePath, ParseCallback parseCb, IntPtr userData);
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar.csproj b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar.csproj
new file mode 100644 (file)
index 0000000..2c183b6
--- /dev/null
@@ -0,0 +1,21 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <Version>1.0.0</Version>
+    <Authors>Samsung Electronics</Authors>
+    <Copyright>© Samsung Electronics Co., Ltd All Rights Reserved</Copyright>
+    <Description>Calendar Service API for Tizen .NET</Description>
+    <PackageProjectUrl>https://www.tizen.org/</PackageProjectUrl>
+    <PackageLicenseUrl>https://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
+    <PackageIconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</PackageIconUrl>
+  </PropertyGroup>
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.6</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Tizen" Version="1.0.5" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar.nuspec b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar.nuspec
new file mode 100644 (file)
index 0000000..23512ec
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<package>
+       <metadata>
+               <id>Tizen.Pims.Calendar</id>
+               <version>$version$</version>
+               <authors>Tizen Developers</authors>
+               <description>Calendar Service API for Tizen.Net</description>
+               <dependencies>
+                       <dependency id="Tizen" version="1.0.0" />
+               </dependencies>
+       </metadata>
+</package>
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarDatabase.cs b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarDatabase.cs
new file mode 100644 (file)
index 0000000..2cbb6bf
--- /dev/null
@@ -0,0 +1,563 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// The Calendar Service API provides functions, enumerations used in the entire Content Service.
+/// </summary>
+/// <remarks>
+/// The Calendar Service API provides functions and ienumerations used in the entire Content Service.
+/// The Information about calendar items i.e. book, event, todo, alarm, attendee and extended are managed in the database
+/// and operations that involve database requires an active connection with the calendar service.
+/// </remarks>
+
+namespace Tizen.Pims.Calendar
+{
+    /// <summary>
+    /// CalendarDatabase provides methods to manage calendar information from/to the database.
+    /// </summary>
+    /// <remarks>
+    /// This class allows usre to access/create/update db operations for calendar information.
+    /// </remarks>
+    public class CalendarDatabase
+    {
+        /// <summary>
+        /// Delegete for detecting the calendar database changes.
+        /// </summary>
+        /// <param name="uri">The record uri</param>
+        /// <remarks>
+        /// The delegate must be registered using AddDBChangedDelegate.
+        /// It's invoked when the designated view changes.
+        /// </remarks>
+        /// <see cref="AddDBChangedDelegate"/>
+        public delegate void CalendarDBChangedDelegate(string uri);
+
+        private Object thisLock = new Object();
+        private Dictionary<string, CalendarDBChangedDelegate> _callbackMap = new Dictionary<string, CalendarDBChangedDelegate>();
+        private Dictionary<string, Interop.Calendar.Database.DBChangedCallback> _delegateMap = new Dictionary<string, Interop.Calendar.Database.DBChangedCallback>();
+        private Interop.Calendar.Database.DBChangedCallback _dbChangedDelegate;
+
+        internal CalendarDatabase()
+        {
+            ///To be created in CalendarManager only
+        }
+
+        /// <summary>
+        /// The calendar database version.
+        /// </summary>
+        public int Version
+        {
+            get
+            {
+                int version = -1;
+                int error = Interop.Calendar.Database.GetCurrentVersion(out version);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "Version Failed with error " + error);
+                }
+                return version;
+            }
+        }
+
+        /// <summary>
+        /// Gets last successful changed calendar database version on the current connection.
+        /// </summary>
+        /// <returns>The last successful changed calendar database version on the current connection</returns>
+        /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public int LastChangeVersion
+        {
+            get
+            {
+                int version = -1;
+                int error = Interop.Calendar.Database.GetLastChangeVersion(out version);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "LastChangeVersion Failed with error " + error);
+                }
+                return version;
+            }
+        }
+
+        /// <summary>
+        /// Inserts a record into the calendar database.
+        /// </summary>
+        /// <param name="record">The record to be inserted</param>
+        /// <returns>The ID of inserted record</returns>
+        /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public int Insert(CalendarRecord record)
+        {
+            int id = -1;
+            int error = Interop.Calendar.Database.Insert(record._recordHandle, out id);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "Insert Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            return id;
+        }
+
+        /// <summary>
+        /// Gets a record from the calendar database.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a record</param>
+        /// <param name="recordId">The record ID</param>
+        /// <returns>
+        /// The record associated with the record ID
+        /// </returns>
+        /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public CalendarRecord Get(string viewUri, int recordId)
+        {
+            IntPtr handle;
+            int error = Interop.Calendar.Database.Get(viewUri, recordId, out handle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                               if (CalendarError.DBNotFound == (CalendarError)error)
+                               {
+                                       Log.Error(Globals.LogTag, "No data" + error);
+                                       return null;
+                               }
+                               Log.Error(Globals.LogTag, "Get Failed with error " + error);
+                               throw CalendarErrorFactory.GetException(error);
+            }
+            return new CalendarRecord(handle);
+        }
+
+        /// <summary>
+        /// Updates a record in the calendar database.
+        /// </summary>
+        /// <param name="record">The record to be updated</param>
+        /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public void Update(CalendarRecord record)
+        {
+            int error = Interop.Calendar.Database.Update(record._recordHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "Update Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Deletes a record from the calendar database with related child records.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a record</param>
+        /// <param name="recordId">The record ID to be deleted</param>
+        /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public void Delete(string viewUri, int recordId)
+        {
+            int error = Interop.Calendar.Database.Delete(viewUri, recordId);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "Delete Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Replaces a record in the calendar database.
+        /// </summary>
+        /// <param name="record">The record to be replaced</param>
+        /// <param name="id">the record id</param>
+        /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public void Replace(CalendarRecord record, int id)
+        {
+            int error = Interop.Calendar.Database.Replace(record._recordHandle, id);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "Replace Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Retrieves all records as a list.
+        /// </summary>
+        /// <param name="viewUri">The view URI to get records from</param>
+        /// <param name="offset">The index from which results are received</param>
+        /// <param name="limit">The maximum number of results(value 0 is used for all records)</param>
+        /// <returns>
+        /// The record list
+        /// </returns>
+        /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public CalendarList GetAll(string viewUri, int offset, int limit)
+        {
+            IntPtr handle;
+            int error = Interop.Calendar.Database.GetAllRecords(viewUri, offset, limit, out handle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "GetAll Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            return new CalendarList(handle);
+        }
+
+        /// <summary>
+        /// Retrieves records using a query.
+        /// </summary>
+        /// <param name="query">The query used to filter results</param>
+        /// <param name="offset">The index from which results are received</param>
+        /// <param name="limit">The maximum number of results(value 0 is used for all records)</param>
+        /// <returns>
+        /// CalendarList
+        /// </returns>
+        /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public CalendarList GetRecordsWithQuery(CalendarQuery query, int offset, int limit)
+        {
+            IntPtr handle;
+            int error = Interop.Calendar.Database.GetRecords(query._queryHandle, offset, limit, out handle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "GetAllWithQuery Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            return new CalendarList(handle);
+        }
+
+        /// <summary>
+        /// Inserts multiple records into the calendar database as a batch operation.
+        /// </summary>
+        /// <param name="list">The record list</param>
+        /// <returns>
+        /// The inserted record id array
+        /// </returns>
+        /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public int[] Insert(CalendarList list)
+        {
+            IntPtr ids;
+            int count;
+            int error = Interop.Calendar.Database.InsertRecords(list._listHandle, out ids, out count);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "Insert Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            int[] idArr = new int[count];
+            Marshal.Copy(ids, idArr, 0, count);
+
+            return idArr;
+        }
+
+        /// <summary>
+        /// Updates multiple records into the calendar database as a batch operation.
+        /// </summary>
+        /// <param name="list">The record list</param>
+        /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public void Update(CalendarList list)
+        {
+            int error = Interop.Calendar.Database.UpdateRecords(list._listHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "Update Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Deletes multiple records with related child records from the calendar database as a batch operation.
+        /// </summary>
+        /// <param name="viewUri">The view URI of the records to delete</param>
+        /// <param name="idArray">The record IDs to delete</param>
+        /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public void Delete(string viewUri, int[] idArray)
+        {
+            int error = Interop.Calendar.Database.DeleteRecords(viewUri, idArray, idArray.Length);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "Delete Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Deletes multiple records with related child records from the calendar database as a batch operation.
+        /// </summary>
+        /// <param name="list">The record list</param>
+        /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public void Delete(CalendarList list)
+        {
+            CalendarRecord record = null;
+            if (list.Count <= 0)
+                return;
+
+            int[] ids = new int[list.Count];
+            int i;
+            uint propertyId = 0;
+            list.MoveFirst();
+            for (i = 0; i < list.Count; i++)
+            {
+                record = list.GetCurrentRecord();
+                if (0 == propertyId)
+                {
+                    if (0 == String.Compare(CalendarViews.Book.Uri, record.Uri))
+                        propertyId = CalendarViews.Book.Id;
+                    else if (0 == String.Compare(CalendarViews.Event.Uri, record.Uri))
+                        propertyId = CalendarViews.Event.Id;
+                    else if (0 == String.Compare(CalendarViews.Todo.Uri, record.Uri))
+                        propertyId = CalendarViews.Todo.Id;
+                    else if (0 == String.Compare(CalendarViews.Timezone.Uri, record.Uri))
+                        propertyId = CalendarViews.Timezone.Id;
+                    else if (0 == String.Compare(CalendarViews.Extended.Uri, record.Uri))
+                        propertyId = CalendarViews.Extended.Id;
+                    else
+                    {
+                        Log.Error(Globals.LogTag, "Invalid uri [" + record.Uri + "]");
+                        continue;
+                    }
+                }
+                ids[i] = record.Get<int>(propertyId);
+                list.MoveNext();
+            }
+            Delete(record.Uri, ids);
+        }
+
+        /// <summary>
+        /// Replaces multiple records in the calendar database as a batch operation.
+        /// </summary>
+        /// <param name="list">The record list</param>
+        /// <param name="idArray">The record IDs</param>
+        /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public void Replace(CalendarList list, int[] idArray)
+        {
+            int error = Interop.Calendar.Database.ReplaceRecords(list._listHandle, idArray, idArray.Length);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "Replace Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Retrieves records with the given calendar database version.
+        /// </summary>
+        /// <param name="viewUri">The view URI to get records from</param>
+        /// <param name="BookId">The calendar book ID to filter</param>
+        /// <param name="calendarDBVersion">The calendar database version</param>
+        /// <param name="currentDBVersion"The current calendar database versio></param>
+        /// <returns>
+        /// The record list
+        /// </returns>
+        /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public CalendarList GetChangesByVersion(string viewUri, int BookId, int calendarDBVersion, out int currentDBVersion)
+        {
+            IntPtr recordList;
+            int error = Interop.Calendar.Database.GetChangesByVersion(viewUri, BookId, calendarDBVersion, out recordList, out currentDBVersion);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "GetChangesByVersion Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            return new CalendarList(recordList);
+        }
+
+        /// <summary>
+        /// Gets the record count of a specific view.
+        /// </summary>
+        /// <param name="viewUri">The view URI to get records from</param>
+        /// <returns>
+        /// The count of records
+        /// </returns>
+        /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        public int GetCount(string viewUri)
+        {
+            int count = -1;
+            int error = Interop.Calendar.Database.GetCount(viewUri, out count);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "GetCount Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            return count;
+        }
+
+        /// <summary>
+        /// Gets the record count with a query.
+        /// </summary>
+        /// <param name="query">The query used for filtering the results</param>
+        /// <returns>
+        /// The count of records
+        /// </returns>
+        /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        public int GetCount(CalendarQuery query)
+        {
+            int count = -1;
+            int error = Interop.Calendar.Database.GetCountWithQuery(query._queryHandle, out count);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "GetCount Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            return count;
+        }
+
+        /// <summary>
+        /// Registers a callback function to be invoked when a record changes.
+        /// </summary>
+        /// <param name="viewUri">The view URI of the record to subscribe for change notifications</param>
+        /// <param name="callback">The callback function to register</param>
+        /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        public void AddDBChangedDelegate(string viewUri, CalendarDBChangedDelegate callback)
+        {
+            Log.Debug(Globals.LogTag, "AddDBChangedDelegate");
+
+            _dbChangedDelegate = (string uri, IntPtr userData) =>
+            {
+                _callbackMap[uri](uri);
+            };
+            int error = Interop.Calendar.Database.AddChangedCallback(viewUri, _dbChangedDelegate, IntPtr.Zero);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "AddDBChangedDelegate Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            _callbackMap[viewUri] = callback;
+            _delegateMap[viewUri] = _dbChangedDelegate;
+        }
+
+        /// <summary>
+        /// Unregisters a callback function.
+        /// </summary>
+        /// <param name="viewUri">The view URI of the record to subscribe for change notifications</param>
+        /// <param name="callback">The callback function to register</param>
+        /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        public void RemoveDBChangedDelegate(string viewUri, CalendarDBChangedDelegate callback)
+        {
+            Log.Debug(Globals.LogTag, "RemoveDBChangedDelegate");
+
+            int error = Interop.Calendar.Database.RemoveChangedCallback(viewUri, _delegateMap[viewUri], IntPtr.Zero);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "RemoveDBChangedDelegate Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            _callbackMap.Remove(viewUri);
+            _delegateMap.Remove(viewUri);
+        }
+
+        /// <summary>
+        /// Link a record to another record.
+        /// </summary>
+        /// <param name="baseId">The base record ID</param>
+        /// <param name="recordId">The record ID to link to</param>
+        /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public void LinkRecord(int baseId, int recordId)
+        {
+            Log.Debug(Globals.LogTag, "LinkRecord");
+            int error = Interop.Calendar.Database.LinkRecord(baseId, recordId);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "LinkRecor Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Unlink a record from base record.
+        /// </summary>
+        /// <param name="recordId">The record ID to unlink</param>
+        /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public void UnlinkRecord(int recordId)
+        {
+            Log.Debug(Globals.LogTag, "UnlinkRecord");
+            int error = Interop.Calendar.Database.UnlinkRecord(recordId);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "UnlinkRecor Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarErrorFactory.cs b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarErrorFactory.cs
new file mode 100644 (file)
index 0000000..6918f88
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Pims.Calendar
+{
+    internal enum CalendarError
+    {
+        None = Tizen.Internals.Errors.ErrorCode.None,                           /**< Successful */
+        OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,             /**< Out of Memory (-12) */
+        InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,   /**< Invalid parameter (-22) */
+        FileNoSpace = Tizen.Internals.Errors.ErrorCode.FileNoSpaceOnDevice,     /** <FS Full (-28) */
+        PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,   /**< Permission denied (-13) */
+        NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,           /**< Not supported (-1073741822) */
+        NoData = Tizen.Internals.Errors.ErrorCode.NoData,                       /**< Requested data does not exist (-61) */
+        DBLocked = Globals.ErrorCalendar | 0x81,                                /**< Database table locked or file locked (-33619839) */
+        ErrorDB = Globals.ErrorCalendar | 0x9F,                                 /**< Unknown DB error (-33619809) */
+        IPCNotAvailable = Globals.ErrorCalendar | 0xB1,                         /**< IPC server is not available (-33619791) */
+        ErrorIPC = Globals.ErrorCalendar | 0xBF,                                /**< Unknown IPC error (-33619777) */
+        ErrorSystem = Globals.ErrorCalendar | 0xEF,                             /**< Internal system module error (-33619729) */
+        ErrorInternal = Globals.ErrorCalendar | 0x04,                           /**< Implementation Error Temporary Use (-33619713) */
+        DBNotFound = Globals.ErrorCalendar | 0x05,                              /**< No data in DB (-33554427) */
+    };
+
+    internal static class Globals
+    {
+        internal const string LogTag = "Tizen.Pims.Calendar";
+        internal const int ErrorCalendar = -0x02000000;
+    }
+
+    internal static class CalendarErrorFactory
+    {
+        internal static void ThrowException(int e)
+        {
+            throw GetException(e);
+        }
+
+        internal static Exception GetException(int e)
+        {
+            Exception exp;
+            switch ((CalendarError)e)
+            {
+            case CalendarError.OutOfMemory:
+                exp = new OutOfMemoryException("Out of memory");
+                Log.Error(Globals.LogTag, "Out of memory");
+                break;
+            case CalendarError.InvalidParameter:
+                exp = new ArgumentException("Invalid parameter");
+                Log.Error(Globals.LogTag, "Invalid parameter");
+                break;
+            case CalendarError.FileNoSpace:
+                exp = new InvalidOperationException("File no space Error");
+                Log.Error(Globals.LogTag, "File no space Error");
+                break;
+            case CalendarError.PermissionDenied:
+                exp = new UnauthorizedAccessException("Permission denied");
+                Log.Error(Globals.LogTag, "Permission denied");
+                break;
+            case CalendarError.NotSupported:
+                exp = new NotSupportedException("Not supported");
+                Log.Error(Globals.LogTag, "Not supported");
+                break;
+            case CalendarError.NoData:
+                exp = new InvalidOperationException("No data found");
+                Log.Error(Globals.LogTag, "No data found");
+                break;
+            case CalendarError.DBLocked:
+                exp = new InvalidOperationException("DB locked");
+                Log.Error(Globals.LogTag, "DB locked");
+                break;
+            case CalendarError.ErrorDB:
+                exp = new InvalidOperationException("DB error");
+                Log.Error(Globals.LogTag, "DB error");
+                break;
+            case CalendarError.IPCNotAvailable:
+                exp = new InvalidOperationException("IPC not available");
+                Log.Error(Globals.LogTag, "IPC not available");
+                break;
+            case CalendarError.ErrorIPC:
+                exp = new InvalidOperationException("IPC error");
+                Log.Error(Globals.LogTag, "IPC error");
+                break;
+            case CalendarError.ErrorSystem:
+                exp = new InvalidOperationException("System error");
+                Log.Error(Globals.LogTag, "System error");
+                break;
+            case CalendarError.ErrorInternal:
+                exp = new InvalidOperationException("Internal error");
+                Log.Error(Globals.LogTag, "Internal error");
+                break;
+            default:
+                exp = new InvalidOperationException("Invalid operation");
+                Log.Error(Globals.LogTag, "Invalid operation");
+                break;
+            }
+            return exp;
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarFilter.cs b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarFilter.cs
new file mode 100644 (file)
index 0000000..fd59b0f
--- /dev/null
@@ -0,0 +1,440 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Pims.Calendar
+{
+    /// <summary>
+    /// A filter includes the conditions for the search.
+    /// </summary>
+    public class CalendarFilter:IDisposable
+    {
+        internal IntPtr _filterHandle;
+
+        /// <summary>
+        /// Creates a filter with a condition for a string type.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a filter</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public CalendarFilter(string viewUri, uint propertyId, StringMatchType matchType, string matchValue)
+        {
+            int error = 0;
+            error = Interop.Calendar.Filter.Create(viewUri, out _filterHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+
+            error = Interop.Calendar.Filter.AddString(_filterHandle, propertyId, matchType, matchValue);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Creates a filter with a condition for an integer type.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a filter</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public CalendarFilter(string viewUri, uint propertyId, IntegerMatchType matchType, int matchValue)
+        {
+            int error = 0;
+            error = Interop.Calendar.Filter.Create(viewUri, out _filterHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+
+            error = Interop.Calendar.Filter.AddInteger(_filterHandle, propertyId, matchType, matchValue);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Creates a filter with a condition for long type.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a filter</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public CalendarFilter(string viewUri, uint propertyId, IntegerMatchType matchType, long matchValue)
+        {
+            int error = 0;
+            error = Interop.Calendar.Filter.Create(viewUri, out _filterHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+
+            error = Interop.Calendar.Filter.AddLong(_filterHandle, propertyId, matchType, matchValue);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Creates a filter with a condition for double type.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a filter</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public CalendarFilter(string viewUri, uint propertyId, IntegerMatchType matchType, double matchValue)
+        {
+            int error = 0;
+            error = Interop.Calendar.Filter.Create(viewUri, out _filterHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+
+            error = Interop.Calendar.Filter.AddDouble(_filterHandle, propertyId, matchType, matchValue);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Creates a filter with a condition for CalendarTime type.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a filter</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public CalendarFilter(string viewUri, uint propertyId, IntegerMatchType matchType, CalendarTime matchValue)
+        {
+            int error = 0;
+            error = Interop.Calendar.Filter.Create(viewUri, out _filterHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+
+            Interop.Calendar.Record.DateTime time = CalendarRecord.ConvertCalendarTimeToStruct(matchValue);
+            error = Interop.Calendar.Filter.AddCalendarTime(_filterHandle, propertyId, matchType, time);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        ~CalendarFilter()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// Enumeration for the filter match type of a string.
+        /// </summary>
+        public enum StringMatchType
+        {
+            /// <summary>
+            /// Full string, case-sensitive
+            /// </summary>
+            Exactly,
+            /// <summary>
+            /// Full string, case-insensitive
+            /// </summary>
+            Fullstring,
+            /// <summary>
+            /// Sub string, case-insensitive
+            /// </summary>
+            Contains,
+            /// <summary>
+            /// Start with, case-insensitive
+            /// </summary>
+            Startswith,
+            /// <summary>
+            /// End with, case-insensitive
+            /// </summary>
+            Endswith,
+            /// <summary>
+            /// IS NOT NUL
+            /// </summary>
+            Exists,
+        }
+
+        /// <summary>
+        /// Enumeration for the filter match type of an integer.
+        /// </summary>
+        public enum IntegerMatchType
+        {
+            /// <summary>
+            /// '='
+            /// </summary>
+            Equal,
+            /// <summary>
+            /// '>'
+            /// </summary>
+            GreaterThan,
+            /// <summary>
+            /// '>='
+            /// </summary>
+            GreaterThanOrEqual,
+            /// <summary>
+            /// &lt;
+            /// </summary>
+            LessThan,
+            /// <summary>
+            /// &lt;=
+            /// </summary>
+            LessThanOrEqual,
+            /// <summary>
+            /// &lt;>, this flag can yield poor performance
+            /// </summary>
+            NotEqual,
+            /// <summary>
+            /// IS NULL
+            /// </summary>
+            None,
+        }
+
+        /// <summary>
+        /// Enumeration for a filter operator.
+        /// </summary>
+        public enum LogicalOperator
+        {
+            /// <summary>
+            /// AND
+            /// </summary>
+            And,
+            /// <summary>
+            /// OR
+            /// </summary>
+            Or,
+        }
+
+#region IDisposable Support
+        private bool disposedValue = false; // To detect redundant calls
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!disposedValue)
+            {
+                Log.Debug(Globals.LogTag, "Dispose :" + disposing);
+
+                int error = Interop.Calendar.Filter.Destroy(_filterHandle);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "Destroy Failed with error " + error);
+                    throw CalendarErrorFactory.GetException(error);
+                }
+                disposedValue = true;
+            }
+        }
+
+        /// <summary>
+        /// Releases all resources used by the CalendarFilter.
+        /// It should be called after finished using of the object.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+#endregion
+
+        /// <summary>
+        /// Adds a condition for the string type.
+        /// </summary>
+        /// <param name="logicalOperator">The operator type</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match valu</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddCondition(LogicalOperator logicalOperator, uint propertyId, StringMatchType matchType, string matchValue)
+        {
+            int error = Interop.Calendar.Filter.AddOperator(_filterHandle, logicalOperator);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+
+            error = Interop.Calendar.Filter.AddString(_filterHandle, propertyId, matchType, matchValue);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Adds a condition for the integer type.
+        /// </summary>
+        /// <param name="logicalOperator">The operator type</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match valu</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddCondition(LogicalOperator logicalOperator, uint propertyId, IntegerMatchType matchType, int matchValue)
+        {
+            int error = Interop.Calendar.Filter.AddOperator(_filterHandle, logicalOperator);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+
+            error = Interop.Calendar.Filter.AddInteger(_filterHandle, propertyId, matchType, matchValue);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Adds a condition for the long type.
+        /// </summary>
+        /// <param name="logicalOperator">The operator type</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match valu</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddCondition(LogicalOperator logicalOperator, uint propertyId, IntegerMatchType matchType, long matchValue)
+        {
+            int error = Interop.Calendar.Filter.AddOperator(_filterHandle, logicalOperator);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+
+            error = Interop.Calendar.Filter.AddLong(_filterHandle, propertyId, matchType, matchValue);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Adds a condition for the double type.
+        /// </summary>
+        /// <param name="logicalOperator">The operator type</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match valu</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddCondition(LogicalOperator logicalOperator, uint propertyId, IntegerMatchType matchType, double matchValue)
+        {
+            int error = Interop.Calendar.Filter.AddOperator(_filterHandle, logicalOperator);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+
+            error = Interop.Calendar.Filter.AddDouble(_filterHandle, propertyId, matchType, matchValue);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Adds a condition for the CalendarTime type.
+        /// </summary>
+        /// <param name="logicalOperator">The operator type</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match valu</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddCondition(LogicalOperator logicalOperator, uint propertyId, IntegerMatchType matchType, CalendarTime matchValue)
+        {
+            int error = Interop.Calendar.Filter.AddOperator(_filterHandle, logicalOperator);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+
+            Interop.Calendar.Record.DateTime time = CalendarRecord.ConvertCalendarTimeToStruct(matchValue);
+            error = Interop.Calendar.Filter.AddCalendarTime(_filterHandle, propertyId, matchType, time);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Adds a child filter to a parent filter.
+        /// </summary>
+        /// <param name="logicalOperator">The operator type</param>
+        /// <param name="filter">The child filter</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddFilter(LogicalOperator logicalOperator, CalendarFilter filter)
+        {
+            int error = Interop.Calendar.Filter.AddOperator(_filterHandle, logicalOperator);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+
+            error = Interop.Calendar.Filter.AddFilter(_filterHandle, filter._filterHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "AddFilter Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarList.cs b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarList.cs
new file mode 100644 (file)
index 0000000..fdcf2a9
--- /dev/null
@@ -0,0 +1,245 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Tizen.Pims.Calendar
+{
+    /// <summary>
+    /// A list of records with the same type.
+    /// </summary>
+    public class CalendarList:IDisposable
+    {
+        private Int64 _memoryPressure = 20;
+        internal int _count = -1;
+        internal IntPtr _listHandle;
+
+        internal CalendarList(IntPtr handle)
+        {
+            _listHandle = handle;
+
+            _memoryPressure += this.Count * CalendarViews.AverageSizeOfRecord;
+            GC.AddMemoryPressure(_memoryPressure);
+        }
+
+        /// <summary>
+        /// Creates a calendar list.
+        /// </summary>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public CalendarList()
+        {
+            int error = Interop.Calendar.List.Create(out _listHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "CalendarList Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            GC.AddMemoryPressure(_memoryPressure);
+        }
+
+        ~CalendarList()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// The count of the calendar entity.
+        /// </summary>
+        public int Count
+        {
+            get
+            {
+                if (_count == -1)
+                {
+                    int count = -1;
+                    int error = Interop.Calendar.List.GetCount(_listHandle, out count);
+                    if (CalendarError.None != (CalendarError)error)
+                    {
+                        Log.Error(Globals.LogTag, "GetCount Failed with error " + error);
+                    }
+                    _count = count;
+                }
+                return _count;
+            }
+        }
+
+#region IDisposable Support
+        private bool disposedValue = false; // To detect redundant calls
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!disposedValue)
+            {
+                Log.Debug(Globals.LogTag, "Dispose :" + disposing);
+
+                int error = Interop.Calendar.List.Destroy(_listHandle, true);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "Destroy Failed with error " + error);
+                    throw CalendarErrorFactory.GetException(error);
+                }
+                disposedValue = true;
+                GC.RemoveMemoryPressure(_memoryPressure);
+            }
+        }
+
+        /// <summary>
+        /// Releases all resources used by the CalendarList.
+        /// It should be called after finished using of the object.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+#endregion
+
+        /// <summary>
+        /// Adds a record to the calendar list.
+        /// </summary>
+        /// <param name="record">The record to be added</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddRecord(CalendarRecord record)
+        {
+            int error = Interop.Calendar.List.Add(_listHandle, record._recordHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "AddRecord Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            record._disposedValue = true;
+            _count = -1;
+            _memoryPressure += CalendarViews.AverageSizeOfRecord;
+        }
+
+        /// <summary>
+        /// Removes a record from the calendar list.
+        /// </summary>
+        /// <param name="record">The record to be removed</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void RemoveRecord(CalendarRecord record)
+        {
+            int error = Interop.Calendar.List.Remove(_listHandle, record._recordHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "RemoveRecord Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            record._disposedValue = false;
+            _count = -1;
+            _memoryPressure -= CalendarViews.AverageSizeOfRecord;
+        }
+
+        /// <summary>
+        /// Retrieves a record from the calendar list.
+        /// </summary>
+        /// <returns>
+        /// calendar record
+        /// </returns>
+        public CalendarRecord GetCurrentRecord()
+        {
+            IntPtr handle;
+            int error = Interop.Calendar.List.GetCurrentRecordP(_listHandle, out handle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "GetCurrentRecord Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            return new CalendarRecord(handle, true);
+        }
+
+        /// <summary>
+        /// Moves a calendar list to the previous position.
+        /// </summary>
+        /// <returns>
+        /// if cursor is moved to the end, it returns false.
+        /// </returns>
+        public bool MovePrevious()
+        {
+            int error = Interop.Calendar.List.Prev(_listHandle);
+            if (CalendarError.None == (CalendarError)error)
+            {
+                return true;
+            }
+            else if (this.Count > 0 && CalendarError.NoData == (CalendarError)error)
+            {
+                Log.Debug(Globals.LogTag, "Nodata MovePrevious " + error);
+                return false;
+            }
+            else
+            {
+                Log.Error(Globals.LogTag, "MovePrevious Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Moves a calendar list to the next position.
+        /// </summary>
+        /// <returns>
+        /// if cursor is moved to the end, it returns false.
+        /// </returns>
+        public bool MoveNext()
+        {
+            int error = Interop.Calendar.List.Next(_listHandle);
+            if (CalendarError.None == (CalendarError)error)
+            {
+                return true;
+            }
+            else if (this.Count > 0 && CalendarError.NoData == (CalendarError)error)
+            {
+                Log.Debug(Globals.LogTag, "Nodata MoveNext" + error);
+                return false;
+            }
+            else
+            {
+                Log.Error(Globals.LogTag, "MoveNext Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Moves a calendar list to the first position.
+        /// </summary>
+        public void MoveFirst()
+        {
+            int error = Interop.Calendar.List.First(_listHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "MoveFirst Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Moves a calendar list to the last position.
+        /// </summary>
+        public void MoveLast()
+        {
+            int error = Interop.Calendar.List.Last(_listHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "MoveLast Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarManager.cs b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarManager.cs
new file mode 100644 (file)
index 0000000..af6ef04
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using static Interop.Calendar.Service;
+
+namespace Tizen.Pims.Calendar
+{
+    /// <summary>
+    /// A class for managing calendar information. It allows applications to use calendar service.
+    /// </summary>
+    public class CalendarManager : IDisposable
+    {
+        private CalendarDatabase _db = null;
+
+        /// <summary>
+        /// Create a manager.
+        /// </summary>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        public CalendarManager()
+        {
+            int error = Interop.Calendar.Service.Connect();
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "Connect Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            _db = new CalendarDatabase();
+        }
+
+        ~CalendarManager()
+        {
+            Dispose(false);
+        }
+
+#region IDisposable Support
+        /// To detect redundant calls
+        private bool disposedValue = false;
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!disposedValue)
+            {
+                Log.Debug(Globals.LogTag, "Dispose :" + disposing);
+
+                int error = Interop.Calendar.Service.Disconnect();
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "Disconnect Failed with error " + error);
+                    throw CalendarErrorFactory.GetException(error);
+                }
+                disposedValue = true;
+            }
+        }
+
+        /// <summary>
+        /// Releases all resources used by the CalendarManager.
+        /// It should be called after finished using of the object.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+#endregion
+
+        /// <summary>
+        /// Get database.
+        /// </summary>
+        public CalendarDatabase Database
+        {
+            get
+            {
+                return _db;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarQuery.cs b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarQuery.cs
new file mode 100644 (file)
index 0000000..941699a
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using static Interop.Calendar.Query;
+
+namespace Tizen.Pims.Calendar
+{
+    /// A query is used to retrieve data which satisfies given criteria.
+    /// </summary>
+    /// <remarks>
+    /// A query is used to retrieve calendar data which satisfies a given criteria,
+    /// such as an integer property being greater than a given value,
+    /// or a string property containing a given substring.
+    /// A query needs a filter which can set the conditions for the search.
+    /// </remarks>
+    public class CalendarQuery : IDisposable
+    {
+        internal IntPtr _queryHandle;
+
+        /// <summary>
+        /// Creates a query.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a query</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public CalendarQuery(string viewUri)
+        {
+            int error = Interop.Calendar.Query.Create(viewUri, out _queryHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "CalendarQuery Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        internal CalendarQuery(IntPtr handle)
+        {
+            _queryHandle = handle;
+        }
+
+        ~CalendarQuery()
+        {
+            Dispose(false);
+        }
+
+#region IDisposable Support
+        private bool disposedValue = false;
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!disposedValue)
+            {
+                Log.Debug(Globals.LogTag, "Dispose :" + disposing);
+
+                int error = Interop.Calendar.Query.Destroy(_queryHandle);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "CalendarQueryDestroy Failed with error " + error);
+                    throw CalendarErrorFactory.GetException(error);
+                }
+                disposedValue = true;
+            }
+        }
+
+        /// <summary>
+        /// Releases all resources used by the CalendarQuery.
+        /// It should be called after finished using of the object.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+#endregion
+
+        /// <summary>
+        /// Adds property IDs for projection.
+        /// </summary>
+        /// <param name="propertyIdArray">The property ID array </param>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void SetProjection(uint[] propertyIdArray)
+        {
+            int error = Interop.Calendar.Query.SetProjection(_queryHandle, propertyIdArray, propertyIdArray.Length);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "SetProjection Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Sets the "distinct" option for projection.
+        /// </summary>
+        /// <param name="set">If true it is set, otherwise if false it is unset</param>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void SetDistinct(bool set)
+        {
+            int error = Interop.Calendar.Query.SetDistinct(_queryHandle, set);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "SetDistinct Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Sets the filter for a query.
+        /// </summary>
+        /// <param name="filter">The filter</param>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void SetFilter(CalendarFilter filter)
+        {
+            int error = Interop.Calendar.Query.SetFilter(_queryHandle, filter._filterHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "SetFilter Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+
+        /// <summary>
+        /// Sets the sort mode for a query.
+        /// </summary>
+        /// <param name="propertyId">The property ID to sort</param>
+        /// <param name="isAscending">If true it sorts in the ascending order, otherwise if false it sorts in the descending order</param>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void SetSort(uint propertyId, bool isAscending)
+        {
+            int error = Interop.Calendar.Query.SetSort(_queryHandle, propertyId, isAscending);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "SetSort Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarRecord.cs b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarRecord.cs
new file mode 100644 (file)
index 0000000..224ff4e
--- /dev/null
@@ -0,0 +1,452 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Pims.Calendar
+{
+    /// <summary>
+    /// A record represents an actual record in the database
+    /// </summary>
+    /// <remarks>
+    /// A record represents an actual record in the database,
+    /// but you can also consider it a piece of information, such as an alarm, attendee and extended.
+    /// A record can be a complex set of data, containing other data.
+    /// For example, a calendar record contains the alarm property, which is a reference to an alarm record.
+    /// An alarm record could belong to a event record,
+    /// and its alarm id property is set to the identifier of the corresponding event.
+    /// In this case, the alarm is the child record of the event and the event is the parent record.
+    /// </remarks>
+    public class CalendarRecord : IDisposable
+    {
+        internal string _uri;
+        internal uint _id;
+        private Int64 _memoryPressure = CalendarViews.AverageSizeOfRecord;
+        internal IntPtr _recordHandle;
+
+        internal CalendarRecord(IntPtr handle)
+        {
+            _recordHandle = handle;
+
+            IntPtr viewUri;
+            int error = Interop.Calendar.Record.GetUriPointer(handle, out viewUri);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "GetUriPointer Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            _uri = Marshal.PtrToStringAnsi(viewUri);
+            GC.AddMemoryPressure(_memoryPressure);
+        }
+
+        internal CalendarRecord(IntPtr handle, bool disposedValue)
+        {
+            _recordHandle = handle;
+            _disposedValue = disposedValue;
+
+            IntPtr viewUri;
+            int error = Interop.Calendar.Record.GetUriPointer(handle, out viewUri);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "GetUriPointer Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            _uri = Marshal.PtrToStringAnsi(viewUri);
+            if (!_disposedValue)
+                GC.AddMemoryPressure(_memoryPressure);
+        }
+
+        internal CalendarRecord(IntPtr handle, int id)
+        {
+            _recordHandle = handle;
+            _id = (uint)id;
+
+            IntPtr viewUri;
+            int error = Interop.Calendar.Record.GetUriPointer(handle, out viewUri);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "GetUriPointer Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            _uri = Marshal.PtrToStringAnsi(viewUri);
+            GC.AddMemoryPressure(_memoryPressure);
+        }
+
+        /// <summary>
+        /// Creates a record.
+        /// </summary>
+        /// <param name="viewUri">The view URI</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public CalendarRecord(string viewUri)
+        {
+            int error = 0;
+            error = Interop.Calendar.Record.Create(viewUri, out _recordHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "CalendarRecord Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            _uri = viewUri;
+            GC.AddMemoryPressure(_memoryPressure);
+        }
+
+        ~CalendarRecord()
+        {
+            Dispose(false);
+        }
+
+#region IDisposable Support
+        /// To detect redundant calls
+        internal bool _disposedValue = false;
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!_disposedValue)
+            {
+                Log.Debug(Globals.LogTag, "Dispose :" + disposing);
+
+                int error = Interop.Calendar.Record.Destroy(_recordHandle, false);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "Destroy Failed with error " + error);
+                    throw CalendarErrorFactory.GetException(error);
+                }
+                _disposedValue = true;
+                GC.RemoveMemoryPressure(_memoryPressure);
+            }
+        }
+
+        /// <summary>
+        /// Releases all resources used by the CalendarRecord.
+        /// It should be called after finished using of the object.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+#endregion
+
+        internal static Interop.Calendar.Record.DateTime ConvertCalendarTimeToStruct(CalendarTime value)
+        {
+            Interop.Calendar.Record.DateTime time = new Interop.Calendar.Record.DateTime();
+            time.type = value._type;
+
+            if ((int)CalendarTime.Type.Utc == value._type)
+            {
+                DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0);
+                time.utime = (value.UtcTime.Ticks - epoch.Ticks) / 10000000;
+            }
+            else
+            {
+                time.year = value.LocalTime.Year;
+                time.month = value.LocalTime.Month;
+                time.mday = value.LocalTime.Day;
+                time.hour = value.LocalTime.Hour;
+                time.minute = value.LocalTime.Minute;
+                time.second = value.LocalTime.Second;
+            }
+            return time;
+        }
+
+        internal static CalendarTime ConvertIntPtrToCalendarTime(Interop.Calendar.Record.DateTime time)
+        {
+            CalendarTime value;
+            if ((int)CalendarTime.Type.Utc == time.type)
+            {
+                DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0);
+                value = new CalendarTime(time.utime * 10000000 + epoch.Ticks);
+            }
+            else
+            {
+                value = new CalendarTime(time.year, time.month, time.mday, time.hour, time.minute, time.second);
+            }
+            value._type = time.type;
+            return value;
+        }
+
+        /// <summary>
+        /// Makes a clone of a record.
+        /// </summary>
+        /// <returns>
+        /// A cloned record
+        /// </returns>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public CalendarRecord Clone()
+        {
+            IntPtr _clonedRecordHandle;
+            int error = Interop.Calendar.Record.Clone(_recordHandle, out _clonedRecordHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "Clone Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            return new CalendarRecord(_clonedRecordHandle, (int)_id);
+        }
+
+        /// <summary>
+        /// The URI of the record
+        /// </summary>
+        public string Uri
+        {
+            get
+            {
+                return _uri;
+            }
+        }
+
+        /// <summary>
+        /// Gets a object from a record.
+        /// </summary>
+        /// <param name="propertyId">The property ID</param>
+        /// <returns>
+        /// The value of the property corresponding to property id.
+        /// </returns>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public T Get<T>(uint propertyId)
+        {
+            object parsedValue = null;
+            if (typeof(T) == typeof(string))
+            {
+                string val;
+                int error = Interop.Calendar.Record.GetString(_recordHandle, propertyId, out val);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "Get String Failed [" + error + "]" + String.Format("{0:X}", propertyId));
+                    throw CalendarErrorFactory.GetException(error);
+                }
+                parsedValue = Convert.ChangeType(val, typeof(T));
+            }
+            else if (typeof(T) == typeof(int))
+            {
+                int val;
+                int error = Interop.Calendar.Record.GetInteger(_recordHandle, propertyId, out val);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "Get Intger Failed [" + error + "]" + String.Format("{0:X}", propertyId));
+                    throw CalendarErrorFactory.GetException(error);
+                }
+                parsedValue = Convert.ChangeType(val, typeof(T));
+            }
+            else if (typeof(T) == typeof(long))
+            {
+                long val;
+                int error = Interop.Calendar.Record.GetLli(_recordHandle, propertyId, out val);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "Get Long Failed [" + error + "]" + String.Format("{0:X}", propertyId));
+                    throw CalendarErrorFactory.GetException(error);
+                }
+                parsedValue = Convert.ChangeType(val, typeof(T));
+            }
+            else if (typeof(T) == typeof(double))
+            {
+                double val;
+                int error = Interop.Calendar.Record.GetDouble(_recordHandle, propertyId, out val);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "Get Double Failed [" + error + "]" + String.Format("{0:X}", propertyId));
+                    throw CalendarErrorFactory.GetException(error);
+                }
+                parsedValue = Convert.ChangeType(val, typeof(T));
+            }
+            else if (typeof(T) == typeof(CalendarTime))
+            {
+                Interop.Calendar.Record.DateTime time;
+                int error = Interop.Calendar.Record.GetCalendarTime(_recordHandle, propertyId, out time);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "Get CalendarTime Failed [" + error + "]" + String.Format("{0:X}", propertyId));
+                    throw CalendarErrorFactory.GetException(error);
+                }
+                CalendarTime val = ConvertIntPtrToCalendarTime(time);
+                parsedValue = Convert.ChangeType(val, typeof(T));
+            }
+            else
+            {
+                Log.Error(Globals.LogTag, "Not supported Data T/ype");
+                throw CalendarErrorFactory.GetException((int)CalendarError.NotSupported);
+            }
+            return (T)parsedValue;
+        }
+
+        /// <summary>
+        /// Sets a value of the property to a record.
+        /// </summary>
+        /// <param name="propertyId">The property ID</param>
+        /// <param name="value">value</param>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void Set<T>(uint propertyId, T value)
+        {
+            if (typeof(T) == typeof(string))
+            {
+                string val = Convert.ToString(value);
+                int error = Interop.Calendar.Record.SetString(_recordHandle, propertyId, val);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "Set String Failed [" + error + "]" + String.Format("{0:X}", propertyId));
+                    throw CalendarErrorFactory.GetException(error);
+                }
+            }
+            else if (typeof(T) == typeof(int))
+            {
+                int val = Convert.ToInt32(value);
+                int error = Interop.Calendar.Record.SetInteger(_recordHandle, propertyId, val);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "Set Integer Failed [" + error + "]" + String.Format("{0:X}", propertyId));
+                    throw CalendarErrorFactory.GetException(error);
+                }
+            }
+            else if (typeof(T) == typeof(long))
+            {
+                long val = Convert.ToInt64(value);
+                int error = Interop.Calendar.Record.SetLli(_recordHandle, propertyId, val);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "Set Long Failed [" + error + "]" + String.Format("{0:X}", propertyId));
+                    throw CalendarErrorFactory.GetException(error);
+                }
+            }
+            else if (typeof(T) == typeof(double))
+            {
+                double val = Convert.ToDouble(value);
+                int error = Interop.Calendar.Record.SetDouble(_recordHandle, propertyId, val);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "Set Double Failed [" + error + "]" + String.Format("{0:X}", propertyId));
+                    throw CalendarErrorFactory.GetException(error);
+                }
+            }
+            else if (typeof(T) == typeof(CalendarTime))
+            {
+                CalendarTime time = (CalendarTime)Convert.ChangeType(value, typeof(CalendarTime));
+                Interop.Calendar.Record.DateTime val = ConvertCalendarTimeToStruct(time);
+                int error = Interop.Calendar.Record.SetCalendarTime(_recordHandle, propertyId, val);
+                if (CalendarError.None != (CalendarError)error)
+                {
+                    Log.Error(Globals.LogTag, "Set CalendarTime Failed [" + error + "]" + String.Format("{0:X}", propertyId));
+                    throw CalendarErrorFactory.GetException(error);
+                }
+            }
+            else
+            {
+                Log.Error(Globals.LogTag, "Not supported Data T/ype");
+                throw CalendarErrorFactory.GetException((int)CalendarError.NotSupported);
+            }
+        }
+
+        /// <summary>
+        /// Adds a child record to the parent record.
+        /// </summary>
+        /// <param name="propertyId">The property ID</param>
+        /// <param name="childRecord">The child record</param>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddChildRecord(uint propertyId, CalendarRecord childRecord)
+        {
+            int error = Interop.Calendar.Record.AddChildRecord(_recordHandle, propertyId, childRecord._recordHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "AddChildRecord Failed [" + error + "]" + String.Format("{0:X}", propertyId));
+                throw CalendarErrorFactory.GetException(error);
+            }
+            childRecord._disposedValue = true;
+        }
+
+        /// <summary>
+        /// Removes a child record from the parent record.
+        /// </summary>
+        /// <param name="propertyId">The property ID</param>
+        /// <param name="childRecord">The child record</param>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void RemoveChildRecord(uint propertyId, CalendarRecord childRecord)
+        {
+            int error = Interop.Calendar.Record.RemoveChildRecord(_recordHandle, propertyId, childRecord._recordHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "RemoveChildRecord Failed [" + error + "]" + String.Format("{0:X}", propertyId));
+                throw CalendarErrorFactory.GetException(error);
+            }
+            childRecord._disposedValue = false;
+        }
+
+        /// <summary>
+        /// Gets a child record from the parent record
+        /// </summary>
+        /// <param name="propertyId">The property ID</param>
+        /// <returns>
+        /// The number of child records corresponding to property ID
+        /// </returns>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public int GetChildRecordCount(uint propertyId)
+        {
+            int count = 0;
+            int error = Interop.Calendar.Record.GetChildRecordCount(_recordHandle, propertyId, out count);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "GetChildRecordCount Failed [" + error + "]" + String.Format("{0:X}", propertyId));
+                throw CalendarErrorFactory.GetException(error);
+            }
+            return count;
+        }
+
+        /// <summary>
+        /// Gets a child record from the parent record
+        /// </summary>
+        /// <param name="propertyId">The property ID</param>
+        /// <param name="index">The child record index</param>
+        /// <returns>
+        /// The record
+        /// </returns>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public CalendarRecord GetChildRecord(uint propertyId, int index)
+        {
+            IntPtr handle;
+
+            int error = Interop.Calendar.Record.GetChildRecordPointer(_recordHandle, propertyId, index, out handle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "GetChildRecord Failed [" + error + "]" + String.Format("{0:X}", propertyId));
+                throw CalendarErrorFactory.GetException(error);
+            }
+            return new CalendarRecord(handle, true);
+        }
+
+        /// <summary>
+        /// Clones a child record list corresponding to property ID
+        /// </summary>
+        /// <param name="propertyId">The property ID</param>
+        /// <returns>
+        /// the record list
+        /// </returns>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public CalendarList CloneChildRecordList(uint propertyId)
+        {
+            IntPtr listHandle;
+            int error = Interop.Calendar.Record.CloneChildRecordList(_recordHandle, propertyId, out listHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "CloneChildRecordList Failed with [" + error + "]" + String.Format("{0:X}", propertyId));
+                throw CalendarErrorFactory.GetException(error);
+            }
+            CalendarList list = new CalendarList(listHandle);
+            return list;
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarReminder.cs b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarReminder.cs
new file mode 100644 (file)
index 0000000..f1193ef
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using static Interop.Calendar.Reminder;
+
+namespace Tizen.Pims.Calendar
+{
+    /// <summary>
+    /// A class for reminder for event.
+    /// </summary>
+    /// <remarks>
+    /// The client who wants to be alerted at specific time should register MIME("application/x-tizen.calendar.reminder") type in manifest.xml file.
+    /// </remarks>
+    public class CalendarReminder : IDisposable
+    {
+#region IDisposable Support
+        private bool disposedValue = false;
+
+        internal CalendarReminder()
+        {
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!disposedValue)
+            {
+                disposedValue = true;
+            }
+        }
+
+        /// <summary>
+        /// Releases all resources used by the CalendarReminder.
+        /// It should be called after finished using of the object.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+#endregion
+
+        private static readonly Interop.Calendar.Reminder.ReminderAlertedCallback _reminderAlertedCallback = (string param, IntPtr userData) =>
+        {
+            ReminderAlertedEventArgs args = new ReminderAlertedEventArgs(param);
+            s_reminderAlerted?.Invoke(null, args);
+        };
+
+        private static event EventHandler<ReminderAlertedEventArgs> s_reminderAlerted;
+
+        /// <summary>
+        /// Reminder event is triggered when the alarm is alerted.
+        /// </summary>
+        public static event EventHandler<ReminderAlertedEventArgs> ReminderAlerted
+        {
+            add
+            {
+                Log.Debug(Globals.LogTag, "Add Reminder");
+
+                if (s_reminderAlerted == null)
+                {
+                    int error = Interop.Calendar.Reminder.Add(_reminderAlertedCallback, IntPtr.Zero);
+                    if (CalendarError.None != (CalendarError)error)
+                    {
+                        Log.Error(Globals.LogTag, "Add reminder Failed with error " + error);
+                        throw CalendarErrorFactory.GetException(error);
+                    }
+                }
+                s_reminderAlerted += value;
+            }
+
+            remove
+            {
+                Log.Debug(Globals.LogTag, "Remove Reminder");
+
+                s_reminderAlerted -= value;
+                if (s_reminderAlerted == null)
+                {
+                    /// _reminderAlertedCallback is removed by .Net Core
+                    int error = Interop.Calendar.Reminder.Remove(_reminderAlertedCallback, IntPtr.Zero);
+                    if (CalendarError.None != (CalendarError)error)
+                    {
+                        Log.Error(Globals.LogTag, "Remove reminder Failed with error " + error);
+                        throw CalendarErrorFactory.GetException(error);
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarStructs.cs b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarStructs.cs
new file mode 100644 (file)
index 0000000..3ac883c
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Pims.Calendar
+{
+    /// <summary>
+    /// A class for time to set, get or calcurate.
+    /// </summary>
+    public class CalendarTime : IComparable<CalendarTime>
+    {
+        internal int _type;
+        internal const int milliseconds = 10000000;
+
+        /// <summary>
+        /// Enumeration for the time type.
+        /// </summary>
+        public enum Type
+        {
+            /// <summary>
+            /// UTC time
+            /// </summary>
+            Utc,
+            /// <summary>
+            /// Local time
+            /// </summary>
+            Local
+        }
+
+        /// <summary>
+        /// Create UTC CalendarTime
+        /// </summary>
+        /// <param name="utcTime">UTC epoch time. 0 is 1971/01/01</param>
+        public CalendarTime(long utcTime)
+        {
+            _type = (int)Type.Utc;
+            utcTime -= utcTime % milliseconds; /* delete millisecond */
+            UtcTime = new DateTime(utcTime);
+        }
+
+        /// <summary>
+        /// Create Local CalendarTime
+        /// </summary>
+        /// <param name="year">year</param>
+        /// <param name="month">month</param>
+        /// <param name="day">day</param>
+        /// <param name="hour">hour</param>
+        /// <param name="minute">minute</param>
+        /// <param name="second">second</param>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public CalendarTime(int year, int month, int day, int hour, int minute, int second)
+        {
+            _type = (int)Type.Local;
+            LocalTime = new DateTime(year, month, day, hour, minute, second);
+        }
+
+        /// <summary>
+        /// Get utcTime
+        /// </summary>
+        public DateTime UtcTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Get localTime
+        /// </summary>
+        public DateTime LocalTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Compare CalendarTime
+        /// </summary>
+        /// <param name="t">The CalendarTime to be compared</param>
+        /// <returns>
+        /// A 32-bit signed integer that indicates the relative order of the objects being compared.
+        /// </returns>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public int CompareTo(CalendarTime t)
+        {
+            if (_type != t._type)
+            {
+                Log.Error(Globals.LogTag, "Not to compare with different type");
+                throw CalendarErrorFactory.GetException((int)CalendarError.InvalidParameter);
+            }
+
+            if (_type == (int)Type.Utc)
+                return UtcTime.CompareTo(t.UtcTime);
+            else
+                return LocalTime.CompareTo(t.LocalTime);
+        }
+    }
+}
+
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarTypes.cs b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarTypes.cs
new file mode 100644 (file)
index 0000000..560e898
--- /dev/null
@@ -0,0 +1,458 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+/// <summary>
+/// </summary>
+/// <remarks>
+/// </remarks>
+namespace Tizen.Pims.Calendar
+{
+       /// <summary>
+       /// </summary>
+       public static class CalendarTypes
+       {
+               /// <summary>
+               /// Enumeration for Default book
+               /// </summary>
+               public enum DefaultBook
+               {
+                       /// <summary>
+                       /// Default event calendar book.
+                       /// </summary>
+                       Event,
+                       /// <summary>
+                       /// Default Todo calendar book.
+                       /// </summary>
+                       Todo,
+                       /// <summary>
+                       /// Default Birthday calendar book.
+                       /// </summary>
+                       Birthday,
+               }
+
+               /// <summary>
+               /// Enumeration for Store type
+               /// </summary>
+               public enum StoreType
+               {
+                       /// <summary>
+                       /// Book type
+                       /// </summary>
+                       Book,
+                       /// <summary>
+                       /// Event type
+                       /// </summary>
+                       Event,
+                       /// <summary>
+                       /// Todo type
+                       /// </summary>
+                       Todo,
+               }
+
+               /// <summary>
+               /// Enumeration for the book mode.
+               /// </summary>
+               public enum BookMode
+               {
+                       /// <summary>
+                       /// All modules can read and write records of this calendar_book
+                       /// </summary>
+                       Default,
+                       /// <summary>
+                       /// All modules can only read records of this calendar book
+                       /// </summary>
+                       ReadOnly,
+               }
+
+               /// <summary>
+               /// Enumeration for the event status.
+               /// </summary>
+               public enum EventStatus
+               {
+                       /// <summary>
+                       /// No status
+                       /// </summary>
+                       None = 0x01,
+                       /// <summary>
+                       /// The event is tentative
+                       /// </summary>
+                       Tentative = 0x02,
+                       /// <summary>
+                       /// The event is confirmed
+                       /// </summary>
+                       Confirmed = 0x04,
+                       /// <summary>
+                       /// The event is canceled
+                       /// </summary>
+                       Cancelled = 0x08,
+               }
+
+               /// <summary>
+               /// Enumeration for for the status of a to-do.
+               /// </summary>
+               public enum TodoStatus
+               {
+                       /// <summary>
+                       /// No status
+                       /// </summary>
+                       None = 0x0100,
+                       /// <summary>
+                       /// Needs action status
+                       /// </summary>
+                       NeedAction = 0x0200,
+                       /// <summary>
+                       /// Completed status
+                       /// </summary>
+                       Completed = 0x0400,
+                       /// <summary>
+                       /// Work in process status
+                       /// </summary>
+                       InProcess = 0x0800,
+                       /// <summary>
+                       /// Canceled status
+                       /// </summary>
+                       Canceled = 0x1000,
+               }
+
+               /// <summary>
+               /// Enumeration for the busy status of an event.
+               /// </summary>
+               public enum BusyStatus
+               {
+                       /// <summary>
+                       /// The free status
+                       /// </summary>
+                       Free,
+                       /// <summary>
+                       /// The busy status
+                       /// </summary>
+                       Busy,
+                       /// <summary>
+                       /// The unavailable status
+                       /// </summary>
+                       Unavailable,
+                       /// <summary>
+                       /// The tentative status
+                       /// </summary>
+                       Tentative,
+               }
+
+               /// <summary>
+               /// Enumeration for the calendar sensitivity type.
+               /// </summary>
+               public enum Sensitivity
+               {
+                       /// <summary>
+                       /// Public Sensitivity
+                       /// </summary>
+                       Public,
+                       /// <summary>
+                       /// Private Sensitivity
+                       /// </summary>
+                       Private,
+                       /// <summary>
+                       /// Confidential Sensitivity
+                       /// </summary>
+                       Confidential,
+               }
+
+               /// <summary>
+               /// Enumeration for the meeting status.
+               /// </summary>
+               public enum MeetingStatus
+               {
+                       /// <summary>
+                       /// No meeting
+                       /// </summary>
+                       Notmeeting,
+                       /// <summary>
+                       /// Meeting exists
+                       /// </summary>
+                       Meeting,
+                       /// <summary>
+                       /// Meeting received
+                       /// </summary>
+                       Received,
+                       /// <summary>
+                       /// Meeting canceled
+                       /// </summary>
+                       Canceled,
+               }
+
+               /// <summary>
+               /// Enumeration for the calendar event item's priority
+               /// </summary>
+               public enum Priority
+               {
+                       /// <summary>
+                       /// No priority
+                       /// </summary>
+                       None = 0x01,
+                       /// <summary>
+                       /// Low priority
+                       /// </summary>
+                       High = 0x02,
+                       /// <summary>
+                       /// Normal priority
+                       /// </summary>
+                       Normal = 0x04,
+                       /// <summary>
+                       /// High priority
+                       /// </summary>
+                       Low = 0x08,
+               }
+
+               /// <summary>
+               /// Enumeration for the frequency of an event's recurrence.
+               /// </summary>
+               public enum Recurrence
+               {
+                       /// <summary>
+                       /// No recurrence event
+                       /// </summary>
+                       None,
+                       /// <summary>
+                       /// An event occurs every day
+                       /// </summary>
+                       Daily,
+                       /// <summary>
+                       /// An event occurs on the same day of every week. According to the week flag, the event will recur every day of the week
+                       /// </summary>
+                       Weekly,
+                       /// <summary>
+                       /// An event occurs on the same day of every month
+                       /// </summary>
+                       Monthly,
+                       /// <summary>
+                       /// An event occurs on the same day of every year
+                       /// </summary>
+                       Yearly,
+               }
+
+               /// <summary>
+               /// Enumeration for the range type.
+               /// </summary>
+               public enum RangeType
+               {
+                       /// <summary>
+                       /// Range until
+                       /// </summary>
+                       Until,
+                       /// <summary>
+                       /// Range count
+                       /// </summary>
+                       Count,
+                       /// <summary>
+                       /// No range
+                       /// </summary>
+                       None,
+               }
+
+               /// <summary>
+               /// Enumeration for the system type.
+               /// </summary>
+               public enum SystemType
+               {
+                       /// <summary>
+                       /// Locale's default calendar
+                       /// </summary>
+                       Default,
+                       /// <summary>
+                       /// Locale's default calendar
+                       /// </summary>
+                       Gregorian,
+                       /// <summary>
+                       /// East asian lunisolar calendar
+                       /// </summary>
+                       Lunisolar,
+               }
+
+               /// <summary>
+               /// Enumeration for the alarm time unit type of an event, such as minutes, hours, days, and so on.
+               /// </summary>
+               public enum TickUnit
+               {
+                       /// <summary>
+                       /// No reminder set
+                       /// </summary>
+                       None = -1,
+                       /// <summary>
+                       /// Specific in seconds
+                       /// </summary>
+                       Specific = 1,
+                       /// <summary>
+                       /// Alarm time unit in minutes
+                       /// </summary>
+                       Minute = 60,
+                       /// <summary>
+                       /// Alarm time unit in hours
+                       /// </summary>
+                       Hour = 3600,
+                       /// <summary>
+                       /// Alarm time unit in days
+                       /// </summary>
+                       Day = 86400,
+                       /// <summary>
+                       /// Alarm time unit in weeks
+                       /// </summary>
+                       Week = 604800,
+               }
+
+               /// <summary>
+               /// Enumeration for weekdays.
+               /// </summary>
+               public enum WeekDay
+               {
+                       /// <summary>
+                       /// Sunday
+                       /// </summary>
+                       Sunday = 1,
+                       /// <summary>
+                       /// Monday
+                       /// </summary>
+                       Monday,
+                       /// <summary>
+                       /// Tuesday
+                       /// </summary>
+                       Thuesday,
+                       /// <summary>
+                       /// Wednesday
+                       /// </summary>
+                       Wednesday,
+                       /// <summary>
+                       /// Thursday
+                       /// </summary>
+                       Thurday,
+                       /// <summary>
+                       /// Friday
+                       /// </summary>
+                       Friday,
+                       /// <summary>
+                       /// Saturday
+                       /// </summary>
+                       Saterday,
+               }
+
+               /// <summary>
+               /// Enumeration for the attendee cutype.
+               /// </summary>
+               public enum Cutype
+               {
+                       /// <summary>
+                       /// Individual cutype
+                       /// </summary>
+                       Individual,
+                       /// <summary>
+                       /// Group cutype
+                       /// </summary>
+                       Group,
+                       /// <summary>
+                       /// Resource cutype
+                       /// </summary>
+                       Recource,
+                       /// <summary>
+                       /// Room cutype
+                       /// </summary>
+                       Room,
+                       /// <summary>
+                       /// Unknown cutype
+                       /// </summary>
+                       Unknown,
+               }
+
+               /// <summary>
+               /// Enumeration for the attendee role.
+               /// </summary>
+               public enum AttendeeRole
+               {
+                       /// <summary>
+                       /// Participation is required
+                       /// </summary>
+                       ReqParticipant,
+                       /// <summary>
+                       /// Accepted status
+                       /// </summary>
+                       OptParticipant,
+                       /// <summary>
+                       /// Non-Participant
+                       /// </summary>
+                       NonParticipant,
+                       /// <summary>
+                       /// Chairperson
+                       /// </summary>
+                       Chair,
+               }
+
+               /// <summary>
+               /// Enumeration for the attendee status.
+               /// </summary>
+               public enum AttendeeStatus
+               {
+                       /// <summary>
+                       /// Pending status
+                       /// </summary>
+                       Pending,
+                       /// <summary>
+                       /// Accepted status
+                       /// </summary>
+                       Accepted,
+                       /// <summary>
+                       /// Declined status
+                       /// </summary>
+                       Declined,
+                       /// <summary>
+                       /// Tentative status
+                       /// </summary>
+                       Tentative,
+                       /// <summary>
+                       /// Delegated status
+                       /// </summary>
+                       Delegated,
+                       /// <summary>
+                       /// Completed status
+                       /// </summary>
+                       Completed,
+                       /// <summary>
+                       /// In process status
+                       /// </summary>
+                       InProcess,
+               }
+
+               /// <summary>
+               /// Enumeration for the alarm action.
+               /// </summary>
+               public enum Action
+               {
+                       /// <summary>
+                       /// Audio action
+                       /// </summary>
+                       Audio,
+                       /// <summary>
+                       /// Display action
+                       /// </summary>
+                       Display,
+                       /// <summary>
+                       /// Email action
+                       /// </summary>
+                       Email,
+               }
+       }
+}
+
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarVcalendar.cs b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarVcalendar.cs
new file mode 100644 (file)
index 0000000..1a7a3a8
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Tizen.Pims.Calendar
+{
+    /// <summary>
+    /// A class for parsing and composing vCalendar.
+    /// </summary>
+    /// <remarks>
+    /// It's based on the vCalendar v2.0 specification
+    /// </remarks>
+    public class CalendarVcalendar
+    {
+        internal CalendarVcalendar()
+        {
+        }
+
+        public delegate bool ParseDelegate(CalendarRecord record);
+
+        /// <summary>
+        /// Retrieves a vcalendar stream from a calendar list.
+        /// </summary>
+        /// <param name="list">The calendar list</param>
+        /// <returns>
+        /// The composed stream.
+        /// </returns>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public static string Compose(CalendarList list)
+        {
+            string stream;
+            int error = Interop.Calendar.Vcalendar.Compose(list._listHandle, out stream);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "MakeVcalendar Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+            return stream;
+        }
+
+        /// <summary>
+        /// Retrieves all calendars from a vcalendar stream.
+        /// </summary>
+        /// <param name="stream">The vcalendar stream</param>
+        /// <returns>
+        /// the record list
+        /// </returns>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public static CalendarList Parse(string stream)
+        {
+            int error = 0;
+            IntPtr _listHandle;
+            error = Interop.Calendar.Vcalendar.Parse(stream, out _listHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "Parse Vcalendar Failed [" + error + "]");
+                throw CalendarErrorFactory.GetException(error);
+            }
+            return new CalendarList(_listHandle);
+        }
+
+        /// <summary>
+        /// Parse vcalendar file with foreach
+        /// </summary>
+        /// <param name="path">The file path of the vCalendar stream file</param>
+        /// <param name="callback">he callback function to invoke</param>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public static void ParseForEach(string path, ParseDelegate callback)
+        {
+            int error = 0;
+
+            Interop.Calendar.Vcalendar.ParseCallback cb = (IntPtr handle, IntPtr data) =>
+            {
+                return callback(new CalendarRecord(handle, true));
+            };
+
+            error = Interop.Calendar.Vcalendar.ParseForEach(path, cb, IntPtr.Zero);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "Parse foreach Vcalendar Failed [" + error + "]");
+                throw CalendarErrorFactory.GetException(error);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarViews.cs b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarViews.cs
new file mode 100644 (file)
index 0000000..b4ddd17
--- /dev/null
@@ -0,0 +1,1448 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Tizen.Pims.Calendar
+{
+    /// <summary>
+    /// This class provides information about views with properties.
+    /// </summary>
+    /// <remarks>
+    ///  A view is a class which describes properties of a record.
+    ///  A record can have basic properties of five types: integer, string, long, double, CalendarTime.
+    /// </remarks>
+    public static class CalendarViews
+    {
+        /// data type mask 0x0FF00000
+        private const uint ViewMask                          = 0xFF000000;
+        private const uint ViewBook                          = 0x01000000;
+        private const uint ViewEvent                         = 0x02000000;
+        private const uint ViewTodo                          = 0x03000000;
+        private const uint ViewTimezone                      = 0x04000000;
+        private const uint ViewAttendee                      = 0x05000000;
+        private const uint ViewAlarm                         = 0x06000000;
+        private const uint ViewInstanceUtimeBook             = 0x07000000;
+        private const uint ViewInstanceLocaltimeBook         = 0x08000000;
+        private const uint ViewUpdateInfo                    = 0x09000000;
+        private const uint ViewExtended                      = 0x0A000000;
+        private const uint ViewInstanceUtimeBookExtended     = 0x0B000000;
+        private const uint ViewInstanceLocaltimeBookExtended = 0x0C000000;
+
+        private const uint DataTypeMask    = 0x000FF000;
+        private const uint DataTypeInteger = 0x00001000;
+        private const uint DataTypeString  = 0x00002000;
+        private const uint DataTypeDouble  = 0x00003000;
+        private const uint DataTypeLong    = 0x00004000;
+        private const uint DataTypeCaltime = 0x00005000;
+        private const uint DataTypeRecord  = 0x00006000;
+
+        /// property : mask 0x0000F000
+        private const uint PropertyMask       = 0x00F00000;
+        private const uint PropertyFilter     = 0x00100000;
+        private const uint PropertyProjection = 0x00200000;
+        private const uint PropertyReadOnly   = 0x00300000;
+
+        private enum PropertyIds : uint
+        {
+            /// book
+            BookId          = (ViewBook|DataTypeInteger|PropertyReadOnly),
+            BookUid         = (ViewBook|DataTypeString) + 1,
+            BookName        = (ViewBook|DataTypeString) + 2,
+            BookDescription = (ViewBook|DataTypeString) + 3,
+            BookColor       = (ViewBook|DataTypeString) + 4,
+            BookLocation    = (ViewBook|DataTypeString) + 5,
+            BookVisibility  = (ViewBook|DataTypeInteger) + 6,
+            BookSyncEvent   = (ViewBook|DataTypeInteger) + 7,
+            BookAccountId   = (ViewBook|DataTypeInteger) + 8,
+            BookStoreType   = (ViewBook|DataTypeInteger) + 9,
+            BookSyncData1   = (ViewBook|DataTypeString) + 10,
+            BookSyncData2   = (ViewBook|DataTypeString) + 11,
+            BookSyncData3   = (ViewBook|DataTypeString) + 12,
+            BookSyncData4   = (ViewBook|DataTypeString) + 13,
+            BookMode        = (ViewBook|DataTypeInteger) + 14,
+
+            /// Event
+            EventId                 = (ViewEvent|DataTypeInteger|PropertyReadOnly),
+            EventBookId             = (ViewEvent|DataTypeInteger) + 1,
+            EventSummary            = (ViewEvent|DataTypeString) + 2,
+            EventDescription        = (ViewEvent|DataTypeString) + 3,
+            EventLocation           = (ViewEvent|DataTypeString) + 4,
+            EventCategories         = (ViewEvent|DataTypeString) + 5,
+            EventExdate             = (ViewEvent|DataTypeString) + 6,
+            EventEventStatus        = (ViewEvent|DataTypeInteger) + 7,
+            EventPriority           = (ViewEvent|DataTypeInteger) + 8,
+            EventTimezone           = (ViewEvent|DataTypeInteger) + 9,
+            EventContactId          = (ViewEvent|DataTypeInteger) + 10,
+            EventBusyStatus         = (ViewEvent|DataTypeInteger) + 11,
+            EventSensitivity        = (ViewEvent|DataTypeInteger) + 12,
+            EventUid                = (ViewEvent|DataTypeString) + 13,
+            EventOrganizerName      = (ViewEvent|DataTypeString) + 14,
+            EventOrganizerEmail     = (ViewEvent|DataTypeString) + 15,
+            EventMeetingStatus      = (ViewEvent|DataTypeInteger) + 16,
+            EventOriginalEventId    = (ViewEvent|DataTypeInteger) + 17,
+            EventLatitude           = (ViewEvent|DataTypeDouble) + 18,
+            EventLongitude          = (ViewEvent|DataTypeDouble) + 19,
+            EventEmailId            = (ViewEvent|DataTypeInteger) + 20,
+            EventCreatedTime        = (ViewEvent|DataTypeLong) + 21,
+            EventLastModifiedTime   = (ViewEvent|DataTypeLong|PropertyReadOnly) + 22,
+            EventIsDeleted          = (ViewEvent|DataTypeInteger|PropertyReadOnly) + 23,
+            EventFreq               = (ViewEvent|DataTypeInteger) + 24,
+            EventRangeType          = (ViewEvent|DataTypeInteger) + 25,
+            EventUntil              = (ViewEvent|DataTypeCaltime) + 26,
+            EventCount              = (ViewEvent|DataTypeInteger) + 27,
+            EventInterval           = (ViewEvent|DataTypeInteger) + 28,
+            EventBysecond           = (ViewEvent|DataTypeString) + 29,
+            EventByminute           = (ViewEvent|DataTypeString) + 30,
+            EventByhour             = (ViewEvent|DataTypeString) + 31,
+            EventByday              = (ViewEvent|DataTypeString) + 32,
+            EventBymonthday         = (ViewEvent|DataTypeString) + 33,
+            EventByyearday          = (ViewEvent|DataTypeString) + 34,
+            EventByweekno           = (ViewEvent|DataTypeString) + 35,
+            EventBymonth            = (ViewEvent|DataTypeString) + 36,
+            EventBysetpos           = (ViewEvent|DataTypeString) + 37,
+            EventWkst               = (ViewEvent|DataTypeInteger) + 38,
+            EventRecurrenceId       = (ViewEvent|DataTypeString) + 39,
+            EventRdate              = (ViewEvent|DataTypeString) + 40,
+            EventHasAttendee        = (ViewEvent|DataTypeInteger|PropertyReadOnly) + 41,
+            EventHasAlarm           = (ViewEvent|DataTypeInteger|PropertyReadOnly) + 42,
+            EventSyncData1          = (ViewEvent|DataTypeString) + 43,
+            EventSyncData2          = (ViewEvent|DataTypeString) + 44,
+            EventSyncData3          = (ViewEvent|DataTypeString) + 45,
+            EventSyncData4          = (ViewEvent|DataTypeString) + 46,
+            EventStart              = (ViewEvent|DataTypeCaltime) + 47,
+            EventEnd                = (ViewEvent|DataTypeCaltime) + 48,
+            EventAlarm              = (ViewEvent|DataTypeRecord) + 49,
+            EventAttendee           = (ViewEvent|DataTypeRecord) + 50,
+            EventCalendarSystemType = (ViewEvent|DataTypeInteger) + 51,
+            EventStartTzid          = (ViewEvent|DataTypeString) + 52,
+            EventEndTzid            = (ViewEvent|DataTypeString) + 53,
+            EventException          = (ViewEvent|DataTypeRecord) + 54,
+            EventExtended           = (ViewEvent|DataTypeRecord) + 55,
+            EventIsAllday           = (ViewEvent|DataTypeInteger|PropertyReadOnly) + 56,
+            EventLinkCount          = (ViewEvent|DataTypeInteger|PropertyReadOnly) + 57,
+            EventLinkBaseId         = (ViewEvent|DataTypeInteger|PropertyReadOnly) + 58,
+
+            /// Todo
+            TodoId                   = (ViewTodo|DataTypeInteger|PropertyReadOnly),
+            TodoBookId               = (ViewTodo|DataTypeInteger) + 1,
+            TodoSummary              = (ViewTodo|DataTypeString) + 2,
+            TodoDescription          = (ViewTodo|DataTypeString) + 3,
+            TodoLocation             = (ViewTodo|DataTypeString) + 4,
+            TodoCategories           = (ViewTodo|DataTypeString) + 5,
+            TodoStatus               = (ViewTodo|DataTypeInteger) + 6,
+            TodoPriority             = (ViewTodo|DataTypeInteger) + 7,
+            TodoSensitivity          = (ViewTodo|DataTypeInteger) + 8,
+            TodoUid                  = (ViewTodo|DataTypeString) + 9,
+            TodoLatitude             = (ViewTodo|DataTypeDouble) + 10,
+            TodoLongitude            = (ViewTodo|DataTypeDouble) + 11,
+            TodoProgress             = (ViewTodo|DataTypeInteger) + 12,
+            TodoCreatedTime          = (ViewTodo|DataTypeLong) + 13,
+            TodoLastModifiedTime     = (ViewTodo|DataTypeLong|PropertyReadOnly) + 14,
+            TodoCompletedTime        = (ViewTodo|DataTypeLong) + 15,
+            TodoIsDeleted            = (ViewTodo|DataTypeInteger|PropertyReadOnly) + 16,
+            TodoFreq                 = (ViewTodo|DataTypeInteger) + 17,
+            TodoRangeType            = (ViewTodo|DataTypeInteger) + 18,
+            TodoUntil                = (ViewTodo|DataTypeCaltime) + 19,
+            TodoCount                = (ViewTodo|DataTypeInteger) + 20,
+            TodoIntegererval         = (ViewTodo|DataTypeInteger) + 21,
+            TodoBysecond             = (ViewTodo|DataTypeString) + 22,
+            TodoByminute             = (ViewTodo|DataTypeString) + 23,
+            TodoByhour               = (ViewTodo|DataTypeString) + 24,
+            TodoByday                = (ViewTodo|DataTypeString) + 25,
+            TodoBymonthday           = (ViewTodo|DataTypeString) + 26,
+            TodoByyearday            = (ViewTodo|DataTypeString) + 27,
+            TodoByweekno             = (ViewTodo|DataTypeString) + 28,
+            TodoBymonth              = (ViewTodo|DataTypeString) + 29,
+            TodoBysetpos             = (ViewTodo|DataTypeString) + 30,
+            TodoWkst                 = (ViewTodo|DataTypeInteger) + 31,
+            TodoHasAlarm             = (ViewTodo|DataTypeInteger|PropertyReadOnly) + 32,
+            TodoSyncData1            = (ViewTodo|DataTypeString) + 33,
+            TodoSyncData2            = (ViewTodo|DataTypeString) + 34,
+            TodoSyncData3            = (ViewTodo|DataTypeString) + 35,
+            TodoSyncData4            = (ViewTodo|DataTypeString) + 36,
+            TodoStart                = (ViewTodo|DataTypeCaltime) + 37,
+            TodoDue                  = (ViewTodo|DataTypeCaltime) + 38,
+            TodoAlarm                = (ViewTodo|DataTypeRecord) + 39,
+            TodoStartTzid            = (ViewTodo|DataTypeString) + 40,
+            TodoDueTzid              = (ViewTodo|DataTypeString) + 41,
+            TodoOrganizerName        = (ViewTodo|DataTypeString) + 42,
+            TodoOrganizerEmail       = (ViewTodo|DataTypeString) + 43,
+            TodoHasAttendee          = (ViewTodo|DataTypeInteger|PropertyReadOnly) + 44,
+            TodoAttendee             = (ViewTodo|DataTypeRecord) + 45,
+            TodoExtended             = (ViewTodo|DataTypeRecord) + 46,
+            TodoIsAllday             = (ViewTodo|DataTypeInteger|PropertyReadOnly) + 47,
+
+            /// Timezone
+            TimezoneId                          = (ViewTimezone|DataTypeInteger|PropertyReadOnly),
+            TimezoneTzOffsetFromGmt             = (ViewTimezone|DataTypeInteger) + 1,
+            TimezoneStandardName                = (ViewTimezone|DataTypeString) + 2,
+            TimezoneStdStartMonth               = (ViewTimezone|DataTypeInteger) + 3,
+            TimezoneStdStartPositionOfWeek      = (ViewTimezone|DataTypeInteger) + 4,
+            TimezoneStdStartDay                 = (ViewTimezone|DataTypeInteger) + 5,
+            TimezoneStdStartHour                = (ViewTimezone|DataTypeInteger) + 6,
+            TimezoneStandardBias                = (ViewTimezone|DataTypeInteger) + 7,
+            TimezoneDayLightName                = (ViewTimezone|DataTypeString) + 8,
+            TimezoneDayLightStartMonth          = (ViewTimezone|DataTypeInteger) + 9,
+            TimezoneDayLightStartPositionOfWeek = (ViewTimezone|DataTypeInteger) + 10,
+            TimezoneDayLightStartDay            = (ViewTimezone|DataTypeInteger) + 11,
+            TimezoneDayLightStartHour           = (ViewTimezone|DataTypeInteger) + 12,
+            TimezoneDayLightBias                = (ViewTimezone|DataTypeInteger) + 13,
+            TimezoneCalendarId                  = (ViewTimezone|DataTypeInteger) + 14,
+
+            AttendeeNumber       = (ViewAttendee|DataTypeString),
+            AttendeeCutype       = (ViewAttendee|DataTypeInteger) + 1,
+            AttendeeCtIndex      = (ViewAttendee|DataTypeInteger) + 2,
+            AttendeeUid          = (ViewAttendee|DataTypeString) + 3,
+            AttendeeGroup        = (ViewAttendee|DataTypeString) + 4,
+            AttendeeEmail        = (ViewAttendee|DataTypeString) + 5,
+            AttendeeRole         = (ViewAttendee|DataTypeInteger) + 6,
+            AttendeeStatus       = (ViewAttendee|DataTypeInteger) + 7,
+            AttendeeRsvp         = (ViewAttendee|DataTypeInteger) + 8,
+            AttendeeDelegateeUri = (ViewAttendee|DataTypeString) + 9,
+            AttendeeDelegatorUri = (ViewAttendee|DataTypeString) + 10,
+            AttendeeName         = (ViewAttendee|DataTypeString) + 11,
+            AttendeeMember       = (ViewAttendee|DataTypeString) + 12,
+            AttendeeParentId     = (ViewAttendee|DataTypeInteger|PropertyReadOnly) + 13,
+
+            AlarmTick            = (ViewAlarm|DataTypeInteger),
+            AlarmTickUnit        = (ViewAlarm|DataTypeInteger) + 1,
+            AlarmDescription     = (ViewAlarm|DataTypeString) + 2,
+            AlarmParentId        = (ViewAlarm|DataTypeInteger|PropertyReadOnly) + 3,
+            AlarmSummary         = (ViewAlarm|DataTypeString) + 4,
+            AlarmAction          = (ViewAlarm|DataTypeInteger) + 5,
+            AlarmAttach          = (ViewAlarm|DataTypeString) + 6,
+            AlarmAlarm           = (ViewAlarm|DataTypeCaltime) + 7,
+
+            InstanceUtimeBookEventId          = (ViewInstanceUtimeBook|DataTypeInteger),
+            InstanceUtimeBookStart            = (ViewInstanceUtimeBook|DataTypeCaltime) + 1,
+            InstanceUtimeBookEnd              = (ViewInstanceUtimeBook|DataTypeCaltime) + 2,
+            InstanceUtimeBookSummary          = (ViewInstanceUtimeBook|DataTypeString) + 3,
+            InstanceUtimeBookLocation         = (ViewInstanceUtimeBook|DataTypeString) + 4,
+            InstanceUtimeBookBookId           = (ViewInstanceUtimeBook|DataTypeInteger) + 5,
+            InstanceUtimeBookDescription      = (ViewInstanceUtimeBook|DataTypeString) + 6,
+            InstanceUtimeBookBusyStatus       = (ViewInstanceUtimeBook|DataTypeInteger) + 7,
+            InstanceUtimeBookEventStatus      = (ViewInstanceUtimeBook|DataTypeInteger) + 8,
+            InstanceUtimeBookPriority         = (ViewInstanceUtimeBook|DataTypeInteger) + 9,
+            InstanceUtimeBookSensitivity      = (ViewInstanceUtimeBook|DataTypeInteger) + 10,
+            InstanceUtimeBookHasRrule         = (ViewInstanceUtimeBook|DataTypeInteger) + 11,
+            InstanceUtimeBookLatitude         = (ViewInstanceUtimeBook|DataTypeDouble) + 12,
+            InstanceUtimeBookLongitude        = (ViewInstanceUtimeBook|DataTypeDouble) + 13,
+            InstanceUtimeBookHasAlarm         = (ViewInstanceUtimeBook|DataTypeInteger) + 14,
+            InstanceUtimeBookOriginalEventId  = (ViewInstanceUtimeBook|DataTypeInteger) + 15,
+            InstanceUtimeBookLastModifiedtime = (ViewInstanceUtimeBook|DataTypeLong) + 16,
+            InstanceUtimeBookSyncData1        = (ViewInstanceUtimeBook|DataTypeString) + 17,
+
+            InstanceLocaltimeBookEventId          = (ViewInstanceLocaltimeBook|DataTypeInteger),
+            InstanceLocaltimeBookStart            = (ViewInstanceLocaltimeBook|DataTypeCaltime) + 1,
+            InstanceLocaltimeBookEnd              = (ViewInstanceLocaltimeBook|DataTypeCaltime) + 2,
+            InstanceLocaltimeBookSummary          = (ViewInstanceLocaltimeBook|DataTypeString) + 3,
+            InstanceLocaltimeBookLocation         = (ViewInstanceLocaltimeBook|DataTypeString) + 4,
+            InstanceLocaltimeBookBookId           = (ViewInstanceLocaltimeBook|DataTypeInteger) + 5,
+            InstanceLocaltimeBookDescription      = (ViewInstanceLocaltimeBook|DataTypeString) + 6,
+            InstanceLocaltimeBookBusyStatus       = (ViewInstanceLocaltimeBook|DataTypeInteger) + 7,
+            InstanceLocaltimeBookEventStatus      = (ViewInstanceLocaltimeBook|DataTypeInteger) + 8,
+            InstanceLocaltimeBookPriority         = (ViewInstanceLocaltimeBook|DataTypeInteger) + 9,
+            InstanceLocaltimeBookSensitivity      = (ViewInstanceLocaltimeBook|DataTypeInteger) + 10,
+            InstanceLocaltimeBookHasRrule         = (ViewInstanceLocaltimeBook|DataTypeInteger) + 11,
+            InstanceLocaltimeBookLatitude         = (ViewInstanceLocaltimeBook|DataTypeDouble) + 12,
+            InstanceLocaltimeBookLongitude        = (ViewInstanceLocaltimeBook|DataTypeDouble) + 13,
+            InstanceLocaltimeBookHasAlarm         = (ViewInstanceLocaltimeBook|DataTypeInteger) + 14,
+            InstanceLocaltimeBookOriginalEventId  = (ViewInstanceLocaltimeBook|DataTypeInteger) + 15,
+            InstanceLocaltimeBookLastModifiedTime = (ViewInstanceLocaltimeBook|DataTypeLong) + 16,
+            InstanceLocaltimeBookSyncData1        = (ViewInstanceLocaltimeBook|DataTypeString) + 17,
+            InstanceLocaltimeBookIsAllday         = (ViewInstanceLocaltimeBook|DataTypeInteger|PropertyReadOnly) + 18,
+
+            InstanceUtimeBookExtendedEventId          = (ViewInstanceUtimeBookExtended|DataTypeInteger),
+            InstanceUtimeBookExtendedStart            = (ViewInstanceUtimeBookExtended|DataTypeCaltime) + 1,
+            InstanceUtimeBookExtendedEnd              = (ViewInstanceUtimeBookExtended|DataTypeCaltime) + 2,
+            InstanceUtimeBookExtendedSummary          = (ViewInstanceUtimeBookExtended|DataTypeString) + 3,
+            InstanceUtimeBookExtendedLocation         = (ViewInstanceUtimeBookExtended|DataTypeString) + 4,
+            InstanceUtimeBookExtendedBookId           = (ViewInstanceUtimeBookExtended|DataTypeInteger) + 5,
+            InstanceUtimeBookExtendedDescription      = (ViewInstanceUtimeBookExtended|DataTypeString) + 6,
+            InstanceUtimeBookExtendedBusyStatus       = (ViewInstanceUtimeBookExtended|DataTypeInteger) + 7,
+            InstanceUtimeBookExtendedEventStatus      = (ViewInstanceUtimeBookExtended|DataTypeInteger) + 8,
+            InstanceUtimeBookExtendedPriority         = (ViewInstanceUtimeBookExtended|DataTypeInteger) + 9,
+            InstanceUtimeBookExtendedSensitivity      = (ViewInstanceUtimeBookExtended|DataTypeInteger) + 10,
+            InstanceUtimeBookExtendedHasRrule         = (ViewInstanceUtimeBookExtended|DataTypeInteger) + 11,
+            InstanceUtimeBookExtendedLatitude         = (ViewInstanceUtimeBookExtended|DataTypeDouble) + 12,
+            InstanceUtimeBookExtendedLongitude        = (ViewInstanceUtimeBookExtended|DataTypeDouble) + 13,
+            InstanceUtimeBookExtendedHasAlarm         = (ViewInstanceUtimeBookExtended|DataTypeInteger) + 14,
+            InstanceUtimeBookExtendedOriginalEventId  = (ViewInstanceUtimeBookExtended|DataTypeInteger) + 15,
+            InstanceUtimeBookExtendedLastModifiedTime = (ViewInstanceUtimeBookExtended|DataTypeLong) + 16,
+            InstanceUtimeBookExtendedSyncData1        = (ViewInstanceUtimeBookExtended|DataTypeString) + 17,
+            InstanceUtimeBookExtendedOrganizerName    = (ViewInstanceUtimeBookExtended|DataTypeString) + 18,
+            InstanceUtimeBookExtendedCategories       = (ViewInstanceUtimeBookExtended|DataTypeString) + 19,
+            InstanceUtimeBookExtendedHasAttendee      = (ViewInstanceUtimeBookExtended|DataTypeInteger) + 20,
+            InstanceUtimeBookExtendedSyncData2        = (ViewInstanceUtimeBookExtended|DataTypeString) + 21,
+            InstanceUtimeBookExtendedSyncData3        = (ViewInstanceUtimeBookExtended|DataTypeString) + 22,
+            InstanceUtimeBookExtendedSyncData4        = (ViewInstanceUtimeBookExtended|DataTypeString) + 23,
+
+            InstanceLocaltimeBookExtendedEventId          = (ViewInstanceLocaltimeBookExtended|DataTypeInteger),
+            InstanceLocaltimeBookExtendedStart            = (ViewInstanceLocaltimeBookExtended|DataTypeCaltime) + 1,
+            InstanceLocaltimeBookExtendedEnd              = (ViewInstanceLocaltimeBookExtended|DataTypeCaltime) + 2,
+            InstanceLocaltimeBookExtendedSummary          = (ViewInstanceLocaltimeBookExtended|DataTypeString) + 3,
+            InstanceLocaltimeBookExtendedLocation         = (ViewInstanceLocaltimeBookExtended|DataTypeString) + 4,
+            InstanceLocaltimeBookExtendedBookId           = (ViewInstanceLocaltimeBookExtended|DataTypeInteger) + 5,
+            InstanceLocaltimeBookExtendedDescription      = (ViewInstanceLocaltimeBookExtended|DataTypeString) + 6,
+            InstanceLocaltimeBookExtendedBusyStatus       = (ViewInstanceLocaltimeBookExtended|DataTypeInteger) + 7,
+            InstanceLocaltimeBookExtendedEventStatus      = (ViewInstanceLocaltimeBookExtended|DataTypeInteger) + 8,
+            InstanceLocaltimeBookExtendedPriority         = (ViewInstanceLocaltimeBookExtended|DataTypeInteger) + 9,
+            InstanceLocaltimeBookExtendedSensitivity      = (ViewInstanceLocaltimeBookExtended|DataTypeInteger) + 10,
+            InstanceLocaltimeBookExtendedHasRrule         = (ViewInstanceLocaltimeBookExtended|DataTypeInteger) + 11,
+            InstanceLocaltimeBookExtendedLatitude         = (ViewInstanceLocaltimeBookExtended|DataTypeDouble) + 12,
+            InstanceLocaltimeBookExtendedLongitude        = (ViewInstanceLocaltimeBookExtended|DataTypeDouble) + 13,
+            InstanceLocaltimeBookExtendedHasAlarm         = (ViewInstanceLocaltimeBookExtended|DataTypeInteger) + 14,
+            InstanceLocaltimeBookExtendedOriginalEventId  = (ViewInstanceLocaltimeBookExtended|DataTypeInteger) + 15,
+            InstanceLocaltimeBookExtendedLastModifiedTime = (ViewInstanceLocaltimeBookExtended|DataTypeLong) + 16,
+            InstanceLocaltimeBookExtendedSyncData1        = (ViewInstanceLocaltimeBookExtended|DataTypeString) + 17,
+            InstanceLocaltimeBookExtendedOrganizerName    = (ViewInstanceLocaltimeBookExtended|DataTypeString) + 18,
+            InstanceLocaltimeBookExtendedCategories       = (ViewInstanceLocaltimeBookExtended|DataTypeString) + 19,
+            InstanceLocaltimeBookExtendedHasAttendee      = (ViewInstanceLocaltimeBookExtended|DataTypeInteger) + 20,
+            InstanceLocaltimeBookExtendedSyncData2        = (ViewInstanceLocaltimeBookExtended|DataTypeString) + 21,
+            InstanceLocaltimeBookExtendedSyncData3        = (ViewInstanceLocaltimeBookExtended|DataTypeString) + 22,
+            InstanceLocaltimeBookExtendedSyncData4        = (ViewInstanceLocaltimeBookExtended|DataTypeString) + 23,
+            InstanceLocaltimeBookExtendedIsAllday         = (ViewInstanceLocaltimeBookExtended|DataTypeInteger|PropertyReadOnly) + 24,
+
+            UpdateInfoId         = (ViewUpdateInfo|DataTypeInteger),
+            UpdateInfoCalendarId = (ViewUpdateInfo|DataTypeInteger) + 1,
+            UpdateInfoType       = (ViewUpdateInfo|DataTypeInteger) + 2,
+            UpdateInfoVersion    = (ViewUpdateInfo|DataTypeInteger) + 3,
+
+            ExtendedId           = (ViewExtended|DataTypeInteger|PropertyReadOnly),
+            ExtendedRecordId     = (ViewExtended|DataTypeInteger) + 1,
+            ExtendedRecordType   = (ViewExtended|DataTypeInteger) + 2,
+            ExtendedKey          = (ViewExtended|DataTypeString) + 3,
+            ExtendedValue        = (ViewExtended|DataTypeString) + 4,
+        }
+
+        ///average size
+        internal const uint AverageSizeOfRecord = 56;
+
+        public static class Book
+        {
+            /// <summary>
+            /// Identifier of this calendar book view
+            /// </summary>
+            public const string Uri = "tizen.calendar_view.book";
+            /// <summary>
+            /// DB record ID of the calendar book
+            /// </summary>
+            public const uint Id          = (uint)PropertyIds.BookId;
+            /// <summary>
+            /// Unique identifier
+            /// </summary>
+            public const uint Uid         = (uint)PropertyIds.BookUid;
+            /// <summary>
+            /// Calendar book name
+            /// </summary>
+            public const uint Name        = (uint)PropertyIds.BookName;
+            /// <summary>
+            /// Calendar book description
+            /// </summary>
+            public const uint Description = (uint)PropertyIds.BookDescription;
+            /// <summary>
+            /// Calendar book color for UX
+            /// </summary>
+            public const uint Color       = (uint)PropertyIds.BookColor;
+            /// <summary>
+            /// Location of the event
+            /// </summary>
+            public const uint Location    = (uint)PropertyIds.BookLocation;
+            /// <summary>
+            /// Visibility of the calendar book for UX
+            /// </summary>
+            public const uint Visibility  = (uint)PropertyIds.BookVisibility;
+            /// <summary>
+            /// Currently NOT Used
+            /// </summary>
+            public const uint SyncEvent   = (uint)PropertyIds.BookSyncEvent;
+            /// <summary>
+            /// Account for this calendar
+            /// </summary>
+            public const uint AccountId   = (uint)PropertyIds.BookAccountId;
+            /// <summary>
+            /// Type of calendar contents(refer to the CalendarTypes.StoreType)
+            /// </summary>
+            public const uint StoreType   = (uint)PropertyIds.BookStoreType;
+            /// <summary>
+            /// Generic data for use by syncing
+            /// </summary>
+            public const uint SyncData1   = (uint)PropertyIds.BookSyncData1;
+            /// <summary>
+            /// Generic data for use by syncing
+            /// </summary>
+            public const uint SyncData2   = (uint)PropertyIds.BookSyncData2;
+            /// <summary>
+            /// Generic data for use by syncing
+            /// </summary>
+            public const uint SyncData3   = (uint)PropertyIds.BookSyncData3;
+            /// <summary>
+            /// Generic data for use by syncing
+            /// </summary>
+            public const uint SyncData4   = (uint)PropertyIds.BookSyncData4;
+            /// <summary>
+            /// Calendar book mode(refer to the CalendarTypes.BookMode)
+            /// </summary>
+            public const uint Mode        = (uint)PropertyIds.BookMode;
+        }
+
+        public static class Event
+        {
+            /// <summary>
+            /// Identifier of this event view
+            /// </summary>
+            public const string Uri = "tizen.calendar_view.event";
+            /// <summary>
+            /// DB record ID of the event
+            /// </summary>
+            public const uint Id                 = (uint)PropertyIds.EventId;
+            /// <summary>
+            /// ID of the calendar book to which the event belongs
+            /// </summary>
+            public const uint BookId             = (uint)PropertyIds.EventBookId;
+            /// <summary>
+            /// The short description of the event
+            /// </summary>
+            public const uint Summary            = (uint)PropertyIds.EventSummary;
+            /// <summary>
+            /// The description of the event
+            /// </summary>
+            public const uint Description        = (uint)PropertyIds.EventDescription;
+            /// <summary>
+            /// The location of the event
+            /// </summary>
+            public const uint Location           = (uint)PropertyIds.EventLocation;
+            /// <summary>
+            /// The category of the event. For example APPOINTMENT, BIRTHDAY
+            /// </summary>
+            public const uint Categories         = (uint)PropertyIds.EventCategories;
+            /// <summary>
+            /// The exception list of the event. If this event has a recurrence rule, the instance of the exdate is removed. Format is "YYYYMMDD"(allday event) or "YYYYMMDDTHHMMSS". Multiple exceptions can be included with a comma
+            /// </summary>
+            public const uint Exdate             = (uint)PropertyIds.EventExdate;
+            /// <summary>
+            /// The status of event(refer to the CalendarTypes.EventStatus).
+            /// </summary>
+            public const uint EventStatus        = (uint)PropertyIds.EventEventStatus;
+            /// <summary>
+            /// The priority of event(refer to the CalendarTypes.Priority).
+            /// </summary>
+            public const uint Priority           = (uint)PropertyIds.EventPriority;
+            /// <summary>
+            /// The timezone_id of the event if it exists.
+            /// </summary>
+            public const uint Timezone           = (uint)PropertyIds.EventTimezone;
+            /// <summary>
+            /// The person_id of the event if the event is a birthday. Refer to the contacts-service
+            /// </summary>
+            public const uint ContactId          = (uint)PropertyIds.EventContactId;
+            /// <summary>
+            /// The busy status of event(refer to the CalendarTypes.BusyStatus).
+            /// </summary>
+            public const uint BusyStatus         = (uint)PropertyIds.EventBusyStatus;
+            /// <summary>
+            /// The Sensitivity of event(refer to the CalendarTypes.Sensitivity).
+            /// </summary>
+            public const uint Sensitivity        = (uint)PropertyIds.EventSensitivity;
+            /// <summary>
+            /// The unique ID of the event
+            /// </summary>
+            public const uint Uid                = (uint)PropertyIds.EventUid;
+            /// <summary>
+            /// The name of organizer of the event
+            /// </summary>
+            public const uint OrganizerName      = (uint)PropertyIds.EventOrganizerName;
+            /// <summary>
+            /// The email address of the organizer of the event
+            /// </summary>
+            public const uint OrganizerEmail     = (uint)PropertyIds.EventOrganizerEmail;
+            /// <summary>
+            /// The meeting status of event(refer to the CalendarTypes.MeetingStatus).
+            /// </summary>
+            public const uint MeetingStatus      = (uint)PropertyIds.EventMeetingStatus;
+            /// <summary>
+            /// The ID of the original event if the event is an exception.
+            /// </summary>
+            public const uint OriginalEventId    = (uint)PropertyIds.EventOriginalEventId;
+            /// <summary>
+            /// The latitude of the location of the event
+            /// </summary>
+            public const uint Latitude           = (uint)PropertyIds.EventLatitude;
+            /// <summary>
+            /// The longitude of the location of the event
+            /// </summary>
+            public const uint Longitude          = (uint)PropertyIds.EventLongitude;
+            /// <summary>
+            /// ID of the email_id. Refer to the email-service.
+            /// </summary>
+            public const uint EmailId            = (uint)PropertyIds.EventEmailId;
+            /// <summary>
+            /// The time when the event is created
+            /// </summary>
+            public const uint CreatedTime        = (uint)PropertyIds.EventCreatedTime;
+            /// <summary>
+            /// The time when the event is updated
+            /// </summary>
+            public const uint LastModifiedTime   = (uint)PropertyIds.EventLastModifiedTime;
+            /// <summary>
+            ///  Whether or not the event is deleted
+            /// </summary>
+            public const uint IsDeleted          = (uint)PropertyIds.EventIsDeleted;
+            /// <summary>
+            /// The frequent type of event recurrence(refer to the CalendarTypes.Recurrence).
+            /// </summary>
+            public const uint Freq               = (uint)PropertyIds.EventFreq;
+            /// <summary>
+            /// The range type of event recurrence(refer to the CalendarTypes.RangeType).
+            /// </summary>
+            public const uint RangeType          = (uint)PropertyIds.EventRangeType;
+            /// <summary>
+            /// The end time of the event recurrence. Only if this is used with RangeType.Until.
+            /// </summary>
+            public const uint Until              = (uint)PropertyIds.EventUntil;
+            /// <summary>
+            /// The count of the event recurrence. Only if this is used with RangeType.Count.
+            /// </summary>
+            public const uint Count              = (uint)PropertyIds.EventCount;
+            /// <summary>
+            /// The interval of the event recurrence
+            /// </summary>
+            public const uint Interval           = (uint)PropertyIds.EventInterval;
+            /// <summary>
+            /// The second list of the event recurrence. The value can be from 0 to 59. The list is separated by comma
+            /// </summary>
+            public const uint Bysecond           = (uint)PropertyIds.EventBysecond;
+            /// <summary>
+            /// The minute list of the event recurrence. The value can be from 0 to 59. The list is separated by commas
+            /// </summary>
+            public const uint Byminute           = (uint)PropertyIds.EventByminute;
+            /// <summary>
+            /// The hour list of the event recurrence. The value can be from 0 to 23. The list is separated by commas
+            /// </summary>
+            public const uint Byhour             = (uint)PropertyIds.EventByhour;
+            /// <summary>
+            /// The day list of the event recurrence. The value can be SU, MO, TU, WE, TH, FR, SA. The list is separated by commas.
+            /// </summary>
+            public const uint Byday              = (uint)PropertyIds.EventByday;
+            /// <summary>
+            /// The month day list of the event recurrence. The value can be from 1 to 31 and from -31 to -1. The list is separated by commas.
+            /// </summary>
+            public const uint Bymonthday         = (uint)PropertyIds.EventBymonthday;
+            /// <summary>
+            /// The year day list of the event recurrence. The value can be from 1 to 366 and from -366 to -1. The list is separated by commas
+            /// </summary>
+            public const uint Byyearday          = (uint)PropertyIds.EventByyearday;
+            /// <summary>
+            /// The week number list of the event recurrence. The value can be from 1 to 53 and from -53 to -1. The list is separated by commas
+            /// </summary>
+            public const uint Byweekno           = (uint)PropertyIds.EventByweekno;
+            /// <summary>
+            /// The month list of the event recurrence. The value can be from 1 to 12. The list is separated by commas
+            /// </summary>
+            public const uint Bymonth            = (uint)PropertyIds.EventBymonth;
+            /// <summary>
+            /// The position list of the event recurrence. The value can be from 1 to 366 and from -366 to -1. The list is separated by commas
+            /// </summary>
+            public const uint Bysetpos           = (uint)PropertyIds.EventBysetpos;
+            /// <summary>
+            /// The start day of the week(refer to the CalendarTypes.WeekDay).
+            /// </summary>
+            public const uint Wkst               = (uint)PropertyIds.EventWkst;
+            /// <summary>
+            /// RECURRENCE-ID of RFC #2445
+            /// </summary>
+            public const uint RecurrenceId       = (uint)PropertyIds.EventRecurrenceId;
+            /// <summary>
+            /// RDATE of RFC #2445
+            /// </summary>
+            public const uint Rdate              = (uint)PropertyIds.EventRdate;
+            /// <summary>
+            /// Whether or not the event has an attendee list
+            /// </summary>
+            public const uint HasAttendee        = (uint)PropertyIds.EventHasAttendee;
+            /// <summary>
+            /// Whether or not the event has an alarm list
+            /// </summary>
+            public const uint HasAlarm           = (uint)PropertyIds.EventHasAlarm;
+            /// <summary>
+            /// The sync data of the event. If developer need to save some information related to the event, they can use this property
+            /// </summary>
+            public const uint SyncData1          = (uint)PropertyIds.EventSyncData1;
+            /// <summary>
+            /// The sync data of the event. If developer need to save some information related to the event, they can use this property
+            /// </summary>
+            public const uint SyncData2          = (uint)PropertyIds.EventSyncData2;
+            /// <summary>
+            /// The sync data of the event. If developer need to save some information related to the event, they can use this property
+            /// </summary>
+            public const uint SyncData3          = (uint)PropertyIds.EventSyncData3;
+            /// <summary>
+            /// The sync data of the event. If developer need to save some information related to the event, they can use this property
+            /// </summary>
+            public const uint SyncData4          = (uint)PropertyIds.EventSyncData4;
+            /// <summary>
+            /// The start time of the event
+            /// </summary>
+            public const uint Start              = (uint)PropertyIds.EventStart;
+            /// <summary>
+            /// The end time of the event
+            /// </summary>
+            public const uint End                = (uint)PropertyIds.EventEnd;
+            /// <summary>
+            /// The alarm list of the event.
+            /// </summary>
+            public const uint Alarm              = (uint)PropertyIds.EventAlarm;
+            /// <summary>
+            /// The attendee list of the event.
+            /// </summary>
+            public const uint Attendee           = (uint)PropertyIds.EventAttendee;
+            /// <summary>
+            /// The Calendar system type(refer to the CalendarTypes.SystemType).
+            /// </summary>
+            public const uint CalendarSystemType = (uint)PropertyIds.EventCalendarSystemType;
+            /// <summary>
+            /// The timezone of the start_time
+            /// </summary>
+            public const uint StartTzid          = (uint)PropertyIds.EventStartTzid;
+            /// <summary>
+            /// The timezone of the end_time
+            /// </summary>
+            public const uint EndTzid            = (uint)PropertyIds.EventEndTzid;
+            /// <summary>
+            /// The exception mod event list of the event
+            /// </summary>
+            public const uint Exception          = (uint)PropertyIds.EventException;
+            /// <summary>
+            /// The extended property list of the event.
+            /// </summary>
+            public const uint Extended           = (uint)PropertyIds.EventExtended;
+            /// <summary>
+            /// The event is an allday event or not
+            /// </summary>
+            public const uint IsAllday           = (uint)PropertyIds.EventIsAllday;
+            /// <summary>
+            /// The linked event count
+            /// </summary>
+            public const uint LinkCount          = (uint)PropertyIds.EventLinkCount;
+            /// <summary>
+            /// The event is an base linked event
+            /// </summary>
+            public const uint LinkBaseId         = (uint)PropertyIds.EventLinkBaseId;
+        }
+
+        public static class Todo
+        {
+            /// <summary>
+            /// Identifier of this todo view
+            /// </summary>
+            public const string Uri = "tizen.calendar_view.todo";
+            /// <summary>
+            /// DB record ID of the todo
+            /// </summary>
+            public const uint Id                = (uint)PropertyIds.TodoId;
+            /// <summary>
+            /// ID of the calendar book to which the todo belongs
+            /// </summary>
+            public const uint BookId            = (uint)PropertyIds.TodoBookId;
+            /// <summary>
+            /// The short description of the todo
+            /// </summary>
+            public const uint Summary           = (uint)PropertyIds.TodoSummary;
+            /// <summary>
+            /// The description of the todo
+            /// </summary>
+            public const uint Description       = (uint)PropertyIds.TodoDescription;
+            /// <summary>
+            /// The location of the todo
+            /// </summary>
+            public const uint Location          = (uint)PropertyIds.TodoLocation;
+            /// <summary>
+            /// The category of the todo. i.g. APPOINTMENT, BIRTHDAY
+            /// </summary>
+            public const uint Categories        = (uint)PropertyIds.TodoCategories;
+            /// <summary>
+            /// The status of todo(refer to the CalendarTypes.TodoStatus).
+            /// </summary>
+            public const uint TodoStatus        = (uint)PropertyIds.TodoStatus;
+            /// <summary>
+            /// The Priority of todo(refer to the CalendarTypes.Priority).
+            /// </summary>
+            public const uint Priority          = (uint)PropertyIds.TodoPriority;
+            /// <summary>
+            /// The Sensitivity of todo(refer to the CalendarTypes.Sensitivity).
+            /// </summary>
+            public const uint Sensitivity       = (uint)PropertyIds.TodoSensitivity;
+            /// <summary>
+            /// The unique ID of the todo
+            /// </summary>
+            public const uint Uid               = (uint)PropertyIds.TodoUid;
+            /// <summary>
+            /// The latitude of the location of the todo
+            /// </summary>
+            public const uint Latitude          = (uint)PropertyIds.TodoLatitude;
+            /// <summary>
+            /// The longitude of the location of the todo
+            /// </summary>
+            public const uint Longitude         = (uint)PropertyIds.TodoLongitude;
+            /// <summary>
+            /// The progression of the todo. The value can be from 0 to 100
+            /// </summary>
+            public const uint Progress          = (uint)PropertyIds.TodoProgress;
+            /// <summary>
+            /// The time when the todo is create
+            /// </summary>
+            public const uint CreatedTime       = (uint)PropertyIds.TodoCreatedTime;
+            /// <summary>
+            /// The time when the todo is updated
+            /// </summary>
+            public const uint LastModifiedTime  = (uint)PropertyIds.TodoLastModifiedTime;
+            /// <summary>
+            /// The time when the todo is completed
+            /// </summary>
+            public const uint CompletedTime     = (uint)PropertyIds.TodoCompletedTime;
+            /// <summary>
+            ///  Whether or not the todo is deleted
+            /// </summary>
+            public const uint IsDeleted         = (uint)PropertyIds.TodoIsDeleted;
+            /// <summary>
+            /// The frequent type of todo recurrence(refer to the CalendarTypes.Recurrence).
+            /// </summary>
+            public const uint Freq              = (uint)PropertyIds.TodoFreq;
+            /// <summary>
+            /// The range type of todo recurrence(refer to the CalendarTypes.RangeType).
+            /// </summary>
+            public const uint RangeType         = (uint)PropertyIds.TodoRangeType;
+            /// <summary>
+            /// The end time of the todo recurrence. Only if this is used with RangeType.Until.
+            /// </summary>
+            public const uint Until             = (uint)PropertyIds.TodoUntil;
+            /// <summary>
+            /// The count of the todo recurrence. Only if this is used with RangeType.Count.
+            /// </summary>
+            public const uint Count             = (uint)PropertyIds.TodoCount;
+            /// <summary>
+            /// The interval of the todo recurrence
+            /// </summary>
+            public const uint Integererval      = (uint)PropertyIds.TodoIntegererval;
+            /// <summary>
+            /// The second list of the todo recurrence. The value can be from 0 to 59. The list is separated by commas
+            /// </summary>
+            public const uint Bysecond          = (uint)PropertyIds.TodoBysecond;
+            /// <summary>
+            /// The minute list of the todo recurrence. The value can be from 0 to 59. The list is separated by commas
+            /// </summary>
+            public const uint Byminute          = (uint)PropertyIds.TodoByminute;
+            /// <summary>
+            /// The hour list of the todo recurrence. The value can be from 0 to 23. The list is separated by commas
+            /// </summary>
+            public const uint Byhour            = (uint)PropertyIds.TodoByhour;
+            /// <summary>
+            /// The day list of the todo recurrence. The value can be SU, MO, TU, WE, TH, FR, SA. The list is separated by commas
+            /// </summary>
+            public const uint Byday             = (uint)PropertyIds.TodoByday;
+            /// <summary>
+            /// The month day list of the todo recurrence. The value can be from 1 to 31 and from -31 to -1. The list is separated by commas
+            /// </summary>
+            public const uint Bymonthday        = (uint)PropertyIds.TodoBymonthday;
+            /// <summary>
+            /// The year day list of the todo recurrence. The value can be from 1 to 366 and from -366 to -1. The list is separated by commas
+            /// </summary>
+            public const uint Byyearday         = (uint)PropertyIds.TodoByyearday;
+            /// <summary>
+            /// The week number list of the todo recurrence. The value can be from 1 to 53 and from -53 to -1. The list is separated by commas
+            /// </summary>
+            public const uint Byweekno          = (uint)PropertyIds.TodoByweekno;
+            /// <summary>
+            /// The month list of the todo recurrence. The value can be from 1 to 12. The list is separated by commas
+            /// </summary>
+            public const uint Bymonth           = (uint)PropertyIds.TodoBymonth;
+            /// <summary>
+            /// The position list of the todo recurrence. The value can be from 1 to 366 and from -366 to -1. The list is separated by commas
+            /// </summary>
+            public const uint Bysetpos          = (uint)PropertyIds.TodoBysetpos;
+            /// <summary>
+            /// The start day of the week(refer to the CalendarTypes.WeekDay).
+            /// </summary>
+            public const uint Wkst              = (uint)PropertyIds.TodoWkst;
+            /// <summary>
+            /// Whether or not the todo has an alarm list
+            /// </summary>
+            public const uint HasAlarm          = (uint)PropertyIds.TodoHasAlarm;
+            /// <summary>
+            /// The sync data of the todo. If developers need to save some information related to the todo, they can use this property
+            /// </summary>
+            public const uint SyncData1         = (uint)PropertyIds.TodoSyncData1;
+            /// <summary>
+            /// The sync data of the todo. If developers need to save some information related to the todo, they can use this property
+            /// </summary>
+            public const uint SyncData2         = (uint)PropertyIds.TodoSyncData2;
+            /// <summary>
+            /// The sync data of the todo. If developers need to save some information related to the todo, they can use this property
+            /// </summary>
+            public const uint SyncData3         = (uint)PropertyIds.TodoSyncData3;
+            /// <summary>
+            /// The sync data of the todo. If developers need to save some information related to the todo, they can use this property
+            /// </summary>
+            public const uint SyncData4         = (uint)PropertyIds.TodoSyncData4;
+            /// <summary>
+            /// The start time of the todo
+            /// </summary>
+            public const uint Start             = (uint)PropertyIds.TodoStart;
+            /// <summary>
+            /// The due time of the todo
+            /// </summary>
+            public const uint Due               = (uint)PropertyIds.TodoDue;
+            /// <summary>
+            /// The alarm list of the todo.
+            /// </summary>
+            public const uint Alarm             = (uint)PropertyIds.TodoAlarm;
+            /// <summary>
+            /// The timezone of the start_time
+            /// </summary>
+            public const uint StartTzid         = (uint)PropertyIds.TodoStartTzid;
+            /// <summary>
+            /// The timezone of the due_time
+            /// </summary>
+            public const uint DueTzid           = (uint)PropertyIds.TodoDueTzid;
+            /// <summary>
+            /// The name of the organizer of the event
+            /// </summary>
+            public const uint OrganizerName     = (uint)PropertyIds.TodoOrganizerName;
+            /// <summary>
+            /// The email address of the organizer of the todo
+            /// </summary>
+            public const uint OrganizerEmail    = (uint)PropertyIds.TodoOrganizerEmail;
+            /// <summary>
+            /// Whether or not the todo has an attendee list
+            /// </summary>
+            public const uint HasAttendee       = (uint)PropertyIds.TodoHasAttendee;
+            /// <summary>
+            /// The attendee list of the todo.
+            /// </summary>
+            public const uint Attendee          = (uint)PropertyIds.TodoAttendee;
+            /// <summary>
+            /// The extended property list of the todo.
+            /// </summary>
+            public const uint Extended          = (uint)PropertyIds.TodoExtended;
+            /// <summary>
+            /// The todo is an allday event or not
+            /// </summary>
+            public const uint IsAllday          = (uint)PropertyIds.TodoIsAllday;
+        }
+
+        public static class Timezone
+        {
+            /// <summary>
+            /// Identifier of this timezone view
+            /// </summary>
+            public const string Uri = "tizen.calendar_view.timezone";
+            /// <summary>
+            /// DB record ID of the timezone
+            /// </summary>
+            public const uint Id                          = (uint)PropertyIds.TimezoneId;
+            /// <summary>
+            /// UTC offset which is in use when the onset of this time zone observance begins. Valid values are -720(-12:00) to 840(+14:00)
+            /// </summary>
+            public const uint TzOffsetFromGmt             = (uint)PropertyIds.TimezoneTzOffsetFromGmt;
+            /// <summary>
+            /// Name of the Standard Time
+            /// </summary>
+            public const uint StandardName                = (uint)PropertyIds.TimezoneStandardName;
+            /// <summary>
+            /// Starting month of the Standard Time. Month is 0-based. eg, 0 for January
+            /// </summary>
+            public const uint StdStartMonth               = (uint)PropertyIds.TimezoneStdStartMonth;
+            /// <summary>
+            /// Starting day-of-week-in-month of the Standard Time. Day is 1-based
+            /// </summary>
+            public const uint StdStartPositionOfWeek      = (uint)PropertyIds.TimezoneStdStartPositionOfWeek;
+            /// <summary>
+            /// Starting day-of-week of the Standard Time. Valid values are 1(SUNDAY) to 7(SATURDAY)
+            /// </summary>
+            public const uint StdStartDay                 = (uint)PropertyIds.TimezoneStdStartDay;
+            /// <summary>
+            /// Starting hour of the Standard Time. Valid values are 0 to 23
+            /// </summary>
+            public const uint StdStartHour                = (uint)PropertyIds.TimezoneStdStartHour;
+            /// <summary>
+            /// The number of minutes added during the Standard Time
+            /// </summary>
+            public const uint StandardBias                = (uint)PropertyIds.TimezoneStandardBias;
+            /// <summary>
+            /// Name of Daylight
+            /// </summary>
+            public const uint DayLightName                = (uint)PropertyIds.TimezoneDayLightName;
+            /// <summary>
+            /// Starting month of Daylight. Month is 0-based. eg, 0 for January
+            /// </summary>
+            public const uint DayLightStartMonth          = (uint)PropertyIds.TimezoneDayLightStartMonth;
+            /// <summary>
+            /// Starting day-of-week-in-month of Daylight. Day is 1-based
+            /// </summary>
+            public const uint DayLightStartPositionOfWeek = (uint)PropertyIds.TimezoneDayLightStartPositionOfWeek;
+            /// <summary>
+            /// Starting day-of-week of Daylight. Valid values are 1(SUNDAY) to 7(SATURDAY)
+            /// </summary>
+            public const uint DayLightStartDay            = (uint)PropertyIds.TimezoneDayLightStartDay;
+            /// <summary>
+            /// Starting hour of Daylight. Valid values are 0 to 23
+            /// </summary>
+            public const uint DayLightStartHour           = (uint)PropertyIds.TimezoneDayLightStartHour;
+            /// <summary>
+            /// The number of minutes added during Daylight Time
+            /// </summary>
+            public const uint DayLightBias                = (uint)PropertyIds.TimezoneDayLightBias;
+            /// <summary>
+            /// DB record ID of a related calendar book
+            /// </summary>
+            public const uint CalendarId                  = (uint)PropertyIds.TimezoneCalendarId;
+        }
+
+        public static class Attendee
+        {
+            /// <summary>
+            /// Identifier of this calendar attendee view
+            /// </summary>
+            public const string Uri = "tizen.calendar_view.attendee";
+            /// <summary>
+            /// The number of the attendee
+            /// </summary>
+            public const uint Number       = (uint)PropertyIds.AttendeeNumber;
+            /// <summary>
+            /// The type of attendee(refer to the CalendarTypes.Cutype).
+            /// </summary>
+            public const uint Cutype       = (uint)PropertyIds.AttendeeCutype;
+            /// <summary>
+            ///
+            /// </summary>
+            public const uint CtIndex      = (uint)PropertyIds.AttendeeCtIndex;
+            /// <summary>
+            /// Unique identifier
+            /// </summary>
+            public const uint Uid          = (uint)PropertyIds.AttendeeUid;
+            /// <summary>
+            ///
+            /// </summary>
+            public const uint Group        = (uint)PropertyIds.AttendeeGroup;
+            /// <summary>
+            /// The email address of the attendee
+            /// </summary>
+            public const uint Email        = (uint)PropertyIds.AttendeeEmail;
+            /// <summary>
+            /// Attendee role(refer to the CalendarTypes.AttendeeRole).
+            /// </summary>
+            public const uint Role         = (uint)PropertyIds.AttendeeRole;
+            /// <summary>
+            /// Attendee status(refer to the CalendarTypes.AttendeeStatus).
+            /// </summary>
+            public const uint Status       = (uint)PropertyIds.AttendeeStatus;
+            /// <summary>
+            /// RSVP invitation reply (one of true, false)
+            /// </summary>
+            public const uint Rsvp         = (uint)PropertyIds.AttendeeRsvp;
+            /// <summary>
+            /// Delegatee (DELEGATED-TO)
+            /// </summary>
+            public const uint DelegateeUri = (uint)PropertyIds.AttendeeDelegateeUri;
+            /// <summary>
+            /// Delegator (DELEGATED-FROM)
+            /// </summary>
+            public const uint DelegatorUri = (uint)PropertyIds.AttendeeDelegatorUri;
+            /// <summary>
+            /// Attendee name
+            /// </summary>
+            public const uint Name         = (uint)PropertyIds.AttendeeName;
+            /// <summary>
+            /// Group that the attendee belongs to
+            /// </summary>
+            public const uint Member       = (uint)PropertyIds.AttendeeMember;
+            /// <summary>
+            /// Event/TODO that the attendee belongs to
+            /// </summary>
+            public const uint ParentId     = (uint)PropertyIds.AttendeeParentId;
+        }
+
+        public static class Alarm
+        {
+            /// <summary>
+            /// Identifier of this calendar alarm view
+            /// </summary>
+            public const string Uri = "tizen.calendar_view.alarm";
+            /// <summary>
+            /// The number of unit before start time. This MUST be used with one of TickUnit.
+            /// </summary>
+            public const uint Tick        = (uint)PropertyIds.AlarmTick;
+            /// <summary>
+            /// Reminder tick time unit(refer to the CalendarTypes.TickUnit).
+            /// </summary>
+            public const uint TickUnit    = (uint)PropertyIds.AlarmTickUnit;
+            /// <summary>
+            /// Alarm description
+            /// </summary>
+            public const uint Description = (uint)PropertyIds.AlarmDescription;
+            /// <summary>
+            /// Event that the alarm belongs to
+            /// </summary>
+            public const uint ParentId    = (uint)PropertyIds.AlarmParentId;
+            /// <summary>
+            /// Alarm summary
+            /// </summary>
+            public const uint Summary     = (uint)PropertyIds.AlarmSummary;
+            /// <summary>
+            /// Action of alarm(refer to the CalendarTypes.Action).
+            /// </summary>
+            public const uint Action      = (uint)PropertyIds.AlarmAction;
+            /// <summary>
+            /// Alarm tone path
+            /// </summary>
+            public const uint Attach      = (uint)PropertyIds.AlarmAttach;
+            /// <summary>
+            /// The alarm time
+            /// </summary>
+            public const uint AlarmTime   = (uint)PropertyIds.AlarmAlarm;
+        }
+
+        public static class InstanceUtimeBook
+        {
+            /// <summary>
+            /// Identifier of this instance utime book
+            /// </summary>
+            public const string Uri = "tizen.calendar_view.instance_utime/book";
+            /// <summary>
+            /// Event id
+            /// </summary>
+            public const uint EventId          = (uint)PropertyIds.InstanceUtimeBookEventId;
+            /// <summary>
+            /// Start time
+            /// </summary>
+            public const uint Start            = (uint)PropertyIds.InstanceUtimeBookStart;
+            /// <summary>
+            /// End time
+            /// </summary>
+            public const uint End              = (uint)PropertyIds.InstanceUtimeBookEnd;
+            /// <summary>
+            /// Summary
+            /// </summary>
+            public const uint Summary          = (uint)PropertyIds.InstanceUtimeBookSummary;
+            /// <summary>
+            /// Location
+            /// </summary>
+            public const uint Location         = (uint)PropertyIds.InstanceUtimeBookLocation;
+            /// <summary>
+            /// Book id
+            /// </summary>
+            public const uint BookId           = (uint)PropertyIds.InstanceUtimeBookBookId;
+            /// <summary>
+            /// Description
+            /// </summary>
+            public const uint Description      = (uint)PropertyIds.InstanceUtimeBookDescription;
+            /// <summary>
+            /// BusyStatus
+            /// </summary>
+            public const uint BusyStatus       = (uint)PropertyIds.InstanceUtimeBookBusyStatus;
+            /// <summary>
+            /// EventStatus
+            /// </summary>
+            public const uint EventStatus      = (uint)PropertyIds.InstanceUtimeBookEventStatus;
+            /// <summary>
+            /// Priority
+            /// </summary>
+            public const uint Priority         = (uint)PropertyIds.InstanceUtimeBookPriority;
+            /// <summary>
+            /// Sensitivity
+            /// </summary>
+            public const uint Sensitivity      = (uint)PropertyIds.InstanceUtimeBookSensitivity;
+            /// <summary>
+            /// HasRrule
+            /// </summary>
+            public const uint HasRrule         = (uint)PropertyIds.InstanceUtimeBookHasRrule;
+            /// <summary>
+            /// Latitude
+            /// </summary>
+            public const uint Latitude         = (uint)PropertyIds.InstanceUtimeBookLatitude;
+            /// <summary>
+            /// Longitude
+            /// </summary>
+            public const uint Longitude        = (uint)PropertyIds.InstanceUtimeBookLongitude;
+            /// <summary>
+            /// HasAlarm
+            /// </summary>
+            public const uint HasAlarm         = (uint)PropertyIds.InstanceUtimeBookHasAlarm;
+            /// <summary>
+            /// OriginalEventId
+            /// </summary>
+            public const uint OriginalEventId  = (uint)PropertyIds.InstanceUtimeBookOriginalEventId;
+            /// <summary>
+            /// LastModifiedtime
+            /// </summary>
+            public const uint LastModifiedtime = (uint)PropertyIds.InstanceUtimeBookLastModifiedtime;
+            /// <summary>
+            /// SyncData1
+            /// </summary>
+            public const uint SyncData1        = (uint)PropertyIds.InstanceUtimeBookSyncData1;
+        }
+
+        public static class InstanceLocaltimeBook
+        {
+            /// <summary>
+            /// Uri
+            /// </summary>
+            public const string Uri = "tizen.calendar_view.instance_localtime/book";
+            /// <summary>
+            /// EventId
+            /// </summary>
+            public const uint EventId          = (uint)PropertyIds.InstanceLocaltimeBookEventId;
+            /// <summary>
+            /// Start
+            /// </summary>
+            public const uint Start            = (uint)PropertyIds.InstanceLocaltimeBookStart;
+            /// <summary>
+            /// End
+            /// </summary>
+            public const uint End              = (uint)PropertyIds.InstanceLocaltimeBookEnd;
+            /// <summary>
+            /// Summary
+            /// </summary>
+            public const uint Summary          = (uint)PropertyIds.InstanceLocaltimeBookSummary;
+            /// <summary>
+            /// Location
+            /// </summary>
+            public const uint Location         = (uint)PropertyIds.InstanceLocaltimeBookLocation;
+            /// <summary>
+            /// BookId
+            /// </summary>
+            public const uint BookId           = (uint)PropertyIds.InstanceLocaltimeBookBookId;
+            /// <summary>
+            /// Description
+            /// </summary>
+            public const uint Description      = (uint)PropertyIds.InstanceLocaltimeBookDescription;
+            /// <summary>
+            /// BusyStatus
+            /// </summary>
+            public const uint BusyStatus       = (uint)PropertyIds.InstanceLocaltimeBookBusyStatus;
+            /// <summary>
+            /// EventStatus
+            /// </summary>
+            public const uint EventStatus      = (uint)PropertyIds.InstanceLocaltimeBookEventStatus;
+            /// <summary>
+            /// Priority
+            /// </summary>
+            public const uint Priority         = (uint)PropertyIds.InstanceLocaltimeBookPriority;
+            /// <summary>
+            /// Sensitivity
+            /// </summary>
+            public const uint Sensitivity      = (uint)PropertyIds.InstanceLocaltimeBookSensitivity;
+            /// <summary>
+            /// HasRrule
+            /// </summary>
+            public const uint HasRrule         = (uint)PropertyIds.InstanceLocaltimeBookHasRrule;
+            /// <summary>
+            /// Latitude
+            /// </summary>
+            public const uint Latitude         = (uint)PropertyIds.InstanceLocaltimeBookLatitude;
+            /// <summary>
+            /// Longitude
+            /// </summary>
+            public const uint Longitude        = (uint)PropertyIds.InstanceLocaltimeBookLongitude;
+            /// <summary>
+            /// HasAlarm
+            /// </summary>
+            public const uint HasAlarm         = (uint)PropertyIds.InstanceLocaltimeBookHasAlarm;
+            /// <summary>
+            /// OriginalEventId
+            /// </summary>
+            public const uint OriginalEventId  = (uint)PropertyIds.InstanceLocaltimeBookOriginalEventId;
+            /// <summary>
+            /// LastModifiedTime
+            /// </summary>
+            public const uint LastModifiedTime = (uint)PropertyIds.InstanceLocaltimeBookLastModifiedTime;
+            /// <summary>
+            /// SyncData1
+            /// </summary>
+            public const uint SyncData1        = (uint)PropertyIds.InstanceLocaltimeBookSyncData1;
+            /// <summary>
+            /// IsAllday
+            /// </summary>
+            public const uint IsAllday         = (uint)PropertyIds.InstanceLocaltimeBookIsAllday;
+        }
+
+        public static class InstanceUtimeBookExtended
+        {
+            /// <summary>
+            /// Uri
+            /// </summary>
+            public const string Uri = "tizen.calendar_view.extended/instance_utime/book";
+            /// <summary>
+            /// EventId
+            /// </summary>
+            public const uint EventId           = (uint)PropertyIds.InstanceUtimeBookExtendedEventId;
+            /// <summary>
+            /// Start
+            /// </summary>
+            public const uint Start             = (uint)PropertyIds.InstanceUtimeBookExtendedStart;
+            /// <summary>
+            /// End
+            /// </summary>
+            public const uint End               = (uint)PropertyIds.InstanceUtimeBookExtendedEnd;
+            /// <summary>
+            /// Summary
+            /// </summary>
+            public const uint Summary           = (uint)PropertyIds.InstanceUtimeBookExtendedSummary;
+            /// <summary>
+            /// Location
+            /// </summary>
+            public const uint Location          = (uint)PropertyIds.InstanceUtimeBookExtendedLocation;
+            /// <summary>
+            /// BookId
+            /// </summary>
+            public const uint BookId            = (uint)PropertyIds.InstanceUtimeBookExtendedBookId;
+            /// <summary>
+            /// Description
+            /// </summary>
+            public const uint Description       = (uint)PropertyIds.InstanceUtimeBookExtendedDescription;
+            /// <summary>
+            /// BusyStatus
+            /// </summary>
+            public const uint BusyStatus        = (uint)PropertyIds.InstanceUtimeBookExtendedBusyStatus;
+            /// <summary>
+            /// EventStatus
+            /// </summary>
+            public const uint EventStatus       = (uint)PropertyIds.InstanceUtimeBookExtendedEventStatus;
+            /// <summary>
+            /// Priority
+            /// </summary>
+            public const uint Priority          = (uint)PropertyIds.InstanceUtimeBookExtendedPriority;
+            /// <summary>
+            /// Sensitivity
+            /// </summary>
+            public const uint Sensitivity       = (uint)PropertyIds.InstanceUtimeBookExtendedSensitivity;
+            /// <summary>
+            /// HasRrule
+            /// </summary>
+            public const uint HasRrule          = (uint)PropertyIds.InstanceUtimeBookExtendedHasRrule;
+            /// <summary>
+            /// Latitude
+            /// </summary>
+            public const uint Latitude          = (uint)PropertyIds.InstanceUtimeBookExtendedLatitude;
+            /// <summary>
+            /// Longitude
+            /// </summary>
+            public const uint Longitude         = (uint)PropertyIds.InstanceUtimeBookExtendedLongitude;
+            /// <summary>
+            /// HasAlarm
+            /// </summary>
+            public const uint HasAlarm          = (uint)PropertyIds.InstanceUtimeBookExtendedHasAlarm;
+            /// <summary>
+            /// OriginalEventId
+            /// </summary>
+            public const uint OriginalEventId   = (uint)PropertyIds.InstanceUtimeBookExtendedOriginalEventId;
+            /// <summary>
+            /// LastModifiedTime
+            /// </summary>
+            public const uint LastModifiedTime  = (uint)PropertyIds.InstanceUtimeBookExtendedLastModifiedTime;
+            /// <summary>
+            /// SyncData1
+            /// </summary>
+            public const uint SyncData1         = (uint)PropertyIds.InstanceUtimeBookExtendedSyncData1;
+            /// <summary>
+            /// OrganizerName
+            /// </summary>
+            public const uint OrganizerName     = (uint)PropertyIds.InstanceUtimeBookExtendedOrganizerName;
+            /// <summary>
+            /// Categories
+            /// </summary>
+            public const uint Categories        = (uint)PropertyIds.InstanceUtimeBookExtendedCategories;
+            /// <summary>
+            /// HasAttendee
+            /// </summary>
+            public const uint HasAttendee       = (uint)PropertyIds.InstanceUtimeBookExtendedHasAttendee;
+            /// <summary>
+            /// SyncData2
+            /// </summary>
+            public const uint SyncData2         = (uint)PropertyIds.InstanceUtimeBookExtendedSyncData2;
+            /// <summary>
+            /// SyncData3
+            /// </summary>
+            public const uint SyncData3         = (uint)PropertyIds.InstanceUtimeBookExtendedSyncData3;
+            /// <summary>
+            /// SyncData4
+            /// </summary>
+            public const uint SyncData4         = (uint)PropertyIds.InstanceUtimeBookExtendedSyncData4;
+        }
+
+        public static class InstanceLocaltimeBookExtended
+        {
+            /// <summary>
+            /// Uri
+            /// </summary>
+            public const string Uri = "tizen.calendar_view.extended/instance_localtime/book";
+            /// <summary>
+            /// EventId
+            /// </summary>
+            public const uint EventId          = (uint)PropertyIds.InstanceLocaltimeBookExtendedEventId;
+            /// <summary>
+            /// Start
+            /// </summary>
+            public const uint Start            = (uint)PropertyIds.InstanceLocaltimeBookExtendedStart;
+            /// <summary>
+            /// End
+            /// </summary>
+            public const uint End              = (uint)PropertyIds.InstanceLocaltimeBookExtendedEnd;
+            /// <summary>
+            /// Summary
+            /// </summary>
+            public const uint Summary          = (uint)PropertyIds.InstanceLocaltimeBookExtendedSummary;
+            /// <summary>
+            /// Location
+            /// </summary>
+            public const uint Location         = (uint)PropertyIds.InstanceLocaltimeBookExtendedLocation;
+            /// <summary>
+            /// BookId
+            /// </summary>
+            public const uint BookId           = (uint)PropertyIds.InstanceLocaltimeBookExtendedBookId;
+            /// <summary>
+            /// </summary>
+            public const uint Description      = (uint)PropertyIds.InstanceLocaltimeBookExtendedDescription;
+            /// <summary>
+            /// </summary>
+            public const uint BusyStatus       = (uint)PropertyIds.InstanceLocaltimeBookExtendedBusyStatus;
+            /// <summary>
+            /// EventStatus
+            /// </summary>
+            public const uint EventStatus      = (uint)PropertyIds.InstanceLocaltimeBookExtendedEventStatus;
+            /// <summary>
+            /// Priority
+            /// </summary>
+            public const uint Priority         = (uint)PropertyIds.InstanceLocaltimeBookExtendedPriority;
+            /// <summary>
+            /// Sensitivity
+            /// </summary>
+            public const uint Sensitivity      = (uint)PropertyIds.InstanceLocaltimeBookExtendedSensitivity;
+            /// <summary>
+            /// HasRrule
+            /// </summary>
+            public const uint HasRrule         = (uint)PropertyIds.InstanceLocaltimeBookExtendedHasRrule;
+            /// <summary>
+            /// Latitude
+            /// </summary>
+            public const uint Latitude         = (uint)PropertyIds.InstanceLocaltimeBookExtendedLatitude;
+            /// <summary>
+            /// Longitude
+            /// </summary>
+            public const uint Longitude        = (uint)PropertyIds.InstanceLocaltimeBookExtendedLongitude;
+            /// <summary>
+            /// HasAlarm
+            /// </summary>
+            public const uint HasAlarm         = (uint)PropertyIds.InstanceLocaltimeBookExtendedHasAlarm;
+            /// <summary>
+            /// OriginalEventId
+            /// </summary>
+            public const uint OriginalEventId  = (uint)PropertyIds.InstanceLocaltimeBookExtendedOriginalEventId;
+            /// <summary>
+            /// LastModifiedTime
+            /// </summary>
+            public const uint LastModifiedTime = (uint)PropertyIds.InstanceLocaltimeBookExtendedLastModifiedTime;
+            /// <summary>
+            /// SyncData1
+            /// </summary>
+            public const uint SyncData1        = (uint)PropertyIds.InstanceLocaltimeBookExtendedSyncData1;
+            /// <summary>
+            /// OrganizerName
+            /// </summary>
+            public const uint OrganizerName    = (uint)PropertyIds.InstanceLocaltimeBookExtendedOrganizerName;
+            /// <summary>
+            /// Categories
+            /// </summary>
+            public const uint Categories       = (uint)PropertyIds.InstanceLocaltimeBookExtendedCategories;
+            /// <summary>
+            /// HasAttendee
+            /// </summary>
+            public const uint HasAttendee      = (uint)PropertyIds.InstanceLocaltimeBookExtendedHasAttendee;
+            /// <summary>
+            /// SyncData2
+            /// </summary>
+            public const uint SyncData2        = (uint)PropertyIds.InstanceLocaltimeBookExtendedSyncData2;
+            /// <summary>
+            /// SyncData3
+            /// </summary>
+            public const uint SyncData3        = (uint)PropertyIds.InstanceLocaltimeBookExtendedSyncData3;
+            /// <summary>
+            /// SyncData4
+            /// </summary>
+            public const uint SyncData4        = (uint)PropertyIds.InstanceLocaltimeBookExtendedSyncData4;
+            /// <summary>
+            /// IsAllday
+            /// </summary>
+            public const uint IsAllday         = (uint)PropertyIds.InstanceLocaltimeBookExtendedIsAllday;
+        }
+
+        public static class UpdatedInfo
+        {
+            /// <summary>
+            /// Identifier of this updatedInfo view
+            /// </summary>
+            public const string Uri = "tizen.calendar_view.updated_info";
+            /// <summary>
+            /// Modified event(or todo) record ID
+            /// </summary>
+            public const uint Id         = (uint)PropertyIds.UpdateInfoId;
+            /// <summary>
+            /// Calendar book ID of the modified event(or todo) record
+            /// </summary>
+            public const uint CalendarId = (uint)PropertyIds.UpdateInfoCalendarId;
+            /// <summary>
+            /// Enumeration value of the modified status.
+            /// </summary>
+            public const uint Type       = (uint)PropertyIds.UpdateInfoType;
+            /// <summary>
+            /// Version after change
+            /// </summary>
+            public const uint Version    = (uint)PropertyIds.UpdateInfoVersion;
+        }
+
+        public static class Extended
+        {
+            /// <summary>
+            /// Identifier of this extended_property view
+            /// </summary>
+            public const string Uri = "tizen.calendar_view.extended_property";
+            /// <summary>
+            /// DB record ID of the extended_property
+            /// </summary>
+            public const uint Id         = (uint)PropertyIds.ExtendedId;
+            /// <summary>
+            /// Related record ID
+            /// </summary>
+            public const uint RecordId   = (uint)PropertyIds.ExtendedRecordId;
+            /// <summary>
+            /// Enumeration value of the record type.
+            /// </summary>
+            public const uint RecordType = (uint)PropertyIds.ExtendedRecordType;
+            /// <summary>
+            /// The key of the property
+            /// </summary>
+            public const uint Key        = (uint)PropertyIds.ExtendedKey;
+            /// <summary>
+            /// The value of the property
+            /// </summary>
+            public const uint Value      = (uint)PropertyIds.ExtendedValue;
+        }
+    }
+}
+
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/NamespaceDoc.cs b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/NamespaceDoc.cs
new file mode 100644 (file)
index 0000000..2d090bd
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/// <summary>
+/// The Tizen.Pims.Calendar namespace provides classes for managing calendar information for schedule.
+/// </summary>
+/// <remarks>
+/// The Tizen.Pims.Calendar namespace provides classes for managing calendar information for schedule.
+/// </remarks>
+namespace Tizen.Pims.Calendar {}
+
diff --git a/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/ReminderEventArgs.cs b/src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/ReminderEventArgs.cs
new file mode 100644 (file)
index 0000000..678a093
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Pims.Calendar
+{
+    /// <summary>
+    /// Event arguments passed when alarm is alerted.
+    /// </summary>
+    public class ReminderAlertedEventArgs : EventArgs
+    {
+        internal ReminderAlertedEventArgs(string param)
+        {
+            Param = param;
+            Log.Debug(Globals.LogTag, "[TEST]" + param);
+        }
+
+        /// <summary>
+        /// The paramter which data is combinded(Value string like id=value&amp;time=value&amp;tick=value&amp;unit=value&amp;type=value)
+        /// </summary>
+        public string Param
+        {
+            get;
+            internal set;
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Interop/Interop.Activity.cs b/src/Tizen.Pims.Contacts/Interop/Interop.Activity.cs
new file mode 100755 (executable)
index 0000000..ccff505
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// Partial Interop Class
+/// </summary>
+internal static partial class Interop
+{
+    internal static class Activity
+    {
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_activity_delete_by_contact_id")]
+        internal static extern int DeleteByContactId(int contactId);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_activity_delete_by_account_id")]
+        internal static extern int DeleteByAccountId(int accountId);
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Interop/Interop.Contacts.cs b/src/Tizen.Pims.Contacts/Interop/Interop.Contacts.cs
new file mode 100755 (executable)
index 0000000..7efa40f
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// Partial Interop Class
+/// </summary>
+internal static partial class Interop
+{
+    /// <summary>
+    /// Contacts Interop Class
+    /// </summary>
+    internal static class Contacts
+    {
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_connect")]
+        internal static extern int Connect();
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_disconnect")]
+        internal static extern int Disconnect();
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_connect_on_thread")]
+        internal static extern int OnThreadConnect();
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_disconnect_on_thread")]
+        internal static extern int OnThreadDisconnect();
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_connect_with_flags")]
+        internal static extern int DisconnectWithFlags(uint flags);
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Interop/Interop.Database.cs b/src/Tizen.Pims.Contacts/Interop/Interop.Database.cs
new file mode 100644 (file)
index 0000000..787baaa
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal enum ContactsChanged
+    {
+        Inserted,
+        Updated,
+        Deleted
+    }
+
+    internal static partial class Database
+    {
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_insert_record")]
+        internal static extern int Insert(IntPtr recordHandle, out int recordId);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_record")]
+        internal static extern int Get(string uri, int recordId, out IntPtr recordHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_update_record")]
+        internal static extern int Update(IntPtr recordHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_delete_record")]
+        internal static extern int Delete(string uri, int recordId);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_replace_record")]
+        internal static extern int Replace(IntPtr recordHandle, int recordId);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_all_records")]
+        internal static extern int GetRecords(string uri, int offset, int limit, out IntPtr listHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_records_with_query")]
+        internal static extern int GetRecords(IntPtr queryHandle, int offset, int limit, out IntPtr listHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_insert_records")]
+        internal static extern int InsertRecords(IntPtr listHandle, out IntPtr ids, out int count);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_update_records")]
+        internal static extern int UpdateRecords(IntPtr listHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_delete_records")]
+        internal static extern int DeleteRecords(string uri, int[] recordIdArray, int count);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_replace_records")]
+        internal static extern int ReplaceRecords(IntPtr listHandle, int[] recordIdArray, int count);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_current_version")]
+        internal static extern int GetVersion(out int contactsDBVersion);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_add_changed_cb")]
+        internal static extern int AddChangedCb(string uri, ContactsDBChangedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_remove_changed_cb")]
+        internal static extern int RemoveChangedCb(string uri, ContactsDBChangedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_changes_by_version")]
+        internal static extern int GetChangesByVersion(string uri, int addressBookId, int contactsDBVersion, out IntPtr changeRecordList, out int currentContactsDBVersion);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_search_records")]
+        internal static extern int Search(string uri, string keyword, int offset, int limit, out IntPtr listHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_search_records_with_query")]
+        internal static extern int Search(IntPtr queryHandle, string keyword, int offset, int limit, out IntPtr listHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_search_records_with_range")]
+        internal static extern int Search(string uri, string keyword, int offset, int limit, int range, out IntPtr listHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_search_records_for_snippet")]
+        internal static extern int Search(string uri, string keyword, int offset, int limit, string startMatch, string endMatch, int tokenNumber, out IntPtr listHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_search_records_with_query_for_snippet")]
+        internal static extern int Search(IntPtr queryHandle, string keyword, int offset, int limit, string startMatch, string endMatch, int tokenNumber, out IntPtr listHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_search_records_with_range_for_snippet")]
+        internal static extern int Search(string uri, string keyword, int offset, int limit, int range, string startMatch, string endMatch, int tokenNumber, out IntPtr listHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_count")]
+        internal static extern int GetCount(string uri, out int count);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_count_with_query")]
+        internal static extern int GetCount(IntPtr queryHandle, out int count);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_last_change_version")]
+        internal static extern int GetLastChangeVersion(out int version);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_status")]
+        internal static extern int GetStatus(out Tizen.Pims.Contacts.ContactsDatabase.DBStatus status);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_add_changed_cb")]
+        internal static extern int AddStatusChangedCb(ContactsDBStatusChangedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_remove_changed_cb")]
+        internal static extern int RemoveStatusChangedCb(ContactsDBStatusChangedCallback callback, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void ContactsDBChangedCallback(string uri, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void ContactsDBStatusChangedCallback(Tizen.Pims.Contacts.ContactsDatabase.DBStatus status, IntPtr userData);
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Interop/Interop.Filter.cs b/src/Tizen.Pims.Contacts/Interop/Interop.Filter.cs
new file mode 100644 (file)
index 0000000..8435ef8
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using static Tizen.Pims.Contacts.ContactsFilter;
+
+internal static partial class Interop
+{
+    internal static partial class Filter
+    {
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_filter_create")]
+        internal static extern int ContactsFilterCreate(string uri, out IntPtr filterHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_filter_destroy")]
+        internal static extern int ContactsFilterDestroy(IntPtr filterHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_filter_add_str")]
+        internal static extern int ContactsFilterAddStr(IntPtr filterHandle, uint propertyId, StringMatchType match, string matchValue);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_filter_add_int")]
+        internal static extern int ContactsFilterAddInt(IntPtr filterHandle, uint propertyId, IntegerMatchType match, int matchValue);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_filter_add_lli")]
+        internal static extern int ContactsFilterAddLli(IntPtr filterHandle, uint propertyId, IntegerMatchType match, long matchValue);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_filter_add_double")]
+        internal static extern int ContactsFilterAddDouble(IntPtr filterHandle, uint propertyId, IntegerMatchType match, double matchValue);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_filter_add_bool")]
+        internal static extern int ContactsFilterAddBool(IntPtr filterHandle, uint propertyId, bool matchValue);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_filter_add_operator")]
+        internal static extern int ContactsFilterAddOperator(IntPtr filterHandle, LogicalOperator operatorType);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_filter_add_filter")]
+        internal static extern int ContactsFilterAddFilter(IntPtr parentFilter, IntPtr childFilter);
+
+
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Interop/Interop.Group.cs b/src/Tizen.Pims.Contacts/Interop/Interop.Group.cs
new file mode 100755 (executable)
index 0000000..a028fb5
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// Partial Interop Class
+/// </summary>
+internal static partial class Interop
+{
+    /// <summary>
+    /// Contacts Interop Class
+    /// </summary>
+    internal static class Group
+    {
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_group_add_contact")]
+        internal static extern int AddContact(int groupId, int contactId);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_group_remove_contact")]
+        internal static extern int RemoveContact(int groupId, int contactId);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_group_set_group_order")]
+        internal static extern int SetGroupOrder(int groupId, int previousGroupId, int nextGroupId);
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.Pims.Contacts/Interop/Interop.Libraries.cs b/src/Tizen.Pims.Contacts/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..b916131
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/// <summary>
+/// Partial Interop Class
+/// </summary>
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string Contacts = "libcontacts-service2.so.0";
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Interop/Interop.List.cs b/src/Tizen.Pims.Contacts/Interop/Interop.List.cs
new file mode 100755 (executable)
index 0000000..67454cb
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class List
+    {
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_list_create")]
+        internal static extern int ContactsListCreate(out IntPtr contactsList);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_list_destroy")]
+        internal static extern int ContactsListDestroy(IntPtr contactsList, bool deleteChild);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_list_get_count")]
+        internal static extern int ContactsListGetCount(IntPtr contactsList, out int count);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_list_add")]
+        internal static extern int ContactsListAdd(IntPtr contactsList, IntPtr recordHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_list_remove")]
+        internal static extern int ContactsListRemove(IntPtr contactsList, IntPtr recordHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_list_get_current_record_p")]
+        internal static extern int ContactsListGetCurrentRecordP(IntPtr contactsList, out IntPtr recordHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_list_prev")]
+        internal static extern int ContactsListPrev(IntPtr contactsList);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_list_next")]
+        internal static extern int ContactsListNext(IntPtr contactsList);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_list_first")]
+        internal static extern int ContactsListFirst(IntPtr contactsList);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_list_last")]
+        internal static extern int ContactsListLast(IntPtr contactsList);
+
+
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Interop/Interop.Person.cs b/src/Tizen.Pims.Contacts/Interop/Interop.Person.cs
new file mode 100755 (executable)
index 0000000..7dd177f
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal enum ContactsPersonProperty
+    {
+        NameContact, // Default contacts record
+        Number, // Default number record
+        Email, // Default Email record
+        Image // Default image record
+    };
+
+    internal enum  ContactsUsageType
+    {
+        None,          /**< None */
+        OutgoingCall, /**< Outgoing Call */
+        OutgoingMsg,   /**< Outgoing message */
+        OutgoingEmail, /**< Outgoing Email (Since 3.0) */
+        IncomingCall, /**< Incoming Call (Since 3.0) */
+        IncomingMsg,  /**< Incoming message (Since 3.0) */
+        IncomingEmail,/**< Incoming Email (Since 3.0) */
+        MissedCall,     /**< Missed Call (Since 3.0) */
+        RejectedCall, /**< Rejected Call (Since 3.0) */
+        BlockedCall, /**< Blocked Call (Since 3.0) */
+        BlockedMsg /**< Blocked message (Since 3.0) */
+    };
+
+    internal static partial class Person
+    {
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_person_link_person")]
+        internal static extern int ContactsPersonLinkPerson(int basePersonId, int personId);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_person_unlink_contact")]
+        internal static extern int ContactsPersonUnlinkContact(int personId, int contactId, out int unlinkedPersonId);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_person_reset_usage")]
+        internal static extern int ContactsPersonResetUsage(int personId, ContactsUsageType type);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_person_set_favorite_order")]
+        internal static extern int ContactsPersonSetFavoriteOrder(int personId, int previousPersonId, int nextPersonId);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_person_set_default_property")]
+        internal static extern int ContactsPersonSetDefaultProperty(ContactsPersonProperty property, int personId, int id);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_person_get_default_property")]
+        internal static extern int ContactsPersonGetDefaultProperty(ContactsPersonProperty property, int personId, out int id);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_person_get_aggregation_suggestions")]
+        internal static extern int ContactsPersonGetAggregationSuggestions(int personId, int limit, out IntPtr listHandle);
+
+
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Interop/Interop.PhoneLog.cs b/src/Tizen.Pims.Contacts/Interop/Interop.PhoneLog.cs
new file mode 100755 (executable)
index 0000000..f530c5f
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// Partial Interop Class
+/// </summary>
+internal static partial class Interop
+{
+    internal static class PhoneLog
+    {
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_phone_log_reset_statistics")]
+        internal static extern int resetStatistics();
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_phone_log_reset_statistics_by_sim")]
+        internal static extern int resetStatisticsBySim(int simSlotNo);
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Interop/Interop.Query.cs b/src/Tizen.Pims.Contacts/Interop/Interop.Query.cs
new file mode 100755 (executable)
index 0000000..7c23038
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Query
+    {
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_query_create")]
+        internal static extern int ContactsQueryCreate(string uri, out IntPtr queryHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_query_destroy")]
+        internal static extern int ContactsQueryDestroy(IntPtr queryHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_query_set_projection")]
+        internal static extern int ContactsQuerySetProjection(IntPtr queryHandle, uint[] propertyIdArray, int count);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_query_set_distinct")]
+        internal static extern int ContactsQuerySetDistinct(IntPtr queryHandle, bool set);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_query_set_filter")]
+        internal static extern int ContactsQuerySetFilter(IntPtr queryHandle, IntPtr filterHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_query_set_sort")]
+        internal static extern int ContactsQuerySetSort(IntPtr queryHandle, uint propertyId, bool isAscending);
+
+
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Interop/Interop.Record.cs b/src/Tizen.Pims.Contacts/Interop/Interop.Record.cs
new file mode 100644 (file)
index 0000000..82f67a1
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Record
+    {
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_create")]
+        internal static extern int Create(string uri, out IntPtr recordIdHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_destroy")]
+        internal static extern int Destroy(IntPtr recordHandle, bool deleteChild);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_clone")]
+        internal static extern int Clone(IntPtr recordHandle, out IntPtr clonedRecordHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_get_str")]
+        internal static extern int GetStr(IntPtr recordHandle, uint propertyId, out string value);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_get_str_p")]
+        internal static extern int GetStrP(IntPtr recordHandle, uint propertyId, out string value);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_set_str")]
+        internal static extern int SetStr(IntPtr recordHandle, uint propertyId, string value);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_get_int")]
+        internal static extern int GetInt(IntPtr recordHandle, uint propertyId, out int value);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_set_int")]
+        internal static extern int SetInt(IntPtr recordHandle, uint propertyId, int value);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_get_lli")]
+        internal static extern int GetLli(IntPtr recordHandle, uint propertyId, out long value);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_set_lli")]
+        internal static extern int SetLli(IntPtr recordHandle, uint propertyId, long value);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_get_bool")]
+        internal static extern int GetBool(IntPtr recordHandle, uint propertyId, out bool value);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_set_bool")]
+        internal static extern int SetBool(IntPtr recordHandle, uint propertyId, bool value);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_get_double")]
+        internal static extern int GetDouble(IntPtr recordHandle, uint propertyId, out double value);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_set_double")]
+        internal static extern int SetDouble(IntPtr recordHandle, uint propertyId, double value);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_add_child_record")]
+        internal static extern int AddChildRecord(IntPtr recordHandle, uint propertyId, IntPtr childRecordHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_remove_child_record")]
+        internal static extern int RemoveChildRecord(IntPtr recordHandle, uint propertyId, IntPtr childRecordHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_get_child_record_count")]
+        internal static extern int GetChildRecordCount(IntPtr recordHandle, uint propertyId, out int count);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_get_child_record_at_p")]
+        internal static extern int GetChildRecordAtP(IntPtr recordHandle, uint propertyId, int index, out IntPtr childRecordHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_clone_child_record_list")]
+        internal static extern int CloneChildRecordList(IntPtr recordHandle, uint propertyId, out IntPtr clonedListHandle);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_record_get_uri_p")]
+        internal static extern int GetUriP(IntPtr recordHandle, out IntPtr uri);
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Interop/Interop.Setting.cs b/src/Tizen.Pims.Contacts/Interop/Interop.Setting.cs
new file mode 100755 (executable)
index 0000000..902d7e3
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Pims.Contacts;
+
+/// <summary>
+/// Partial Interop Class
+/// </summary>
+internal static partial class Interop
+{
+    internal static class Setting
+    {
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_setting_get_name_display_order")]
+        internal static extern int GetNameDisplayOrder(out ContactDisplayOrder nameDisplayOrder);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_setting_set_name_display_order")]
+        internal static extern int SetNameDisplayOrder(ContactDisplayOrder nameDisplayOrder);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_setting_get_name_sorting_order")]
+        internal static extern int GetNameSortingOrder(out ContactSortingOrder nameSortingOrder);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_setting_set_name_sorting_order")]
+        internal static extern int SetNameSortingOrder(ContactSortingOrder nameSortingOrder);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_setting_add_name_display_order_changed_cb")]
+        internal static extern int AddNameDisplayOrderChangedCB(DisplayOrderChangedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_setting_remove_name_display_order_changed_cb")]
+        internal static extern int RemoveNameDisplayOrderChangedCB(DisplayOrderChangedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_setting_add_name_sorting_order_changed_cb")]
+        internal static extern int AddNameSortingOrderChangedCB(SortingOrderChangedCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_setting_remove_name_sorting_order_changed_cb")]
+        internal static extern int RemoveNameSortingOrderChangedCB(SortingOrderChangedCallback callback, IntPtr userData);
+
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void DisplayOrderChangedCallback(ContactDisplayOrder nameDisplayOrder, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void SortingOrderChangedCallback(ContactSortingOrder nameSortingOrder, IntPtr userData);
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Interop/Interop.Sim.cs b/src/Tizen.Pims.Contacts/Interop/Interop.Sim.cs
new file mode 100755 (executable)
index 0000000..488a5f6
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// Partial Interop Class
+/// </summary>
+internal static partial class Interop
+{
+    internal static class Sim
+    {
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_sim_import_all_contacts_by_sim_slot_no")]
+        internal static extern int ImportAllContactsBySimSlotNo(int sim_slot_no, ContactsSimImportProgressCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_sim_get_initialization_status_by_sim_slot_no")]
+        internal static extern int GetInitializatOnStatusBySimSlotNo(int sim_slot_no, out bool completed);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void ContactsSimImportProgressCallback(string uri, IntPtr userData);
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Interop/Interop.Vcard.cs b/src/Tizen.Pims.Contacts/Interop/Interop.Vcard.cs
new file mode 100755 (executable)
index 0000000..47f135b
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Vcard
+    {
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_vcard_parse_to_contact_foreach")]
+        internal static extern int ContactsVcardParseToContactForeach(string vcardFilePath, ContactsVcardParseCallback callback, IntPtr /* void */ userData);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_vcard_parse_to_contacts")]
+        internal static extern int ContactsVcardParseToContacts(string vcardStream, out IntPtr contactsList);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_vcard_make_from_contact")]
+        internal static extern int ContactsVcardMakeFromContact(IntPtr contact, out string vcardStream);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_vcard_make_from_my_profile")]
+        internal static extern int ContactsVcardMakeFromMyProfile(IntPtr myProfile, out string vcardStream);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_vcard_make_from_person")]
+        internal static extern int ContactsVcardMakeFromPerson(IntPtr person, out string vcardStream);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_vcard_get_entity_count")]
+        internal static extern int ContactsVcardGetEntityCount(string vcardFilePath, out int count);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_vcard_get_limit_size_of_photo")]
+        internal static extern int ContactsVcardGetLimitSizeOfPhoto(out uint limitSize);
+
+        [DllImport(Libraries.Contacts, EntryPoint = "contacts_vcard_set_limit_size_of_photo")]
+        internal static extern int ContactsVcardSetLimitSizeOfPhoto(uint limitSize);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate bool ContactsVcardParseCallback(IntPtr recordHandle, IntPtr /* void */ userData);
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts.csproj b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts.csproj
new file mode 100644 (file)
index 0000000..ff51c60
--- /dev/null
@@ -0,0 +1,21 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <Version>1.0.0</Version>
+    <Authors>Samsung Electronics</Authors>
+    <Copyright>© Samsung Electronics Co., Ltd All Rights Reserved</Copyright>
+    <Description>Contacts Service API for Tizen .NET</Description>
+    <PackageProjectUrl>https://www.tizen.org/</PackageProjectUrl>
+    <PackageLicenseUrl>https://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
+    <PackageIconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</PackageIconUrl>
+  </PropertyGroup>
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.6</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Tizen" Version="1.0.5" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsDatabase.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsDatabase.cs
new file mode 100644 (file)
index 0000000..bae4710
--- /dev/null
@@ -0,0 +1,709 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Pims.Contacts
+{
+    /// <summary>
+    /// ContactsDatabase provides methods to manage contacts information from/to the database.
+    /// </summary>
+    /// <remarks>
+    /// This class allows user to access/create/update db operations for contacts information.
+    /// </remarks>
+    public class ContactsDatabase
+    {
+        private Object thisLock = new Object();
+        private Interop.Database.ContactsDBStatusChangedCallback _contactsDBStatusChangedCallback;
+        private event EventHandler<DBStatusChangedEventArgs> _dbStatusChanged;
+        private Dictionary<string, ContactsDBChangedDelegate> _callbackMap = new Dictionary<string, ContactsDBChangedDelegate>();
+        private Dictionary<string, Interop.Database.ContactsDBChangedCallback> _delegateMap = new Dictionary<string, Interop.Database.ContactsDBChangedCallback>();
+        private Interop.Database.ContactsDBChangedCallback _dbChangedDelegate;
+        /// <summary>
+        /// Delegete for detecting the contacts database changes
+        /// </summary>
+        /// <param name="uri">The contacts view URI</param>
+        /// <remarks>
+        /// The delegate must be registered using AddDBChangedDelegate.
+        /// It's invoked when the designated view changes.
+        /// </remarks>
+        /// <see cref="AddDBChangedDelegate"/>
+        public delegate void ContactsDBChangedDelegate(string uri);
+
+        internal ContactsDatabase()
+        {
+            ///To be created in ContactsManager only.
+        }
+
+        /// <summary>
+        /// Enumeration for contacts database status.
+        /// </summary>
+        public enum DBStatus
+        {
+            /// <summary>
+            /// Normal
+            /// </summary>
+            Normal,
+            /// <summary>
+            /// Changing collation.
+            /// </summary>
+            ChangingCollation
+        }
+
+        /// <summary>
+        /// Enumeration for Contacts search range.
+        /// </summary>
+        public enum SearchRange
+        {
+            /// <summary>
+            /// Search record from name
+            /// </summary>
+            Name = 0x00000001,
+            /// <summary>
+            /// Search record from number
+            /// </summary>
+            Number = 0x00000002,
+            /// <summary>
+            /// Search record from data
+            /// </summary>
+            Data = 0x00000004,
+            /// <summary>
+            /// Search record from email. Now, support only PersonEmail view
+            /// </summary>
+            Email = 0x00000008,
+        }
+
+        /// <summary>
+        /// Occurs when contacts database status is changed.
+        /// </summary>
+        public event EventHandler<DBStatusChangedEventArgs> DBStatusChanged
+        {
+            add
+            {
+                lock (thisLock)
+                {
+                    _contactsDBStatusChangedCallback = (DBStatus status, IntPtr userData) =>
+                    {
+                        DBStatusChangedEventArgs args = new DBStatusChangedEventArgs(status);
+                        _dbStatusChanged?.Invoke(this, args);
+                    };
+
+                    int error = Interop.Database.AddStatusChangedCb(_contactsDBStatusChangedCallback, IntPtr.Zero);
+                    if ((int)ContactsError.None != error)
+                    {
+                        Log.Error(Globals.LogTag, "Add StatusChanged Failed with error " + error);
+                    }
+                    else
+                    {
+                        _dbStatusChanged += value;
+                    }
+                }
+
+            }
+
+            remove
+            {
+                lock (thisLock)
+                {
+                    int error = Interop.Database.RemoveStatusChangedCb(_contactsDBStatusChangedCallback, IntPtr.Zero);
+                    if ((int)ContactsError.None != error)
+                    {
+                        Log.Error(Globals.LogTag, "Remove StatusChanged Failed with error " + error);
+                    }
+
+                    _dbStatusChanged -= value;
+                }
+            }
+
+        }
+
+        /// <summary>
+        /// The current contacts database version.
+        /// </summary>
+        public int Version
+        {
+            get
+            {
+                int version = -1;
+                int error = Interop.Database.GetVersion(out version);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Version Failed with error " + error);
+                }
+                return version;
+            }
+        }
+
+        /// <summary>
+        /// The last successful changed contacts database version on the current connection.
+        /// </summary>
+        public int LastChangeVersion
+        {
+            get
+            {
+                int version = -1;
+                int error = Interop.Database.GetLastChangeVersion(out version);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "LastChangeVersion Failed with error " + error);
+                }
+                return version;
+            }
+        }
+
+        /// <summary>
+        /// The contacts database status.
+        /// </summary>
+        public DBStatus Status
+        {
+            get
+            {
+                DBStatus status = DBStatus.Normal;
+                int error = Interop.Database.GetStatus(out status);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "GetStatus Failed with error " + error);
+                }
+                return status;
+            }
+        }
+
+        /// <summary>
+        /// Inserts a record into the contacts database.
+        /// </summary>
+        /// <param name="record">The record to insert</param>
+        /// <returns>The ID of inserted record</returns>
+        /// <privilege>http://tizen.org/privilege/contact.write</privilege>
+        /// <privilege>http://tizen.org/privilege/callhistory.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public int Insert(ContactsRecord record)
+        {
+            int id = -1;
+            int error = Interop.Database.Insert(record._recordHandle, out id);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Insert Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return id;
+        }
+
+        /// <summary>
+        /// Inserts multiple records into the contacts database as a batch operation.
+        /// </summary>
+        /// <param name="list">The record list</param>
+        /// <returns>The inserted record ID array</returns>
+        /// <privilege>http://tizen.org/privilege/contact.write</privilege>
+        /// <privilege>http://tizen.org/privilege/callhistory.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public int[] Insert(ContactsList list)
+        {
+            IntPtr ids;
+            int count;
+            int error = Interop.Database.InsertRecords(list._listHandle, out ids, out count);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Insert Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+
+            int[] idArr = new int[count];
+            Marshal.Copy(ids, idArr, 0, count);
+
+            return idArr;
+        }
+
+        /// <summary>
+        /// Gets a record from the contacts database.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a record</param>
+        /// <param name="recordId">The record ID</param>
+        /// <returns>The record associated with the record ID</returns>
+        /// <privilege>http://tizen.org/privilege/contact.read</privilege>
+        /// <privilege>http://tizen.org/privilege/callhistory.read</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public ContactsRecord Get(string viewUri, int recordId)
+        {
+            IntPtr handle;
+            int error = Interop.Database.Get(viewUri, recordId, out handle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Get Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return new ContactsRecord(handle);
+        }
+
+        /// <summary>
+        /// Updates a record in the contacts database.
+        /// </summary>
+        /// <param name="record">The record to update</param>
+        /// <privilege>http://tizen.org/privilege/contact.write</privilege>
+        /// <privilege>http://tizen.org/privilege/callhistory.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public void Update(ContactsRecord record)
+        {
+            int error = Interop.Database.Update(record._recordHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Update Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Updates multiple records in the contacts database as a batch operation.
+        /// </summary>
+        /// <param name="list">The record list</param>
+        /// <privilege>http://tizen.org/privilege/contact.write</privilege>
+        /// <privilege>http://tizen.org/privilege/callhistory.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public void Update(ContactsList list)
+        {
+            int error = Interop.Database.UpdateRecords(list._listHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Update Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Deletes a record from the contacts database with related child records.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a record</param>
+        /// <param name="recordId">The record ID to delete</param>
+        /// <privilege>http://tizen.org/privilege/contact.write</privilege>
+        /// <privilege>http://tizen.org/privilege/callhistory.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public void Delete(string viewUri, int recordId)
+        {
+            int error = Interop.Database.Delete(viewUri, recordId);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Delete Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Deletes multiple records with related child records from the contacts database as a batch operation.
+        /// </summary>
+        /// <param name="viewUri">The view URI of the records to delete</param>
+        /// <param name="idArray">The record IDs to delete</param>
+        /// <privilege>http://tizen.org/privilege/contact.write</privilege>
+        /// <privilege>http://tizen.org/privilege/callhistory.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public void Delete(string viewUri, int[] idArray)
+        {
+            int error = Interop.Database.DeleteRecords(viewUri, idArray, idArray.Length);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Delete Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Replaces a record in the contacts database.
+        /// </summary>
+        /// <param name="record">The record to replace</param>
+        /// <param name="recordId">the record ID to be replaced</param>
+        /// <privilege>http://tizen.org/privilege/contact.write</privilege>
+        /// <privilege>http://tizen.org/privilege/callhistory.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public void Replace(ContactsRecord record, int recordId)
+        {
+            int error = Interop.Database.Replace(record._recordHandle, recordId);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Replace Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Replaces multiple records in the contacts database as a batch operation.
+        /// </summary>
+        /// <param name="list">The record list to replace</param>
+        /// <param name="idArray">The record IDs to be replaced</param>
+        /// <privilege>http://tizen.org/privilege/contact.write</privilege>
+        /// <privilege>http://tizen.org/privilege/callhistory.write</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public void Replace(ContactsList list, int[] idArray)
+        {
+            int error = Interop.Database.ReplaceRecords(list._listHandle, idArray, idArray.Length);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Replace Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Retrieves all records as a list.
+        /// </summary>
+        /// <param name="viewUri">The view URI to get records</param>
+        /// <param name="offset">The index from which results</param>
+        /// <param name="limit">The number to limit results(value 0 is used for all records)</param>
+        /// <returns>
+        /// The record list
+        /// </returns>
+        /// <privilege>http://tizen.org/privilege/contact.read</privilege>
+        /// <privilege>http://tizen.org/privilege/callhistory.read</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public ContactsList GetAll(string viewUri, int offset, int limit)
+        {
+            IntPtr handle;
+            int error = Interop.Database.GetRecords(viewUri, offset, limit, out handle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "GetAll Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return new ContactsList(handle);
+        }
+
+        /// <summary>
+        /// Retrieves records using a query.
+        /// </summary>
+        /// <param name="query">The query to filter the results</param>
+        /// <param name="offset">The index from which to get results</param>
+        /// <param name="limit">The number to limit results(value 0 is used for get all records)</param>
+        /// <returns>
+        /// The record list
+        /// </returns>
+        /// <privilege>http://tizen.org/privilege/contact.read</privilege>
+        /// <privilege>http://tizen.org/privilege/callhistory.read</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public ContactsList GetRecordsWithQuery(ContactsQuery query, int offset, int limit)
+        {
+            IntPtr handle;
+            int error = Interop.Database.GetRecords(query._queryHandle, offset, limit, out handle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "GetAllWithQuery Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return new ContactsList(handle);
+        }
+
+        /// <summary>
+        /// Retrieves records changes since the given database version.
+        /// </summary>
+        /// <param name="viewUri">The view URI to get records</param>
+        /// <param name="addressbookId">The address book ID to filter</param>
+        /// <param name="contactsDBVersion">The contacts database version</param>
+        /// <param name="currentDBVersion">The current contacts database version</param>
+        /// <returns>
+        /// The record list
+        /// </returns>
+        /// <privilege>http://tizen.org/privilege/contact.read</privilege>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public ContactsList GetChangesByVersion(string viewUri, int addressbookId, int contactsDBVersion, out int currentDBVersion)
+        {
+            IntPtr recordList;
+            int error = Interop.Database.GetChangesByVersion(viewUri, addressbookId, contactsDBVersion, out recordList,out currentDBVersion);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "GetChangesByVersion Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return new ContactsList(recordList);
+        }
+
+        /// <summary>
+        /// Finds records based on a given keyword.
+        /// </summary>
+        /// <remarks>
+        /// This API works only for the Views below.
+        /// Person, PersonContact, PersonGroupRelation, PersonGroupAssigned and PersonGroupNotAssigned.
+        /// </remarks>
+        /// <param name="viewUri">The view URI to find records</param>
+        /// <param name="keyword">The keyword</param>
+        /// <param name="offset">The index from which to get results</param>
+        /// <param name="limit">The number to limit results(value 0 is used for get all records)</param>
+        /// <returns></returns>
+        /// <privilege>http://tizen.org/privilege/contact.read</privilege>
+        public ContactsList Search(string viewUri, string keyword, int offset, int limit)
+        {
+            IntPtr recordList;
+            int error = Interop.Database.Search(viewUri, keyword, offset, limit, out recordList);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Search Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return new ContactsList(recordList);
+        }
+
+        /// <summary>
+        /// Finds records based on given query and keyword.
+        /// </summary>
+        /// <remarks>
+        /// This API works only for the Views below.
+        /// Person, PersonContact, PersonGroupRelation, PersonGroupAssigned and PersonGroupNotAssigned.
+        /// </remarks>
+        /// <param name="query">The query to filter</param>
+        /// <param name="keyword">The keyword</param>
+        /// <param name="offset">The index from which to get results</param>
+        /// <param name="limit">The number to limit results(value 0 used for get all records)</param>
+        /// <returns>The record list</returns>
+        public ContactsList Search(ContactsQuery query, string keyword, int offset, int limit)
+        {
+            IntPtr recordList;
+            int error = Interop.Database.Search(query._queryHandle, keyword, offset, limit, out recordList);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Search Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return new ContactsList(recordList);
+        }
+
+        /// <summary>
+        /// Finds records based on a keyword and range.
+        /// </summary>
+        /// <remarks>
+        /// This API works only for the Views below.
+        /// Person, PersonContact, PersonGroupRelation, PersonGroupAssigned, PersonGroupNotAssigned, PersonNumber and PersonEmail
+        /// </remarks>
+        /// <param name="viewUri">The view URI</param>
+        /// <param name="keyword">The keyword</param>
+        /// <param name="offset">The index from which to get results</param>
+        /// <param name="limit">The number to limit results(value 0 is used for get all records)</param>
+        /// <param name="range">The search range, it should be a element of SearchRange or bitwise OR operation of them</param>
+        /// <returns>The record list</returns>
+        public ContactsList Search(string viewUri, string keyword, int offset, int limit, int range)
+        {
+            IntPtr recordList;
+            int error = Interop.Database.Search(viewUri, keyword, offset, limit, range, out recordList);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Search Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return new ContactsList(recordList);
+        }
+
+        /// <summary>
+        /// Finds records based on a given keyword for snippet
+        /// </summary>
+        /// <remarks>
+        /// This API works only for the Views below.
+        /// Person, PersonContact, PersonGroupRelation, PersonGroupAssigned and PersonGroupNotAssigned.
+        /// Because start match and end match are needed to be composed with keyword, this API performance is lower than Search(string viewUri, string keyword, int offset, int limit).
+        /// </remarks>
+        /// <param name="viewUri">The view URI to find records</param>
+        /// <param name="keyword">The keyword</param>
+        /// <param name="offset">The index from which to get results</param>
+        /// <param name="limit">The number to limit results(value 0 used for get all records)</param>
+        /// <param name="startMatch">The text which is inserted into the fragment before the keyword(If NULL, default is "[")</param>
+        /// <param name="endMatch">The text which is inserted into the fragment after the keyword(If NULL, default is "]")</param>
+        /// <param name="tokenNumber">The one side extra number of tokens near keyword(If negative value, full sentence is printed. e.g. if token number is 3 with 'abc' keyword, "my name is [abc]de and my home")</param>
+        /// <returns>The record list</returns>
+        public ContactsList Search(string viewUri, string keyword, int offset, int limit, string startMatch, string endMatch, int tokenNumber)
+        {
+            IntPtr recordList;
+            int error = Interop.Database.Search(viewUri, keyword, offset, limit, startMatch, endMatch, tokenNumber, out recordList);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Search Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return new ContactsList(recordList);
+        }
+
+        /// <summary>
+        /// Finds records based on given query and keyword for snippet.
+        /// </summary>
+        /// <remarks>
+        /// This API works only for the Views below.
+        /// Person, PersonContact, PersonGroupRelation, PersonGroupAssigned and PersonGroupNotAssigned.
+        /// Because start match and end match are needed to be composed with keyword, this API performance is lower than Search(ContactsQuery query, string keyword, int offset, int limit).
+        /// </remarks>
+        /// <param name="query">The query to filter</param>
+        /// <param name="keyword">The keyword</param>
+        /// <param name="offset">The index from which to get results</param>
+        /// <param name="limit">The number to limit results(value 0 used for get all records)</param>
+        /// <param name="startMatch">The text which is inserted into the fragment before the keyword(If NULL, default is "[")</param>
+        /// <param name="endMatch">The text which is inserted into the fragment after the keyword(If NULL, default is "]")</param>
+        /// <param name="tokenNumber">The one side extra number of tokens near keyword(If negative value, full sentence is printed. e.g. if token number is 3 with 'abc' keyword, "my name is [abc]de and my home")</param>
+        /// <returns>The record list</returns>
+        public ContactsList Search(ContactsQuery query, string keyword, int offset, int limit, string startMatch, string endMatch, int tokenNumber)
+        {
+            IntPtr recordList;
+            int error = Interop.Database.Search(query._queryHandle, keyword, offset, limit, startMatch, endMatch, tokenNumber, out recordList);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Search Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return new ContactsList(recordList);
+        }
+
+        /// <summary>
+        /// Finds records based on a keyword and range for snippet.
+        /// </summary>
+        /// <remarks>
+        /// This API works only for the Views below.
+        /// Person, PersonContact, PersonGroupRelation, PersonGroupAssigned, PersonGroupNotAssigned, PersonNumber and PersonEmail
+        /// Because start match and end match are needed to be composed with keyword, this API performance is lower than Search(string viewUri, string keyword, int offset, int limit, int range).
+        /// </remarks>
+        /// <param name="viewUri">The view URI</param>
+        /// <param name="keyword">The keyword</param>
+        /// <param name="offset">The index from which to get results</param>
+        /// <param name="limit">The number to limit results(value 0 is used for get all records)</param>
+        /// <param name="range">The search range, it should be a element of SearchRange or bitwise OR operation of them</param>
+        /// <param name="startMatch">The text which is inserted into the fragment before the keyword(If NULL, default is "[")</param>
+        /// <param name="endMatch">The text which is inserted into the fragment after the keyword(If NULL, default is "]")</param>
+        /// <param name="tokenNumber">The one side extra number of tokens near keyword(If negative value, full sentence is printed. e.g. if token number is 3 with 'abc' keyword, "my name is [abc]de and my home")</param>
+        /// <returns>The record list</returns>
+        public ContactsList Search(string viewUri, string keyword, int offset, int limit, int range, string startMatch, string endMatch, int tokenNumber)
+        {
+            IntPtr recordList;
+            int error = Interop.Database.Search(viewUri, keyword, offset, limit, range, startMatch, endMatch, tokenNumber, out recordList);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Search Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return new ContactsList(recordList);
+        }
+
+        /// <summary>
+        /// Gets the number of records in a specific view
+        /// </summary>
+        /// <param name="viewUri">The view URI</param>
+        /// <returns>The count of records</returns>
+        public int GetCount(string viewUri)
+        {
+            int count = -1;
+            int error = Interop.Database.GetCount(viewUri, out count);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "GetCount Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return count;
+        }
+
+        /// <summary>
+        /// Gets the number of records matching a query.
+        /// </summary>
+        /// <param name="query">The query used for filtering the results</param>
+        /// <returns>The count of records</returns>
+        public int GetCount(ContactsQuery query)
+        {
+            int count = -1;
+            int error = Interop.Database.GetCount(query._queryHandle, out count);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "GetCount Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return count;
+        }
+
+        /// <summary>
+        /// Registers a callback function to be invoked when a record changes.
+        /// </summary>
+        /// <param name="viewUri">The view URI of records whose changes are monitored</param>
+        /// <param name="callback">The callback function to register</param>
+        public void AddDBChangedDelegate(string viewUri, ContactsDBChangedDelegate callback)
+        {
+            _dbChangedDelegate = (string uri, IntPtr userData) =>
+            {
+                _callbackMap[uri](uri);
+            };
+            int error = Interop.Database.AddChangedCb(viewUri, _dbChangedDelegate, IntPtr.Zero);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "AddDBChangedDelegate Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            _callbackMap[viewUri] = callback;
+            _delegateMap[viewUri] = _dbChangedDelegate;
+        }
+
+        /// <summary>
+        /// Unregisters a callback function.
+        /// </summary>
+        /// <param name="viewUri">The view URI of records whose changes are monitored</param>
+        /// <param name="callback">The callback function to register</param>
+        public void RemoveDBChangedDelegate(string viewUri, ContactsDBChangedDelegate callback)
+        {
+            int error = Interop.Database.RemoveChangedCb(viewUri, _delegateMap[viewUri], IntPtr.Zero);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "RemoveDBChangedDelegate Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            _callbackMap.Remove(viewUri);
+            _delegateMap.Remove(viewUri);
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsErrorFactory.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsErrorFactory.cs
new file mode 100644 (file)
index 0000000..b542c57
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Pims.Contacts
+{
+    internal enum ContactsError
+    {
+        None = (int)ErrorCode.None,
+        InvalidParameter = (int)ErrorCode.InvalidParameter,
+        NotSupported = (int)ErrorCode.NotSupported,
+        PermissionDenied = (int)ErrorCode.PermissionDenied,
+        OutOfMemory = (int)ErrorCode.OutOfMemory,
+        FileNoSpaceOnDevice = (int)ErrorCode.FileNoSpaceOnDevice,
+        NoData = (int)ErrorCode.NoData,
+
+        DatabaseLocked = -0x02010000 | 0x81,
+        Database = -0x02010000 | 0x9F,
+        IpcNotAvaliable = -0x02010000 | 0xB1,
+        Ipc = -0x02010000 | 0xBF,
+        System = -0x02010000 | 0xEF
+    }
+
+    internal static class Globals
+    {
+        internal const string LogTag = "Tizen.Pims.Contacts";
+    }
+
+    internal static class ContactsErrorFactory
+    {
+        static internal Exception CheckAndCreateException(int error)
+        {
+            ContactsError e = (ContactsError)error;
+            switch (e)
+            {
+                case ContactsError.None:
+                    return null;
+                case ContactsError.InvalidParameter:
+                    return new ArgumentException("Invalid Parameters Provided");
+                case ContactsError.NotSupported:
+                    return new NotSupportedException("Not Supported");
+                case ContactsError.PermissionDenied:
+                    return new UnauthorizedAccessException("Permission Denied");
+                case ContactsError.OutOfMemory:
+                    return new OutOfMemoryException("Out of Memory");
+                case ContactsError.FileNoSpaceOnDevice:
+                    return new InvalidOperationException("File System is Full");
+                case ContactsError.NoData:
+                    return new InvalidOperationException("No Data");
+                case ContactsError.DatabaseLocked:
+                    return new InvalidOperationException("Database Locked");
+                case ContactsError.Database:
+                    return new InvalidOperationException("Database Failed");
+                case ContactsError.IpcNotAvaliable:
+                    return new InvalidOperationException("IPC Not Avaliable");
+                case ContactsError.Ipc:
+                    return new InvalidOperationException("IPC failed");
+                case ContactsError.System:
+                    return new InvalidOperationException("Internal system error");
+                default:
+                    return new InvalidOperationException("Unknown Error Code");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsFilter.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsFilter.cs
new file mode 100644 (file)
index 0000000..18880ac
--- /dev/null
@@ -0,0 +1,424 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.Collections.Generic;
+using static Interop.Contacts;
+
+namespace Tizen.Pims.Contacts
+{
+    /// <summary>
+    /// A filter includes the conditions for the search
+    /// </summary>
+    public class ContactsFilter:IDisposable
+    {
+        internal IntPtr _filterHandle;
+
+        /// <summary>
+        /// Creates a filter with a condition for a string type property.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a filter</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public ContactsFilter(string viewUri, uint propertyId, StringMatchType matchType, string matchValue)
+        {
+            int error = Interop.Filter.ContactsFilterCreate(viewUri, out _filterHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsFilter Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+
+            error = Interop.Filter.ContactsFilterAddStr(_filterHandle, propertyId, matchType, matchValue);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsFilter Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Creates a filter with a condition for an integer type property.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a filter</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public ContactsFilter(string viewUri, uint propertyId, IntegerMatchType matchType, int matchValue)
+        {
+            int error = Interop.Filter.ContactsFilterCreate(viewUri, out _filterHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsFilter Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+
+            error = Interop.Filter.ContactsFilterAddInt(_filterHandle, propertyId, matchType, matchValue);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsFilter Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Creates a filter with a condition for a long type property.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a filter</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public ContactsFilter(string viewUri, uint propertyId, IntegerMatchType matchType, long matchValue)
+        {
+            int error = Interop.Filter.ContactsFilterCreate(viewUri, out _filterHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsFilter Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+
+            error = Interop.Filter.ContactsFilterAddLli(_filterHandle, propertyId, matchType, matchValue);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsFilter Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Creates a filter with a condition for a double type property.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a filter</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public ContactsFilter(string viewUri, uint propertyId, IntegerMatchType matchType, double matchValue)
+        {
+            int error = Interop.Filter.ContactsFilterCreate(viewUri, out _filterHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsFilter Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+
+            error = Interop.Filter.ContactsFilterAddDouble(_filterHandle, propertyId, matchType, matchValue);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsFilter Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Creates a filter with a condition for a boolean type property.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a filter</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public ContactsFilter(string viewUri, uint propertyId, bool matchValue)
+        {
+            int error = Interop.Filter.ContactsFilterCreate(viewUri, out _filterHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsFilter Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+
+            error = Interop.Filter.ContactsFilterAddBool(_filterHandle, propertyId, matchValue);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsFilter Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        ~ContactsFilter()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// Enumeration for the filter match type of a string.
+        /// </summary>
+        public enum StringMatchType
+        {
+            /// <summary>
+            /// Full string, case-sensitive
+            /// </summary>
+            Exactly,
+            /// <summary>
+            /// Full string, case-insensitive
+            /// </summary>
+            FullString,
+            /// <summary>
+            /// Sub string, case-insensitive
+            /// </summary>
+            Contains,
+            /// <summary>
+            /// Start with, case-insensitive
+            /// </summary>
+            StartsWith,
+            /// <summary>
+            /// End with, case-insensitive
+            /// </summary>
+            EndsWith,
+            /// <summary>
+            /// IS NOT NUL
+            /// </summary>
+            Exists,
+        }
+
+        /// <summary>
+        /// Enumeration for the filter match type of an integer.
+        /// </summary>
+        public enum IntegerMatchType
+        {
+            /// <summary>
+            /// =
+            /// </summary>
+            Equal,
+            /// <summary>
+            /// &gt;
+            /// </summary>
+            GreaterThan,
+            /// <summary>
+            /// &gt;=
+            /// </summary>
+            GreaterThanOrEqual,
+            /// <summary>
+            /// &lt;
+            /// </summary>
+            LessThan,
+            /// <summary>
+            /// &lt;=
+            /// </summary>
+            LessThanOrEqual,
+            /// <summary>
+            /// &lt;&gt;, this flag can yield poor performance
+            /// </summary>
+            NotEqual,
+            /// <summary>
+            /// IS NULL
+            /// </summary>
+            None,
+        }
+
+        /// <summary>
+        /// Enumeration for a filter operator.
+        /// </summary>
+        public enum LogicalOperator
+        {
+            And,
+            Or,
+        }
+
+        #region IDisposable Support
+        private bool disposedValue = false; // To detect redundant calls
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!disposedValue)
+            {
+                int error = Interop.Filter.ContactsFilterDestroy(_filterHandle);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "ContactsFilterDestroy Failed with error " + error);
+                }
+
+                disposedValue = true;
+            }
+        }
+
+        /// <summary>
+        /// Releases all resources used by the ContactsFilter.
+        /// It should be called after finished using of the object.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+        #endregion
+
+        /// <summary>
+        /// Adds a condition for a string type property.
+        /// </summary>
+        /// <param name="logicalOperator">The operator type</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddCondition(LogicalOperator logicalOperator, uint propertyId, StringMatchType matchType, string matchValue)
+        {
+            int error = Interop.Filter.ContactsFilterAddOperator(_filterHandle, logicalOperator);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+
+            error = Interop.Filter.ContactsFilterAddStr(_filterHandle, propertyId, matchType, matchValue);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Adds a condition for a integer type property.
+        /// </summary>
+        /// <param name="logicalOperator">The operator type</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddCondition(LogicalOperator logicalOperator, uint propertyId, IntegerMatchType matchType, int matchValue)
+        {
+            int error = Interop.Filter.ContactsFilterAddOperator(_filterHandle, logicalOperator);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+
+            error = Interop.Filter.ContactsFilterAddInt(_filterHandle, propertyId, matchType, matchValue);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Adds a condition for a long type property.
+        /// </summary>
+        /// <param name="logicalOperator">The operator type</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddCondition(LogicalOperator logicalOperator, uint propertyId, IntegerMatchType matchType, long matchValue)
+        {
+            int error = Interop.Filter.ContactsFilterAddOperator(_filterHandle, logicalOperator);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+
+            error = Interop.Filter.ContactsFilterAddLli(_filterHandle, propertyId, matchType, matchValue);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Adds a condition for a double type property.
+        /// </summary>
+        /// <param name="logicalOperator">The operator type</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchType">The match flag</param>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddCondition(LogicalOperator logicalOperator, uint propertyId, IntegerMatchType matchType, double matchValue)
+        {
+            int error = Interop.Filter.ContactsFilterAddOperator(_filterHandle, logicalOperator);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+
+            error = Interop.Filter.ContactsFilterAddDouble(_filterHandle, propertyId, matchType, matchValue);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Adds a condition for a boolean type property.
+        /// </summary>
+        /// <param name="logicalOperator">The operator type</param>
+        /// <param name="propertyId">The property ID to add a condition</param>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddCondition(LogicalOperator logicalOperator, uint propertyId, bool matchValue)
+        {
+            int error = Interop.Filter.ContactsFilterAddOperator(_filterHandle, logicalOperator);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+
+            error = Interop.Filter.ContactsFilterAddBool(_filterHandle, propertyId, matchValue);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Adds a child filter to a parent filter.
+        /// </summary>
+        /// <param name="logicalOperator">The operator type</param>
+        /// <param name="filter">The child filter</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddFilter(LogicalOperator logicalOperator, ContactsFilter filter)
+        {
+            int error = Interop.Filter.ContactsFilterAddOperator(_filterHandle, logicalOperator);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "AddFilter Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+
+            error = Interop.Filter.ContactsFilterAddFilter(_filterHandle, filter._filterHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "AddFilter Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsList.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsList.cs
new file mode 100644 (file)
index 0000000..d0965eb
--- /dev/null
@@ -0,0 +1,241 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+
+namespace Tizen.Pims.Contacts
+{
+    /// <summary>
+    /// A list of records with the same type
+    /// </summary>
+    public class ContactsList:IDisposable
+    {
+        private Int64 _memoryPressure = 20;
+        internal IntPtr _listHandle;
+        internal ContactsList(IntPtr handle)
+        {
+            int count;
+
+            _listHandle = handle;
+            int error = Interop.List.ContactsListGetCount(_listHandle, out count);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsList Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            _memoryPressure += count * ContactsViews.AverageSizeOfRecord;
+            GC.AddMemoryPressure(_memoryPressure);
+        }
+
+        /// <summary>
+        /// Creates a contacts record list.
+        /// </summary>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public ContactsList()
+        {
+            int error = Interop.List.ContactsListCreate(out _listHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsList Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            GC.AddMemoryPressure(_memoryPressure);
+        }
+
+        ~ContactsList()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// The count of contact entity.
+        /// </summary>
+        public int Count
+        {
+            get
+            {
+                int count = -1;
+                int error = Interop.List.ContactsListGetCount(_listHandle, out count);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "ContactsList Count Failed with error " + error);
+                }
+                return count;
+            }
+        }
+
+        #region IDisposable Support
+        private bool disposedValue = false; // To detect redundant calls
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!disposedValue)
+            {
+                int error = Interop.List.ContactsListDestroy(_listHandle, true);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "ContactsListDestroy Failed with error " + error);
+                }
+
+                disposedValue = true;
+                GC.RemoveMemoryPressure(_memoryPressure);
+            }
+        }
+
+        /// <summary>
+        /// Releases all resources used by the ContactsList.
+        /// It should be called after finished using of the object.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+        #endregion
+
+        /// <summary>
+        /// Adds a record to the contacts list.
+        /// </summary>
+        /// <param name="record">The record to add</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddRecord(ContactsRecord record)
+        {
+            int error = Interop.List.ContactsListAdd(_listHandle, record._recordHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "AddRecord Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            record._disposedValue = true;
+            _memoryPressure += ContactsViews.AverageSizeOfRecord;
+        }
+
+        /// <summary>
+        /// Removes a record from the contacts list.
+        /// </summary>
+        /// <param name="record">The record to remove</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void RemoveRecord(ContactsRecord record)
+        {
+            int error = Interop.List.ContactsListRemove(_listHandle, record._recordHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "RemoveRecord Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            record._disposedValue = false;
+            _memoryPressure -= ContactsViews.AverageSizeOfRecord;
+        }
+
+        /// <summary>
+        /// Retrieves a record from the contacts list.
+        /// </summary>
+        /// <returns>
+        /// contacts record
+        /// </returns>
+        public ContactsRecord GetCurrentRecord()
+        {
+            IntPtr handle;
+            int error = Interop.List.ContactsListGetCurrentRecordP(_listHandle, out handle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "GetCurrentRecord Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return new ContactsRecord(handle, true);
+        }
+
+        /// <summary>
+        /// Moves a contacts list to the previous position.
+        /// </summary>
+        /// <returns>
+        /// When the cursor is already at the first position, it returns false.
+        /// </returns>
+        public bool MovePrevious()
+        {
+            int error = Interop.List.ContactsListPrev(_listHandle);
+
+            if ((int)ContactsError.None == error)
+            {
+                return true;
+            }
+            else if (Count > 0 && (int)ContactsError.NoData == error)
+            {
+                Log.Debug(Globals.LogTag, "Nodata MovePrevious" + error);
+                return false;
+            }
+            else
+            {
+                Log.Error(Globals.LogTag, "MovePrevious Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Moves a contacts list to the next position.
+        /// </summary>
+        /// <returns>
+        /// When the cursor is already at the last position, it returns false.
+        /// </returns>
+        public bool MoveNext()
+        {
+            int error = Interop.List.ContactsListNext(_listHandle);
+
+            if ((int)ContactsError.None == error)
+            {
+                return true;
+            }
+            else if (Count > 0 && (int)ContactsError.NoData == error)
+            {
+                Log.Debug(Globals.LogTag, "Nodata MoveNext" + error);
+                return false;
+            }
+            else
+            {
+                Log.Error(Globals.LogTag, "MoveNext Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Moves a contacts list to the first position.
+        /// </summary>
+        public void MoveFirst()
+        {
+            int error = Interop.List.ContactsListFirst(_listHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "MoveFirst Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Moves a contacts list to the last position.
+        /// </summary>
+        public void MoveLast()
+        {
+            int error = Interop.List.ContactsListLast(_listHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "MoveFirst Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsManager.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsManager.cs
new file mode 100644 (file)
index 0000000..cde2fff
--- /dev/null
@@ -0,0 +1,284 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.Collections.Generic;
+using static Interop.Contacts;
+
+namespace Tizen.Pims.Contacts
+{
+    /// <summary>
+    /// Enumeration for name display order.
+    /// </summary>
+    public enum ContactDisplayOrder
+    {
+        /// <summary>
+        /// First name comes at the first
+        /// </summary>
+        FirstLast,
+        /// <summary>
+        /// First name comes at the last
+        /// </summary>
+        LastFirst
+    };
+
+    /// <summary>
+    /// Enumeration for name sorting order.
+    /// </summary>
+    public enum ContactSortingOrder
+    {
+        /// <summary>
+        /// Contacts are first sorted based on the first name
+        /// </summary>
+        FirstLast,
+        /// <summary>
+        /// Contacts are first sorted based on the last name
+        /// </summary>
+        LastFirst
+    };
+
+    /// <summary>
+    /// A class for managing contact information. It allows applications to access contacts database.
+    /// </summary>
+    public class ContactsManager : IDisposable
+    {
+        private ContactsDatabase _db = null;
+        private Object thisLock = new Object();
+        private Interop.Setting.DisplayOrderChangedCallback _displayOrderDelegate;
+        private Interop.Setting.SortingOrderChangedCallback _sortingOrderDelegate;
+
+        /// <summary>
+        /// Creates a ContactsManager.
+        /// </summary>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        public ContactsManager()
+        {
+            int error = Interop.Contacts.Connect();
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Connect Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            _db = new ContactsDatabase();
+        }
+
+        ~ContactsManager()
+        {
+            Dispose(false);
+        }
+
+        #region IDisposable Support
+        private bool disposedValue = false; // To detect redundant calls
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!disposedValue)
+            {
+                int error = Interop.Contacts.Disconnect();
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Disconnect Failed with error " + error);
+                }
+
+                disposedValue = true;
+            }
+        }
+
+        /// <summary>
+        /// Releases all resources used by the ContactsManager.
+        /// It should be called after finished using of the object.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+        #endregion
+
+        private event EventHandler<NameDisplayOrderChangedEventArgs> _nameDisplayOrderChanged;
+        private event EventHandler<NameSortingOrderChangedEventArgs> _nameSortingOrderChanged;
+
+        /// <summary>
+        /// (event) NameDisplayOrderChanged is raised when changing setting value of contacts name display order
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/contact.read</privilege>
+        public event EventHandler<NameDisplayOrderChangedEventArgs> NameDisplayOrderChanged
+        {
+            add
+            {
+                lock (thisLock)
+                {
+                    if (_displayOrderDelegate == null)
+                    {
+                        _displayOrderDelegate = (ContactDisplayOrder nameDisplayOrder, IntPtr userData) =>
+                        {
+                            NameDisplayOrderChangedEventArgs args = new NameDisplayOrderChangedEventArgs(nameDisplayOrder);
+                            _nameDisplayOrderChanged?.Invoke(this, args);
+                        };
+                    }
+
+                    if (_nameDisplayOrderChanged == null)
+                    {
+                        int error = Interop.Setting.AddNameDisplayOrderChangedCB(_displayOrderDelegate, IntPtr.Zero);
+                        if ((int)ContactsError.None != error)
+                        {
+                            Log.Error(Globals.LogTag, "Add NameDisplayOrderChangedCB Failed with error " + error);
+                        }
+                    }
+
+                    _nameDisplayOrderChanged += value;
+                }
+            }
+
+            remove
+            {
+                lock (thisLock)
+                {
+                    _nameDisplayOrderChanged -= value;
+
+                    if (_nameDisplayOrderChanged == null)
+                    {
+                        int error = Interop.Setting.RemoveNameDisplayOrderChangedCB(_displayOrderDelegate, IntPtr.Zero);
+                        if ((int)ContactsError.None != error)
+                        {
+                            Log.Error(Globals.LogTag, "Remove StateChanged Failed with error " + error);
+                        }
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// (event) NameSortingOrderChanged is raised when changing setting value of contacts name sorting order
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/contact.read</privilege>
+        public event EventHandler<NameSortingOrderChangedEventArgs> NameSortingOrderChanged
+        {
+            add
+            {
+                lock (thisLock)
+                {
+                    if (_sortingOrderDelegate == null)
+                    {
+                        _sortingOrderDelegate = (ContactSortingOrder nameSortingOrder, IntPtr userData) =>
+                        {
+                            NameSortingOrderChangedEventArgs args = new NameSortingOrderChangedEventArgs(nameSortingOrder);
+                            _nameSortingOrderChanged?.Invoke(this, args);
+                        };
+                    }
+
+                    if (_nameSortingOrderChanged == null)
+                    {
+                        int error = Interop.Setting.AddNameSortingOrderChangedCB(_sortingOrderDelegate, IntPtr.Zero);
+                        if ((int)ContactsError.None != error)
+                        {
+                            Log.Error(Globals.LogTag, "Add NameSortingOrderChangedCB Failed with error " + error);
+                        }
+                    }
+
+                    _nameSortingOrderChanged += value;
+                }
+            }
+
+            remove
+            {
+                lock (thisLock)
+                {
+                    _nameSortingOrderChanged -= value;
+
+                    if (_nameSortingOrderChanged == null)
+                    {
+                        int error = Interop.Setting.RemoveNameSortingOrderChangedCB(_sortingOrderDelegate, IntPtr.Zero);
+                        if ((int)ContactsError.None != error)
+                        {
+                            Log.Error(Globals.LogTag, "Remove StateChanged Failed with error " + error);
+                        }
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// A ContactsDatabase
+        /// </summary>
+        public ContactsDatabase Database
+        {
+            get
+            {
+                return _db;
+            }
+        }
+
+        /// <summary>
+        /// A setting value of contacts name display order
+        /// </summary>
+        /// <remarks>
+        /// DisplayName of contacts returned from database are determined by this property
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/contact.read</privilege>
+        /// <privilege>http://tizen.org/privilege/contact.write</privilege>
+        public ContactDisplayOrder NameDisplayOrder
+        {
+            get
+            {
+                ContactDisplayOrder contactDisplayOrder;
+                int error = Interop.Setting.GetNameDisplayOrder(out contactDisplayOrder);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Get NameDisplayOrder Failed with error " + error);
+                }
+                return contactDisplayOrder;
+            }
+            set
+            {
+                int error = Interop.Setting.SetNameDisplayOrder(value);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Set NameDisplayOrder Failed with error " + error);
+                }
+            }
+        }
+
+        /// <summary>
+        /// A setting value of contacts name sorting order
+        /// </summary>
+        /// <remarks>
+        /// Contacts returned from database are first sorted based on the first name or last name by this property
+        /// </remarks>
+        /// <privilege>http://tizen.org/privilege/contact.read</privilege>
+        /// <privilege>http://tizen.org/privilege/contact.write</privilege>
+        public ContactSortingOrder NameSortingOrder
+        {
+            get
+            {
+                ContactSortingOrder contactsSortingOrder;
+                int error = Interop.Setting.GetNameSortingOrder(out contactsSortingOrder);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Get NameSortingOrder Failed with error " + error);
+                }
+                return contactsSortingOrder;
+            }
+            set
+            {
+                int error = Interop.Setting.SetNameSortingOrder(value);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Set NameSortingOrder Failed with error " + error);
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsQuery.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsQuery.cs
new file mode 100644 (file)
index 0000000..6754700
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using static Interop.Contacts;
+
+namespace Tizen.Pims.Contacts
+{
+    /// <summary>
+    /// A query is used to retrieve data which satisfies given criteria
+    /// </summary>
+    /// <remarks>
+    /// A query is used to retrieve person, group, speed dial, and log data which satisfies a given criteria, such as an integer property being greater than a given value, or a string property containing a given substring. 
+    /// A query needs a filter which can set the conditions for the search.
+    /// </remarks>
+    public class ContactsQuery : IDisposable
+    {
+        internal IntPtr _queryHandle;
+
+        /// <summary>
+        /// Creates a query.
+        /// </summary>
+        /// <param name="viewUri">The view URI of a query</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public ContactsQuery(string viewUri)
+        {
+            int error = Interop.Query.ContactsQueryCreate(viewUri, out _queryHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsQuery Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        internal ContactsQuery(IntPtr handle)
+        {
+            _queryHandle = handle;
+        }
+
+        ~ContactsQuery()
+        {
+            Dispose(false);
+        }
+        #region IDisposable Support
+        private bool disposedValue = false;
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!disposedValue)
+            {
+                int error = Interop.Query.ContactsQueryDestroy(_queryHandle);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "ContactsQueryDestroy Failed with error " + error);
+                }
+
+                disposedValue = true;
+            }
+        }
+
+        /// <summary>
+        /// Releases all resources used by the ContactsQuery.
+        /// It should be called after finished using of the object.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+        #endregion
+
+        /// <summary>
+        /// Adds property IDs for projection.
+        /// </summary>
+        /// <param name="propertyIdArray">The property ID array </param>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void SetProjection(uint[] propertyIdArray)
+        {
+            int error = Interop.Query.ContactsQuerySetProjection(_queryHandle, propertyIdArray, propertyIdArray.Length);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "SetProjection Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Sets the "distinct" option for projection.
+        /// </summary>
+        /// <param name="set">If true it is set, otherwise if false it is unset</param>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void SetDistinct(bool set)
+        {
+            int error = Interop.Query.ContactsQuerySetDistinct(_queryHandle, set);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "SetDistinct Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Sets the filter for a query.
+        /// </summary>
+        /// <param name="filter">The filter</param>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void SetFilter(ContactsFilter filter)
+        {
+            int error = Interop.Query.ContactsQuerySetFilter(_queryHandle, filter._filterHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "SetFilter Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+
+        /// <summary>
+        /// Sets the sort mode for a query.
+        /// </summary>
+        /// <param name="propertyId">The property ID to sort</param>
+        /// <param name="isAscending">If true it sorts in the ascending order, otherwise if false it sorts in the descending order</param>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void SetSort(uint propertyId, bool isAscending)
+        {
+            int error = Interop.Query.ContactsQuerySetSort(_queryHandle, propertyId, isAscending);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "SetSort Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsRecord.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsRecord.cs
new file mode 100644 (file)
index 0000000..dd8c592
--- /dev/null
@@ -0,0 +1,396 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Pims.Contacts
+{
+    /// <summary>
+    /// A record represents an actual record in the database
+    /// </summary>
+    /// <remarks>
+    /// A record represents an actual record in the database, but you can also consider it a piece of information, such as an address, a phone number, or a group of contacts. 
+    /// A record can be a complex set of data, containing other data. For example, a contact record contains the address property, which is a reference to an address record. 
+    /// An address record belongs to a contact record, and its ContactId property is set to the identifier of the corresponding contact. In this case, the address is the child record of the contact and the contact is the parent record.
+    /// </remarks>
+    public class ContactsRecord : IDisposable
+    {
+        private string _uri = null;
+        private uint _id;
+        private Int64 _memoryPressure = ContactsViews.AverageSizeOfRecord;
+        internal IntPtr _recordHandle;
+
+        internal ContactsRecord(IntPtr handle)
+        {
+            _recordHandle = handle;
+            IntPtr viewUri;
+            int error = Interop.Record.GetUriP(handle, out viewUri);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsRecord Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            GC.AddMemoryPressure(_memoryPressure);
+            _uri = Marshal.PtrToStringAnsi(viewUri);
+        }
+
+        internal ContactsRecord(IntPtr handle, bool disposedValue)
+        {
+            _recordHandle = handle;
+            _disposedValue = disposedValue;
+            IntPtr viewUri;
+            int error = Interop.Record.GetUriP(handle, out viewUri);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsRecord Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+
+            if (!_disposedValue)
+                GC.AddMemoryPressure(_memoryPressure);
+            _uri = Marshal.PtrToStringAnsi(viewUri);
+        }
+
+        internal ContactsRecord(IntPtr handle, int id)
+        {
+            _recordHandle = handle;
+            _id = (uint)id;
+            IntPtr viewUri;
+            int error = Interop.Record.GetUriP(handle, out viewUri);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsRecord Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            _uri = Marshal.PtrToStringAnsi(viewUri);
+            GC.AddMemoryPressure(_memoryPressure);
+        }
+
+        /// <summary>
+        /// Creates a record.
+        /// </summary>
+        /// <param name="viewUri">The view URI</param>
+        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public ContactsRecord(string viewUri)
+        {
+            int error = Interop.Record.Create(viewUri, out _recordHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ContactsRecord Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            _uri = viewUri;
+            GC.AddMemoryPressure(_memoryPressure);
+        }
+
+        ~ContactsRecord()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// The URI of the record
+        /// </summary>
+        public string Uri
+        {
+            get
+            {
+                return _uri;
+            }
+        }
+
+        #region IDisposable Support
+        internal bool _disposedValue = false; // To detect redundant calls
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!_disposedValue)
+            {
+                int error = Interop.Record.Destroy(_recordHandle, true);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Dispose Failed with error " + error);
+                }
+                _disposedValue = true;
+                GC.RemoveMemoryPressure(_memoryPressure);
+            }
+        }
+
+        /// <summary>
+        /// Releases all resources used by the ContactsRecord.
+        /// It should be called after finished using of the object.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+        #endregion
+
+        /// <summary>
+        /// Makes a clone of a record.
+        /// </summary>
+        /// <returns>A cloned record</returns>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public ContactsRecord Clone()
+        {
+            IntPtr _clonedRecordHandle;
+            int error = Interop.Record.Clone(_recordHandle, out _clonedRecordHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Clone Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return new ContactsRecord(_clonedRecordHandle, (int)_id);
+        }
+
+        /// <summary>
+        /// Gets a value of the property from a record.
+        /// </summary>
+        /// <param name="propertyId">The property ID</param>
+        /// <returns>
+        /// The value of the property corresponding to property id.
+        /// </returns>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public T Get<T>(uint propertyId)
+        {
+            object parsedValue = null;
+            if (typeof(T) == typeof(string))
+            {
+                string val;
+                int error = Interop.Record.GetStr(_recordHandle, propertyId, out val);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Get String Failed with error " + error);
+                    throw ContactsErrorFactory.CheckAndCreateException(error);
+                }
+                parsedValue = Convert.ChangeType(val, typeof(T));
+            }
+            else if (typeof(T) == typeof(int))
+            {
+                int val;
+                int error = Interop.Record.GetInt(_recordHandle, propertyId, out val);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Get Int Failed with error " + error);
+                    throw ContactsErrorFactory.CheckAndCreateException(error);
+                }
+                parsedValue = Convert.ChangeType(val, typeof(T));
+            }
+            else if (typeof(T) == typeof(bool))
+            {
+                bool val;
+                int error = Interop.Record.GetBool(_recordHandle, propertyId, out val);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Get Bool Failed with error " + error);
+                    throw ContactsErrorFactory.CheckAndCreateException(error);
+                }
+                parsedValue = Convert.ChangeType(val, typeof(T));
+            }
+            else if (typeof(T) == typeof(long))
+            {
+                long val;
+                int error = Interop.Record.GetLli(_recordHandle, propertyId, out val);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Get Long Failed with error " + error);
+                    throw ContactsErrorFactory.CheckAndCreateException(error);
+                }
+                parsedValue = Convert.ChangeType(val, typeof(T));
+            }
+            else if (typeof(T) == typeof(double))
+            {
+                double val;
+                int error = Interop.Record.GetDouble(_recordHandle, propertyId, out val);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Get Long Failed with error " + error);
+                    throw ContactsErrorFactory.CheckAndCreateException(error);
+                }
+                parsedValue = Convert.ChangeType(val, typeof(T));
+            }
+            else
+            {
+                Log.Error(Globals.LogTag, "Not Supported Data Type");
+                throw ContactsErrorFactory.CheckAndCreateException((int)ContactsError.NotSupported);
+            }
+            return (T)parsedValue;
+        }
+
+        /// <summary>
+        /// Sets a value of the property to a record.
+        /// </summary>
+        /// <param name="propertyId">The property ID</param>
+        /// <param name="value">The value to set</param>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void Set<T>(uint propertyId, T value)
+        {
+            if (typeof(T) == typeof(string))
+            {
+                string val = Convert.ToString(value);
+                int error = Interop.Record.SetStr(_recordHandle, propertyId, val);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Set String Failed with error " + error);
+                    throw ContactsErrorFactory.CheckAndCreateException(error);
+                }
+            }
+            else if (typeof(T) == typeof(int))
+            {
+                int val = Convert.ToInt32(value);
+                int error = Interop.Record.SetInt(_recordHandle, propertyId, val);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Set Int Failed with error " + error);
+                    throw ContactsErrorFactory.CheckAndCreateException(error);
+                }
+            }
+            else if (typeof(T) == typeof(bool))
+            {
+                bool val = Convert.ToBoolean(value);
+                int error = Interop.Record.SetBool(_recordHandle, propertyId, val);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Set Bool Failed with error " + error);
+                    throw ContactsErrorFactory.CheckAndCreateException(error);
+                }
+            }
+            else if (typeof(T) == typeof(long))
+            {
+                long val = Convert.ToInt64(value);
+                int error = Interop.Record.SetLli(_recordHandle, propertyId, val);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Set Long Failed with error " + error);
+                    throw ContactsErrorFactory.CheckAndCreateException(error);
+                }
+            }
+            else if (typeof(T) == typeof(double))
+            {
+                double val = Convert.ToDouble(value);
+                int error = Interop.Record.SetDouble(_recordHandle, propertyId, val);
+                if ((int)ContactsError.None != error)
+                {
+                    Log.Error(Globals.LogTag, "Get Long Failed with error " + error);
+                    throw ContactsErrorFactory.CheckAndCreateException(error);
+                }
+            }
+            else
+            {
+                Log.Error(Globals.LogTag, "Not Supported Data Type");
+                throw ContactsErrorFactory.CheckAndCreateException((int)ContactsError.NotSupported);
+            }
+        }
+
+        /// <summary>
+        /// Adds a child record to the parent record.
+        /// </summary>
+        /// <param name="propertyId">The property ID</param>
+        /// <param name="childRecord">The child record to add to parent record</param>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void AddChildRecord(uint propertyId, ContactsRecord childRecord)
+        {
+            int error = Interop.Record.AddChildRecord(_recordHandle, propertyId, childRecord._recordHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "AddChildRecord Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            childRecord._disposedValue = true;
+        }
+
+        /// <summary>
+        /// Removes a child record from the parent record.
+        /// </summary>
+        /// <param name="propertyId">The property ID</param>
+        /// <param name="childRecord">The child record to remove from parent record</param>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public void RemoveChildRecord(uint propertyId, ContactsRecord childRecord)
+        {
+            int error = Interop.Record.RemoveChildRecord(_recordHandle, propertyId, childRecord._recordHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "RemoveChildRecord Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            childRecord._disposedValue = false;
+        }
+
+        /// <summary>
+        /// Gets the number of child records of a parent record.
+        /// </summary>
+        /// <param name="propertyId">The property ID</param>
+        /// <returns>The number of child records corresponding to property ID</returns>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public int GetChildRecordCount(uint propertyId)
+        {
+            int count = 0;
+            int error = Interop.Record.GetChildRecordCount(_recordHandle, propertyId, out count);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "GetChildRecordCount Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return count;
+        }
+
+        /// <summary>
+        /// Gets a child record from the parent record
+        /// </summary>
+        /// <param name="propertyId">The property ID</param>
+        /// <param name="index">The index of child record</param>
+        /// <returns>The record </returns>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public ContactsRecord GetChildRecord(uint propertyId, int index)
+        {
+            IntPtr handle;
+
+            int error = Interop.Record.GetChildRecordAtP(_recordHandle, propertyId, index, out handle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "GetChildRecord Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            return new ContactsRecord(handle, true);
+        }
+
+        /// <summary>
+        /// Clones a child record list corresponding to property ID
+        /// </summary>
+        /// <param name="propertyId">The property ID</param>
+        /// <returns>
+        /// The record list
+        /// </returns>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        public ContactsList CloneChildRecordList(uint propertyId)
+        {
+            IntPtr listHandle;
+
+            int error = Interop.Record.CloneChildRecordList(_recordHandle, propertyId, out listHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "CloneChildRecordList Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+            ContactsList list = new ContactsList(listHandle);
+            return list;
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsVcard.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsVcard.cs
new file mode 100644 (file)
index 0000000..c02cc4f
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.Collections.Generic;
+using static Interop.Contacts;
+
+namespace Tizen.Pims.Contacts
+{
+    using static ContactsViews;
+    /// <summary>
+    /// A class for parsing and making vCards.
+    /// </summary>
+    /// <remarks>
+    /// It's based on the vCard v3.0 specification
+    /// </remarks>
+    public static class ContactsVcard
+    {
+        public delegate bool ParseDelegate(ContactsRecord record);
+
+        /// <summary>
+        /// Retrieves the vCard stream from a contacts record.
+        /// </summary>
+        /// <param name="record">The contacts record</param>
+        /// <returns>
+        /// The vCard stream.
+        /// </returns>
+        /// <privilege>http://tizen.org/privilege/contact.read</privilege>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public static string Compose(ContactsRecord record)
+        {
+            int error = 0;
+            string stream = null;
+
+            if (record.Uri.Equals(Person.Uri))
+            {
+                error = Interop.Vcard.ContactsVcardMakeFromPerson(record._recordHandle, out stream);
+            }
+            else if (record.Uri.Equals(Contact.Uri))
+            {
+                error = Interop.Vcard.ContactsVcardMakeFromContact(record._recordHandle, out stream);
+            }
+            else if (record.Uri.Equals(MyProfile.Uri))
+            {
+                error = Interop.Vcard.ContactsVcardMakeFromMyProfile(record._recordHandle, out stream);
+            }
+            else
+            {
+                throw new ArgumentException("Invalid Parameters Provided");
+            }
+
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Compose Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+
+            return stream;
+        }
+
+        /// <summary>
+        /// Retrieves all contacts with a contacts list from a vCard stream
+        /// </summary>
+        /// <param name="stream">The vCard stream</param>
+        /// <returns>
+        /// The contacts list
+        /// </returns>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public static ContactsList Parse(string stream)
+        {
+            IntPtr listHandle;
+
+            int error = Interop.Vcard.ContactsVcardParseToContacts(stream, out listHandle);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "Parse Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+
+            return new ContactsList(listHandle);
+        }
+
+        /// <summary>
+        /// Retrieves all contacts with a record from a vCard file.
+        /// </summary>
+        /// <param name="path">The file path of vCard stream file</param>
+        /// <param name="callback">The callback function to invoke</param>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        public static void ParseForEach(string path, ParseDelegate callback)
+        {
+            Interop.Vcard.ContactsVcardParseCallback cb = (IntPtr handle, IntPtr data) =>
+            {
+                return callback(new ContactsRecord(handle, true));
+            };
+
+            int error = Interop.Vcard.ContactsVcardParseToContactForeach(path, cb, IntPtr.Zero);
+            if ((int)ContactsError.None != error)
+            {
+                Log.Error(Globals.LogTag, "ParseForEach Failed with error " + error);
+                throw ContactsErrorFactory.CheckAndCreateException(error);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsViews.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsViews.cs
new file mode 100644 (file)
index 0000000..82ed5fe
--- /dev/null
@@ -0,0 +1,3236 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Pims.Contacts
+{
+    /// <summary>
+    /// This class provides information about views with properties.
+    /// </summary>
+    /// <remarks>
+    ///  Views are provided to access and handle entities. A view is a structure, which has property elements.
+    ///  A view is almost the same as a database "VIEW", which limits access and guarantees performance.
+    ///  A "record" represents a single row of the views.
+    ///  A record can have basic properties of five types: integer, string, boolean, long, double.
+    /// </remarks>
+    public static class ContactsViews
+    {
+        private const uint PropertyAddressBook = 0x00100000;
+        private const uint PropertyGroup = 0x00200000;
+        private const uint PropertyPerson = 0x00300000;
+        private const uint PropertyData = 0x00600000;
+        private const uint PropertySpeedDial =  0x00700000;
+        private const uint PropertyPhonelog = 0x00800000;
+        private const uint PropertyUpdateInfo = 0x00900000;
+        private const uint PropertyPhonelogStat = 0x00B00000;
+
+        private const uint PropertyContact = 0x01000000;
+        private const uint PropertyName = 0x01100000;
+        private const uint PropertyNumber = 0x01200000;
+        private const uint PropertyEmail = 0x01300000;
+        private const uint PropertyAddress = 0x01400000;
+        private const uint PropertyUrl = 0x01500000;
+        private const uint PropertyEvent = 0x01600000;
+        private const uint PropertyGroupRelation = 0x01700000;
+        private const uint PropertyRelationship = 0x01800000;
+        private const uint PropertyCompany = 0x01900000;
+        private const uint PropertyNickname = 0x01A00000;
+        private const uint PropertyMessenger = 0x01B00000;
+        private const uint PropertyNote = 0x01C00000;
+        private const uint PropertyProfile = 0x01D00000;
+        private const uint PropertyImage = 0x01E00000;
+        private const uint PropertyExtension = 0x01F00000;
+        private const uint PropertyMyProfile = 0x02000000;
+        private const uint PropertyActivityPhoto = 0x02100000;
+        private const uint PropertySip = 0x02200000;
+
+       /* data_type mask 0x000FF000 */
+        private const uint DataTypeBool = 0x00010000;
+        private const uint DataTypeInt = 0x00020000;
+        private const uint DataTypeLong = 0x00030000;
+        private const uint DataTypeString = 0x00040000;
+        private const uint DataTypeDouble = 0x00050000;
+        private const uint DataTypeRecord = 0x00060000;
+
+        private const uint ReadOnly = 0x00001000;
+
+        private enum PropertyIds : uint
+        {
+            /* addressbook */
+            AddressbookId = (PropertyAddressBook | DataTypeInt | ReadOnly),
+            AddressbookAccountId = (PropertyAddressBook | DataTypeInt) + 1,
+            AddressbookName = (PropertyAddressBook | DataTypeString) + 2,
+            AddressbookMode = (PropertyAddressBook | DataTypeInt) + 3,
+
+            /* group */
+            GroupId = (PropertyGroup | DataTypeInt | ReadOnly),
+            GroupAddressbookId = (PropertyGroup | DataTypeInt) + 1,
+            GroupName = (PropertyGroup | DataTypeString) + 2,
+            GroupRingtone = (PropertyGroup | DataTypeString) + 3,
+            GroupImage = (PropertyGroup | DataTypeString) + 4,
+            GroupVibration = (PropertyGroup | DataTypeString) + 5,
+            GroupExtraData = (PropertyGroup | DataTypeString) + 6,
+            GroupIsReadOnly = (PropertyGroup | DataTypeBool) + 7,
+            GroupMessageAlert = (PropertyGroup | DataTypeString) + 8,
+
+            /* person */
+            PersonId = (PropertyPerson | DataTypeInt | ReadOnly),
+            PersonDisplayName = (PropertyPerson | DataTypeString | ReadOnly) + 1,
+            PersonDisplayContactId = (PropertyPerson | DataTypeInt) + 2,
+            PersonRingtone = (PropertyPerson | DataTypeString) + 3,
+            PersonThumbnail = (PropertyPerson | DataTypeString | ReadOnly) + 4,
+            PersonVibration = (PropertyPerson | DataTypeString) + 5,
+            PersonIsFavorite = (PropertyPerson | DataTypeBool) + 6,
+            PersonFavoritePriority = (PropertyPerson | DataTypeDouble | ReadOnly) + 7,
+            PersonLinkCount = (PropertyPerson | DataTypeInt | ReadOnly) + 8,
+            PersonAddressbookIds = (PropertyPerson | DataTypeString | ReadOnly) + 9,
+            PersonHasPhoneNumber = (PropertyPerson | DataTypeBool | ReadOnly) + 10,
+            PersonHasEmail = (PropertyPerson | DataTypeBool | ReadOnly) + 11,
+            PersonDisplayNameIndex = (PropertyPerson | DataTypeString | ReadOnly) + 12,
+            PersonStatus = (PropertyPerson | DataTypeString | ReadOnly) + 13,
+            PersonMessageAlert = (PropertyPerson | DataTypeString) + 14,
+            PersonSnippetType = (PropertyPerson | DataTypeInt | ReadOnly) + 15,
+            PersonSnippetString = (PropertyPerson | DataTypeString | ReadOnly) + 16,
+
+            /* person-stat */
+            PersonUsageType = (PropertyPerson | DataTypeInt) + 100,
+            PersonTimesUsed = (PropertyPerson | DataTypeInt) + 101,
+
+            /* simple contact : read only */
+            /* contact */
+            ContactId = (PropertyContact | DataTypeInt | ReadOnly),
+            ContactDisplayName = (PropertyContact | DataTypeString | ReadOnly) + 1,
+            ContactDisplaySourceDataId = (PropertyContact | DataTypeInt | ReadOnly) + 2,
+            ContactAddressbookId = (PropertyContact | DataTypeInt) + 3,
+            ContactRingtone = (PropertyContact | DataTypeString) + 4,
+            ContactImage = (PropertyContact | DataTypeRecord) + 5,
+            ContactThumbnail = (PropertyContact | DataTypeString | ReadOnly) + 6,
+            ContactIsFavorite = (PropertyContact | DataTypeBool) + 7,
+            ContactHasPhoneNumber = (PropertyContact | DataTypeBool | ReadOnly) + 8,
+            ContactHasEmail = (PropertyContact | DataTypeBool | ReadOnly) + 9,
+            ContactPersonId = (PropertyContact | DataTypeInt) + 10,
+            ContactUid = (PropertyContact | DataTypeString) + 11,
+            ContactVibration = (PropertyContact | DataTypeString) + 12,
+            ContactChangedTime = (PropertyContact | DataTypeInt | ReadOnly) + 13,
+            ContactName = (PropertyContact | DataTypeRecord) + 14,
+            ContactCompany = (PropertyContact | DataTypeRecord) + 15,
+            ContactNote = (PropertyContact | DataTypeRecord) + 16,
+            ContactNumber = (PropertyContact | DataTypeRecord) + 17,
+            ContactEmail = (PropertyContact | DataTypeRecord) + 18,
+            ContactEvent = (PropertyContact | DataTypeRecord) + 19,
+            ContactMessenger = (PropertyContact | DataTypeRecord) + 20,
+            ContactAddress = (PropertyContact | DataTypeRecord) + 21,
+            ContactUrl = (PropertyContact | DataTypeRecord) + 22,
+            ContactNickname = (PropertyContact | DataTypeRecord) + 23,
+            ContactProfile = (PropertyContact | DataTypeRecord) + 24,
+            ContactRelationship = (PropertyContact | DataTypeRecord) + 25,
+            ContactGroupRelation = (PropertyContact | DataTypeRecord) + 26,
+            ContactExtension = (PropertyContact | DataTypeRecord) + 27,
+            ContactLinkMode = (PropertyContact | DataTypeInt) + 28,
+            ContactMessageAlert = (PropertyContact | DataTypeString) + 29,
+            ContactSip = (PropertyContact | DataTypeRecord) + 30,
+
+            /* my_profile */
+            MyProfileId = (PropertyMyProfile | DataTypeInt | ReadOnly),
+            MyProfileDisplayName = (PropertyMyProfile | DataTypeString | ReadOnly) + 1,
+            MyProfileAddressbookId = (PropertyMyProfile | DataTypeInt) + 2,
+            MyProfileImage = (PropertyMyProfile | DataTypeRecord) + 3,
+            MyProfileThumbnail = (PropertyMyProfile | DataTypeString | ReadOnly) + 4,
+            MyProfileUid = (PropertyMyProfile | DataTypeString) + 5,
+            MyProfileChangedTime = (PropertyMyProfile | DataTypeInt) + 6,
+            MyProfileName = (PropertyMyProfile | DataTypeRecord) + 7,
+            MyProfileCompany = (PropertyMyProfile | DataTypeRecord) + 8,
+            MyProfileNote = (PropertyMyProfile | DataTypeRecord) + 9,
+            MyProfileNumber = (PropertyMyProfile | DataTypeRecord) + 10,
+            MyProfileEmail = (PropertyMyProfile | DataTypeRecord) + 11,
+            MyProfileEvent = (PropertyMyProfile | DataTypeRecord) + 12,
+            MyProfileMessenger = (PropertyMyProfile | DataTypeRecord) + 13,
+            MyProfileAddress = (PropertyMyProfile | DataTypeRecord) + 14,
+            MyProfileUrl = (PropertyMyProfile | DataTypeRecord) + 15,
+            MyProfileNickname = (PropertyMyProfile | DataTypeRecord) + 16,
+            MyProfileProfile = (PropertyMyProfile | DataTypeRecord) + 17,
+            MyProfileRelationship = (PropertyMyProfile | DataTypeRecord) + 18,
+            MyProfileExtension = (PropertyMyProfile | DataTypeRecord) + 19,
+            MyProfileSip = (PropertyMyProfile | DataTypeRecord) + 20,
+
+            /* data */
+            DataId = (PropertyData | DataTypeInt),
+            DataContactId = (PropertyData | DataTypeInt) + 1,
+            DataType = (PropertyData | DataTypeInt) + 2,
+            DataIsPrimaryDefault = (PropertyData | DataTypeBool) + 3,
+            DataIsDefault = (PropertyData | DataTypeBool) + 4,
+            DataData1 = (PropertyData | DataTypeInt) + 5,
+            DataData2 = (PropertyData | DataTypeString) + 6,
+            DataData3 = (PropertyData | DataTypeString) + 7,
+            DataData4 = (PropertyData | DataTypeString) + 8,
+            DataData5 = (PropertyData | DataTypeString) + 9,
+            DataData6 = (PropertyData | DataTypeString) + 10,
+            DataData7 = (PropertyData | DataTypeString) + 11,
+            DataData8 = (PropertyData | DataTypeString) + 12,
+            DataData9 = (PropertyData | DataTypeString) + 13,
+            DataData10 = (PropertyData | DataTypeString) + 14,
+
+            /* contact_name */
+            NameId = (PropertyName | DataTypeInt | ReadOnly),
+            NameContactId = (PropertyName | DataTypeInt) + 1,
+            NameFirst = (PropertyName | DataTypeString) + 2,
+            NameLast = (PropertyName | DataTypeString) + 3,
+            NameAddition = (PropertyName | DataTypeString) + 4,
+            NameSuffix = (PropertyName | DataTypeString) + 5,
+            NamePrefix = (PropertyName | DataTypeString) + 6,
+            NamePhoneticFirst = (PropertyName | DataTypeString) + 7,
+            NamePhoneticMiddle = (PropertyName | DataTypeString) + 8,
+            NamePhoneticLast = (PropertyName | DataTypeString) + 9,
+
+            /* contact_number */
+            NumberId = (PropertyNumber | DataTypeInt | ReadOnly),
+            NumberContactId = (PropertyNumber | DataTypeInt) + 1,
+            NumberType = (PropertyNumber | DataTypeInt) + 2,
+            NumberLabel = (PropertyNumber | DataTypeString) + 3,
+            NumberIsDefault = (PropertyNumber | DataTypeBool) + 4,
+            NumberNumber = (PropertyNumber | DataTypeString) + 5,
+            NumberNumberFilter = (PropertyNumber | DataTypeString) + 6,
+            NumberNormalizedNumber = (PropertyNumber | DataTypeString | ReadOnly) + 7,
+            NumberCleanedNumber = (PropertyNumber | DataTypeString | ReadOnly) + 8,
+
+            /* contact_email */
+            EmailId = (PropertyEmail | DataTypeInt | ReadOnly),
+            EmailContactId = (PropertyEmail | DataTypeInt) + 1,
+            EmailType = (PropertyEmail | DataTypeInt) + 2,
+            EmailLabel = (PropertyEmail | DataTypeString) + 3,
+            EmailIsDefault = (PropertyEmail | DataTypeBool) + 4,
+            EmailEmail = (PropertyEmail | DataTypeString) + 5,
+
+            /* contact_address */
+            AddressId = (PropertyAddress | DataTypeInt | ReadOnly),
+            AddressContactId = (PropertyAddress | DataTypeInt) + 1,
+            AddressType = (PropertyAddress | DataTypeInt) + 2,
+            AddressLabel = (PropertyAddress | DataTypeString) + 3,
+            AddressPostbox = (PropertyAddress | DataTypeString) + 4,
+            AddressPostalCode = (PropertyAddress | DataTypeString) + 5,
+            AddressRegion = (PropertyAddress | DataTypeString) + 6,
+            AddressLocality = (PropertyAddress | DataTypeString) + 7,
+            AddressStreet = (PropertyAddress | DataTypeString) + 8,
+            AddressCountry = (PropertyAddress | DataTypeString) + 9,
+            AddressExtended = (PropertyAddress | DataTypeString) + 10,
+            AddressIsDefault = (PropertyAddress | DataTypeBool) + 11,
+
+            /* contact_url */
+            UrlId = (PropertyUrl | DataTypeInt | ReadOnly),
+            UrlContactId = (PropertyUrl | DataTypeInt) + 1,
+            UrlType = (PropertyUrl | DataTypeInt) + 2,
+            UrlLabel = (PropertyUrl | DataTypeString) + 3,
+            UrlUrl = (PropertyUrl | DataTypeString) + 4,
+
+            /* contact_event */
+            EventId = (PropertyEvent | DataTypeInt | ReadOnly),
+            EventContactId = (PropertyEvent | DataTypeInt) + 1,
+            EventType = (PropertyEvent | DataTypeInt) + 2,
+            EventLabel = (PropertyEvent | DataTypeString) + 3,
+            EventDate = (PropertyEvent | DataTypeInt) + 4,
+            EventCalendarType = (PropertyEvent | DataTypeInt) + 5,
+            EventIsLeapMonth = (PropertyEvent | DataTypeBool) + 6,
+
+            /* contact_grouprelation */
+            GroupRelationId = (PropertyGroupRelation | DataTypeInt | ReadOnly),
+            GroupRelationGroupId = (PropertyGroupRelation | DataTypeInt) + 1,
+            GroupRelationContactId = (PropertyGroupRelation | DataTypeInt) + 2,
+            GroupRelationGroupName = (PropertyGroupRelation | DataTypeString) + 3,
+
+            /* contact_relationship */
+            RelationshipId = (PropertyRelationship | DataTypeInt | ReadOnly),
+            RelationshipContactId = (PropertyRelationship | DataTypeInt) + 1,
+            RelationshipType = (PropertyRelationship | DataTypeInt) + 2,
+            RelationshipLabel = (PropertyRelationship | DataTypeString) + 3,
+            RelationshipName = (PropertyRelationship | DataTypeString) + 4,
+
+            /* contact_image */
+            ImageId = (PropertyImage | DataTypeInt | ReadOnly),
+            ImageContactId = (PropertyImage | DataTypeInt) + 1,
+            ImageType = (PropertyImage | DataTypeInt) + 2,
+            ImageLabel = (PropertyImage | DataTypeString) + 3,
+            ImagePath = (PropertyImage | DataTypeString) + 4,
+            ImageIsDefault = (PropertyImage | DataTypeBool) + 5,
+
+            /* contact_company */
+            CompanyId = (PropertyCompany | DataTypeInt | ReadOnly),
+            CompanyContactId = (PropertyCompany | DataTypeInt) + 1,
+            CompanyType = (PropertyCompany | DataTypeInt) + 2,
+            CompanyLabel = (PropertyCompany | DataTypeString) + 3,
+            CompanyName = (PropertyCompany | DataTypeString) + 4,
+            CompanyDepartment = (PropertyCompany | DataTypeString) + 5,
+            CompanyJobTitle = (PropertyCompany | DataTypeString) + 6,
+            CompanyRole = (PropertyCompany | DataTypeString) + 7,
+            CompanyAssistantName = (PropertyCompany | DataTypeString) + 8,
+            CompanyLogo = (PropertyCompany | DataTypeString) + 9,
+            CompanyLocation = (PropertyCompany | DataTypeString) + 10,
+            CompanyDescription = (PropertyCompany | DataTypeString) + 11,
+            CompanyPhoneticName = (PropertyCompany | DataTypeString) + 12,
+
+            /* contact_nickname */
+            NicknameId = (PropertyNickname | DataTypeInt | ReadOnly),
+            NicknameContactId = (PropertyNickname | DataTypeInt) + 1,
+            NicknameName = (PropertyNickname | DataTypeString) + 2,
+
+            /* contact_messenger */
+            MessengerId = (PropertyMessenger | DataTypeInt | ReadOnly),
+            MessengerContactId = (PropertyMessenger | DataTypeInt) + 1,
+            MessengerType = (PropertyMessenger | DataTypeInt) + 2,
+            MessengerLabel = (PropertyMessenger | DataTypeString) + 3,
+            MessengerIMId = (PropertyMessenger | DataTypeString) + 4,
+
+            /* contact_note */
+            NoteId = (PropertyNote | DataTypeInt | ReadOnly),
+            NoteContactId = (PropertyNote | DataTypeInt) + 1,
+            NoteNote = (PropertyNote | DataTypeString) + 2,
+
+            /* contact sip */
+            SipId = (PropertySip | DataTypeInt | ReadOnly),
+            SipContactId = (PropertySip | DataTypeInt) + 1,
+            SipAddress = (PropertySip | DataTypeString) + 2,
+            SipType = (PropertySip | DataTypeInt) + 3,
+            SipLabel = (PropertySip | DataTypeString) + 4,
+
+            /* contact_profile */
+            ProfileId = (PropertyProfile | DataTypeInt | ReadOnly),
+            ProfileContactId = (PropertyProfile | DataTypeInt) + 1,
+            ProfileUid = (PropertyProfile | DataTypeString) + 2,
+            ProfileText = (PropertyProfile | DataTypeString) + 3,
+            ProfileOrder = (PropertyProfile | DataTypeInt) + 4,
+            ProfileServiceOperation = (PropertyProfile | DataTypeString) + 5,
+            ProfileMIME = (PropertyProfile | DataTypeString) + 6,
+            ProfileAppId = (PropertyProfile | DataTypeString) + 7,
+            ProfileUri = (PropertyProfile | DataTypeString) + 8,
+            ProfileCategory = (PropertyProfile | DataTypeString) + 9,
+            ProfileExtraData = (PropertyProfile | DataTypeString) + 10,
+
+            ExtensionId = (PropertyExtension | DataTypeInt | ReadOnly),
+            ExtensionContactId = (PropertyExtension | DataTypeInt) +1,
+            ExtensionData1 = (PropertyExtension | DataTypeInt) +2,
+            ExtensionData2 = (PropertyExtension | DataTypeString) +3,
+            ExtensionData3 = (PropertyExtension | DataTypeString) +4,
+            ExtensionData4 = (PropertyExtension | DataTypeString) +5,
+            ExtensionData5 = (PropertyExtension | DataTypeString) +6,
+            ExtensionData6 = (PropertyExtension | DataTypeString) +7,
+            ExtensionData7 = (PropertyExtension | DataTypeString) +8,
+            ExtensionData8 = (PropertyExtension | DataTypeString) +9,
+            ExtensionData9 = (PropertyExtension | DataTypeString) +10,
+            ExtensionData10 = (PropertyExtension | DataTypeString) +11,
+            ExtensionData11 = (PropertyExtension | DataTypeString) +12,
+            ExtensionData12 = (PropertyExtension | DataTypeString) +13,
+
+            /* speeddial */
+            SpeedDialDialNumber = (PropertySpeedDial | DataTypeInt),
+            SpeedDialNumberId = (PropertySpeedDial | DataTypeInt) +1,
+            SpeedDialNumber = (PropertySpeedDial | DataTypeString | ReadOnly) +2,
+            SpeedDialNumberLabel = (PropertySpeedDial | DataTypeString | ReadOnly) +3,
+            SpeedDialNumberType = (PropertySpeedDial | DataTypeInt | ReadOnly) +4,
+            SpeedDialPersonId = (PropertySpeedDial | DataTypeInt | ReadOnly) +5,
+            SpeedDialDisplayName = (PropertySpeedDial | DataTypeString | ReadOnly) +6,
+            SpeedDialThumbnail = (PropertySpeedDial | DataTypeString | ReadOnly) +7,
+            SpeedDialNormalizedNumber = (PropertySpeedDial | DataTypeString | ReadOnly) +8,
+            SpeedDialCleanedNumber = (PropertySpeedDial | DataTypeString | ReadOnly) +9,
+            SpeedDialNumberFilter = (PropertySpeedDial | DataTypeString | ReadOnly) +10,
+
+            /* phonelog */
+            PhonelogId = (PropertyPhonelog | DataTypeInt | ReadOnly),
+            PhonelogPersonId = (PropertyPhonelog | DataTypeInt) + 1,
+            PhonelogAddress = (PropertyPhonelog | DataTypeString) + 2,
+            PhonelogLogTime = (PropertyPhonelog | DataTypeInt) + 3,
+            PhonelogLogType = (PropertyPhonelog | DataTypeInt) + 4,
+            PhonelogExtraData1 = (PropertyPhonelog | DataTypeInt) + 5,   /* duration, message_id, email_id */
+            PhonelogExtraData2 = (PropertyPhonelog | DataTypeString) + 6,   /* short message, subject */
+            PhonelogNormalizedAddress = (PropertyPhonelog | DataTypeString | ReadOnly) + 7,   /* for search by calllog number */
+            PhonelogCleanedAddress = (PropertyPhonelog | DataTypeString | ReadOnly) + 8,   /* for search by calllog number */
+            PhonelogAddressFilter = (PropertyPhonelog | DataTypeString | ReadOnly) + 9,   /* for search by calllog number */
+            PhonelogSIMSlotNo = (PropertyPhonelog | DataTypeInt) + 10,
+
+            /* phonelog_stat */
+            PhonelogStatLogCount = (PropertyPhonelogStat | DataTypeInt | ReadOnly),
+            PhonelogStatLogType = (PropertyPhonelogStat | DataTypeInt | ReadOnly) + 1,
+            PhonelogStatSIMSlotNo = (PropertyPhonelogStat | DataTypeInt | ReadOnly) + 2,
+
+            /* updated_info : read only */
+            UpdateInfoId = (PropertyUpdateInfo | DataTypeInt),
+            UpdateInfoAddressbookId = (PropertyUpdateInfo | DataTypeInt) +1,
+            UpdateInfoType = (PropertyUpdateInfo | DataTypeInt) +2,
+            UpdateInfoVersion = (PropertyUpdateInfo | DataTypeInt) +3,
+            UpdateInfoImageChanged = (PropertyUpdateInfo | DataTypeBool) +4,
+            UpdateInfoLastChangedType = (PropertyUpdateInfo | DataTypeInt)+5,   /* now, it is used for _contacts_my_profile_updated_info */
+        }
+
+        /// <summary>
+        /// Enumeration for contact change state.
+        /// </summary>
+        public enum ChangeTypes
+        {
+            /// <summary>
+            /// Inserted
+            /// </summary>
+            Inserted,
+            /// <summary>
+            /// Updated
+            /// </summary>
+            Updated,
+            /// <summary>
+            /// Deleted
+            /// </summary>
+            Deleted,
+        }
+
+        internal const uint AverageSizeOfRecord = 120;  /* average size of person record */
+
+        /// <summary>
+        /// Describes properies of a Address book record.
+        /// </summary>
+        public static class Addressbook
+        {
+            /// <summary>
+            /// Identifier of this contacts addressbook view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.addressbook";
+            /// <summary>
+            /// integer, read only,  DB record ID of the addressbook
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.AddressbookId;
+            /// <summary>
+            /// integer, read/write once, Account ID that the addressbook belongs to
+            /// </summary>
+            public const uint AccountId = (uint)PropertyIds.AddressbookAccountId;
+            /// <summary>
+            /// string, read/write, It cannot be NULL. Duplicate names are not allowed.
+            /// </summary>
+            public const uint Name = (uint)PropertyIds.AddressbookName;
+            /// <summary>
+            /// integer, read/write, Addressbook mode, refer to the Modes
+            /// </summary>
+            public const uint Mode = (uint)PropertyIds.AddressbookMode;
+
+            /// <summary>
+            /// Enumeration for Address book mode.
+            /// </summary>
+            public enum Modes
+            {
+                /// <summary>
+                /// All module can read and write contacts of this address_book
+                /// </summary>
+                None,
+                /// <summary>
+                /// All module can only read contacts of this address_book
+                /// </summary>
+                ReadOnly,
+            }
+        }
+
+        /// <summary>
+        /// Describes properies of a Group record.
+        /// </summary>
+        public static class Group
+        {
+            /// <summary>
+            /// Identifier of this contacts group view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.group";
+            /// <summary>
+            /// DB record ID of the group
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.GroupId;
+            /// <summary>
+            /// Addressbook ID that the group belongs to
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.GroupAddressbookId;
+            /// <summary>
+            /// Group name
+            /// </summary>
+            public const uint Name = (uint)PropertyIds.GroupName;
+            /// <summary>
+            /// Ringtone path of the group
+            /// </summary>
+            public const uint RingtonePath = (uint)PropertyIds.GroupRingtone;
+            /// <summary>
+            /// Image path of the group
+            /// </summary>
+            public const uint ImagePath = (uint)PropertyIds.GroupImage;
+            /// <summary>
+            /// Vibration path of the group
+            /// </summary>
+            public const uint Vibration = (uint)PropertyIds.GroupVibration;
+            /// <summary>
+            /// Extra data for default group name
+            /// </summary>
+            public const uint ExtraData = (uint)PropertyIds.GroupExtraData;
+            /// <summary>
+            /// The group is read only or not
+            /// </summary>
+            public const uint IsReadOnly = (uint)PropertyIds.GroupIsReadOnly;
+            /// <summary>
+            /// Message alert path of the group
+            /// </summary>
+            public const uint MessageAlert = (uint)PropertyIds.GroupMessageAlert;
+        }
+
+        /// <summary>
+        /// Describes properies of a Person record.
+        /// </summary>
+        public static class Person
+        {
+            /// <summary>
+            /// Identifier of this contacts person view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.person";
+            /// <summary>
+            /// DB record ID of the person
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.PersonId;
+            /// <summary>
+            /// Display name of the person
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.PersonDisplayName;
+            /// <summary>
+            /// The first character of first string for grouping. This is normalized using icu (projection)
+            /// </summary>
+            public const uint DisplayNameIndex = (uint)PropertyIds.PersonDisplayNameIndex;
+            /// <summary>
+            /// Display contact ID that the person belongs to
+            /// </summary>
+            public const uint DisplayContactId = (uint)PropertyIds.PersonDisplayContactId;
+            /// <summary>
+            /// Ringtone path of the person
+            /// </summary>
+            public const uint RingtonePath = (uint)PropertyIds.PersonRingtone;
+            /// <summary>
+            /// Image thumbnail path of the person
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.PersonThumbnail;
+            /// <summary>
+            /// Vibration path of the person
+            /// </summary>
+            public const uint Vibration = (uint)PropertyIds.PersonVibration;
+            /// <summary>
+            /// Message alert path of the person
+            /// </summary>
+            public const uint MessageAlert = (uint)PropertyIds.PersonMessageAlert;
+            /// <summary>
+            /// Status of social account
+            /// </summary>
+            public const uint Status = (uint)PropertyIds.PersonStatus;
+            /// <summary>
+            /// The person is favorite or not
+            /// </summary>
+            public const uint IsFavorite = (uint)PropertyIds.PersonIsFavorite;
+            /// <summary>
+            /// The priority of favorite contacts. it can be used as sorting key
+            /// </summary>
+            public const uint FavoritePriority = (uint)PropertyIds.PersonFavoritePriority;
+            /// <summary>
+            /// Link count of contact records (projection)
+            /// </summary>
+            public const uint LinkCount = (uint)PropertyIds.PersonLinkCount;
+            /// <summary>
+            /// Addressbook IDs that the person belongs to (projection)
+            /// </summary>
+            public const uint AddressbookIds = (uint)PropertyIds.PersonAddressbookIds;
+            /// <summary>
+            /// The person has phone number or not
+            /// </summary>
+            public const uint HasPhoneNumber = (uint)PropertyIds.PersonHasPhoneNumber;
+            /// <summary>
+            /// The person has email or not
+            /// </summary>
+            public const uint HasEmail = (uint)PropertyIds.PersonHasEmail;
+            /// <summary>
+            /// kerword matched data type
+            /// </summary>
+            public const uint SnippetType = (uint)PropertyIds.PersonSnippetType;
+            /// <summary>
+            /// keyword matched data string
+            /// </summary>
+            public const uint SnippetString = (uint)PropertyIds.PersonSnippetString;
+        }
+
+        /// <summary>
+        /// Describes properies of a Contact record.
+        /// </summary>
+        public static class Contact
+        {
+            /// <summary>
+            /// Identifier of this contact view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.contact";
+            /// <summary>
+            /// DB record ID of the contact
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.ContactId;
+            /// <summary>
+            /// Display name of the contact
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.ContactDisplayName;
+            /// <summary>
+            /// The source type of display name, refer to the DisplayNameSourceTypes
+            /// </summary>
+            public const uint DisplaySourceType = (uint)PropertyIds.ContactDisplaySourceDataId;
+            /// <summary>
+            /// Addressbook ID that the contact belongs to
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.ContactAddressbookId;
+            /// <summary>
+            /// Ringtone path of the contact
+            /// </summary>
+            public const uint RingtonePath = (uint)PropertyIds.ContactRingtone;
+            /// <summary>
+            /// Image thumbnail path of the contact
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.ContactThumbnail;
+            /// <summary>
+            /// The contact is favorite or not
+            /// </summary>
+            public const uint IsFavorite = (uint)PropertyIds.ContactIsFavorite;
+            /// <summary>
+            /// The contact has phone number or not
+            /// </summary>
+            public const uint HasPhoneNumber = (uint)PropertyIds.ContactHasPhoneNumber;
+            /// <summary>
+            /// The contact has email or not
+            /// </summary>
+            public const uint HasEmail = (uint)PropertyIds.ContactHasEmail;
+            /// <summary>
+            /// Person ID that the contact belongs to. If set when inserting, a contact will be linked to person
+            /// </summary>
+            public const uint PersonId = (uint)PropertyIds.ContactPersonId;
+            /// <summary>
+            /// Unique identifier
+            /// </summary>
+            public const uint Uid = (uint)PropertyIds.ContactUid;
+            /// <summary>
+            /// Vibration path of the contact
+            /// </summary>
+            public const uint Vibration = (uint)PropertyIds.ContactVibration;
+            /// <summary>
+            /// Message alert path of the contact
+            /// </summary>
+            public const uint MessageAlert = (uint)PropertyIds.ContactMessageAlert;
+            /// <summary>
+            /// Last changed contact time
+            /// </summary>
+            public const uint ChangedTime = (uint)PropertyIds.ContactChangedTime;
+            /// <summary>
+            /// The link mode, refer to the LinkModes. If the person_id was set, this value will be ignored
+            /// </summary>
+            public const uint LinkMode = (uint)PropertyIds.ContactLinkMode;
+            /// <summary>
+            /// Name child record (single)
+            /// </summary>
+            public const uint Name = (uint)PropertyIds.ContactName;
+            /// <summary>
+            /// Company child record (multiple)
+            /// </summary>
+            public const uint Company = (uint)PropertyIds.ContactCompany;
+            /// <summary>
+            /// Note child record (multiple)
+            /// </summary>
+            public const uint Note = (uint)PropertyIds.ContactNote;
+            /// <summary>
+            /// Number child record (multiple)
+            /// </summary>
+            public const uint Number = (uint)PropertyIds.ContactNumber;
+            /// <summary>
+            /// Email child record (multiple)
+            /// </summary>
+            public const uint Email = (uint)PropertyIds.ContactEmail;
+            /// <summary>
+            /// Event child record (multiple)
+            /// </summary>
+            public const uint Event = (uint)PropertyIds.ContactEvent;
+            /// <summary>
+            /// Messenger child record (multiple)
+            /// </summary>
+            public const uint Messenger = (uint)PropertyIds.ContactMessenger;
+            /// <summary>
+            /// Address child record (multiple)
+            /// </summary>
+            public const uint Address = (uint)PropertyIds.ContactAddress;
+            /// <summary>
+            /// Url child record (multiple)
+            /// </summary>
+            public const uint Url = (uint)PropertyIds.ContactUrl;
+            /// <summary>
+            /// Nickname child record (multiple)
+            /// </summary>
+            public const uint Nickname = (uint)PropertyIds.ContactNickname;
+            /// <summary>
+            /// Profile child record (multiple)
+            /// </summary>
+            public const uint Profile = (uint)PropertyIds.ContactProfile;
+            /// <summary>
+            /// Relationship child record (multiple)
+            /// </summary>
+            public const uint Relationship = (uint)PropertyIds.ContactRelationship;
+            /// <summary>
+            /// Image child record (multiple)
+            /// </summary>
+            public const uint Image = (uint)PropertyIds.ContactImage;
+            /// <summary>
+            /// GroupRelation child record (multiple)
+            /// </summary>
+            public const uint GroupRelation = (uint)PropertyIds.ContactGroupRelation;
+            /// <summary>
+            /// Extension child record (multiple)
+            /// </summary>
+            public const uint Extension = (uint)PropertyIds.ContactExtension;
+            /// <summary>
+            /// Sip child record (multiple)
+            /// </summary>
+            public const uint Sip = (uint)PropertyIds.ContactSip;
+
+            /// <summary>
+            /// Enumeration for link mode when inserting contact.
+            /// </summary>
+            public enum LinkModes
+            {
+                /// <summary>
+                /// Auto link immediately
+                /// </summary>
+                Auto,
+                /// <summary>
+                /// Do not auto link when the contact is inserted
+                /// </summary>
+                None
+            }
+
+            /// <summary>
+            /// Enumeration for Contact display name source type.
+            /// </summary>
+            public enum DisplayNameSourceTypes
+            {
+                /// <summary>
+                /// Invalid source of display name
+                /// </summary>
+                Invalid,
+                /// <summary>
+                /// Produced display name from email record
+                /// </summary>
+                Email,
+                /// <summary>
+                /// Produced display name from number record
+                /// </summary>
+                Number,
+                /// <summary>
+                /// Produced display name from nickname record
+                /// </summary>
+                Nickname,
+                /// <summary>
+                /// Produced display name from company record
+                /// </summary>
+                Company,
+                /// <summary>
+                /// Produced display name from name record
+                /// </summary>
+                Name,
+            }
+
+            /// <summary>
+            /// Enumeration for contacts data type.
+            /// </summary>
+            public enum DataTypes
+            {
+                Name = 1,
+                Address = 2,
+                Messenger = 3,
+                Url = 4,
+                Event = 5,
+                Company = 6,
+                Nickname = 7,
+                Number = 8,
+                Email = 9,
+                Profile = 10,
+                Relationsip = 11,
+                Note = 12,
+                Image = 13,
+                Sip = 14,
+                Extension = 100
+            }
+        }
+
+        /// <summary>
+        /// Describes properies of a Simple contact record.
+        /// </summary>
+        public static class SimpleContact
+        {
+            /// <summary>
+            /// Identifier of this simple contact view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.simple_contact";
+            /// <summary>
+            /// DB record ID of the contact
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.ContactId;
+            /// <summary>
+            /// Display name of the contact
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.ContactDisplayName;
+            /// <summary>
+            /// The source type of display name, refer to the Contact.DisplayNameSourceTypes
+            /// </summary>
+            public const uint DisplaySourceType = (uint)PropertyIds.ContactDisplaySourceDataId;
+            /// <summary>
+            /// Addressbook that the contact belongs to
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.ContactAddressbookId;
+            /// <summary>
+            /// Ringtone path of the contact
+            /// </summary>
+            public const uint RingtonePath = (uint)PropertyIds.ContactRingtone;
+            /// <summary>
+            /// Image thumbnail path of the contact
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.ContactThumbnail;
+            /// <summary>
+            /// The contact is favorite or not
+            /// </summary>
+            public const uint IsFavorite = (uint)PropertyIds.ContactIsFavorite;
+            /// <summary>
+            /// The contact has phone number or not
+            /// </summary>
+            public const uint HasPhoneNumber = (uint)PropertyIds.ContactHasPhoneNumber;
+            /// <summary>
+            /// The contact has email or not
+            /// </summary>
+            public const uint HasEmail = (uint)PropertyIds.ContactHasEmail;
+            /// <summary>
+            /// Person ID that the contact belongs to
+            /// </summary>
+            public const uint PersonId = (uint)PropertyIds.ContactPersonId;
+            /// <summary>
+            /// Unique identifier
+            /// </summary>
+            public const uint Uid = (uint)PropertyIds.ContactUid;
+            /// <summary>
+            /// Vibration path of the contact
+            /// </summary>
+            public const uint Vibration = (uint)PropertyIds.ContactVibration;
+            /// <summary>
+            /// Message alert path of the contact
+            /// </summary>
+            public const uint MessageAlert = (uint)PropertyIds.ContactMessageAlert;
+            /// <summary>
+            /// Last changed contact time
+            /// </summary>
+            public const uint ChangedTime = (uint)PropertyIds.ContactChangedTime;
+        }
+
+        /// <summary>
+        /// Describes properies of a My profile record.
+        /// </summary>
+        public static class MyProfile
+        {
+            /// <summary>
+            /// Identifier of this my profile view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.my_profile";
+            /// <summary>
+            /// DB record ID of the my profile
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.MyProfileId;
+            /// <summary>
+            /// Display name of the profile
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.MyProfileDisplayName;
+            /// <summary>
+            /// Addressbook ID that the profile belongs to
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.MyProfileAddressbookId;
+            /// <summary>
+            /// Image thumbnail path of the profile
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.MyProfileThumbnail;
+            /// <summary>
+            /// Unique identifier
+            /// </summary>
+            public const uint Uid = (uint)PropertyIds.MyProfileUid;
+            /// <summary>
+            /// Last changed profile time
+            /// </summary>
+            public const uint ChangedTime = (uint)PropertyIds.MyProfileChangedTime;
+            /// <summary>
+            /// Name child record (single)
+            /// </summary>
+            public const uint Name = (uint)PropertyIds.MyProfileName;
+            /// <summary>
+            /// Company child record (multiple)
+            /// </summary>
+            public const uint Company = (uint)PropertyIds.MyProfileCompany;
+            /// <summary>
+            /// Note child record (multiple)
+            /// </summary>
+            public const uint Note = (uint)PropertyIds.MyProfileNote;
+            /// <summary>
+            /// Number child record (multiple)
+            /// </summary>
+            public const uint Number = (uint)PropertyIds.MyProfileNumber;
+            /// <summary>
+            /// Email child record (multiple)
+            /// </summary>
+            public const uint Email = (uint)PropertyIds.MyProfileEmail;
+            /// <summary>
+            /// Event child record (multiple)
+            /// </summary>
+            public const uint Event = (uint)PropertyIds.MyProfileEvent;
+            /// <summary>
+            /// Messenger child record (multiple)
+            /// </summary>
+            public const uint Messenger = (uint)PropertyIds.MyProfileMessenger;
+            /// <summary>
+            /// Address child record (multiple)
+            /// </summary>
+            public const uint Address = (uint)PropertyIds.MyProfileAddress;
+            /// <summary>
+            /// Url child record (multiple)
+            /// </summary>
+            public const uint Url = (uint)PropertyIds.MyProfileUrl;
+            /// <summary>
+            /// Nickname child record (multiple)
+            /// </summary>
+            public const uint Nickname = (uint)PropertyIds.MyProfileNickname;
+            /// <summary>
+            /// Profile child record (multiple)
+            /// </summary>
+            public const uint Profile = (uint)PropertyIds.MyProfileProfile;
+            /// <summary>
+            /// Relationship child record (multiple)
+            /// </summary>
+            public const uint Relationship = (uint)PropertyIds.MyProfileRelationship;
+            /// <summary>
+            /// Image child record (multiple)
+            /// </summary>
+            public const uint Image = (uint)PropertyIds.MyProfileImage;
+            /// <summary>
+            /// Extension child record (multiple)
+            /// </summary>
+            public const uint Extension = (uint)PropertyIds.MyProfileExtension;
+            /// <summary>
+            /// Sip child record (multiple)
+            /// </summary>
+            public const uint Sip = (uint)PropertyIds.MyProfileSip;
+        }
+
+        /// <summary>
+        /// Describes properies of a Name record.
+        /// </summary>
+        public static class Name
+        {
+            /// <summary>
+            /// Identifier of this contacts name view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.name";
+            /// <summary>
+            /// DB record ID of the name
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.NameId;
+            /// <summary>
+            /// Contacts ID that the name record belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.NameContactId;
+            /// <summary>
+            /// First name
+            /// </summary>
+            public const uint First = (uint)PropertyIds.NameFirst;
+            /// <summary>
+            /// Last name
+            /// </summary>
+            public const uint Last = (uint)PropertyIds.NameLast;
+            /// <summary>
+            /// Middle name
+            /// </summary>
+            public const uint Addition = (uint)PropertyIds.NameAddition;
+            /// <summary>
+            /// Suffix
+            /// </summary>
+            public const uint Suffix = (uint)PropertyIds.NameSuffix;
+            /// <summary>
+            /// Prefix
+            /// </summary>
+            public const uint Prefix = (uint)PropertyIds.NamePrefix;
+            /// <summary>
+            /// Pronounce the first name
+            /// </summary>
+            public const uint PhoneticFirst = (uint)PropertyIds.NamePhoneticFirst;
+            /// <summary>
+            /// Pronounce the middle name
+            /// </summary>
+            public const uint PhoneticMiddle = (uint)PropertyIds.NamePhoneticMiddle;
+            /// <summary>
+            /// Pronounce the last name
+            /// </summary>
+            public const uint PhoneticLast = (uint)PropertyIds.NamePhoneticLast;
+        }
+
+        /// <summary>
+        /// Describes properies of a Number record.
+        /// </summary>
+        public static class Number
+        {
+            /// <summary>
+            /// Identifier of this contacts number view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.number";
+            /// <summary>
+            /// DB record ID of the number
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.NumberId;
+            /// <summary>
+            /// Contact ID that the number belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.NumberContactId;
+            /// <summary>
+            /// Number type, refer to the Types
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.NumberType;
+            /// <summary>
+            /// Custom number type label, when the number type is Types.Custom
+            /// </summary>
+            public const uint Label = (uint)PropertyIds.NumberLabel;
+            /// <summary>
+            /// The number is default number or not
+            /// </summary>
+            public const uint IsDefault = (uint)PropertyIds.NumberIsDefault;
+            /// <summary>
+            /// Number
+            /// </summary>
+            public const uint NumberData = (uint)PropertyIds.NumberNumber;
+            /// <summary>
+            /// You can only use this property for search filter.
+            /// </summary>
+            public const uint NormalizedNumber = (uint)PropertyIds.NumberNormalizedNumber;
+            /// <summary>
+            /// You can only use this property for search filter.
+            /// </summary>
+            public const uint CleanedNumber = (uint)PropertyIds.NumberCleanedNumber;
+            /// <summary>
+            /// You can only use this property for search filter.
+            /// </summary>
+            public const uint NumberFilter = (uint)PropertyIds.NumberNumberFilter;
+
+            /// <summary>
+            /// Enumeration for number type.
+            /// </summary>
+            public enum Types
+            {
+                /// <summary>
+                /// Other number type
+                /// </summary>
+                Other = 0,
+                /// <summary>
+                /// Custom number type
+                /// </summary>
+                Custom = 1 << 0,
+                /// <summary>
+                /// A telephone number associated with a residence
+                /// </summary>
+                Home = 1 << 1,
+                /// <summary>
+                /// A telephone number associated with a place of work
+                /// </summary>
+                Work = 1 << 2,
+                /// <summary>
+                /// A voice telephone number
+                /// </summary>
+                Voice = 1 << 3,
+                /// <summary>
+                /// A facsimile telephone number
+                /// </summary>
+                Fax = 1 << 4,
+                /// <summary>
+                /// The telephone number has voice messaging support
+                /// </summary>
+                Message = 1 << 5,
+                /// <summary>
+                /// A cellular telephone number
+                /// </summary>
+                Cell = 1 << 6,
+                /// <summary>
+                /// A paging device telephone number
+                /// </summary>
+                Pager = 1 << 7,
+                /// <summary>
+                /// A bulletin board system telephone number
+                /// </summary>
+                BBS = 1 << 8,
+                /// <summary>
+                /// A MODEM connected telephone number
+                /// </summary>
+                Modem = 1 << 9,
+                /// <summary>
+                /// A car-phone telephone number
+                /// </summary>
+                Car = 1 << 10,
+                /// <summary>
+                /// An ISDN service telephone number
+                /// </summary>
+                ISDN = 1 << 11,
+                /// <summary>
+                /// A video conferencing telephone number
+                /// </summary>
+                Video = 1 << 12,
+                /// <summary>
+                /// A personal communication services telephone number
+                /// </summary>
+                PCS = 1 << 13,
+                /// <summary>
+                /// A company main number
+                /// </summary>
+                Company = 1 << 14,
+                /// <summary>
+                /// A radio phone number
+                /// </summary>
+                Radio = 1 << 15,
+                /// <summary>
+                /// An additional type for main
+                /// </summary>
+                Main = 1 << 29,
+                /// <summary>
+                /// An additional type for assistant
+                /// </summary>
+                Assistant = 1 << 30,
+            }
+        }
+
+        /// <summary>
+        /// Describes properies of a Email record.
+        /// </summary>
+        public static class Email
+        {
+            /// <summary>
+            /// Identifier of this contacts email view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.email";
+            /// <summary>
+            /// DB record ID of the email
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.EmailId;
+            /// <summary>
+            /// Contact ID that the email belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.EmailContactId;
+            /// <summary>
+            /// Email type, refer to the Types
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.EmailType;
+            /// <summary>
+            /// Custom mail type label, when the email type is Types.Custom
+            /// </summary>
+            public const uint Label = (uint)PropertyIds.EmailLabel;
+            /// <summary>
+            /// The email is default email or not
+            /// </summary>
+            public const uint IsDefault = (uint)PropertyIds.EmailIsDefault;
+            /// <summary>
+            /// Email address
+            /// </summary>
+            public const uint Address = (uint)PropertyIds.EmailEmail;
+
+            /// <summary>
+            /// Enumeration for Contact email type.
+            /// </summary>
+            public enum Types
+            {
+                /// <summary>
+                /// Other email type
+                /// </summary>
+                Other = 0,
+                /// <summary>
+                /// Custom email type
+                /// </summary>
+                Custom = 1 << 0,
+                /// <summary>
+                /// An email address associated with a residence
+                /// </summary>
+                Home = 1 << 1,
+                /// <summary>
+                /// An email address associated with a place of work
+                /// </summary>
+                Work = 1 << 2,
+                /// <summary>
+                /// A mobile email address
+                /// </summary>
+                Mobile = 1 << 3,
+            }
+        }
+
+        /// <summary>
+        /// Describes properies of a Address record.
+        /// </summary>
+        public static class Address
+        {
+            /// <summary>
+            /// Identifier of this contacts address view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.address";
+            /// <summary>
+            /// DB record ID of the address
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.AddressId;
+            /// <summary>
+            /// Contact ID that the address belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.AddressContactId;
+            /// <summary>
+            /// Address type, refer to the Types
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.AddressType;
+            /// <summary>
+            /// Address type label, when the address type is Types.Custom
+            /// </summary>
+            public const uint Label = (uint)PropertyIds.AddressLabel;
+            /// <summary>
+            /// Post office box
+            /// </summary>
+            public const uint Postbox = (uint)PropertyIds.AddressPostbox;
+            /// <summary>
+            /// Postal code
+            /// </summary>
+            public const uint PostalCode = (uint)PropertyIds.AddressPostalCode;
+            /// <summary>
+            /// Region
+            /// </summary>
+            public const uint Region = (uint)PropertyIds.AddressRegion;
+            /// <summary>
+            /// Locality
+            /// </summary>
+            public const uint Locality = (uint)PropertyIds.AddressLocality;
+            /// <summary>
+            /// Street
+            /// </summary>
+            public const uint Street = (uint)PropertyIds.AddressStreet;
+            /// <summary>
+            /// Country
+            /// </summary>
+            public const uint Country = (uint)PropertyIds.AddressCountry;
+            /// <summary>
+            /// Extended address
+            /// </summary>
+            public const uint Extended = (uint)PropertyIds.AddressExtended;
+            /// <summary>
+            /// The address is default or not
+            /// </summary>
+            public const uint IsDefault = (uint)PropertyIds.AddressIsDefault;
+
+            /// <summary>
+            /// Enumeration for Contact address type.
+            /// </summary>
+            public enum Types
+            {
+                /// <summary>
+                /// Other address type
+                /// </summary>
+                Other = 0,
+                /// <summary>
+                /// Custom address type
+                /// </summary>
+                Custom = 1 << 0,
+                /// <summary>
+                /// A delivery address for a residence
+                /// </summary>
+                Home = 1 << 1,
+                /// <summary>
+                /// A delivery address for a place of work
+                /// </summary>
+                Work = 1 << 2,
+                /// <summary>
+                /// A domestic delivery address
+                /// </summary>
+                Domestic = 1 << 3,
+                /// <summary>
+                /// An international delivery address
+                /// </summary>
+                International = 1 << 4,
+                /// <summary>
+                /// A postal delivery address
+                /// </summary>
+                Postal = 1 << 5,
+                /// <summary>
+                /// A parcel delivery address
+                /// </summary>
+                Parcel = 1 << 6,
+            }
+        }
+
+        /// <summary>
+        /// Describes properies of a Note record.
+        /// </summary>
+        public static class Note
+        {
+            /// <summary>
+            /// Identifier of this contacts note view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.note";
+            /// <summary>
+            /// DB record ID of the note
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.NoteId;
+            /// <summary>
+            /// Contact ID that the note belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.NoteContactId;
+            /// <summary>
+            /// Note contents
+            /// </summary>
+            public const uint Contents = (uint)PropertyIds.NoteNote;
+        }
+
+        /// <summary>
+        /// Describes properies of a Url record.
+        /// </summary>
+        public static class Url
+        {
+            /// <summary>
+            /// Identifier of this contacts URL view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.url";
+            /// <summary>
+            /// DB record ID of the URL
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.UrlId;
+            /// <summary>
+            /// Contact ID that the URL belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.UrlContactId;
+            /// <summary>
+            /// URL type, refer to the Types
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.UrlType;
+            /// <summary>
+            /// Custom URL type label, when the URL type is Types.Custom
+            /// </summary>
+            public const uint Label = (uint)PropertyIds.UrlLabel;
+            /// <summary>
+            /// URL
+            /// </summary>
+            public const uint UrlData = (uint)PropertyIds.UrlUrl;
+
+            /// <summary>
+            /// Enumeration for Contact URL type.
+            /// </summary>
+            public enum Types
+            {
+                /// <summary>
+                /// Other URL type
+                /// </summary>
+                Other,
+                /// <summary>
+                /// Custom URL type
+                /// </summary>
+                Custom,
+                /// <summary>
+                /// Home URL type
+                /// </summary>
+                Home,
+                /// <summary>
+                /// Work URL type
+                /// </summary>
+                Work,
+            }
+        }
+
+        /// <summary>
+        /// Describes properies of a Event record.
+        /// </summary>
+        public static class Event
+        {
+            /// <summary>
+            /// Identifier of this contacts event view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.event";
+            /// <summary>
+            /// DB record ID of the event
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.EventId;
+            /// <summary>
+            /// Contact ID that the event belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.EventContactId;
+            /// <summary>
+            /// Event type, refer to the Types
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.EventType;
+            /// <summary>
+            /// Custom event type label, when the event type is Types.Custom
+            /// </summary>
+            public const uint Label = (uint)PropertyIds.EventLabel;
+            /// <summary>
+            /// Event date(YYYYMMDD). e.g. 2014/1/1 : 20140101. Even if the calendar_type is set as CONTACTS_EVENT_CALENDAR_TYPE_CHINESE, you SHOULD set Gregorian date
+            /// </summary>
+            public const uint Date = (uint)PropertyIds.EventDate;
+            /// <summary>
+            /// Calendar type, refer to the CalendarTypes
+            /// </summary>
+            public const uint IsLeapMonth = (uint)PropertyIds.EventIsLeapMonth;
+
+            /// <summary>
+            /// Enumeration for Contact event type.
+            /// </summary>
+            public enum Types
+            {
+                /// <summary>
+                /// Other event type
+                /// </summary>
+                Other,
+                /// <summary>
+                /// Custom event type
+                /// </summary>
+                Custom,
+                /// <summary>
+                /// Birthday event type
+                /// </summary>
+                Birthday,
+                /// <summary>
+                /// Anniversary event type
+                /// </summary>
+                Anniversary
+            }
+
+            /// <summary>
+            /// Enumeration for Contact event calendar type.
+            /// </summary>
+            public enum CalendarTypes
+            {
+                /// <summary>
+                /// Gregorian calendar
+                /// </summary>
+                Gregorian,
+                /// <summary>
+                /// Chinese calenadr
+                /// </summary>
+                Chinese
+            }
+        }
+
+        /// <summary>
+        /// Describes properies of a Relationship record.
+        /// </summary>
+        public static class Relationship
+        {
+            /// <summary>
+            /// Identifier of this relationship view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.relationship";
+            /// <summary>
+            /// DB record ID of the relationship
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.RelationshipId;
+            /// <summary>
+            /// Contact ID that the relationship belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.RelationshipContactId;
+            /// <summary>
+            /// Relationship type, refer to the Types
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.RelationshipType;
+            /// <summary>
+            /// Custom relationship type label, when the relationship type is Types.Custom
+            /// </summary>
+            public const uint Label = (uint)PropertyIds.RelationshipLabel;
+            /// <summary>
+            /// Selected contact name that the relationship belongs to
+            /// </summary>
+            public const uint Name = (uint)PropertyIds.RelationshipName;
+
+            /// <summary>
+            /// Enumeration for Contact relationship type.
+            /// </summary>
+            public enum Types
+            {
+                /// <summary>
+                /// Other relationship type
+                /// </summary>
+                Other,
+                /// <summary>
+                /// Assistant type
+                /// </summary>
+                Assistant,
+                /// <summary>
+                /// Brother type
+                /// </summary>
+                Brother,
+                /// <summary>
+                /// Child type
+                /// </summary>
+                Child,
+                /// <summary>
+                /// Domestic Partner type
+                /// </summary>
+                DomesticPartner,
+                /// <summary>
+                /// Father type
+                /// </summary>
+                Father,
+                /// <summary>
+                /// Friend type
+                /// </summary>
+                Friend,
+                /// <summary>
+                /// Manager type
+                /// </summary>
+                Manager,
+                /// <summary>
+                /// Mother type
+                /// </summary>
+                Mother,
+                /// <summary>
+                /// Parent type
+                /// </summary>
+                Parent,
+                /// <summary>
+                /// Partner type
+                /// </summary>
+                Partner,
+                /// <summary>
+                /// Referred by type
+                /// </summary>
+                ReferredBy,
+                /// <summary>
+                /// Relative type
+                /// </summary>
+                Relative,
+                /// <summary>
+                /// Sister type
+                /// </summary>
+                Sister,
+                /// <summary>
+                /// Spouse type
+                /// </summary>
+                Spouse,
+                /// <summary>
+                /// Custom type
+                /// </summary>
+                Custom,
+            }
+        }
+
+        /// <summary>
+        /// Describes properies of a Image record.
+        /// </summary>
+        public static class Image
+        {
+            /// <summary>
+            /// Identifier of this contacts image view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.image";
+            /// <summary>
+            /// DB record ID of the image
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.ImageId;
+            /// <summary>
+            /// Contact ID that the image belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.ImageContactId;
+            /// <summary>
+            /// Image type, refer to the Types
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.ImageType;
+            /// <summary>
+            /// Custom image type label, when the image type is Types.Custom
+            /// </summary>
+            public const uint Label = (uint)PropertyIds.ImageLabel;
+            /// <summary>
+            /// Image thumbnail path
+            /// </summary>
+            public const uint Path = (uint)PropertyIds.ImagePath;
+            /// <summary>
+            /// The Image is default or not
+            /// </summary>
+            public const uint IsDefault = (uint)PropertyIds.ImageIsDefault;
+
+            /// <summary>
+            /// Enumeration for Contact image type.
+            /// </summary>
+            public enum Types
+            {
+                /// <summary>
+                /// Other type
+                /// </summary>
+                Other,
+                /// <summary>
+                /// Custom type
+                /// </summary>
+                Custom,
+            }
+        }
+
+        /// <summary>
+        /// Describes properies of a Company record.
+        /// </summary>
+        public static class Company
+        {
+            /// <summary>
+            /// Identifier of this contacts company view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.company";
+            /// <summary>
+            /// DB record ID of the company
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.CompanyId;
+            /// <summary>
+            /// Contact ID that the company belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.CompanyContactId;
+            /// <summary>
+            /// Company type, refer to the Types
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.CompanyType;
+            /// <summary>
+            /// Custom company type label, when the company type is Types.Custom
+            /// </summary>
+            public const uint Label = (uint)PropertyIds.CompanyLabel;
+            /// <summary>
+            /// Company name
+            /// </summary>
+            public const uint Name = (uint)PropertyIds.CompanyName;
+            /// <summary>
+            /// Department
+            /// </summary>
+            public const uint Department = (uint)PropertyIds.CompanyDepartment;
+            /// <summary>
+            /// Job title
+            /// </summary>
+            public const uint JobTitle = (uint)PropertyIds.CompanyJobTitle;
+            /// <summary>
+            /// Assistant name
+            /// </summary>
+            public const uint AssistantName = (uint)PropertyIds.CompanyAssistantName;
+            /// <summary>
+            /// Role
+            /// </summary>
+            public const uint Role = (uint)PropertyIds.CompanyRole;
+            /// <summary>
+            /// Company logo image file path
+            /// </summary>
+            public const uint Logo = (uint)PropertyIds.CompanyLogo;
+            /// <summary>
+            /// Company location
+            /// </summary>
+            public const uint Location = (uint)PropertyIds.CompanyLocation;
+            /// <summary>
+            /// Description
+            /// </summary>
+            public const uint Description = (uint)PropertyIds.CompanyDescription;
+            /// <summary>
+            /// Pronounce the company name
+            /// </summary>
+            public const uint PhoneticName = (uint)PropertyIds.CompanyPhoneticName;
+
+            /// <summary>
+            /// Enumeration for Contact company type.
+            /// </summary>
+            public enum Types
+            {
+                Other = 0, /**< Other company type */
+                Custom = 1 << 0, /**< Custom company type */
+                Work = 1 << 1, /**< Work company type */
+            }
+        }
+
+        /// <summary>
+        /// Describes properies of a Nickname record.
+        /// </summary>
+        public static class Nickname
+        {
+            /// <summary>
+            /// Identifier of this contacts nickname view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.nickname";
+            /// <summary>
+            /// DB record ID of the nickname
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.NicknameId;
+            /// <summary>
+            /// Contact ID that the nickname belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.NicknameContactId;
+            /// <summary>
+            /// Nickname
+            /// </summary>
+            public const uint Name = (uint)PropertyIds.NicknameName;
+        }
+
+        /// <summary>
+        /// Describes properies of a Messenger record.
+        /// </summary>
+        public static class Messenger
+        {
+            /// <summary>
+            /// Identifier of this contacts messenger view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.messenger";
+            /// <summary>
+            /// DB record ID of the messenger
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.MessengerId;
+            /// <summary>
+            /// Contact ID that the messenger belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.MessengerContactId;
+            /// <summary>
+            /// Messenger type, refer to the Types
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.MessengerType;
+            /// <summary>
+            /// Custom messenger type label, when the messenger type is Types.Custom
+            /// </summary>
+            public const uint Label = (uint)PropertyIds.MessengerLabel;
+            /// <summary>
+            /// Messenger ID (email address or email ID...)
+            /// </summary>
+            public const uint IMId = (uint)PropertyIds.MessengerIMId;
+
+            /// <summary>
+            /// Enumeration for Contact messenger type.
+            /// </summary>
+            public enum Types
+            {
+                /// <summary>
+                /// Other messenger type
+                /// </summary>
+                Other,
+                /// <summary>
+                /// Custom messenger type
+                /// </summary>
+                Custom,
+                /// <summary>
+                /// Google messenger type
+                /// </summary>
+                Google,
+                /// <summary>
+                /// Windows live messenger type
+                /// </summary>
+                WindowsLive,
+                /// <summary>
+                /// Yahoo messenger type
+                /// </summary>
+                Yahoo,
+                /// <summary>
+                /// Facebook messenger type
+                /// </summary>
+                Facebook,
+                /// <summary>
+                /// ICQ type
+                /// </summary>
+                ICQ,
+                /// <summary>
+                /// AOL instance messenger type
+                /// </summary>
+                AOL,
+                /// <summary>
+                /// QQ type
+                /// </summary>
+                QQ,
+                /// <summary>
+                /// Jabber type
+                /// </summary>
+                Jabber,
+                /// <summary>
+                /// Skype type
+                /// </summary>
+                Skype,
+                /// <summary>
+                /// IRC type
+                /// </summary>
+                IRC,
+            }
+        }
+
+        /// <summary>
+        /// Describes properies of a Profile record.
+        /// </summary>
+        public static class Profile
+        {
+            /// <summary>
+            /// Identifier of this contacts profile view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.profile";
+            /// <summary>
+            /// DB record ID of profile
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.ProfileId;
+            /// <summary>
+            /// Contacts ID that the profile belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.ProfileContactId;
+            /// <summary>
+            /// Unique identifier
+            /// </summary>
+            public const uint Uid = (uint)PropertyIds.ProfileUid;
+            /// <summary>
+            /// Profile contents
+            /// </summary>
+            public const uint Text = (uint)PropertyIds.ProfileText;
+            /// <summary>
+            /// Priority to display the profile
+            /// </summary>
+            public const uint Order = (uint)PropertyIds.ProfileOrder;
+            /// <summary>
+            /// Data for app_control_set_operation
+            /// </summary>
+            public const uint ServiceOperation = (uint)PropertyIds.ProfileServiceOperation;
+            /// <summary>
+            /// Data for app_control_set_mime
+            /// </summary>
+            public const uint Mime = (uint)PropertyIds.ProfileMIME;
+            /// <summary>
+            /// Data for app_control_set_app_id
+            /// </summary>
+            public const uint AppId = (uint)PropertyIds.ProfileAppId;
+            /// <summary>
+            /// Data for app_control_set_uri
+            /// </summary>
+            public const uint ProfileUri = (uint)PropertyIds.ProfileUri;
+            /// <summary>
+            /// Data for app_control_set_category
+            /// </summary>
+            public const uint Category = (uint)PropertyIds.ProfileCategory;
+            /// <summary>
+            /// It includes "key:value,key:value," pairs. You should parse it. And you must base64 encode each key and value
+            /// </summary>
+            public const uint ExtraData = (uint)PropertyIds.ProfileExtraData;
+        }
+
+        /// <summary>
+        /// Describes properies of a Sip record.
+        /// </summary>
+        public static class Sip
+        {
+            /// <summary>
+            /// Identifier of this contacts sip view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.sip";
+            /// <summary>
+            /// DB record ID of the sip
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.SipId;
+            /// <summary>
+            /// Contact ID that the sip belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.SipContactId;
+            /// <summary>
+            /// SIP address
+            /// </summary>
+            public const uint Address = (uint)PropertyIds.SipAddress;
+            /// <summary>
+            /// sip type, refer to the Types
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.SipType;
+            /// <summary>
+            /// Custom sip type label, when the sip type is Types.Custom
+            /// </summary>
+            public const uint Label = (uint)PropertyIds.SipLabel;
+
+            /// <summary>
+            /// Enumeration for Contact SIP type.
+            /// </summary>
+            public enum Types
+            {
+                /// <summary>
+                /// Other SIP type
+                /// </summary>
+                Other,
+                /// <summary>
+                /// Custom SIP type
+                /// </summary>
+                Custom,
+                /// <summary>
+                /// Home SIP type
+                /// </summary>
+                Home,
+                /// <summary>
+                /// Work SIP type
+                /// </summary>
+                Work,
+            }
+        }
+
+        /// <summary>
+        /// Describes properies of a Extension record.
+        /// </summary>
+        public static class Extension
+        {
+            /// <summary>
+            /// Identifier of this contacts extension view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.extension";
+            /// <summary>
+            /// DB record ID of the contact extension
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.ExtensionId;
+            /// <summary>
+            /// Contact ID that the contact extension belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.ExtensionContactId;
+            /// <summary>
+            /// The extra child record format for non-provided from contacts-service
+            /// </summary>
+            public const uint Data1 = (uint)PropertyIds.ExtensionData1;
+            /// <summary>
+            /// The extra child record format for non-provided from contacts-service
+            /// </summary>
+            public const uint Data2 = (uint)PropertyIds.ExtensionData2;
+            /// <summary>
+            /// The extra child record format for non-provided from contacts-service
+            /// </summary>
+            public const uint Data3 = (uint)PropertyIds.ExtensionData3;
+            /// <summary>
+            /// The extra child record format for non-provided from contacts-service
+            /// </summary>
+            public const uint Data4 = (uint)PropertyIds.ExtensionData4;
+            /// <summary>
+            /// The extra child record format for non-provided from contacts-service
+            /// </summary>
+            public const uint Data5 = (uint)PropertyIds.ExtensionData5;
+            /// <summary>
+            /// The extra child record format for non-provided from contacts-service
+            /// </summary>
+            public const uint Data6 = (uint)PropertyIds.ExtensionData6;
+            /// <summary>
+            /// The extra child record format for non-provided from contacts-service
+            /// </summary>
+            public const uint Data7 = (uint)PropertyIds.ExtensionData7;
+            /// <summary>
+            /// The extra child record format for non-provided from contacts-service
+            /// </summary>
+            public const uint Data8 = (uint)PropertyIds.ExtensionData8;
+            /// <summary>
+            /// The extra child record format for non-provided from contacts-service
+            /// </summary>
+            public const uint Data9 = (uint)PropertyIds.ExtensionData9;
+            /// <summary>
+            /// The extra child record format for non-provided from contacts-service
+            /// </summary>
+            public const uint Data10 = (uint)PropertyIds.ExtensionData10;
+            /// <summary>
+            /// The extra child record format for non-provided from contacts-service
+            /// </summary>
+            public const uint Data11 = (uint)PropertyIds.ExtensionData11;
+            /// <summary>
+            /// The extra child record format for non-provided from contacts-service
+            /// </summary>
+            public const uint Data12 = (uint)PropertyIds.ExtensionData12;
+        }
+
+        /// <summary>
+        /// Describes properies of a Group relation record.
+        /// </summary>
+        public static class GroupRelation
+        {
+            /// <summary>
+            /// Identifier of this relationship view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.group_relation";
+            /// <summary>
+            /// DB record ID of the group relation (can not be used as filter)
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.GroupRelationId;
+            /// <summary>
+            /// DB record ID of the group
+            /// </summary>
+            public const uint GroupId = (uint)PropertyIds.GroupRelationGroupId;
+            /// <summary>
+            /// DB record ID of the contact
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.GroupRelationContactId;
+            /// <summary>
+            /// Group name
+            /// </summary>
+            public const uint Name = (uint)PropertyIds.GroupRelationGroupName;
+        }
+
+        /// <summary>
+        /// Describes properies of a Speed dial record.
+        /// </summary>
+        public static class SpeedDial
+        {
+            /// <summary>
+            /// Identifier of this contact speed dial view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.speeddial";
+            /// <summary>
+            /// Stored speed dial number
+            /// </summary>
+            public const uint SpeedDialNumber = (uint)PropertyIds.SpeedDialDialNumber;
+            /// <summary>
+            /// Number ID that the speed dial belongs to
+            /// </summary>
+            public const uint NumberId = (uint)PropertyIds.SpeedDialNumberId;
+            /// <summary>
+            /// Contact number of specified speed dial
+            /// </summary>
+            public const uint Number = (uint)PropertyIds.SpeedDialNumber;
+            /// <summary>
+            /// Contact number label of specified speed dial, when the number type is Number.Types.Custom
+            /// </summary>
+            public const uint NumberLabel = (uint)PropertyIds.SpeedDialNumberLabel;
+            /// <summary>
+            /// Contact number type, refer to the Number.Types
+            /// </summary>
+            public const uint NumberType = (uint)PropertyIds.SpeedDialNumberType;
+            /// <summary>
+            ///        Person ID that the speed dial belongs to
+            /// </summary>
+            public const uint PersonId = (uint)PropertyIds.SpeedDialPersonId;
+            /// <summary>
+            /// Display name that the speed dial belongs to
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.SpeedDialDisplayName;
+            /// <summary>
+            /// Image thumbnail path that the speed dial belongs to
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.SpeedDialThumbnail;
+            /// <summary>
+            /// You can only use this property for search filter
+            /// </summary>
+            public const uint NormalizedNumber = (uint)PropertyIds.SpeedDialNormalizedNumber;
+            /// <summary>
+            /// You can only use this property for search filter
+            /// </summary>
+            public const uint CleanedNumber = (uint)PropertyIds.SpeedDialCleanedNumber;
+            /// <summary>
+            /// If you add filter with this property, the string will be normalized as minmatch length internally and the match rule will be applied ContactsFilter.StringMatchType.Exactly
+            /// </summary>
+            public const uint NumberFilter = (uint)PropertyIds.SpeedDialNumberFilter;
+        }
+
+        /// <summary>
+        /// Describes properies of a Phone log record.
+        /// </summary>
+        public static class PhoneLog
+        {
+            /// <summary>
+            /// Identifier of this phone log view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.phonelog";
+            /// <summary>
+            /// DB record ID of phone log
+            /// </summary>
+            public const uint Id = (uint)PropertyIds.PhonelogId;
+            /// <summary>
+            /// Person ID that the phone log belongs to
+            /// </summary>
+            public const uint PersonId = (uint)PropertyIds.PhonelogPersonId;
+            /// <summary>
+            /// Number or Email that the phone log displays
+            /// </summary>
+            public const uint Address = (uint)PropertyIds.PhonelogAddress;
+            /// <summary>
+            /// Call end time. The value means number of seconds since 1970-01-01 00:00:00 (UTC)
+            /// </summary>
+            public const uint LogTime = (uint)PropertyIds.PhonelogLogTime;
+            /// <summary>
+            /// Log type, refer to the Types
+            /// </summary>
+            public const uint LogType = (uint)PropertyIds.PhonelogLogType;
+            /// <summary>
+            /// You can set the related integer data (e.g. message_id, email_id or duration(seconds) of call)
+            /// </summary>
+            public const uint ExtraData1 = (uint)PropertyIds.PhonelogExtraData1;
+            /// <summary>
+            /// You can set the related string data (e.g. short message, subject)
+            /// </summary>
+            public const uint ExtraData2 = (uint)PropertyIds.PhonelogExtraData2;
+            /// <summary>
+            /// You can only use this property for search filter
+            /// </summary>
+            public const uint NormalizedAddress = (uint)PropertyIds.PhonelogNormalizedAddress;
+            /// <summary>
+            /// You can only use this property for search filter
+            /// </summary>
+            public const uint CleanedAddress = (uint)PropertyIds.PhonelogCleanedAddress;
+            /// <summary>
+            /// You can only use this property for search filter
+            /// </summary>
+            public const uint AddressFilter = (uint)PropertyIds.PhonelogAddressFilter;
+            /// <summary>
+            /// You can set the related SIM slot number. sim_slot_no 0 means first SIM card, sim_slot_no 1 means second SIM. It is same with handle index of telephony handle list. Refer to the telephony_init()
+            /// </summary>
+            public const uint SimSlotNo = (uint)PropertyIds.PhonelogSIMSlotNo;
+
+            /// <summary>
+            /// Enumeration for Phone log type.
+            /// </summary>
+            public enum Types
+            {
+                /// <summary>
+                /// None
+                /// </summary>
+                None,
+                /// <summary>
+                /// Incoming call
+                /// </summary>
+                VoiceIncoming = 1,
+                /// <summary>
+                /// Outgoing call
+                /// </summary>
+                VoiceOutgoing = 2,
+                /// <summary>
+                /// Incoming video call
+                /// </summary>
+                VideoIncoming = 3,
+                /// <summary>
+                /// Outgoing video call
+                /// </summary>
+                VideoOutgoing = 4,
+                /// <summary>
+                /// Not confirmed missed call
+                /// </summary>
+                VoiceMissedUnseen = 5,
+                /// <summary>
+                /// Confirmed missed call
+                /// </summary>
+                VoiceMissedSeen = 6,
+                /// <summary>
+                /// Not confirmed missed video call
+                /// </summary>
+                VideoMissedUnseen = 7,
+                /// <summary>
+                /// Confirmed missed video call
+                /// </summary>
+                VidoeMissedSeen = 8,
+                /// <summary>
+                /// Rejected call
+                /// </summary>
+                VoiceRejected = 9,
+                /// <summary>
+                /// Rejected video call
+                /// </summary>
+                VideoRejected = 10,
+                /// <summary>
+                /// Blocked call
+                /// </summary>
+                VoiceBlocked = 11,
+                /// <summary>
+                /// Blocked video call
+                /// </summary>
+                VideoBlocked = 12,
+                /// <summary>
+                /// Incoming MMS
+                /// </summary>
+                MmsIncoming = 101,
+                /// <summary>
+                /// Outgoing MMS
+                /// </summary>
+                MmsOutgoing = 102,
+                /// <summary>
+                /// Incoming SMS
+                /// </summary>
+                SmsIncoming = 103,
+                /// <summary>
+                /// Outgoing SMS
+                /// </summary>
+                SmsOutgoing = 104,
+                /// <summary>
+                /// Blocked SMS
+                /// </summary>
+                SmsBlocked = 105,
+                /// <summary>
+                /// Blocked MMS
+                /// </summary>
+                MmsBlocked = 106,
+                /// <summary>
+                /// Received email
+                /// </summary>
+                EmailReceived = 201,
+                /// <summary>
+                /// Sent email
+                /// </summary>
+                EmailSent = 202,
+
+            }
+        }
+
+        /// <summary>
+        /// Describes properies of a Contact updated information record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class ContactUpdatedInfo
+        {
+            /// <summary>
+            /// Identifier of this contact updated info view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.contacts_updated_info";
+            /// <summary>
+            /// Updated contact ID
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.UpdateInfoId;
+            /// <summary>
+            /// Addressbook ID that the updated contact belongs to
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.UpdateInfoAddressbookId;
+            /// <summary>
+            /// Contact change type, refer to the ContactsViews.ChangeTypes
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.UpdateInfoType;
+            /// <summary>
+            /// Updated version
+            /// </summary>
+            public const uint Version = (uint)PropertyIds.UpdateInfoVersion;
+            /// <summary>
+            /// Contact image is changed or not
+            /// </summary>
+            public const uint ImageChanged = (uint)PropertyIds.UpdateInfoImageChanged;
+        }
+
+        /// <summary>
+        /// Describes properies of a My profile updated information record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class MyProfileUpdatedInfo
+        {
+            /// <summary>
+            /// Identifier of this my profile updated info view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.my_profile_updated_info";
+            /// <summary>
+            /// Address book ID that the updated my profile belongs to
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.UpdateInfoAddressbookId;
+            /// <summary>
+            /// MyProfile change type, refer to the ContactsViews.ChangeTypes
+            /// </summary>
+            public const uint LastChangedType = (uint)PropertyIds.UpdateInfoLastChangedType;
+            /// <summary>
+            /// Updated version
+            /// </summary>
+            public const uint Version = (uint)PropertyIds.UpdateInfoVersion;
+        }
+
+        /// <summary>
+        /// Describes properies of a Group updated information record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class GroupUpdatedInfo
+        {
+            /// <summary>
+            /// Identifier of this group updated info view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.groups_updated_info";
+            /// <summary>
+            /// Updated group ID
+            /// </summary>
+            public const uint GroupId = (uint)PropertyIds.UpdateInfoId;
+            /// <summary>
+            /// Address book ID that the updated group belongs to
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.UpdateInfoAddressbookId;
+            /// <summary>
+            /// Group change type, refer to the ContactsViews.ChangeTypes
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.UpdateInfoType;
+            /// <summary>
+            /// Updated version
+            /// </summary>
+            public const uint Version = (uint)PropertyIds.UpdateInfoVersion;
+        }
+
+        /// <summary>
+        /// Describes properies of a Group Member updated information record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class GroupMemberUpdatedInfo
+        {
+            /// <summary>
+            /// Identifier of this group member updated info view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.groups_member_updated_info";
+            /// <summary>
+            /// Updated group ID
+            /// </summary>
+            public const uint GroupId = (uint)PropertyIds.UpdateInfoId;
+            /// <summary>
+            /// Address book ID that the updated group belongs to
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.UpdateInfoAddressbookId;
+            /// <summary>
+            /// Updated version
+            /// </summary>
+            public const uint Version = (uint)PropertyIds.UpdateInfoVersion;
+        }
+
+        /// <summary>
+        /// Describes properies of a Relation updated information record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class GroupRelationUpdatedInfo
+        {
+            /// <summary>
+            /// Identifier of this group relation updated info view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.group_relations_updated_info";
+            /// <summary>
+            /// Group ID of group relation
+            /// </summary>
+            public const uint GroupId = (uint)PropertyIds.GroupId;
+            /// <summary>
+            /// Contact ID of the updated group relation
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.ContactId;
+            /// <summary>
+            /// Address book ID of contact that the updated group relation
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.AddressbookId;
+            /// <summary>
+            /// Group relation change type, refer to the ContactsViews.ChangeTypes
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.UpdateInfoType;
+            /// <summary>
+            /// Updated version
+            /// </summary>
+            public const uint Version = (uint)PropertyIds.UpdateInfoVersion;
+        }
+
+        /// <summary>
+        /// Describes properies of a Person & Contact record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class PersonContact
+        {
+            /// <summary>
+            /// Identifier of this person contact view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.person/simple_contact";
+            /// <summary>
+            /// DB record ID of the person
+            /// </summary>
+            public const uint PersonId = (uint)PropertyIds.PersonId;
+            /// <summary>
+            /// Display name of the person
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.PersonDisplayName;
+            /// <summary>
+            /// The first character of first string for grouping. This is normalized using icu (projection)
+            /// </summary>
+            public const uint DisplayNameIndex = (uint)PropertyIds.PersonDisplayNameIndex;
+            /// <summary>
+            /// Display contact ID that the person belongs to (projection)
+            /// </summary>
+            public const uint DisplayContactId = (uint)PropertyIds.PersonDisplayContactId;
+            /// <summary>
+            /// Ringtone path of the person (projection)
+            /// </summary>
+            public const uint RingtonePath = (uint)PropertyIds.PersonRingtone;
+            /// <summary>
+            /// Image thumbnail path of the person (projection)
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.PersonThumbnail;
+            /// <summary>
+            /// Vibration path of the person (projection)
+            /// </summary>
+            public const uint Vibration = (uint)PropertyIds.PersonVibration;
+            /// <summary>
+            /// Message alert path of the person (projection)
+            /// </summary>
+            public const uint MessageAlert = (uint)PropertyIds.PersonMessageAlert;
+            /// <summary>
+            /// Status of social account (projection)
+            /// </summary>
+            public const uint Status = (uint)PropertyIds.PersonStatus;
+            /// <summary>
+            /// The person is favorite or not
+            /// </summary>
+            public const uint IsFavorite = (uint)PropertyIds.PersonIsFavorite;
+            /// <summary>
+            /// Link count of contact records (projection)
+            /// </summary>
+            public const uint LinkCount = (uint)PropertyIds.PersonLinkCount;
+            /// <summary>
+            /// Contact ID that the person belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.ContactId;
+            /// <summary>
+            /// Addressbook IDs that the person belongs to (projection)
+            /// </summary>
+            public const uint AddressbookIds = (uint)PropertyIds.PersonAddressbookIds;
+            /// <summary>
+            /// The person has phone number or not
+            /// </summary>
+            public const uint HasPhoneNumber = (uint)PropertyIds.PersonHasPhoneNumber;
+            /// <summary>
+            /// The person has email or not
+            /// </summary>
+            public const uint HasEmail = (uint)PropertyIds.PersonHasEmail;
+            /// <summary>
+            /// Addressbook ID that the person belongs to
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.ContactAddressbookId;
+            /// <summary>
+            /// Addressbook mode, refer to the Addressbook.Modes
+            /// </summary>
+            public const uint AddressbookMode = (uint)PropertyIds.AddressbookMode;
+            /// <summary>
+            ///        Addressbook name that the person belongs to
+            /// </summary>
+            public const uint AddressbookName = (uint)PropertyIds.AddressbookName;
+            /// <summary>
+            /// kerword matched data type, refer to the Contact.DataTypes
+            /// </summary>
+            public const uint SnippetType = (uint)PropertyIds.PersonSnippetType;
+            /// <summary>
+            /// keyword matched data string
+            /// </summary>
+            public const uint SnippetString = (uint)PropertyIds.PersonSnippetString;
+        };
+
+        /// <summary>
+        /// Describes properies of a Person & Number record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class PersonNumber
+        {
+            /// <summary>
+            /// Identifier of this person number view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.person/simple_contact/number";
+            /// <summary>
+            /// DB record ID of the person
+            /// </summary>
+            public const uint PersonId = (uint)PropertyIds.PersonId;
+            /// <summary>
+            /// Display name of the person
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.PersonDisplayName;
+            /// <summary>
+            /// The first character of first string for grouping. This is normalized using icu (projection)
+            /// </summary>
+            public const uint DisplayNameIndex = (uint)PropertyIds.PersonDisplayNameIndex;
+            /// <summary>
+            /// Display contact ID that the person belongs to (projection)
+            /// </summary>
+            public const uint DisplayContactId = (uint)PropertyIds.PersonDisplayContactId;
+            /// <summary>
+            /// Ringtone path of the person (projection)
+            /// </summary>
+            public const uint RingtonePath = (uint)PropertyIds.PersonRingtone;
+            /// <summary>
+            /// Image thumbnail path of the person (projection)
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.PersonThumbnail;
+            /// <summary>
+            /// Vibration path of the person (projection)
+            /// </summary>
+            public const uint Vibration = (uint)PropertyIds.PersonVibration;
+            /// <summary>
+            /// Message alert path of the person (projection)
+            /// </summary>
+            public const uint MessageAlert = (uint)PropertyIds.PersonMessageAlert;
+            /// <summary>
+            /// The person is favorite or not
+            /// </summary>
+            public const uint IsFavorite = (uint)PropertyIds.PersonIsFavorite;
+            /// <summary>
+            /// The person has phone number or not
+            /// </summary>
+            public const uint HasPhoneNumber = (uint)PropertyIds.PersonHasPhoneNumber;
+            /// <summary>
+            /// The person has email or not
+            /// </summary>
+            public const uint HasEmail = (uint)PropertyIds.PersonHasEmail;
+            /// <summary>
+            /// Number ID that the person belongs to
+            /// </summary>
+            public const uint NumberId = (uint)PropertyIds.NumberId;
+            /// <summary>
+            /// Number type, refer to the Number.Types (projection)
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.NumberType;
+            /// <summary>
+            /// Custom number type label, when the number type is Number.Types.Custom (projection)
+            /// </summary>
+            public const uint Label = (uint)PropertyIds.NumberLabel;
+            /// <summary>
+            /// The number is default number or not
+            /// </summary>
+            public const uint IsPrimaryDefault = (uint)PropertyIds.DataIsPrimaryDefault;
+            /// <summary>
+            /// Number
+            /// </summary>
+            public const uint Number = (uint)PropertyIds.NumberNumber;
+            /// <summary>
+            /// If you add filter with this property, the string will be normalized as minmatch length internally and the match rule will be applied ContactsFilter.StringMatchType.Exactly.
+            /// </summary>
+            public const uint NumberFilter = (uint)PropertyIds.NumberNumberFilter;
+            /// <summary>
+            /// You can only use this property for search filter
+            /// </summary>
+            public const uint NormalizedNumber = (uint)PropertyIds.NumberNormalizedNumber;
+            /// <summary>
+            /// You can only use this property for search filter
+            /// </summary>
+            public const uint CleanedNumber = (uint)PropertyIds.NumberCleanedNumber;
+            /// <summary>
+            /// kerword matched data type, refer to they Contact.DataTypes
+            /// </summary>
+            public const uint SnippetType = (uint)PropertyIds.PersonSnippetType;
+            /// <summary>
+            /// keyword matched data string
+            /// </summary>
+            public const uint SnippetString = (uint)PropertyIds.PersonSnippetString;
+        };
+
+        /// <summary>
+        /// Describes properies of a Person & Email record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class PersonEmail
+        {
+            /// <summary>
+            /// Identifier of this person email view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.person/simple_contact/email";
+            /// <summary>
+            /// DB record ID of the person
+            /// </summary>
+            public const uint PersonId = (uint)PropertyIds.PersonId;
+            /// <summary>
+            /// Display name of the person
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.PersonDisplayName;
+            /// <summary>
+            /// The first character of first string for grouping. This is normalized using icu (projection)
+            /// </summary>
+            public const uint DisplayNameIndex = (uint)PropertyIds.PersonDisplayNameIndex;
+            /// <summary>
+            /// Display contact ID that the person belongs to (projection)
+            /// </summary>
+            public const uint DisplayContactId = (uint)PropertyIds.PersonDisplayContactId;
+            /// <summary>
+            /// Ringtone path of the person (projection)
+            /// </summary>
+            public const uint RingtonePath = (uint)PropertyIds.PersonRingtone;
+            /// <summary>
+            /// Image thumbnail path of the person (projection)
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.PersonThumbnail;
+            /// <summary>
+            /// Vibration path of the person (projection)
+            /// </summary>
+            public const uint Vibration = (uint)PropertyIds.PersonVibration;
+            /// <summary>
+            /// Message alert path of the person (projection)
+            /// </summary>
+            public const uint MessageAlert = (uint)PropertyIds.PersonMessageAlert;
+            /// <summary>
+            /// The person is favorite or not
+            /// </summary>
+            public const uint IsFavorite = (uint)PropertyIds.PersonIsFavorite;
+            /// <summary>
+            /// The person has phone number or not
+            /// </summary>
+            public const uint HasPhoneNumber = (uint)PropertyIds.PersonHasPhoneNumber;
+            /// <summary>
+            /// The person has email or not
+            /// </summary>
+            public const uint HasEmail = (uint)PropertyIds.PersonHasEmail;
+            /// <summary>
+            /// Email ID that the person belongs to
+            /// </summary>
+            public const uint EmailId = (uint)PropertyIds.EmailId;
+            /// <summary>
+            /// Email type, refer to the Email.Types (projection)
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.EmailType;
+            /// <summary>
+            /// Custom mail type label, when the email type is Email.Types.Custom (projection)
+            /// </summary>
+            public const uint Label = (uint)PropertyIds.EmailLabel;
+            /// <summary>
+            /// The email is default email or not
+            /// </summary>
+            public const uint IsPrimaryDefault = (uint)PropertyIds.DataIsPrimaryDefault;
+            /// <summary>
+            /// Email address
+            /// </summary>
+            public const uint Email = (uint)PropertyIds.EmailEmail;
+            /// <summary>
+            /// kerword matched data type, refer to they Contact.DataTypes
+            /// </summary>
+            public const uint SnippetType = (uint)PropertyIds.PersonSnippetType;
+            /// <summary>
+            /// keyword matched data string
+            /// </summary>
+            public const uint SnippetString = (uint)PropertyIds.PersonSnippetString;
+        };
+
+        /// <summary>
+        /// Describes properies of a Person & Group Relation record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class PersonGroupRelation
+        {
+            /// <summary>
+            /// Identifier of this person group relation view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.person/simple_contact/group";
+            /// <summary>
+            /// DB record ID of the person
+            /// </summary>
+            public const uint PersonId = (uint)PropertyIds.PersonId;
+            /// <summary>
+            /// Display name of the person
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.PersonDisplayName;
+            /// <summary>
+            /// The first character of first string for grouping. This is normalized using icu (projection)
+            /// </summary>
+            public const uint DisplayNameIndex = (uint)PropertyIds.PersonDisplayNameIndex;
+            /// <summary>
+            /// Display contact ID that the person belongs to (projection)
+            /// </summary>
+            public const uint DisplayContactId = (uint)PropertyIds.PersonDisplayContactId;
+            /// <summary>
+            /// Ringtone path of the person (projection)
+            /// </summary>
+            public const uint RingtonePath = (uint)PropertyIds.PersonRingtone;
+            /// <summary>
+            /// Image thumbnail path of the person (projection)
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.PersonThumbnail;
+            /// <summary>
+            /// Vibration path of the person (projection)
+            /// </summary>
+            public const uint Vibration = (uint)PropertyIds.PersonVibration;
+            /// <summary>
+            /// Message alert path of the person (projection)
+            /// </summary>
+            public const uint MessageAlert = (uint)PropertyIds.PersonMessageAlert;
+            /// <summary>
+            /// Status of social account (projection)
+            /// </summary>
+            public const uint Status = (uint)PropertyIds.PersonStatus;
+            /// <summary>
+            /// The person is favorite or not
+            /// </summary>
+            public const uint IsFavorite = (uint)PropertyIds.PersonIsFavorite;
+            /// <summary>
+            /// The person has phone number or not
+            /// </summary>
+            public const uint HasPhoneNumber = (uint)PropertyIds.PersonHasPhoneNumber;
+            /// <summary>
+            /// The person has email or not
+            /// </summary>
+            public const uint HasEmail = (uint)PropertyIds.PersonHasEmail;
+            /// <summary>
+            /// Link count of contat records (projection)
+            /// </summary>
+            public const uint LinkCount = (uint)PropertyIds.PersonLinkCount;
+            /// <summary>
+            /// Addressbook IDs that the person belongs to (projection)
+            /// </summary>
+            public const uint AddressbookIds = (uint)PropertyIds.PersonAddressbookIds;
+            /// <summary>
+            /// Addressbook ID that the person belongs to
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.ContactAddressbookId;
+            /// <summary>
+            /// Addressbook name that the person belongs to
+            /// </summary>
+            public const uint AddressbookName = (uint)PropertyIds.AddressbookName;
+            /// <summary>
+            /// Addressbook mode, refer to the Addressbook.Modes
+            /// </summary>
+            public const uint AddressbookMode = (uint)PropertyIds.AddressbookMode;
+            /// <summary>
+            /// Group ID that the person belongs to
+            /// </summary>
+            public const uint GroupId = (uint)PropertyIds.GroupRelationGroupId;
+            /// <summary>
+            /// Contact ID that the person belongs to (projection)
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.GroupRelationContactId;
+            /// <summary>
+            /// kerword matched data type, refer to they Contact.DataTypes
+            /// </summary>
+            public const uint SnippetType = (uint)PropertyIds.PersonSnippetType;
+            /// <summary>
+            /// keyword matched data string
+            /// </summary>
+            public const uint SnippetString = (uint)PropertyIds.PersonSnippetString;
+        };
+
+        /// <summary>
+        /// Describes properies of a Person & Group Assigned record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class PersonGroupAssigned
+        {
+            /// <summary>
+            /// Identifier of this person group assigned view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.person/simple_contact/group_assigned";
+            /// <summary>
+            /// DB record ID of the person
+            /// </summary>
+            public const uint PersonId = (uint)PropertyIds.PersonId;
+            /// <summary>
+            /// Display name of the person
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.PersonDisplayName;
+            /// <summary>
+            /// The first character of first string for grouping. This is normalized using icu (projection)
+            /// </summary>
+            public const uint DisplayNameIndex = (uint)PropertyIds.PersonDisplayNameIndex;
+            /// <summary>
+            /// Display contact ID that the person belongs to (projection)
+            /// </summary>
+            public const uint DisplayContactId = (uint)PropertyIds.PersonDisplayContactId;
+            /// <summary>
+            /// Ringtone path of the person (projection)
+            /// </summary>
+            public const uint RingtonePath = (uint)PropertyIds.PersonRingtone;
+            /// <summary>
+            /// Image thumbnail path of the person (projection)
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.PersonThumbnail;
+            /// <summary>
+            /// Vibration path of the person (projection)
+            /// </summary>
+            public const uint Vibration = (uint)PropertyIds.PersonVibration;
+            /// <summary>
+            /// Message alert path of the person (projection)
+            /// </summary>
+            public const uint MessageAlert = (uint)PropertyIds.PersonMessageAlert;
+            /// <summary>
+            /// Status of social account (projection)
+            /// </summary>
+            public const uint Status = (uint)PropertyIds.PersonStatus;
+            /// <summary>
+            /// The person is favorite or not
+            /// </summary>
+            public const uint IsFavorite = (uint)PropertyIds.PersonIsFavorite;
+            /// <summary>
+            /// The person has phone number or not
+            /// </summary>
+            public const uint HasPhoneNumber = (uint)PropertyIds.PersonHasPhoneNumber;
+            /// <summary>
+            /// The person has email or not
+            /// </summary>
+            public const uint HasEmail = (uint)PropertyIds.PersonHasEmail;
+            /// <summary>
+            /// Link count of contact records (projection)
+            /// </summary>
+            public const uint LinkCount = (uint)PropertyIds.PersonLinkCount;
+            /// <summary>
+            /// Addressbook IDs that the linked person belongs to (projection)
+            /// </summary>
+            public const uint AddressbookIds = (uint)PropertyIds.PersonAddressbookIds;
+            /// <summary>
+            /// Addressbook ID that the person belongs to
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.ContactAddressbookId;
+            /// <summary>
+            /// Addressbook mode, refer to the Addressbook.Modes
+            /// </summary>
+            public const uint AddressbookMode = (uint)PropertyIds.AddressbookMode;
+            /// <summary>
+            /// Group ID that the person belongs to
+            /// </summary>
+            public const uint GroupId = (uint)PropertyIds.GroupRelationGroupId;
+            /// <summary>
+            /// Contact ID that the person belongs to (projection)
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.GroupRelationContactId;
+            /// <summary>
+            /// kerword matched data type, refer to they Contact.DataTypes
+            /// </summary>
+            public const uint SnippetType = (uint)PropertyIds.PersonSnippetType;
+            /// <summary>
+            /// keyword matched data string
+            /// </summary>
+            public const uint SnippetString = (uint)PropertyIds.PersonSnippetString;
+        };
+
+        /// <summary>
+        /// Describes properies of a Person & Group Not Assigned record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class PersonGroupNotAssigned
+        {
+            /// <summary>
+            /// Identifier of this person group not assigned view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.person/simple_contact/group_not_assigned";
+            /// <summary>
+            /// DB record ID of the person
+            /// </summary>
+            public const uint PersonId = (uint)PropertyIds.PersonId;
+            /// <summary>
+            /// Display name of the person
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.PersonDisplayName;
+            /// <summary>
+            /// The first character of first string for grouping. This is normalized using icu (projection)
+            /// </summary>
+            public const uint DisplayNameIndex = (uint)PropertyIds.PersonDisplayNameIndex;
+            /// <summary>
+            /// Display contact ID that the person belongs to (projection)
+            /// </summary>
+            public const uint DisplayContactId = (uint)PropertyIds.PersonDisplayContactId;
+            /// <summary>
+            /// Ringtone path of the person (projection)
+            /// </summary>
+            public const uint RingtonePath = (uint)PropertyIds.PersonRingtone;
+            /// <summary>
+            /// Image thumbnail path of the person (projection)
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.PersonThumbnail;
+            /// <summary>
+            /// Vibration path of the person (projection)
+            /// </summary>
+            public const uint Vibration = (uint)PropertyIds.PersonVibration;
+            /// <summary>
+            /// Message alert path of the person (projection)
+            /// </summary>
+            public const uint MessageAlert = (uint)PropertyIds.PersonMessageAlert;
+            /// <summary>
+            /// Status of social account (projection)
+            /// </summary>
+            public const uint Status = (uint)PropertyIds.PersonStatus;
+            /// <summary>
+            /// The person is favorite or not
+            /// </summary>
+            public const uint IsFavorite = (uint)PropertyIds.PersonIsFavorite;
+            /// <summary>
+            /// The person has phone number or not
+            /// </summary>
+            public const uint HasPhoneNumber = (uint)PropertyIds.PersonHasPhoneNumber;
+            /// <summary>
+            /// The person has email or not
+            /// </summary>
+            public const uint HasEmail = (uint)PropertyIds.PersonHasEmail;
+            /// <summary>
+            /// Link count of contact records (projection)
+            /// </summary>
+            public const uint LinkCount = (uint)PropertyIds.PersonLinkCount;
+            /// <summary>
+            /// Addressbook IDs that the linked person belongs to (projection)
+            /// </summary>
+            public const uint AddressbookIds = (uint)PropertyIds.PersonAddressbookIds;
+            /// <summary>
+            /// Addressbook ID that the person belongs to
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.ContactAddressbookId;
+            /// <summary>
+            /// Addressbook mode, refer to the Addressbook.Modes
+            /// </summary>
+            public const uint AddressbookMode = (uint)PropertyIds.AddressbookMode;
+            /// <summary>
+            /// Contact ID that the person belongs to (projection)
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.ContactId;
+            /// <summary>
+            /// kerword matched data type, refer to they Contact.DataTypes
+            /// </summary>
+            public const uint SnippetType = (uint)PropertyIds.PersonSnippetType;
+            /// <summary>
+            /// keyword matched data string
+            /// </summary>
+            public const uint SnippetString = (uint)PropertyIds.PersonSnippetString;
+        };
+
+        /// <summary>
+        /// Describes properies of a Person & Phone Log record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class PersonPhonelog
+        {
+            /// <summary>
+            /// Identifier of this phone log view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.person/simple_contact/phonelog";
+            /// <summary>
+            /// DB record ID of the person
+            /// </summary>
+            public const uint PersonId = (uint)PropertyIds.PersonId;
+            /// <summary>
+            /// Display name of the person
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.PersonDisplayName;
+            /// <summary>
+            /// Image thumbnail path of the person (projection)
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.PersonThumbnail;
+            /// <summary>
+            /// DB record ID of phone log
+            /// </summary>
+            public const uint LogId = (uint)PropertyIds.PhonelogId;
+            /// <summary>
+            /// Number or Email that the phone log displays
+            /// </summary>
+            public const uint Address = (uint)PropertyIds.PhonelogAddress;
+            /// <summary>
+            /// Number or Email type (projection)
+            /// </summary>
+            public const uint AddressType = (uint)PropertyIds.DataData1;
+            /// <summary>
+            /// Call end time. The value means number of seconds since 1970-01-01 00:00:00 (UTC)
+            /// </summary>
+            public const uint LogTime = (uint)PropertyIds.PhonelogLogTime;
+            /// <summary>
+            /// Log type, refer to the PhoneLog.Types
+            /// </summary>
+            public const uint LogType = (uint)PropertyIds.PhonelogLogType;
+            /// <summary>
+            /// You can set the related integer data (e.g. message_id, email_id or duration(seconds) of call) (projection)
+            /// </summary>
+            public const uint ExtraData1 = (uint)PropertyIds.PhonelogExtraData1;
+            /// <summary>
+            /// You can set the related string data (e.g. short message, subject) (projection)
+            /// </summary>
+            public const uint ExtraData2 = (uint)PropertyIds.PhonelogExtraData2;
+            /// <summary>
+            /// You can only use this property for search filter
+            /// </summary>
+            public const uint NormalizedAddress = (uint)PropertyIds.PhonelogNormalizedAddress;
+            /// <summary>
+            /// You can only use this property for search filter
+            /// </summary>
+            public const uint CleanedAddress = (uint)PropertyIds.PhonelogCleanedAddress;
+            /// <summary>
+            /// You can only use this property for search filter
+            /// </summary>
+            public const uint AddressFilter = (uint)PropertyIds.PhonelogAddressFilter;
+            /// <summary>
+            /// It is related to the SIM slot number. sim_slot_no 0 means first SIM card, sim_slot_no 1 means second SIM. It is same with handle index of telephony handle list. Refer to the telephony_init()
+            /// </summary>
+            public const uint SIMSlotNo = (uint)PropertyIds.PhonelogSIMSlotNo;
+        };
+
+        /// <summary>
+        /// Describes properies of a Person Usage record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class PersonUsage
+        {
+            /// <summary>
+            /// Identifier of this person usage view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.person/usag";
+            /// <summary>
+            /// DB record ID of the person
+            /// </summary>
+            public const uint PersonId = (uint)PropertyIds.PersonId;
+            /// <summary>
+            /// Display name of the person
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.PersonDisplayName;
+            /// <summary>
+            /// The first character of first string for grouping. This is normalized using icu (projection)
+            /// </summary>
+            public const uint DisplayNameIndex = (uint)PropertyIds.PersonDisplayNameIndex;
+            /// <summary>
+            /// Display contact ID that the person belongs to (projection)
+            /// </summary>
+            public const uint DisplayContactId = (uint)PropertyIds.PersonDisplayContactId;
+            /// <summary>
+            /// Ringtone path of the person (projection)
+            /// </summary>
+            public const uint RingtonePath = (uint)PropertyIds.PersonRingtone;
+            /// <summary>
+            /// Image thumbnail path of the person (projection)
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.PersonThumbnail;
+            /// <summary>
+            /// Vibration path of the person (projection)
+            /// </summary>
+            public const uint Vibration = (uint)PropertyIds.PersonVibration;
+            /// <summary>
+            /// Message alert path of the person (projection)
+            /// </summary>
+            public const uint MessageAlert = (uint)PropertyIds.PersonMessageAlert;
+            /// <summary>
+            /// The person is favorite or not
+            /// </summary>
+            public const uint IsFavorite = (uint)PropertyIds.PersonIsFavorite;
+            /// <summary>
+            /// The person has phone number or not
+            /// </summary>
+            public const uint HasPhoneNumber = (uint)PropertyIds.PersonHasPhoneNumber;
+            /// <summary>
+            /// The person has email or not
+            /// </summary>
+            public const uint HasEmail = (uint)PropertyIds.PersonHasEmail;
+            /// <summary>
+            /// Usage type, refer to the UsageTypes
+            /// </summary>
+            public const uint UsageType = (uint)PropertyIds.PersonUsageType;
+            /// <summary>
+            /// Usage number of person
+            /// </summary>
+            public const uint TimesUsed = (uint)PropertyIds.PersonTimesUsed;
+
+            /// <summary>
+            /// Enumeration for Person usage type.
+            /// </summary>
+            public enum Types
+            {
+                /// <summary>
+                /// None
+                /// </summary>
+                None,
+                /// <summary>
+                /// Outgoing call
+                /// </summary>
+                OutgoingCall,
+                /// <summary>
+                /// Outgoing message
+                /// </summary>
+                OutgoingMessage,
+                /// <summary>
+                /// Outgoing email
+                /// </summary>
+                OutgoingEmail,
+                /// <summary>
+                /// Incoming call
+                /// </summary>
+                IncomingCall,
+                /// <summary>
+                /// Incoming message
+                /// </summary>
+                IncomingMessage,
+                /// <summary>
+                /// Incoming email
+                /// </summary>
+                IncomingEmail,
+                /// <summary>
+                /// Missed call
+                /// </summary>
+                MissedCall,
+                /// <summary>
+                /// Rejected call
+                /// </summary>
+                RejectedCall,
+                /// <summary>
+                /// Blocked call
+                /// </summary>
+                BlockedCall,
+                /// <summary>
+                /// Blocked message
+                /// </summary>
+                BlockedMessage
+            }
+        };
+
+        /// <summary>
+        /// Describes properies of a Contact & Number record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class ContactNumber
+        {
+            /// <summary>
+            /// Identifier of this contacts number view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.simple_contact/number";
+            /// <summary>
+            /// Contact ID that the number belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.ContactId;
+            /// <summary>
+            /// Display name of contact that the number belongs to
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.ContactDisplayName;
+            /// <summary>
+            /// The source type of display name, refer to the Contact.DisplayNameSourceTypes (projection)
+            /// </summary>
+            public const uint DisplaySourceType = (uint)PropertyIds.ContactDisplaySourceDataId;
+            /// <summary>
+            /// Addressbook ID that the number belongs to
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.ContactAddressbookId;
+            /// <summary>
+            /// Person ID that the number belongs to
+            /// </summary>
+            public const uint PersonId = (uint)PropertyIds.ContactPersonId;
+            /// <summary>
+            /// Ringtone path that the number belongs to (projection)
+            /// </summary>
+            public const uint RingtonePath = (uint)PropertyIds.ContactRingtone;
+            /// <summary>
+            /// Image thumbnail path that the number belongs to (projection)
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.ContactThumbnail;
+            /// <summary>
+            /// DB record ID of the number
+            /// </summary>
+            public const uint NumberId = (uint)PropertyIds.NumberId;
+            /// <summary>
+            /// Number type, refer to the Number.Types (projection)
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.NumberType;
+            /// <summary>
+            /// Custom number type label, when the number type is Number.Types.Custom (projection)
+            /// </summary>
+            public const uint Label = (uint)PropertyIds.NumberLabel;
+            /// <summary>
+            /// The number is default number or not
+            /// </summary>
+            public const uint IsDefault = (uint)PropertyIds.NumberIsDefault;
+            /// <summary>
+            /// Number
+            /// </summary>
+            public const uint Number = (uint)PropertyIds.NumberNumber;
+            /// <summary>
+            /// If you add filter with this property, the string will be normalized as minmatch length internally and the match rule will be applied ContactsFilter.StringMatchType.Exactly
+            /// </summary>
+            public const uint NumberFilter = (uint)PropertyIds.NumberNumberFilter;
+            /// <summary>
+            /// You can only use this property for search filter
+            /// </summary>
+            public const uint NormalizedNumber = (uint)PropertyIds.NumberNormalizedNumber;
+            /// <summary>
+            /// You can only use this property for search filter
+            /// </summary>
+            public const uint CleanedNumber = (uint)PropertyIds.NumberCleanedNumber;
+        };
+
+        /// <summary>
+        /// Describes properies of a Contact & Email record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class ContactEmail
+        {
+            /// <summary>
+            /// Identifier of this contacts email view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.simple_contact/email";
+            /// <summary>
+            /// Contact ID that the number belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.ContactId;
+            /// <summary>
+            /// Display name of contact that the number belongs to
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.ContactDisplayName;
+            /// <summary>
+            /// The source type of display name, refer to the Contact.DisplayNameSourceTypes (projection)
+            /// </summary>
+            public const uint DisplaySourceType = (uint)PropertyIds.ContactDisplaySourceDataId;
+            /// <summary>
+            /// Addressbook ID that the number belongs to
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.ContactAddressbookId;
+            /// <summary>
+            /// Person ID that the number belongs to
+            /// </summary>
+            public const uint PersonId = (uint)PropertyIds.ContactPersonId;
+            /// <summary>
+            /// Ringtone path that the number belongs to (projection)
+            /// </summary>
+            public const uint RingtonePath = (uint)PropertyIds.ContactRingtone;
+            /// <summary>
+            /// Image thumbnail path that the number belongs to (projection)
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.ContactThumbnail;
+            /// <summary>
+            /// DB record ID of the email
+            /// </summary>
+            public const uint EmailId = (uint)PropertyIds.EmailId;
+            /// <summary>
+            /// Email type, refer to the Email.Types (projection)
+            /// </summary>
+            public const uint Type = (uint)PropertyIds.EmailType;
+            /// <summary>
+            /// Custom mail type label, when the email type is Email.Types.Custom (projection)
+            /// </summary>
+            public const uint Label = (uint)PropertyIds.EmailLabel;
+            /// <summary>
+            /// Email is default email or not
+            /// </summary>
+            public const uint IsDefault = (uint)PropertyIds.EmailIsDefault;
+            /// <summary>
+            /// Email address
+            /// </summary>
+            public const uint Email = (uint)PropertyIds.EmailEmail;
+        };
+
+        /// <summary>
+        /// Describes properies of a Contact & Group Relation record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class ContactGroupRelation
+        {
+            /// <summary>
+            /// Identifier of this contact grouprel view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.simple_contact/group";
+            /// <summary>
+            /// Contact ID that the number belongs to
+            /// </summary>
+            public const uint ContactId = (uint)PropertyIds.ContactId;
+            /// <summary>
+            /// Display name of contact that the number belongs to
+            /// </summary>
+            public const uint DisplayName = (uint)PropertyIds.ContactDisplayName;
+            /// <summary>
+            /// The source type of display name, refer to the Contact.DisplayNameSourceTypes (projection)
+            /// </summary>
+            public const uint DisplaySourceType = (uint)PropertyIds.ContactDisplaySourceDataId;
+            /// <summary>
+            /// Addressbook ID that the number belongs to
+            /// </summary>
+            public const uint AddressbookId = (uint)PropertyIds.ContactAddressbookId;
+            /// <summary>
+            /// Person ID that the number belongs to
+            /// </summary>
+            public const uint PersonId = (uint)PropertyIds.ContactPersonId;
+            /// <summary>
+            /// Ringtone path that the number belongs to (projection)
+            /// </summary>
+            public const uint RingtonePath = (uint)PropertyIds.ContactRingtone;
+            /// <summary>
+            /// Image thumbnail path that the number belongs to (projection)
+            /// </summary>
+            public const uint ThumbnailPath = (uint)PropertyIds.ContactThumbnail;
+            /// <summary>
+            /// DB record ID of the group relation
+            /// </summary>
+            public const uint GroupId = (uint)PropertyIds.GroupRelationGroupId;
+            /// <summary>
+            /// Group name (projection)
+            /// </summary>
+            public const uint GroupName = (uint)PropertyIds.GroupRelationGroupName;
+        };
+
+        /// <summary>
+        /// Describes properies of a Phone Log Statistics record.
+        /// </summary>
+        /// <remarks>Read only view</remarks>
+        public static class PhonelogStatistics
+        {
+            /// <summary>
+            /// Identifier of this log statistics view
+            /// </summary>
+            public const string Uri = "tizen.contacts_view.phonelog_stat";
+            /// <summary>
+            /// Log count (projection)
+            /// </summary>
+            public const uint LogCount = (uint)PropertyIds.PhonelogStatLogCount;
+            /// <summary>
+            /// Log type, see the contacts_phone_log_type_e
+            /// </summary>
+            public const uint LogType = (uint)PropertyIds.PhonelogStatLogType;
+            /// <summary>
+            /// It is related to the SIM slot number. sim_slot_no 0 means first SIM card, sim_slot_no 1 means second SIM. It is same with handle index of telephony handle list. Refer to the telephony_init()
+            /// </summary>
+            public const uint SIMSlotNo = (uint)PropertyIds.PhonelogStatSIMSlotNo;
+        };
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/DBStatusChangedEventArgs.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/DBStatusChangedEventArgs.cs
new file mode 100644 (file)
index 0000000..4029e35
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using static Tizen.Pims.Contacts.ContactsDatabase;
+
+namespace Tizen.Pims.Contacts
+{
+    /// <summary>
+    /// Event arguments passed when contacts database status is changed
+    /// </summary>
+    public class DBStatusChangedEventArgs
+    {
+        internal DBStatusChangedEventArgs(DBStatus status)
+        {
+            this.Status = status;
+        }
+
+        public DBStatus Status
+        {
+            get;
+            internal set;
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NameDisplayOrderChangedEventArgs.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NameDisplayOrderChangedEventArgs.cs
new file mode 100644 (file)
index 0000000..71ce4d3
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+namespace Tizen.Pims.Contacts
+{
+    /// <summary>
+    /// Event arguments passed when setting value of contacts name display order is changed
+    /// </summary>
+    public class NameDisplayOrderChangedEventArgs
+    {
+        internal NameDisplayOrderChangedEventArgs(ContactDisplayOrder displayOrder)
+        {
+            this.NameDisplayOrder = displayOrder;
+        }
+
+        public ContactDisplayOrder NameDisplayOrder
+        {
+            get;
+            internal set;
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NameSortingOrderChangedEventArgs.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NameSortingOrderChangedEventArgs.cs
new file mode 100644 (file)
index 0000000..1f9b663
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+namespace Tizen.Pims.Contacts
+{
+    /// <summary>
+    /// Event arguments passed when setting value of contacts name sorting order is changed
+    /// </summary>
+    public class NameSortingOrderChangedEventArgs
+    {
+        internal NameSortingOrderChangedEventArgs(ContactSortingOrder SortingOrder)
+        {
+            this.NameSortingOrder = SortingOrder;
+        }
+
+        public ContactSortingOrder NameSortingOrder
+        {
+            get;
+            internal set;
+        }
+    }
+}
diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NamespaceDoc.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NamespaceDoc.cs
new file mode 100644 (file)
index 0000000..487113c
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/// <summary>
+/// The Tizen.Pims.Contacts namespace provides classes for managing contact information for people.
+/// </summary>
+/// <remarks>
+/// The Tizen.Pims.Contacts namespace provides classes for managing contact information for people.
+/// </remarks>
+namespace Tizen.Pims.Contacts {}