Adding C# API for D2D Convevergence
authorJyothi Kumar Sambolu <s.jyothi@samsung.com>
Wed, 26 Apr 2017 11:52:57 +0000 (17:22 +0530)
committerJyothi Kumar Sambolu <s.jyothi@samsung.com>
Mon, 22 May 2017 11:52:18 +0000 (17:22 +0530)
Change-Id: I38355916a679dd1b44ffac189e4e47174aa39c85
Signed-off-by: Jyothi Kumar Sambolu <s.jyothi@samsung.com>
24 files changed:
LICENSE [new file with mode: 0755]
packaging/csapi-convergence.manifest [new file with mode: 0755]
packaging/csapi-convergence.spec [new file with mode: 0755]
src/Tizen.Convergence/Interop/Interop.Common.cs [new file with mode: 0755]
src/Tizen.Convergence/Interop/Interop.Conv.Channel.cs [new file with mode: 0755]
src/Tizen.Convergence/Interop/Interop.Conv.Device.cs [new file with mode: 0755]
src/Tizen.Convergence/Interop/Interop.Conv.Manager.cs [new file with mode: 0755]
src/Tizen.Convergence/Interop/Interop.Conv.Payload.cs [new file with mode: 0755]
src/Tizen.Convergence/Interop/Interop.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: 0755]
src/Tizen.Convergence/Tizen.Convergence.nuspec [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence.snk [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/AppCommunicationService.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/Channel.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/Device.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/DeviceFinder.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/DeviceFoundEventArgs.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/ErrorFactory.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/Payload.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/Service.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/ServiceErrorOccuredEventArgs.cs [new file with mode: 0755]
src/Tizen.Convergence/Tizen.Convergence/ServiceEventOccuredEventArgs.cs [new file with mode: 0755]

diff --git a/LICENSE b/LICENSE
new file mode 100755 (executable)
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+                                 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-convergence.manifest b/packaging/csapi-convergence.manifest
new file mode 100755 (executable)
index 0000000..75b0fa5
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+    <request>
+        <domain name="_"/>
+    </request>
+</manifest>
diff --git a/packaging/csapi-convergence.spec b/packaging/csapi-convergence.spec
new file mode 100755 (executable)
index 0000000..17edda9
--- /dev/null
@@ -0,0 +1,47 @@
+Name:       csapi-convergence
+Summary:    Device to device convergence C# API for Tizen
+Version:    1.0.0
+Release:    0
+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-nuget
+BuildRequires: elm-sharp-nuget
+BuildRequires: csapi-information-nuget
+
+%define Assemblies Tizen.Convergence
+
+%description
+%{summary}
+
+%dotnet_import_sub_packages
+
+%prep
+%setup -q
+cp %{SOURCE1} .
+
+%build
+for ASM in %{Assemblies}; do
+%dotnet_build $ASM
+%dotnet_pack $ASM/$ASM.nuspec %{version}
+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.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.Conv.Channel.cs b/src/Tizen.Convergence/Interop/Interop.Conv.Channel.cs
new file mode 100755 (executable)
index 0000000..ab85367
--- /dev/null
@@ -0,0 +1,64 @@
+// 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 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)\r
+                {\r
+                    Log.Error(ErrorFactory.LogTag, "Failed to destroy conv channel handle");\r
+                    throw ErrorFactory.GetException(err);\r
+                }\r
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Interop/Interop.Conv.Device.cs b/src/Tizen.Convergence/Interop/Interop.Conv.Device.cs
new file mode 100755 (executable)
index 0000000..3271ab6
--- /dev/null
@@ -0,0 +1,59 @@
+// 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 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)\r
+                {\r
+                    Log.Error(ErrorFactory.LogTag, "Failed to destroy conv device handle");\r
+                    throw ErrorFactory.GetException(err);\r
+                }\r
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Interop/Interop.Conv.Manager.cs b/src/Tizen.Convergence/Interop/Interop.Conv.Manager.cs
new file mode 100755 (executable)
index 0000000..9e95ae4
--- /dev/null
@@ -0,0 +1,75 @@
+// 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
+{
+    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);\r
+            if (err != (int)ConvErrorCode.None)\r
+            {\r
+                Log.Error(ErrorFactory.LogTag, "Failed to destroy conv manager handle");\r
+                throw ErrorFactory.GetException(err);\r
+            }\r
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Interop/Interop.Conv.Payload.cs b/src/Tizen.Convergence/Interop/Interop.Conv.Payload.cs
new file mode 100755 (executable)
index 0000000..d98300c
--- /dev/null
@@ -0,0 +1,72 @@
+// 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 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);
+
+
+    }
+
+    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);\r
+                if (err != (int)ConvErrorCode.None)\r
+                {\r
+                    Log.Error(ErrorFactory.LogTag, "Failed to destroy conv payload handle");\r
+                    throw ErrorFactory.GetException(err);\r
+                }\r
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Interop/Interop.Conv.Service.cs b/src/Tizen.Convergence/Interop/Interop.Conv.Service.cs
new file mode 100755 (executable)
index 0000000..6f98b00
--- /dev/null
@@ -0,0 +1,102 @@
+// 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 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)\r
+                {\r
+                    Log.Error(ErrorFactory.LogTag, "Failed to destroy conv service handle");\r
+                    throw ErrorFactory.GetException(err);\r
+                }\r
+            }
+        }
+    }
+}
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 100755 (executable)
index 0000000..7346817
--- /dev/null
@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFramework>netstandard1.3</TargetFramework>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Convergence.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+    <GenerateReferenceAssembly>True</GenerateReferenceAssembly>
+  </PropertyGroup>
+  <ItemGroup>
+    <PackageReference Include="Tizen" Version="1.0.5" />
+  </ItemGroup>
+</Project>
diff --git a/src/Tizen.Convergence/Tizen.Convergence.nuspec b/src/Tizen.Convergence/Tizen.Convergence.nuspec
new file mode 100755 (executable)
index 0000000..85fb9c3
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<package>
+  <metadata>
+    <id>Tizen.Convergence</id>
+    <version>$version$</version>
+    <authors>Samsung Electronics</authors>
+    <requireLicenseAcceptance>false</requireLicenseAcceptance>
+    <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
+    <projectUrl>https://www.tizen.org/</projectUrl>
+    <iconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</iconUrl>
+    <copyright>© Samsung Electronics Co., Ltd All Rights Reserved</copyright>
+    <description>Device to device convergence C# API for Tizen</description>
+    <dependencies>
+      <dependency id="Tizen" version="1.0.1" />
+    </dependencies>
+  </metadata>
+</package>
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/AppCommunicationService.cs b/src/Tizen.Convergence/Tizen.Convergence/AppCommunicationService.cs
new file mode 100755 (executable)
index 0000000..d17a395
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+* 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.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>
+    public class AppCommunicationService : Service
+    {
+        /// <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 AppCommunicationService() :
+                base(Interop.ServiceType.AppCommunication)
+        {
+
+        }
+
+        internal AppCommunicationService(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(Channel channel, Payload payload)
+        {
+            if (channel == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            Interop.ConvPayloadHandle handle = (payload == null) ? new Interop.ConvPayloadHandle() : payload._payloadHandle;
+            int ret = Interop.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(Channel channel, Payload payload)
+        {
+            if (channel == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            Interop.ConvPayloadHandle handle = (payload == null) ? new Interop.ConvPayloadHandle() : payload._payloadHandle;
+            int ret = Interop.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(Channel channel, Payload payload)
+        {
+            if (channel == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            Interop.ConvPayloadHandle handle = (payload == null) ? new Interop.ConvPayloadHandle() : payload._payloadHandle;
+            int ret = Interop.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(Channel channel, Payload payload)
+        {
+            if (channel == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            Interop.ConvPayloadHandle handle = (payload == null) ? new Interop.ConvPayloadHandle() : payload._payloadHandle;
+            int ret = Interop.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/Channel.cs b/src/Tizen.Convergence/Tizen.Convergence/Channel.cs
new file mode 100755 (executable)
index 0000000..528636f
--- /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 System.Runtime.InteropServices;
+
+namespace Tizen.Convergence
+{
+    /// <summary>
+    /// The Channel class provies a logical session for communicating with AppCommunicationService.
+    /// </summary>
+    public class Channel : IDisposable
+    {
+        internal Interop.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 Channel(string uri, string id)
+        {
+            if (uri == null || id == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            int ret = Interop.ConvChannel.Create(out _channelHandle);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to create channel");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            ret = Interop.ConvChannel.SetString(_channelHandle, ChannelUriKey, uri);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to create channel");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            ret = Interop.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 Channel(IntPtr channelHandle)
+        {
+            _channelHandle = new Interop.ConvChannelHandle(channelHandle, false);
+
+            IntPtr stringPtr = IntPtr.Zero;
+            int ret = Interop.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.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/Device.cs b/src/Tizen.Convergence/Tizen.Convergence/Device.cs
new file mode 100755 (executable)
index 0000000..4899f78
--- /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 System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Convergence
+{
+    /// <summary>
+    /// The class encapsulates a D2D convergence compliant device information
+    /// </summary>
+    public class Device : IDisposable
+    {
+        internal const string DeviceIdKey = "device_id";
+        internal const string DeviceNameKey = "device_name";
+        internal const string DeviceTypeKey = "device_type";
+        internal Interop.ConvDeviceHandle _deviceHandle;
+        internal List<Service> _services = new List<Service>();
+
+        /// <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<Service> Services
+        {
+            get
+            {
+                return _services;
+            }
+        }
+
+        internal Device(IntPtr deviceHandle)
+        {
+            int ret = Interop.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.ConvDevice.GetPropertyString(_deviceHandle, DeviceIdKey, out stringPtr);
+            if (ret == (int)ConvErrorCode.None)
+            {
+                Id = Marshal.PtrToStringAnsi(stringPtr);
+                Interop.Libc.Free(stringPtr);
+            }
+
+            ret = Interop.ConvDevice.GetPropertyString(_deviceHandle, DeviceNameKey, out stringPtr);
+            if (ret == (int)ConvErrorCode.None)
+            {
+                Name = Marshal.PtrToStringAnsi(stringPtr);
+                Interop.Libc.Free(stringPtr);
+            }
+
+            ret = Interop.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.ConvDevice.ConvServiceForeachCallback cb = (IntPtr serviceHandle, IntPtr userData) =>
+            {
+                    _services.Add(Service.GetService(serviceHandle));
+            };
+
+            ret = Interop.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/DeviceFinder.cs b/src/Tizen.Convergence/Tizen.Convergence/DeviceFinder.cs
new file mode 100755 (executable)
index 0000000..ab5e63a
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+* 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;
+
+namespace Tizen.Convergence
+{
+    /// <summary>
+    /// DeviceFinder provides API to find all nearby Tizen D2D convergence compliant devices
+    /// </summary>
+    public class DeviceFinder : IDisposable
+    {
+        internal Interop.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 DeviceFinder()
+        {
+            int ret = Interop.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<DeviceFoundEventArgs> 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.ConvManager.ConvDiscoveryCallback discoveredCb = (IntPtr deviceHandle, Interop.ConvDiscoveryResult result, IntPtr userData) =>
+            {
+                Log.Debug(ErrorFactory.LogTag, "discovery callback called with result:[" + result + "]");
+                switch (result)
+                {
+                    case Interop.ConvDiscoveryResult.Success:
+                        {
+                            Device device = new Device(deviceHandle);
+                            DeviceFoundEventArgs deviceFoundEventArgs = new DeviceFoundEventArgs()
+                            {
+                                Device = device
+                            };
+                            DeviceFound?.Invoke(this, deviceFoundEventArgs);
+                            break;
+                        }
+                    case Interop.ConvDiscoveryResult.Error:
+                        {
+                            task.TrySetException(new InvalidOperationException("Discovery error occured"));
+                            break;
+                        }
+                    case Interop.ConvDiscoveryResult.Lost:
+                        {
+                            task.TrySetException(new InvalidOperationException("Discovery Lost"));
+                            break;
+                        }
+                    case Interop.ConvDiscoveryResult.Finished:
+                        {
+                            Log.Debug(ErrorFactory.LogTag, "discovery process finished");
+                            task.TrySetResult(true);
+                            break;
+                        }
+                }
+            };
+            int ret = Interop.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.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/DeviceFoundEventArgs.cs b/src/Tizen.Convergence/Tizen.Convergence/DeviceFoundEventArgs.cs
new file mode 100755 (executable)
index 0000000..200b614
--- /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;
+
+namespace Tizen.Convergence
+{
+    /// <summary>
+    /// Contains arguments for the event DeviceFound.
+    /// </summary>
+    public class DeviceFoundEventArgs : EventArgs
+    {
+        internal DeviceFoundEventArgs() { }
+
+        /// <summary>
+        /// The device found
+        /// </summary>
+        public Device Device { get; internal set; }
+    }
+}
diff --git a/src/Tizen.Convergence/Tizen.Convergence/ErrorFactory.cs b/src/Tizen.Convergence/Tizen.Convergence/ErrorFactory.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/Payload.cs b/src/Tizen.Convergence/Tizen.Convergence/Payload.cs
new file mode 100755 (executable)
index 0000000..1c02801
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+* 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.Convergence
+{
+    /// <summary>
+    /// Represents a payload used in Tizen D2D convergence
+    /// </summary>
+    public class Payload : IDisposable
+    {
+        internal Interop.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 Payload()
+        {
+            int ret = Interop.ConvPayload.Create(out _payloadHandle);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to create payload");
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+
+        internal Payload(IntPtr payloadHandle)
+        {
+            _payloadHandle = new Interop.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.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.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>
+        /// 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.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.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>
+        /// The dispose method
+        /// </summary>
+        public void Dispose()
+        {
+            _payloadHandle.Dispose();
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Tizen.Convergence/Service.cs b/src/Tizen.Convergence/Tizen.Convergence/Service.cs
new file mode 100755 (executable)
index 0000000..f5dd0ce
--- /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 System.Runtime.InteropServices;
+
+namespace Tizen.Convergence
+{
+    /// <summary>
+    /// The class abstracts the features provided by Tizen D2D Convergence.
+    /// </summary>
+    /// <seealso cref="AppCommunicationService"/>
+    public abstract class Service : IDisposable
+    {
+        internal Interop.ConvServiceHandle _serviceHandle;
+        internal const string ServiceIdKey = "service_id";
+        internal const string ServiceVersionKey = "service_version";
+
+        private event EventHandler<ServiceEventOccuredEventArgs> _serviceEventOccured;
+
+        internal Service(Interop.ServiceType type)
+        {
+            int ret = Interop.ConvService.Create(out _serviceHandle);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to create service handle");
+                throw ErrorFactory.GetException(ret);
+            }
+
+            ret = Interop.ConvService.SetType(_serviceHandle, (int)type);
+            if (ret != (int)ConvErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to create service handle");
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+
+        internal Service(IntPtr existingServiceHandle)
+        {
+            int ret = Interop.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.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.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<ServiceEventOccuredEventArgs> 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<ServiceErrorOccuredEventArgs> ServiceErrorOccured;
+
+        /// <summary>
+        /// The dispose method
+        /// </summary>
+        public void Dispose()
+        {
+            _serviceHandle.Dispose();
+        }
+
+        internal static Service GetService(IntPtr serviceHandle)
+        {
+            Service service = null;
+            int serviceType;
+            int ret = Interop.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.ServiceType.AppCommunication)
+            {
+                service = new AppCommunicationService(serviceHandle);
+            }
+
+            return service;
+        }
+
+        private void RegisterServiceEventListener()
+        {
+            int ret = Interop.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.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 Channel(channelHandle);
+                var payload = (resultPayloadHandle == IntPtr.Zero) ? null : new Payload(resultPayloadHandle);
+                _serviceEventOccured?.Invoke(this, new ServiceEventOccuredEventArgs()
+                {
+                    Payload = payload,
+                    Channel = channel
+                });
+            }
+            else
+            {
+                var eventArgs = new ServiceErrorOccuredEventArgs()
+                {
+                    Exception = ErrorFactory.GetException(error)
+                };
+                ServiceErrorOccured?.Invoke(this, eventArgs);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Convergence/Tizen.Convergence/ServiceErrorOccuredEventArgs.cs b/src/Tizen.Convergence/Tizen.Convergence/ServiceErrorOccuredEventArgs.cs
new file mode 100755 (executable)
index 0000000..b99b88c
--- /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;
+
+namespace Tizen.Convergence
+{
+    /// <summary>
+    /// Contains arguments for the event ServiceErrorOccured.
+    /// </summary>
+    public class ServiceErrorOccuredEventArgs : EventArgs
+    {
+        internal ServiceErrorOccuredEventArgs() { }
+
+        /// <summary>
+        /// The exception
+        /// </summary>
+        public Exception Exception { get; internal set; }
+    }
+}
diff --git a/src/Tizen.Convergence/Tizen.Convergence/ServiceEventOccuredEventArgs.cs b/src/Tizen.Convergence/Tizen.Convergence/ServiceEventOccuredEventArgs.cs
new file mode 100755 (executable)
index 0000000..67159f9
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+* 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.Convergence
+{
+    /// <summary>
+    /// Contains arguments for ServiceEventOccured
+    /// </summary>
+    public class ServiceEventOccuredEventArgs : EventArgs
+    {
+        internal ServiceEventOccuredEventArgs() { }
+
+        /// <summary>
+        /// The channel on which the event occured
+        /// </summary>
+        public Channel Channel { get; internal set; }
+
+        /// <summary>
+        /// The payload containing the result
+        /// </summary>
+        public Payload Payload { get; internal set; }
+    }
+}