[IoTConnectivity] Added Base implementation
authorJyothi Kumar Sambolu <s.jyothi@samsung.com>
Wed, 11 May 2016 13:51:44 +0000 (19:21 +0530)
committeryons.kim <yons.kim@samsung.com>
Thu, 2 Jun 2016 01:27:31 +0000 (10:27 +0900)
Change-Id: I458fb1420c9dfa90f6728cf851f867ffd2d59f7f
Signed-off-by: Jyothi Kumar Sambolu <s.jyothi@samsung.com>
42 files changed:
Makefile [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Client.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Common.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Server.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Interop/Interop.Libraries.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Properties/AssemblyInfo.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity.csproj [new file with mode: 0644]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity.snk [new file with mode: 0644]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/CacheUpdatedEventArgs.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/DeviceInformationFoundEventArgs.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/FindingError.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/FindingErrorOccurredEventArgs.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityClientManager.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityErrorFactory.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityServerManager.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/LiteResource.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ObservePolicy.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ObserveType.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ObserverNotifiedEventArgs.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/PlatformInformationFoundEventArgs.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/PresenceEventType.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/PresenceReceivedEventArgs.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/QualityOfService.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResource.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResponse.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Representation.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Request.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Resource.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceFoundEventArgs.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceInterfaces.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceOptions.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourcePolicy.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceQuery.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceState.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceTypes.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Response.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResponseCode.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/State.cs [new file with mode: 0755]
Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/StateChangedEventArgs.cs [new file with mode: 0755]
packaging/csapi-network-iotconnectivity.manifest [new file with mode: 0644]
packaging/csapi-network-iotconnectivity.pc.in [new file with mode: 0644]
packaging/csapi-network-iotconnectivity.spec [new file with mode: 0755]

diff --git a/Makefile b/Makefile
new file mode 100755 (executable)
index 0000000..8058f34
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,24 @@
+ASM_DIRS := Tizen.Network.IoTConnectivity
+ASM_DLLS := $(addsuffix .dll,$(ASM_DIRS))
+
+FLAGS := /unsafe
+
+ALL: $(ASM_DLLS)
+
+define make-dll
+$(eval ASM = $(strip $1))
+$(eval SRC = $(shell find $(ASM) -path $(ASM)/obj -prune -o -name '*.cs' -print))
+$(eval PKG = $(shell echo $2 | tr ' ' ','))
+$(ASM).dll: $(SRC)
+       @echo "[BUILD] $$@"
+       @mcs /nologo /out:$$@ /t:library /keyfile:$(ASM)/$(ASM).snk $(addprefix /pkg:,$(PKG)) $(FLAGS) $(SRC)
+       @echo "[CHECK] $$@"
+       @RET=`mono-shlib-cop $$@`; \
+  CNT=`echo $$$$RET | grep -e '^error:' | wc -l`; \
+  if [ $$$$CNT -gt 0 ]; then echo $$$$RET; rm -f $$@ exit 1; fi
+endef
+
+$(eval $(call make-dll, Tizen.Network.IoTConnectivity, csapi-tizen))
+
+clean:
+       @rm -f $(ASM_DLLS)
diff --git a/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Client.cs b/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Client.cs
new file mode 100755 (executable)
index 0000000..a1195ad
--- /dev/null
@@ -0,0 +1,224 @@
+/// 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 static partial class IoTConnectivity
+    {
+        internal static partial class Client
+        {
+            internal static partial class DeviceInformation
+            {
+                internal delegate void DeviceInformationCallback(IntPtr deviceInfoHandle, int result, IntPtr userData);
+
+                internal enum Property
+                {
+                    Name = 0,
+                    SpecVersion,
+                    Id,
+                    DataModelVersion,
+                }
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_get_device_info")]
+                internal static extern int Get(string hostAddress, int connectivityType, DeviceInformationCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_device_info_get_property")]
+                internal static extern int GetProperty(IntPtr deviceInfoHandle, int property, out string value);
+            }
+
+            internal static partial class PlatformInformation
+            {
+                internal delegate void PlatformInformationCallback(IntPtr platformInfoHandle, int result, IntPtr userData);
+
+                internal enum Propery
+                {
+                    Id = 0,
+                    MfgName,
+                    MfgUrl,
+                    ModelNumber,
+                    DateOfMfg,
+                    PlatformVer,
+                    OsVer,
+                    HardwareVer,
+                    FirmwareVer,
+                    SupportUrl,
+                    SystemTime
+                }
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_get_platform_info")]
+                internal static extern int Get(string hostAddress, int connectivityType, PlatformInformationCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_platform_info_get_property")]
+                internal static extern int GetProperty(IntPtr platformInfoHandle, int property, out string value);
+            }
+
+            internal static partial class RemoteResource
+            {
+                [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+                internal delegate void ResponseCallback(IntPtr resource, int err, int requestType, IntPtr response, IntPtr userData);
+
+                [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+                internal delegate void ObserveCallback(IntPtr resource, int err, int sequenceNumber, IntPtr response, IntPtr userData);
+
+                [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+                internal delegate void CachedRepresentationChangedCallback(IntPtr resource, IntPtr representation, IntPtr userData);
+
+                [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+                internal delegate void StateChangedCallback(IntPtr resource, int state, IntPtr userData);
+
+                internal enum ConnectivityType
+                {
+                    None = 0,
+                    Ipv4,
+                    Ipv6
+                }
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_create")]
+                internal static extern int Create(string hostAddress, int connectivityType, string uriPath, int properties, IntPtr resourceTypes, IntPtr resourceInterfaces, out IntPtr remoteResource);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_destroy")]
+                internal static extern void Destroy(IntPtr resource);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_clone")]
+                internal static extern int Clone(IntPtr src, out IntPtr dest);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_observe_register")]
+                internal static extern int RegisterObserve(IntPtr resource, int observePolicy, IntPtr query, ObserveCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_observe_deregister")]
+                internal static extern int DeregisterObserve(IntPtr resource);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get")]
+                internal static extern int Get(IntPtr resource, IntPtr query, ResponseCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_put")]
+                internal static extern int Put(IntPtr resource, IntPtr repr, IntPtr query, ResponseCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_post")]
+                internal static extern int Post(IntPtr resource, IntPtr repr, IntPtr query, ResponseCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_delete")]
+                internal static extern int Delete(IntPtr resource, ResponseCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_start_caching")]
+                internal static extern int StartCaching(IntPtr resource, CachedRepresentationChangedCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_stop_caching")]
+                internal static extern int StopCaching(IntPtr resource);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_start_monitoring")]
+                internal static extern int StartMonitoring(IntPtr resource, StateChangedCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_stop_monitoring")]
+                internal static extern int StopMonitoring(IntPtr resource);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_uriPath")]
+                internal static extern int GetUriPath(IntPtr resource, out string uriPath);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_connectivity_type")]
+                internal static extern int GetConnectivityType(IntPtr resource, out int connectivityType);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_host_address")]
+                internal static extern int GetHostAddress(IntPtr resource, out string hostAddress);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_device_id")]
+                internal static extern int GetDeviceId(IntPtr resource, out string deviceId);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_types")]
+                internal static extern int GetTypes(IntPtr resource, out IntPtr types);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_interfaces")]
+                internal static extern int GetInterfaces(IntPtr resource, out IntPtr ifaces);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_properties")]
+                internal static extern int GetProperties(IntPtr resource, out int properties);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_options")]
+                internal static extern int GetOptions(IntPtr resource, out IntPtr options);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_set_options")]
+                internal static extern int SetOptions(IntPtr resource, IntPtr options);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_cached_representation")]
+                internal static extern int GetCachedRepresentation(IntPtr resource, out IntPtr representation);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_get_time_interval")]
+                internal static extern int GetTimeInterval(IntPtr resource, out int timeInterval);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remote_resource_set_time_interval")]
+                internal static extern int SetTimeInterval(IntPtr resource, int timeInterval);
+            }
+
+            internal static partial class IoTCon
+            {
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_initialize")]
+                internal static extern int Initialize();
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_deinitialize")]
+                internal static extern void Deinitialize();
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_get_timeout")]
+                internal static extern int GetTimeout(out int timeoutSeconds);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_set_timeout")]
+                internal static extern int SetTimeout(int timeoutSeconds);
+            }
+
+            internal static partial class ResourceFinder
+            {
+                [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+                internal delegate void FoundResourceCallback(IntPtr remoteResourceHandle, int result, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_find_resource")]
+                internal static extern int AddResourceFoundCb(string hostAddress, int connectivityType, string resourceType, bool isSecure, FoundResourceCallback cb, IntPtr userData);
+            }
+
+            internal static partial class Presence
+            {
+                [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+                internal delegate void PresenceCallback(IntPtr presenceResponseHandle, int err, IntPtr response, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_add_presence_cb")]
+                internal static extern int AddPresenceCb(string hostAddress, int connectivityType, string resourceType, PresenceCallback cb, IntPtr userData, out IntPtr presenceHandle);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_remove_presence_cb")]
+                internal static extern int RemovePresenceCb(IntPtr presenceHandle);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_get_host_address")]
+                internal static extern int GetHostAddress(IntPtr presence, out string hostAddress);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_get_connectivity_type")]
+                internal static extern int GetConnectivityType(IntPtr presence, out int connectivityType);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_get_resource_type")]
+                internal static extern int GetResourceType(IntPtr presence, out string resourceType);
+            }
+
+            internal static partial class PresenceResponse
+            {
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_result")]
+                internal static extern int GetResult(IntPtr response, out int result);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_trigger")]
+                internal static extern int GetTrigger(IntPtr response, out int trigger);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_host_address")]
+                internal static extern int GetHostAddress(IntPtr response, out string hostAddress);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_connectivity_type")]
+                internal static extern int GetConnectivityType(IntPtr response, out int connectivityType);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_presence_response_get_resource_type")]
+                internal static extern int GetResourceType(IntPtr response, out string resourceType);
+            }
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Common.cs b/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Common.cs
new file mode 100755 (executable)
index 0000000..63b6447
--- /dev/null
@@ -0,0 +1,360 @@
+/// 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 static partial class IoTConnectivity
+    {
+        internal static partial class Common
+        {
+            internal enum DataType
+            {
+                None = 0,
+                Int,
+                Bool,
+                Double,
+                String,
+                ByteStr,
+                Null,
+                List,
+                State
+            }
+
+            internal static partial class ResourceTypes
+            {
+                [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+                internal delegate bool ForeachCallback(string type, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_create")]
+                internal static extern int Create(out IntPtr types);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_destroy")]
+                internal static extern void Destroy(IntPtr types);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_add")]
+                internal static extern int Add(IntPtr types, string type);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_remove")]
+                internal static extern int Remove(IntPtr types, string type);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_foreach")]
+                internal static extern int Foreach(IntPtr types, ForeachCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_types_clone")]
+                internal static extern int Clone(IntPtr src, out IntPtr dest);
+            }
+
+            internal static partial class ResourceInterfaces
+            {
+                [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+                internal delegate bool ForeachCallback(string iface, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_create")]
+                internal static extern int Create(out IntPtr ifaces);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_destroy")]
+                internal static extern void Destroy(IntPtr ifaces);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_add")]
+                internal static extern int Add(IntPtr ifaces, string iface);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_remove")]
+                internal static extern int Remove(IntPtr ifaces, string iface);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_foreach")]
+                internal static extern int Foreach(IntPtr ifaces, ForeachCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_interfaces_clone")]
+                internal static extern int Clone(IntPtr src, out IntPtr dest);
+            }
+
+            internal static partial class State
+            {
+                internal delegate bool StateCallback(IntPtr state, string key, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_create")]
+                internal static extern int Create(out IntPtr state);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_destroy")]
+                internal static extern void Destroy(IntPtr state);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_clone")]
+                internal static extern int Clone(IntPtr state, out IntPtr dest);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_int")]
+                internal static extern int AddInt(IntPtr state, string key, int val);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_bool")]
+                internal static extern int AddBool(IntPtr state, string key, bool val);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_double")]
+                internal static extern int AddDouble(IntPtr state, string key, double val);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_str")]
+                internal static extern int AddStr(IntPtr state, string key, string val);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_byte_str")]
+                internal static extern unsafe int AddByteStr(IntPtr state, string key, byte[] val, int len);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_list")]
+                internal static extern int AddList(IntPtr state, string key, IntPtr list);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_state")]
+                internal static extern int AddState(IntPtr dest, string key, IntPtr src);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_add_null")]
+                internal static extern int AddNull(IntPtr state, string key);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_int")]
+                internal static extern int GetInt(IntPtr state, string key, out int val);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_bool")]
+                internal static extern int GetBool(IntPtr state, string key, out bool val);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_double")]
+                internal static extern int GetDouble(IntPtr state, string key, out double val);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_str")]
+                internal static extern int GetStr(IntPtr state, string key, out string val);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_byte_str")]
+                internal static extern int GetByteStr(IntPtr state, string key, out IntPtr value, out int size);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_list")]
+                internal static extern int GetList(IntPtr state, string key, out IntPtr list);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_state")]
+                internal static extern int GetState(IntPtr src, string key, out IntPtr dest);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_is_null")]
+                internal static extern int IsNull(IntPtr state, string key, out bool isNull);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_remove")]
+                internal static extern int Remove(IntPtr state, string key);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_type")]
+                internal static extern int GetType(IntPtr state, string key, out DataType type);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_foreach")]
+                internal static extern int Foreach(IntPtr state, StateCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_state_get_keys_count")]
+                internal static extern int GetKeysCount(IntPtr state, out int count);
+            }
+
+            internal static partial class Query
+            {
+                internal delegate bool QueryCallback(string key, string value, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_create")]
+                internal static extern int Create(out IntPtr query);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_destroy")]
+                internal static extern void Destroy(IntPtr query);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_get_resource_type")]
+                internal static extern int GetResourceType(IntPtr query, out string resourceType);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_get_interface")]
+                internal static extern int GetInterface(IntPtr query, out string resourceInterface);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_set_resource_type")]
+                internal static extern int SetResourceType(IntPtr query, string resourceType);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_set_interface")]
+                internal static extern int SetInterface(IntPtr query, string resourceInterface);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_add")]
+                internal static extern int Add(IntPtr query, string key, string value);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_remove")]
+                internal static extern int Remove(IntPtr query, string key);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_lookup")]
+                internal static extern int Lookup(IntPtr query, string key, out string data);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_query_foreach")]
+                internal static extern int Foreach(IntPtr query, QueryCallback cb, IntPtr userData);
+            }
+
+            internal static partial class Representation
+            {
+                internal delegate bool RepresentationChildrenCallback(IntPtr child, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_create")]
+                internal static extern int Create(out IntPtr repr);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_destroy")]
+                internal static extern void Destroy(IntPtr repr);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_clone")]
+                internal static extern int Clone(IntPtr src, out IntPtr dest);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_uri_path")]
+                internal static extern int SetUriPath(IntPtr repr, string uriPath);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_uri_path")]
+                internal static extern int GetUriPath(IntPtr repr, out string uriPath);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_resource_types")]
+                internal static extern int SetResourceTypes(IntPtr repr, IntPtr types);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_resource_types")]
+                internal static extern int GetResourceTypes(IntPtr repr, out IntPtr types);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_resource_interfaces")]
+                internal static extern int SetResourceInterfaces(IntPtr repr, IntPtr ifaces);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_resource_interfaces")]
+                internal static extern int GetResourceInterfaces(IntPtr repr, out IntPtr ifaces);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_set_state")]
+                internal static extern int SetState(IntPtr repr, IntPtr state);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_state")]
+                internal static extern int GetState(IntPtr repr, out IntPtr state);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_add_child")]
+                internal static extern int AddChild(IntPtr parent, IntPtr child);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_remove_child")]
+                internal static extern int RemoveChild(IntPtr parent, IntPtr child);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_foreach_children")]
+                internal static extern int ForeachChildren(IntPtr parent, RepresentationChildrenCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_children_count")]
+                internal static extern int GetChildrenCount(IntPtr parent, out int count);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_representation_get_nth_child")]
+                internal static extern int GetNthChild(IntPtr parent, int pos, out IntPtr child);
+            }
+
+            internal static partial class Options
+            {
+                internal delegate bool OptionsCallback(ushort id, string data, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_create")]
+                internal static extern int Create(out IntPtr options);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_destroy")]
+                internal static extern void Destroy(IntPtr options);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_add")]
+                internal static extern int Add(IntPtr options, ushort id, string data);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_remove")]
+                internal static extern int Remove(IntPtr options, ushort id);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_lookup")]
+                internal static extern int Lookup(IntPtr options, ushort id, out string data);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_options_foreach")]
+                internal static extern int ForEach(IntPtr options, OptionsCallback cb, IntPtr userData);
+            }
+
+            internal static partial class List
+            {
+                internal delegate bool IntCallback(int pos, int value, IntPtr userData);
+
+                internal delegate bool BoolCallback(int pos, bool value, IntPtr userData);
+
+                internal delegate bool DoubleCallback(int pos, double value, IntPtr userData);
+
+                internal delegate bool ByteStrCallback(int pos, byte[] value, int len, IntPtr userData);
+
+                internal delegate bool StrCallback(int pos, string value, IntPtr userData);
+
+                internal delegate bool ListCallback(int pos, IntPtr value, IntPtr userData);
+
+                internal delegate bool StateCallback(int pos, IntPtr value, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_create")]
+                internal static extern int Create(DataType type, out IntPtr list);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_destroy")]
+                internal static extern void Destroy(IntPtr list);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_int")]
+                internal static extern int AddInt(IntPtr list, int val, int pos);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_bool")]
+                internal static extern int AddBool(IntPtr list, bool val, int pos);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_double")]
+                internal static extern int AddDouble(IntPtr list, double val, int pos);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_str")]
+                internal static extern int AddStr(IntPtr list, string val, int pos);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_byte_str")]
+                internal static extern int AddByteStr(IntPtr list, byte[] val, int len, int pos);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_list")]
+                internal static extern int AddList(IntPtr list, IntPtr val, int pos);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_add_state")]
+                internal static extern int AddState(IntPtr list, IntPtr val, int pos);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_int")]
+                internal static extern int GetNthInt(IntPtr list, int pos, out int val);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_bool")]
+                internal static extern int GetNthBool(IntPtr list, int pos, out bool val);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_double")]
+                internal static extern int GetNthDouble(IntPtr list, int pos, out double val);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_str")]
+                internal static extern int GetNthStr(IntPtr list, int pos, out string val);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_byte_str")]
+                internal static extern int GetNthByteStr(IntPtr list, int pos, out string val, out int len);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_list")]
+                internal static extern int GetNthList(IntPtr src, int pos, out IntPtr dest);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_nth_state")]
+                internal static extern int GetNthState(IntPtr list, int pos, out IntPtr state);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_remove_nth")]
+                internal static extern int RemoveNth(IntPtr list, int pos);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_type")]
+                internal static extern int GetType(IntPtr list, out int type);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_get_length")]
+                internal static extern int GetLength(IntPtr list, out int length);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_int")]
+                internal static extern int ForeachInt(IntPtr list, IntCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_bool")]
+                internal static extern int ForeachBool(IntPtr list, BoolCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_double")]
+                internal static extern int ForeachDouble(IntPtr list, DoubleCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_byte_str")]
+                internal static extern int ForeachByteStr(IntPtr list, ByteStrCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_str")]
+                internal static extern int ForeachStr(IntPtr list, StrCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_list")]
+                internal static extern int ForeachList(IntPtr list, ListCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_list_foreach_state")]
+                internal static extern int ForeachState(IntPtr list, StateCallback cb, IntPtr userData);
+            }
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Server.cs b/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Server.cs
new file mode 100755 (executable)
index 0000000..8a85141
--- /dev/null
@@ -0,0 +1,156 @@
+/// 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 static partial class IoTConnectivity
+    {
+        internal static partial class Server
+        {
+            internal enum RequestType
+            {
+                Unknown = 0,
+                Get = 1,
+                Put = 2,
+                Post = 3,
+                Delete = 4,
+            }
+
+            internal static partial class IoTCon
+            {
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_start_presence")]
+                internal static extern int StartPresence(uint time);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_stop_presence")]
+                internal static extern int StopPresence();
+            }
+
+            internal static partial class Resource
+            {
+                internal delegate void RequestHandlerCallback(IntPtr resource, IntPtr request, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_create")]
+                internal static extern int Create(string uriPath, IntPtr resTypes, IntPtr ifaces, int properties, RequestHandlerCallback cb, IntPtr userData, out IntPtr resourceHandle);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_destroy")]
+                internal static extern int Destroy(IntPtr resourceHandle);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_bind_interface")]
+                internal static extern int BindInterface(IntPtr resource, string iface);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_bind_type")]
+                internal static extern int BindType(IntPtr resourceHandle, string resourceType);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_set_request_handler")]
+                internal static extern int SetRequestHandler(IntPtr resource, RequestHandlerCallback cb, IntPtr userData);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_bind_child_resource")]
+                internal static extern int BindChildResource(IntPtr parent, IntPtr child);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_unbind_child_resource")]
+                internal static extern int UnbindChildResource(IntPtr parent, IntPtr child);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_notify")]
+                internal static extern int Notify(IntPtr resource, IntPtr repr, IntPtr observers, int qos);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_number_of_children")]
+                internal static extern int GetNumberOfChildren(IntPtr resource, out int number);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_nth_child")]
+                internal static extern int GetNthChild(IntPtr parent, int index, out IntPtr child);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_uri_path")]
+                internal static extern int GetUriPath(IntPtr resource, out string uriPpath);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_types")]
+                internal static extern int GetTypes(IntPtr resource, out IntPtr types);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_interfaces")]
+                internal static extern int GetInterfaces(IntPtr resource, out IntPtr ifaces);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_resource_get_properties")]
+                internal static extern int GetProperties(IntPtr resource, out int properties);
+            }
+
+            internal static partial class Request
+            {
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_host_address")]
+                internal static extern int GetHostAddress(IntPtr request, out string hostAddress);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_connectivity_type")]
+                internal static extern int GetConnectivityType(IntPtr request, out int connectivityType);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_representation")]
+                internal static extern int GetRepresentation(IntPtr request, out IntPtr repr);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_request_type")]
+                internal static extern int GetRequestType(IntPtr request, out int type);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_options")]
+                internal static extern int GetOptions(IntPtr request, out IntPtr options);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_query")]
+                internal static extern int GetQuery(IntPtr request, out IntPtr query);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_observe_type")]
+                internal static extern int GetObserveType(IntPtr request, out int observeType);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_request_get_observe_id")]
+                internal static extern int GetObserveId(IntPtr request, out int observeId);
+            }
+
+            internal static partial class Response
+            {
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_create")]
+                internal static extern int Create(IntPtr request, out IntPtr response);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_destroy")]
+                internal static extern void Destroy(IntPtr resp);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_get_options")]
+                internal static extern int GetOptions(IntPtr resp, out IntPtr options);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_get_representation")]
+                internal static extern int GetRepresentation(IntPtr resp, out IntPtr repr);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_get_result")]
+                internal static extern int GetResult(IntPtr resp, out int result);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_set_result")]
+                internal static extern int SetResult(IntPtr resp, int result);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_set_representation")]
+                internal static extern int SetRepresentation(IntPtr resp, string iface, IntPtr repr);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_set_options")]
+                internal static extern int SetOptions(IntPtr resp, IntPtr options);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_response_send")]
+                internal static extern int Send(IntPtr resp);
+            }
+
+            internal static partial class Observers
+            {
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_create")]
+                internal static extern int Create(out IntPtr observers);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_destroy")]
+                internal static extern void Destroy(IntPtr observers);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_add")]
+                internal static extern int Add(IntPtr observers, int observeId);
+
+                [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_observers_remove")]
+                internal static extern int Remove(IntPtr observers, int observeId);
+            }
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Interop/Interop.Libraries.cs b/Tizen.Network.IoTConnectivity/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..2ce39e9
--- /dev/null
@@ -0,0 +1,17 @@
+/// 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.
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string IoTCon = "libiotcon.so.0.0.12";
+        public const string Glib = "libglib-2.0.so.0";
+        public const string Libc = "libc.so.6";
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Properties/AssemblyInfo.cs b/Tizen.Network.IoTConnectivity/Properties/AssemblyInfo.cs
new file mode 100755 (executable)
index 0000000..fc4130c
--- /dev/null
@@ -0,0 +1,43 @@
+/// 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.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tizen.Network.IoTConnectivity")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tizen.Network.IoTConnectivity")]
+[assembly: AssemblyCopyright("Copyright (c) 2016 Samsung Electronics Co., Ltd")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("3577eae8-b409-4bae-a5da-c6340be1dbc2")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity.csproj b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity.csproj
new file mode 100644 (file)
index 0000000..95ad115
--- /dev/null
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{3577EAE8-B409-4BAE-A5DA-C6340BE1DBC2}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Tizen.Network.IoTConnectivity</RootNamespace>
+    <AssemblyName>Tizen.Network.IoTConnectivity</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SignAssembly>true</SignAssembly>
+  </PropertyGroup>
+  <PropertyGroup>
+    <AssemblyOriginatorKeyFile>Tizen.Network.IoTConnectivity.snk</AssemblyOriginatorKeyFile>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+    <Reference Include="Tizen.Internals">
+      <HintPath>..\..\tizen\Tizen.Internals\bin\Debug\Tizen.Internals.dll</HintPath>
+    </Reference>
+    <Reference Include="Tizen">
+      <HintPath>..\..\tizen\Tizen\bin\Debug\Tizen.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Tizen.Network.IoTConnectivity\CacheUpdatedEventArgs.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\DeviceInformationFoundEventArgs.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\FindingErrorOccurredEventArgs.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\IoTConnectivityClientManager.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\IoTConnectivityErrorFactory.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\LiteResource.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\ObserverNotifiedEventArgs.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\PlatformInformationFoundEventArgs.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\PresenceReceivedEventArgs.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\RemoteResource.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\RemoteResponse.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\ResourceFoundEventArgs.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\ResourceInterfaces.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\ResourceQuery.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\Representation.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\ResourceOptions.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\State.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\ResourceTypes.cs" />
+    <Compile Include="Interop\Interop.Libraries.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\IoTConnectivityServerManager.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\Request.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\Resource.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\Response.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\ObservePolicy.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\PresenceEventType.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\QualityOfService.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\FindingError.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\ResourcePolicy.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\ResourceState.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\ResponseCode.cs" />
+    <Compile Include="Interop\Interop.IoTConnectivity.Client.cs" />
+    <Compile Include="Interop\Interop.IoTConnectivity.Common.cs" />
+    <Compile Include="Interop\Interop.IoTConnectivity.Server.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\ObserveType.cs" />
+    <Compile Include="Tizen.Network.IoTConnectivity\StateChangedEventArgs.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Tizen.Network.IoTConnectivity.snk" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity.snk b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity.snk
new file mode 100644 (file)
index 0000000..2913977
Binary files /dev/null and b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity.snk differ
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/CacheUpdatedEventArgs.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/CacheUpdatedEventArgs.cs
new file mode 100755 (executable)
index 0000000..27cb177
--- /dev/null
@@ -0,0 +1,24 @@
+/// 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;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// CacheUpdatedEventArgs class. This class is an event arguments of the CacheUpdated event.
+    /// </summary>
+    public class CacheUpdatedEventArgs : EventArgs
+    {
+        /// <summary>
+        /// Representation property.
+        /// </summary>
+        /// <returns>Representation Representation.</returns>
+        public Representation Representation { get; internal set; }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/DeviceInformationFoundEventArgs.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/DeviceInformationFoundEventArgs.cs
new file mode 100755 (executable)
index 0000000..7bda503
--- /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.
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// DeviceInformationFoundEventArgs class. This class is an event arguments of the DeviceInformationFound event.
+    /// </summary>
+    public class DeviceInformationFoundEventArgs
+    {
+        /// <summary>
+        /// The request id
+        /// </summary>
+        public int RequestId { get; internal set; }
+
+        /// <summary>
+        /// Indicates human friendly name for device
+        /// </summary>
+        public string Name { get; internal set; }
+
+        /// <summary>
+        /// Indicates human friendly name for device
+        /// </summary>
+        public string SpecVersion { get; internal set; }
+
+        /// <summary>
+        /// Indicates unique identifier for OIC device
+        /// </summary>
+        public string DeviceId { get; internal set; }
+
+        /// <summary>
+        /// Indicates version of the specs this device data model is implemented to
+        /// </summary>
+        public string DataModelVersion { get; internal set; }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/FindingError.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/FindingError.cs
new file mode 100755 (executable)
index 0000000..edf55ae
--- /dev/null
@@ -0,0 +1,65 @@
+/// 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.
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// Enumeration for resource found errors
+    /// </summary>
+    internal enum FindingError
+    {
+        /// <summary>
+        /// I/O error
+        /// </summary>
+        Io = 1,
+        /// <summary>
+        /// Out of memory
+        /// </summary>
+        OutOfMemory,
+        /// <summary>
+        /// Permission denied
+        /// </summary>
+        PermissionDenied,
+        /// <summary>
+        /// Not supported
+        /// </summary>
+        NotSupported,
+        /// <summary>
+        /// Invalid parameter
+        /// </summary>
+        InvalidParameter,
+        /// <summary>
+        /// No data available
+        /// </summary>
+        NoData,
+        /// <summary>
+        /// Time out
+        /// </summary>
+        TimeOut,
+        /// <summary>
+        /// IoTivity errors
+        /// </summary>
+        Iotivity,
+        /// <summary>
+        /// Representation errors
+        /// </summary>
+        Representation,
+        /// <summary>
+        /// Invalid type
+        /// </summary>
+        InvalidType,
+        /// <summary>
+        /// Already
+        /// </summary>
+        Already,
+        /// <summary>
+        /// System errors
+        /// </summary>
+        System
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/FindingErrorOccurredEventArgs.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/FindingErrorOccurredEventArgs.cs
new file mode 100755 (executable)
index 0000000..587f353
--- /dev/null
@@ -0,0 +1,30 @@
+/// 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;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// FoundErrorEventArgs class. This class is an event arguments of the FoundError event.
+    /// </summary>
+    public class FindingErrorOccurredEventArgs : EventArgs
+    {
+        /// <summary>
+        /// RequestId property.
+        /// </summary>
+        /// <returns>int RequestId.</returns>
+        public int RequestId { get; internal set; }
+
+        /// <summary>
+        /// Result property.
+        /// </summary>
+        /// <returns>FindingError Result.</returns>
+        public Exception Error { get; internal set; }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityClientManager.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityClientManager.cs
new file mode 100755 (executable)
index 0000000..6b55115
--- /dev/null
@@ -0,0 +1,589 @@
+/// 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.Collections.Generic;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    public static class IoTConnectivityClientManager
+    {
+        public const string MulticastAddress = null;
+
+        private static int s_presenceListenerId = 1;
+        private static Dictionary<IntPtr, Interop.IoTConnectivity.Client.Presence.PresenceCallback> s_presenceCallbacksMap = new Dictionary<IntPtr, Interop.IoTConnectivity.Client.Presence.PresenceCallback>();
+        private static Dictionary<IntPtr, IntPtr> s_presenceHandlesMap = new Dictionary<IntPtr, IntPtr>();
+
+        private static int s_requestId = 1;
+        private static Dictionary<IntPtr, Interop.IoTConnectivity.Client.ResourceFinder.FoundResourceCallback> s_resourceFoundCallbacksMap = new Dictionary<IntPtr, Interop.IoTConnectivity.Client.ResourceFinder.FoundResourceCallback>();
+        private static Dictionary<IntPtr, Interop.IoTConnectivity.Client.DeviceInformation.DeviceInformationCallback> s_deviceInformationCallbacksMap = new Dictionary<IntPtr, Interop.IoTConnectivity.Client.DeviceInformation.DeviceInformationCallback>();
+        private static Dictionary<IntPtr, Interop.IoTConnectivity.Client.PlatformInformation.PlatformInformationCallback> s_platformInformationCallbacksMap = new Dictionary<IntPtr, Interop.IoTConnectivity.Client.PlatformInformation.PlatformInformationCallback>();
+
+        /// <summary>
+        /// presence event on the resource
+        /// </summary>
+        public static event EventHandler<PresenceReceivedEventArgs> PresenceReceived;
+
+        /// <summary>
+        /// Resource found event handler
+        /// </summary>
+        public static event EventHandler<ResourceFoundEventArgs> ResourceFound;
+
+        /// <summary>
+        /// PlatformInformationFound event handler
+        /// </summary>
+        public static event EventHandler<PlatformInformationFoundEventArgs> PlatformInformationFound;
+
+        /// <summary>
+        /// DeviceInformationFound event handler
+        /// </summary>
+        public static event EventHandler<DeviceInformationFoundEventArgs> DeviceInformationFound;
+
+        /// <summary>
+        /// FoundError event handler
+        /// </summary>
+        public static event EventHandler<FindingErrorOccurredEventArgs> FindingErrorOccurred;
+
+        /// <summary>
+        /// Timeout property
+        /// </summary>
+        public static int TimeOut
+        {
+            get
+            {
+                int timeout;
+                int ret = Interop.IoTConnectivity.Client.IoTCon.GetTimeout(out timeout);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Warn(IoTConnectivityErrorFactory.LogTag, "Failed to get timeout");
+                    return 0;
+                }
+                return timeout;
+            }
+            set
+            {
+                int ret = Interop.IoTConnectivity.Client.IoTCon.SetTimeout(value);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to set timeout");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Connects to the iotcon service
+        /// </summary>
+        public static void Initialize()
+        {
+            int ret = Interop.IoTConnectivity.Client.IoTCon.Initialize();
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to initialize");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Disconnects from the iotcon service
+        /// </summary>
+        public static void Deinitialize()
+        {
+            Interop.IoTConnectivity.Client.IoTCon.Deinitialize();
+        }
+
+        /// <summary>
+        /// Starts receiving presence events
+        /// </summary>
+        /// <returns>
+        /// PresenceId
+        /// </returns>
+        public static int StartReceivingPresence(string hostAddress, string resourceType)
+        {
+            Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType connectivityType = RemoteResource.GetConnectivityType(hostAddress);
+            if (connectivityType == Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Unable to parse host address");
+                throw new ArgumentException("Unable to parse host address");
+            }
+
+            if (resourceType != null && !ResourceTypes.IsValid(resourceType))
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Invalid type");
+                throw new ArgumentException("Invalid type");
+            }
+
+            IntPtr id = IntPtr.Zero;
+            lock (s_presenceCallbacksMap)
+            {
+                id = (IntPtr)s_presenceListenerId++;
+            }
+            s_presenceCallbacksMap[id] = (IntPtr presence, int result, IntPtr presenceResponseHandle, IntPtr userData) =>
+            {
+                if (presenceResponseHandle != IntPtr.Zero)
+                {
+                    int presenceId = (int)userData;
+                    if (result == 0)
+                    {
+                        PresenceReceivedEventArgs e = GetPresenceReceivedEventArgs(presenceId, presenceResponseHandle);
+                        if (e == null)
+                        {
+                            Log.Error(IoTConnectivityErrorFactory.LogTag, "Can't get PresenceReceivedEventArgs");
+                            return;
+                        }
+                        PresenceReceived?.Invoke(null, e);
+                    }
+                    else
+                    {
+                        FindingErrorOccurredEventArgs e = GetFindingErrorOccurredEventArgs(presenceId, result);
+                        FindingErrorOccurred?.Invoke(null, e);
+                    }
+                }
+            };
+
+            IntPtr presenceHandle;
+            int errorCode = Interop.IoTConnectivity.Client.Presence.AddPresenceCb(hostAddress, (int)connectivityType, resourceType, s_presenceCallbacksMap[id], id, out presenceHandle);
+            if (errorCode != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to register presence event handler");
+                lock (s_presenceCallbacksMap)
+                {
+                    s_presenceCallbacksMap.Remove(id);
+                }
+                throw IoTConnectivityErrorFactory.GetException(errorCode);
+            }
+
+            lock (s_presenceHandlesMap)
+            {
+                s_presenceHandlesMap[id] = presenceHandle;
+            }
+            return (int)id;
+        }
+
+        /// <summary>
+        /// Stops receiving presence events
+        /// </summary>
+        public static void StopReceivingPresence(int presenceId)
+        {
+            if (s_presenceHandlesMap.ContainsKey((IntPtr)presenceId))
+            {
+                IntPtr presenceHandle = s_presenceHandlesMap[(IntPtr)presenceId];
+                int ret = Interop.IoTConnectivity.Client.Presence.RemovePresenceCb(presenceHandle);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to deregister presence event handler");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+
+                lock (s_presenceHandlesMap)
+                {
+                    s_presenceHandlesMap.Remove((IntPtr)presenceId);
+                }
+            }
+
+            if (s_presenceCallbacksMap.ContainsKey((IntPtr)presenceId))
+            {
+                lock (s_presenceCallbacksMap)
+                {
+                    s_presenceCallbacksMap.Remove((IntPtr)presenceId);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Starts finding resource events
+        /// </summary>
+        /// <returns>
+        /// RequestId
+        /// </returns>
+        public static int StartFindingResource(string hostAddress, string resourceType, bool isSecure = false)
+        {
+            Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType connectivityType = RemoteResource.GetConnectivityType(hostAddress);
+            if (connectivityType == Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Unable to parse host address");
+                throw new ArgumentException("Unable to parse host address");
+            }
+
+            if (resourceType != null && !ResourceTypes.IsValid(resourceType))
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Invalid type");
+                throw new ArgumentException("Invalid type");
+            }
+
+            IntPtr id = IntPtr.Zero;
+            lock (s_resourceFoundCallbacksMap)
+            {
+                id = (IntPtr)s_requestId++;
+            }
+            s_resourceFoundCallbacksMap[id] = (IntPtr remoteResourceHandle, int result, IntPtr userData) =>
+            {
+                if (remoteResourceHandle != IntPtr.Zero)
+                {
+                    int requestId = (int)userData;
+                    if (result == (int)IoTConnectivityError.None)
+                    {
+                        RemoteResource resource = null;
+                        try
+                        {
+                            resource = new RemoteResource(remoteResourceHandle);
+                        }
+                        catch (Exception exp)
+                        {
+                            Log.Error(IoTConnectivityErrorFactory.LogTag, "Can't clone RemoteResource's handle: " + exp.Message);
+                            return;
+                        }
+                        ResourceFoundEventArgs e = new ResourceFoundEventArgs()
+                        {
+                            RequestId = requestId,
+                            Resource = resource
+                        };
+                        ResourceFound?.Invoke(null, e);
+                    }
+                    else
+                    {
+                        FindingErrorOccurredEventArgs e = GetFindingErrorOccurredEventArgs(requestId, result);
+                        FindingErrorOccurred?.Invoke(null, e);
+
+                        lock (s_resourceFoundCallbacksMap)
+                        {
+                            s_resourceFoundCallbacksMap.Remove(id);
+                        }
+                    }
+                }
+            };
+
+            int errorCode = Interop.IoTConnectivity.Client.ResourceFinder.AddResourceFoundCb(hostAddress, (int)connectivityType, resourceType, isSecure, s_resourceFoundCallbacksMap[id], id);
+            if (errorCode != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to register resource found event handler");
+                lock (s_resourceFoundCallbacksMap)
+                {
+                    s_resourceFoundCallbacksMap.Remove(id);
+                }
+                throw IoTConnectivityErrorFactory.GetException(errorCode);
+            }
+            return (int)id;
+        }
+
+        /// <summary>
+        /// Starts finding device information events
+        /// </summary>
+        /// <returns>
+        /// RequestId
+        /// </returns>
+        public static int StartFindingDeviceInformation(string hostAddress)
+        {
+            Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType connectivityType = RemoteResource.GetConnectivityType(hostAddress);
+            if (connectivityType == Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Unable to parse host address");
+                throw new ArgumentException("Unable to parse host address");
+            }
+
+            IntPtr id = IntPtr.Zero;
+            lock (s_deviceInformationCallbacksMap)
+            {
+                id = (IntPtr)s_requestId++;
+            }
+            s_deviceInformationCallbacksMap[id] = (IntPtr deviceInfoHandle, int result, IntPtr userData) =>
+            {
+                if (deviceInfoHandle != IntPtr.Zero)
+                {
+                    int requestId = (int)userData;
+                    if (result == 0)
+                    {
+                        DeviceInformationFoundEventArgs e = GetDeviceInformationFoundEventArgs(requestId, deviceInfoHandle);
+                        if (e == null)
+                        {
+                            Log.Error(IoTConnectivityErrorFactory.LogTag, "Can't get DeviceInformationFoundEventArgs");
+                            return;
+                        }
+                        DeviceInformationFound?.Invoke(null, e);
+                    }
+                    else
+                    {
+                        FindingErrorOccurredEventArgs e = GetFindingErrorOccurredEventArgs(requestId, result);
+                        FindingErrorOccurred?.Invoke(null, e);
+
+                        lock (s_deviceInformationCallbacksMap)
+                        {
+                            s_deviceInformationCallbacksMap.Remove(id);
+                        }
+                    }
+                }
+            };
+
+            int errorCode = Interop.IoTConnectivity.Client.DeviceInformation.Get(hostAddress, (int)connectivityType, s_deviceInformationCallbacksMap[id], id);
+            if (errorCode != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get device information");
+                lock (s_deviceInformationCallbacksMap)
+                {
+                    s_deviceInformationCallbacksMap.Remove(id);
+                }
+                throw IoTConnectivityErrorFactory.GetException(errorCode);
+            }
+
+            return (int)id;
+        }
+
+        /// <summary>
+        /// Starts finding platform information events
+        /// </summary>
+        /// <returns>
+        /// RequestId
+        /// </returns>
+        public static int StartFindingPlatformInformation(string hostAddress)
+        {
+            Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType connectivityType = RemoteResource.GetConnectivityType(hostAddress);
+            if (connectivityType == Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Unable to parse host address");
+                throw new ArgumentException("Unable to parse host address");
+            }
+
+            IntPtr id = IntPtr.Zero;
+            lock (s_platformInformationCallbacksMap)
+            {
+                id = (IntPtr)s_requestId++;
+            }
+            s_platformInformationCallbacksMap[id] = (IntPtr platformInfoHandle, int result, IntPtr userData) =>
+            {
+                if (platformInfoHandle != IntPtr.Zero)
+                {
+                    int requestId = (int)userData;
+                    if (result == 0)
+                    {
+                        PlatformInformationFoundEventArgs e = GetPlatformInformationFoundEventArgs(requestId, platformInfoHandle);
+                        if (e == null)
+                        {
+                            Log.Error(IoTConnectivityErrorFactory.LogTag, "Can't get PlatformInformationFoundEventArgs");
+                            return;
+                        }
+                        PlatformInformationFound?.Invoke(null, e);
+                    }
+                    else
+                    {
+                        FindingErrorOccurredEventArgs e = GetFindingErrorOccurredEventArgs(requestId, result);
+                        FindingErrorOccurred?.Invoke(null, e);
+
+                        lock (s_platformInformationCallbacksMap)
+                        {
+                            s_platformInformationCallbacksMap.Remove(id);
+                        }
+                    }
+                }
+            };
+
+            int errorCode = Interop.IoTConnectivity.Client.PlatformInformation.Get(hostAddress, (int)connectivityType, s_platformInformationCallbacksMap[id], id);
+            if (errorCode != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get platform information");
+                lock (s_platformInformationCallbacksMap)
+                {
+                    s_platformInformationCallbacksMap.Remove(id);
+                }
+                throw IoTConnectivityErrorFactory.GetException(errorCode);
+            }
+
+            return (int)id;
+        }
+
+        private static PresenceReceivedEventArgs GetPresenceReceivedEventArgs(int presenceId, IntPtr presenceResponseHandle)
+        {
+            int trigger;
+            string host, type;
+
+            int ret = Interop.IoTConnectivity.Client.PresenceResponse.GetHostAddress(presenceResponseHandle, out host);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get host address");
+                return null;
+            }
+
+            ret = Interop.IoTConnectivity.Client.PresenceResponse.GetResourceType(presenceResponseHandle, out type);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get resource type");
+                return null;
+            }
+
+            ret = Interop.IoTConnectivity.Client.PresenceResponse.GetTrigger(presenceResponseHandle, out trigger);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get event type");
+                return null;
+            }
+
+            PresenceReceivedEventArgs e = new PresenceReceivedEventArgs()
+            {
+                PresenceId = presenceId,
+                HostAddress = host,
+                Type = type,
+                EventType = (PresenceEventType)trigger
+            };
+
+            return e;
+        }
+
+        private static DeviceInformationFoundEventArgs GetDeviceInformationFoundEventArgs(int requestId, IntPtr deviceInfoHandle)
+        {
+            string name, specVersion, deviceId, dataModelVersion;
+
+            int ret = Interop.IoTConnectivity.Client.DeviceInformation.GetProperty(deviceInfoHandle, (int)Interop.IoTConnectivity.Client.DeviceInformation.Property.Name, out name);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get name");
+                return null;
+            }
+
+            ret = Interop.IoTConnectivity.Client.DeviceInformation.GetProperty(deviceInfoHandle, (int)Interop.IoTConnectivity.Client.DeviceInformation.Property.SpecVersion, out specVersion);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get spec version");
+                return null;
+            }
+
+            ret = Interop.IoTConnectivity.Client.DeviceInformation.GetProperty(deviceInfoHandle, (int)Interop.IoTConnectivity.Client.DeviceInformation.Property.Id, out deviceId);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get device id");
+                return null;
+            }
+
+            ret = Interop.IoTConnectivity.Client.DeviceInformation.GetProperty(deviceInfoHandle, (int)Interop.IoTConnectivity.Client.DeviceInformation.Property.DataModelVersion, out dataModelVersion);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get data model version");
+                return null;
+            }
+
+            DeviceInformationFoundEventArgs e = new DeviceInformationFoundEventArgs()
+            {
+                RequestId = requestId,
+                Name = name,
+                SpecVersion = specVersion,
+                DeviceId = deviceId,
+                DataModelVersion = dataModelVersion
+            };
+
+            return e;
+        }
+
+        private static PlatformInformationFoundEventArgs GetPlatformInformationFoundEventArgs(int requestId, IntPtr platformInfoHandle)
+        {
+            string platformId, manufacturerName, manufacturerUrl, modelNumber, dateOfManufacture, platformVersion, osVersion, hardwareVersion, firmwareVersion, supportUrl, systemTime;
+
+            int ret = Interop.IoTConnectivity.Client.PlatformInformation.GetProperty(platformInfoHandle, (int)Interop.IoTConnectivity.Client.PlatformInformation.Propery.Id, out platformId);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get platform id");
+                return null;
+            }
+
+            ret = Interop.IoTConnectivity.Client.PlatformInformation.GetProperty(platformInfoHandle, (int)Interop.IoTConnectivity.Client.PlatformInformation.Propery.MfgName, out manufacturerName);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get manufacturer name");
+                return null;
+            }
+
+            ret = Interop.IoTConnectivity.Client.PlatformInformation.GetProperty(platformInfoHandle, (int)Interop.IoTConnectivity.Client.PlatformInformation.Propery.MfgUrl, out manufacturerUrl);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get manufacturer url");
+                return null;
+            }
+
+            ret = Interop.IoTConnectivity.Client.PlatformInformation.GetProperty(platformInfoHandle, (int)Interop.IoTConnectivity.Client.PlatformInformation.Propery.ModelNumber, out modelNumber);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get model number");
+                return null;
+            }
+
+            ret = Interop.IoTConnectivity.Client.PlatformInformation.GetProperty(platformInfoHandle, (int)Interop.IoTConnectivity.Client.PlatformInformation.Propery.DateOfMfg, out dateOfManufacture);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get date of manufacture");
+                return null;
+            }
+
+            ret = Interop.IoTConnectivity.Client.PlatformInformation.GetProperty(platformInfoHandle, (int)Interop.IoTConnectivity.Client.PlatformInformation.Propery.PlatformVer, out platformVersion);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get platform version");
+                return null;
+            }
+
+            ret = Interop.IoTConnectivity.Client.PlatformInformation.GetProperty(platformInfoHandle, (int)Interop.IoTConnectivity.Client.PlatformInformation.Propery.OsVer, out osVersion);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to os version");
+                return null;
+            }
+
+            ret = Interop.IoTConnectivity.Client.PlatformInformation.GetProperty(platformInfoHandle, (int)Interop.IoTConnectivity.Client.PlatformInformation.Propery.HardwareVer, out hardwareVersion);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to hardware version");
+                return null;
+            }
+
+            ret = Interop.IoTConnectivity.Client.PlatformInformation.GetProperty(platformInfoHandle, (int)Interop.IoTConnectivity.Client.PlatformInformation.Propery.FirmwareVer, out firmwareVersion);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get firmware version");
+                return null;
+            }
+
+            ret = Interop.IoTConnectivity.Client.PlatformInformation.GetProperty(platformInfoHandle, (int)Interop.IoTConnectivity.Client.PlatformInformation.Propery.SupportUrl, out supportUrl);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get support url");
+                return null;
+            }
+
+            ret = Interop.IoTConnectivity.Client.PlatformInformation.GetProperty(platformInfoHandle, (int)Interop.IoTConnectivity.Client.PlatformInformation.Propery.SystemTime, out systemTime);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get system time");
+                return null;
+            }
+
+            PlatformInformationFoundEventArgs e = new PlatformInformationFoundEventArgs()
+            {
+                RequestId = requestId,
+                PlatformId = platformId,
+                ManufacturerName = manufacturerName,
+                ManufacturerURL = manufacturerUrl,
+                DateOfManufacture = dateOfManufacture,
+                ModelNumber = modelNumber,
+                PlatformVersion = platformVersion,
+                OsVersion = osVersion,
+                HardwareVersion = hardwareVersion,
+                FirmwareVersion = firmwareVersion,
+                SupportUrl = supportUrl,
+                SystemTime = systemTime
+            };
+
+            return e;
+        }
+
+        private static FindingErrorOccurredEventArgs GetFindingErrorOccurredEventArgs(int requestId, int err)
+        {
+            FindingErrorOccurredEventArgs e = new FindingErrorOccurredEventArgs()
+            {
+                RequestId = requestId,
+                Error = IoTConnectivityErrorFactory.GetException(err)
+            };
+            return e;
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityErrorFactory.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityErrorFactory.cs
new file mode 100755 (executable)
index 0000000..dc29628
--- /dev/null
@@ -0,0 +1,137 @@
+/// 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 Tizen.Internals.Errors;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    internal enum IoTConnectivityError
+    {
+        None = ErrorCode.None,
+        InvalidParameter = ErrorCode.InvalidParameter,
+        OutOfMemory = ErrorCode.OutOfMemory,
+        Io = ErrorCode.IoError,
+        PermissionDenied = ErrorCode.PermissionDenied,
+        NotSupported = ErrorCode.NotSupported,
+        NoData = ErrorCode.NoData,
+        TimedOut = ErrorCode.TimedOut,
+        // TODO: Fix IoTivity error mask
+        Representation = 0x10700000 | 0x01,
+        InvalidType = 0x10700000 | 0x02,
+        Already = 0x10700000 | 0x03,
+        System = 0x10700000 | 0x04,
+    }
+
+    internal static class IoTConnectivityErrorFactory
+    {
+        internal const string LogTag = "Tizen.Network.IoTConnectivity";
+
+        internal static void ThrowException(int err)
+        {
+            IoTConnectivityError error = (IoTConnectivityError)err;
+            if (error == IoTConnectivityError.OutOfMemory)
+            {
+                throw new InvalidOperationException("Out of memory");
+            }
+            else if (error == IoTConnectivityError.InvalidParameter)
+            {
+                throw new ArgumentException("Invalid parameter");
+            }
+            else if (error == IoTConnectivityError.Io)
+            {
+                throw new ArgumentException("I/O Error");
+            }
+            else if (error == IoTConnectivityError.NoData)
+            {
+                throw new ArgumentException("No data found");
+            }
+            else if (error == IoTConnectivityError.TimedOut)
+            {
+                throw new ArgumentException("timed out");
+            }
+            else if (error == IoTConnectivityError.PermissionDenied)
+            {
+                throw new ArgumentException("Permission denied");
+            }
+            else if (error == IoTConnectivityError.NotSupported)
+            {
+                throw new ArgumentException("Not supported");
+            }
+            else if (error == IoTConnectivityError.Representation)
+            {
+                throw new ArgumentException("Representation error");
+            }
+            else if (error == IoTConnectivityError.InvalidType)
+            {
+                throw new ArgumentException("Invalid type");
+            }
+            else if (error == IoTConnectivityError.Already)
+            {
+                throw new ArgumentException("Duplicate");
+            }
+            else if (error == IoTConnectivityError.System)
+            {
+                throw new InvalidOperationException("System error");
+            }
+        }
+
+        internal static Exception GetException(int err)
+        {
+            IoTConnectivityError error = (IoTConnectivityError)err;
+            if (error == IoTConnectivityError.OutOfMemory)
+            {
+                return new InvalidOperationException("Out of memory");
+            }
+            else if (error == IoTConnectivityError.InvalidParameter)
+            {
+                return new ArgumentException("Invalid parameter");
+            }
+            else if (error == IoTConnectivityError.Io)
+            {
+                return new ArgumentException("I/O Error");
+            }
+            else if (error == IoTConnectivityError.NoData)
+            {
+                return new ArgumentException("No data found");
+            }
+            else if (error == IoTConnectivityError.TimedOut)
+            {
+                return new ArgumentException("timed out");
+            }
+            else if (error == IoTConnectivityError.PermissionDenied)
+            {
+                return new ArgumentException("Permission denied");
+            }
+            else if (error == IoTConnectivityError.NotSupported)
+            {
+                return new ArgumentException("Not supported");
+            }
+            else if (error == IoTConnectivityError.Representation)
+            {
+                return new ArgumentException("Representation error");
+            }
+            else if (error == IoTConnectivityError.InvalidType)
+            {
+                return new ArgumentException("Invalid type");
+            }
+            else if (error == IoTConnectivityError.Already)
+            {
+                return new ArgumentException("Duplicate");
+            }
+            else if (error == IoTConnectivityError.System)
+            {
+                return new InvalidOperationException("System error");
+            }
+            else
+            {
+                return new InvalidOperationException("Invalid operation");
+            }
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityServerManager.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/IoTConnectivityServerManager.cs
new file mode 100755 (executable)
index 0000000..11f3320
--- /dev/null
@@ -0,0 +1,85 @@
+/// 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;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// IoT connectivity server manager.
+    /// </summary>
+    public static class IoTConnectivityServerManager
+    {
+        /// <summary>
+        /// Initializes connection with IoTCon service
+        /// </summary>
+        public static void Initialize()
+        {
+            int ret = Interop.IoTConnectivity.Client.IoTCon.Initialize();
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to initialize");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Disconnects with IoTCon service
+        /// </summary>
+        public static void Deinitialize()
+        {
+            Interop.IoTConnectivity.Client.IoTCon.Deinitialize();
+        }
+
+        /// <summary>
+        /// Registers a resource to be available from IoTCon server
+        /// </summary>
+        /// <param name="resource">The resource to register</param>
+        public static void RegisterResource(Resource resource)
+        {
+            IntPtr handle = IntPtr.Zero;
+            int ret = Interop.IoTConnectivity.Server.Resource.Create(resource.UriPath, resource.Types._resourceTypeHandle, resource.Interfaces.ResourceInterfacesHandle, (int)resource.Policy, resource.OnRequest, IntPtr.Zero, out handle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed create resource");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+            else
+            {
+                resource.ResourceHandle = handle;
+            }
+        }
+
+        /// <summary>
+        /// Starts presence of a server
+        /// </summary>
+        /// <param name="time">The interval of announcing presence in seconds.</param>
+        public static void StartSendingPresence(uint time)
+        {
+            int ret = Interop.IoTConnectivity.Server.IoTCon.StartPresence(time);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to start presence");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Stops presence of a server.
+        /// </summary>
+        public static void StopSendingPresence()
+        {
+            int ret = Interop.IoTConnectivity.Server.IoTCon.StopPresence();
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed cancel presence");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/LiteResource.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/LiteResource.cs
new file mode 100755 (executable)
index 0000000..e55b823
--- /dev/null
@@ -0,0 +1,130 @@
+/// 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.Collections.Generic;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    public class LiteResource : Resource
+    {
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="uri">The uri path of the lite resource</param>
+        /// <param name="types">Resource type</param>
+        /// <param name="policy">Policy of the resource</param>
+        /// <param name="state">Optional State of the resource</param>
+        public LiteResource(string uri, ResourceTypes types, ResourcePolicy policy, State state = null)
+            : base(uri, types, new ResourceInterfaces(new string[] { ResourceInterfaces.DefaultInterface }), policy)
+        {
+            State = state;
+        }
+
+        /// <summary>
+        /// The state of the lite resource
+        /// </summary>
+        public State State { get; set; }
+
+        /// <summary>
+        /// The method to accept post request
+        /// </summary>
+        /// <param name="state">The new state of the lite resource</param>
+        /// <returns>true to accept post request, false to reject it</returns>
+        public virtual bool OnPost(State state)
+        {
+            return true;
+        }
+
+        /// <summary>
+        /// Called on the get event.
+        /// </summary>
+        /// <param name="request">Request.</param>
+        public sealed override Response OnGet(Request request)
+        {
+            Representation representation = new Representation()
+            {
+                UriPath = UriPath,
+                Interface = Interfaces,
+                Type = Types,
+                State = State
+            };
+
+            Response response = new Response()
+            {
+                Representation = representation,
+                Result = ResponseCode.Ok
+            };
+
+            return response;
+        }
+
+        /// <summary>
+        /// Called on the put event.
+        /// </summary>
+        /// <param name="request">Request.</param>
+        public sealed override Response OnPut(Request request)
+        {
+            Response response = new Response();
+            response.Result = ResponseCode.Forbidden;
+            return response;
+        }
+
+        /// <summary>
+        /// Called on the post event.
+        /// </summary>
+        /// <param name="request">Request.</param>
+        public sealed override Response OnPost(Request request)
+        {
+            if (OnPost(request.Representation.State))
+            {
+                State = request.Representation.State;
+                Representation representation = new Representation() {
+                    UriPath = UriPath,
+                    Interface = Interfaces,
+                    Type = Types,
+                    State = State
+                };
+
+                Response response = new Response() {
+                    Representation = representation,
+                    Result = ResponseCode.Ok
+                };
+
+                Notify(representation, QualityOfService.High);
+                return response;
+            }
+
+            return new Response()
+            {
+                Result = ResponseCode.Error
+            };
+        }
+
+        /// <summary>
+        /// Called on the delete event.
+        /// </summary>
+        /// <param name="request">Request.</param>
+        public sealed override Response OnDelete(Request request)
+        {
+            Response response = new Response();
+            response.Result = ResponseCode.Forbidden;
+            return response;
+        }
+
+        /// <summary>
+        /// Called on the observing event.
+        /// </summary>
+        /// <param name="request">Request.</param>
+        /// <param name="observerType">Observer type</param>
+        /// <param name="observeId">Observe identifier.</param>
+        public sealed override bool OnObserving(Request request, ObserveType observeType, int observeId)
+        {
+            return true;
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ObservePolicy.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ObservePolicy.cs
new file mode 100755 (executable)
index 0000000..0d013db
--- /dev/null
@@ -0,0 +1,25 @@
+/// 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.
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// Indicates delete method of request
+    /// </summary>
+    public enum ObservePolicy
+    {
+        /// <summary>
+        /// Indicates observation request for most up-to-date notifications only
+        /// </summary>
+        IgnoreOutOfOrder = 0,
+        /// <summary>
+        /// Indicates observation request for all notifications including stale notifications
+        /// </summary>
+        AcceptOutOfOrder
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ObserveType.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ObserveType.cs
new file mode 100755 (executable)
index 0000000..6ff7ec0
--- /dev/null
@@ -0,0 +1,32 @@
+/// 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.
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// Observe type.
+    /// </summary>
+    public enum ObserveType
+    {
+        /// <summary>
+        /// No observe action
+        /// </summary>
+        NoType = 0,
+
+        /// <summary>
+        /// Indicates action of registering observation
+        /// </summary>
+        Register = 1,
+
+        /// <summary>
+        /// Indicates action of unregistering observation
+        /// </summary>
+        Deregister = 2,
+    }
+}
+
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ObserverNotifiedEventArgs.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ObserverNotifiedEventArgs.cs
new file mode 100755 (executable)
index 0000000..46b1397
--- /dev/null
@@ -0,0 +1,30 @@
+/// 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;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// ObserverNotifiedEventArgs class. This class is an event arguments of the ObserverNotified event.
+    /// </summary>
+    public class ObserverNotifiedEventArgs : EventArgs
+    {
+        /// <summary>
+        /// Result property.
+        /// </summary>
+        /// <returns>ResponseCode Result.</returns>
+        public ResponseCode Result { get; internal set; }
+
+        /// <summary>
+        /// Representation property.
+        /// </summary>
+        /// <returns>Representation Representation.</returns>
+        public Representation Representation { get; internal set; }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/PlatformInformationFoundEventArgs.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/PlatformInformationFoundEventArgs.cs
new file mode 100755 (executable)
index 0000000..b085872
--- /dev/null
@@ -0,0 +1,76 @@
+/// 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.
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// PlatformInformationFoundEventArgs class. This class is an event arguments of the PlatformInformationFound event.
+    /// </summary>
+    public class PlatformInformationFoundEventArgs
+    {
+        /// <summary>
+        /// The request id
+        /// </summary>
+        public int RequestId { get; internal set; }
+
+        /// <summary>
+        /// The platform identifier
+        /// </summary>
+        public string PlatformId { get; internal set; }
+
+        /// <summary>
+        /// The name of manufacturer
+        /// </summary>
+        public string ManufacturerName { get; internal set; }
+
+        /// <summary>
+        /// URL of the manufacturer
+        /// </summary>
+        public string ManufacturerURL { get; internal set; }
+
+        /// <summary>
+        /// Model number as designated by manufacturer
+        /// </summary>
+        public string ModelNumber { get; internal set; }
+
+        /// <summary>
+        /// Manugacturing date of the device
+        /// </summary>
+        public string DateOfManufacture { get; internal set; }
+
+        /// <summary>
+        /// Version of platfrom defined by manufacturer
+        /// </summary>
+        public string PlatformVersion { get; internal set; }
+
+        /// <summary>
+        /// Version of platfrom resident OS
+        /// </summary>
+        public string OsVersion { get; internal set; }
+
+        /// <summary>
+        /// Version of platform Hardware
+        /// </summary>
+        public string HardwareVersion { get; internal set; }
+
+        /// <summary>
+        /// Version of device firmware
+        /// </summary>
+        public string FirmwareVersion { get; internal set; }
+
+        /// <summary>
+        /// URL that points to support information from manufacturer
+        /// </summary>
+        public string SupportUrl { get; internal set; }
+
+        /// <summary>
+        /// Reference time of the device
+        /// </summary>
+        public string SystemTime { get; internal set; }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/PresenceEventType.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/PresenceEventType.cs
new file mode 100755 (executable)
index 0000000..19d2cc4
--- /dev/null
@@ -0,0 +1,29 @@
+/// 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.
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// Enumeration for presence events.
+    /// </summary>
+    public enum PresenceEventType
+    {
+        /// <summary>
+        /// Indicates for resource creation operation of server
+        /// </summary>
+        ResourceCreated = 0,
+        /// <summary>
+        /// Indicates for resource creation operation of server
+        /// </summary>
+        ResourceUpdated,
+        /// <summary>
+        /// Indicates for resource destruction operation of server
+        /// </summary>
+        ResourceDestroyed
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/PresenceReceivedEventArgs.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/PresenceReceivedEventArgs.cs
new file mode 100755 (executable)
index 0000000..053b575
--- /dev/null
@@ -0,0 +1,42 @@
+/// 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;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// PresenceReceivedEventArgs class. This class is an event arguments of the PresenceReceived event.
+    /// </summary>
+    public class PresenceReceivedEventArgs : EventArgs
+    {
+        /// <summary>
+        /// PresenceId property.
+        /// </summary>
+        /// <returns>int PresenceId.</returns>
+        public int PresenceId { get; internal set; }
+
+        /// <summary>
+        /// EventType property.
+        /// </summary>
+        /// <returns>PresenceEventType EventType.</returns>
+        public PresenceEventType EventType { get; internal set; }
+
+        /// <summary>
+        /// HostAddress property.
+        /// </summary>
+        /// <returns>string HostAddress.</returns>
+        public string HostAddress { get; internal set; }
+
+        /// <summary>
+        /// Type property.
+        /// </summary>
+        /// <returns>string Type.</returns>
+        public string Type { get; internal set; }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/QualityOfService.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/QualityOfService.cs
new file mode 100755 (executable)
index 0000000..65624e6
--- /dev/null
@@ -0,0 +1,25 @@
+/// 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.
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// Indicates observation request for all notifications including stale notifications
+    /// </summary>
+    public enum QualityOfService
+    {
+        /// <summary>
+        /// Indicates low quality of service
+        /// </summary>
+        Low = 0,
+        /// <summary>
+        /// Indicates high quality of service
+        /// </summary>
+        High
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResource.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResource.cs
new file mode 100755 (executable)
index 0000000..fcfc6f0
--- /dev/null
@@ -0,0 +1,728 @@
+/// 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.Collections.Generic;
+using System.Net;
+using System.Threading.Tasks;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// RemoteResource class
+    /// </summary>
+    public class RemoteResource : IDisposable
+    {
+        internal const int TimeOutMax = 3600;
+        internal IntPtr _remoteResourceHandle = IntPtr.Zero;
+
+        private bool _disposed = false;
+        private bool _cacheEnabled = false;
+        private ResourceOptions _options;
+
+        private int _responseCallbackId = 1;
+        private static Dictionary<IntPtr, Interop.IoTConnectivity.Client.RemoteResource.ResponseCallback> _responseCallbacksMap = new Dictionary<IntPtr, Interop.IoTConnectivity.Client.RemoteResource.ResponseCallback>();
+
+        private Interop.IoTConnectivity.Client.RemoteResource.CachedRepresentationChangedCallback _cacheUpdatedCallback;
+        private Interop.IoTConnectivity.Client.RemoteResource.StateChangedCallback _stateChangedCallback;
+        private Interop.IoTConnectivity.Client.RemoteResource.ObserveCallback _observeCallback;
+
+        private EventHandler<StateChangedEventArgs> _stateChangedEventHandler;
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        public RemoteResource(string hostAddress, string uriPath, ResourcePolicy policy, ResourceTypes resourceTypes, ResourceInterfaces resourceInterfaces)
+        {
+            if (hostAddress == null || uriPath == null || resourceTypes == null || resourceInterfaces == null)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Invalid parameters");
+                throw new ArgumentException("Invalid parameter");
+            }
+
+            HostAddress = hostAddress;
+            UriPath = uriPath;
+            Policy = policy;
+            Types = new List<string>(resourceTypes);
+            Interfaces = new List<string>(resourceInterfaces);
+            DeviceId = null;
+
+            CreateRemoteResource(resourceTypes._resourceTypeHandle, resourceInterfaces.ResourceInterfacesHandle);
+        }
+
+        internal RemoteResource(IntPtr handleToClone)
+        {
+            int ret = Interop.IoTConnectivity.Client.RemoteResource.Clone(handleToClone, out _remoteResourceHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Faled to clone");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+            SetRemoteResource();
+        }
+
+        ~RemoteResource()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// Event that is called to cache resource attribute's
+        /// </summary>
+        public event EventHandler<CacheUpdatedEventArgs> CacheUpdated;
+
+        /// <summary>
+        /// Observe event on the resource
+        /// </summary>
+        public event EventHandler<ObserverNotifiedEventArgs> ObserverNotified;
+
+        /// <summary>
+        /// Event that is called when remote resource's state are changed
+        /// </summary>
+        public event EventHandler<StateChangedEventArgs> StateChanged
+        {
+            add
+            {
+                if (_stateChangedEventHandler == null)
+                {
+                    RegisterStateChangedEvent();
+                }
+                _stateChangedEventHandler += value;
+            }
+            remove
+            {
+                _stateChangedEventHandler -= value;
+                if (_stateChangedEventHandler == null)
+                {
+                    UnregisterStateChangedEvent();
+                }
+            }
+        }
+
+        /// <summary>
+        /// The host address of the resource
+        /// </summary>
+        public string HostAddress { get; private set; }
+
+        /// <summary>
+        /// The URI path of the resource
+        /// </summary>
+        public string UriPath { get; private set; }
+
+        /// <summary>
+        /// The resource types of the remote resource
+        /// </summary>
+        public IEnumerable<string> Types { get; private set; }
+
+        /// <summary>
+        /// The interfaces of the resource
+        /// </summary>
+        public IEnumerable<string> Interfaces { get; private set; }
+
+        /// <summary>
+        /// The policy of the resource
+        /// </summary>
+        public ResourcePolicy Policy { get; private set; }
+
+        /// <summary>
+        /// The header options of the resource
+        /// </summary>
+        public ResourceOptions Options
+        {
+            get
+            {
+                return _options;
+            }
+            set
+            {
+                _options = value;
+                if (value != null)
+                {
+                    int ret = Interop.IoTConnectivity.Client.RemoteResource.SetOptions(_remoteResourceHandle, value._resourceOptionsHandle);
+                    if (ret != (int)IoTConnectivityError.None)
+                    {
+                        Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to set options");
+                        throw IoTConnectivityErrorFactory.GetException(ret);
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// Cache enabled property
+        /// </summary>
+        public bool CacheEnabled
+        {
+            get
+            {
+                return _cacheEnabled;
+            }
+            set
+            {
+                if (_cacheEnabled != value)
+                {
+                    _cacheEnabled = value;
+                    HandleCachePolicyChanged();
+                }
+            }
+        }
+
+        /// <summary>
+        /// Time interval of monitoring and caching API
+        /// </summary>
+        public int TimeInterval
+        {
+            get
+            {
+                int interval;
+                int ret = Interop.IoTConnectivity.Client.RemoteResource.GetTimeInterval(_remoteResourceHandle, out interval);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Warn(IoTConnectivityErrorFactory.LogTag, "Failed to get time interval");
+                    return 0;
+                }
+                return interval;
+            }
+            set
+            {
+                int ret = (int)IoTConnectivityError.InvalidParameter;
+                if (value < TimeOutMax && value > 0)
+                {
+                    ret = Interop.IoTConnectivity.Client.RemoteResource.SetTimeInterval(_remoteResourceHandle, value);
+                }
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to set time interval");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// The device id of the resource
+        /// </summary>
+        public string DeviceId { get; private set; }
+
+        /// <summary>
+        /// Gets cached representation of the remote resource
+        /// </summary>
+        public Representation CachedRepresentation()
+        {
+            IntPtr handle;
+            int ret = Interop.IoTConnectivity.Client.RemoteResource.GetCachedRepresentation(_remoteResourceHandle, out handle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Warn(IoTConnectivityErrorFactory.LogTag, "Failed to get CachedRepresentation");
+                return null;
+            }
+
+            Representation representation = new Representation(handle);
+            return representation;
+        }
+
+        /// <summary>
+        /// Registers the observe callback on the resource
+        /// </summary>
+        /// <param name="policy">The type to specify how client wants to observe</param>
+        /// <param name="query">The ResourceQuery to send to server</param>
+        public void StartObserving(ObservePolicy policy, ResourceQuery query = null)
+        {
+            _observeCallback = (IntPtr resource, int err, int sequenceNumber, IntPtr response, IntPtr userData) =>
+            {
+                int result;
+                IntPtr representationHandle;
+                int ret = Interop.IoTConnectivity.Server.Response.GetResult(response, out result);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get result");
+                    return;
+                }
+
+                ret = Interop.IoTConnectivity.Server.Response.GetRepresentation(response, out representationHandle);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get representation");
+                    return;
+                }
+
+                Representation repr = null;
+                try
+                {
+                    repr = new Representation(representationHandle);
+                }
+                catch (Exception exp)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to new representation: " + exp.Message);
+                    return;
+                }
+
+                ObserverNotifiedEventArgs e = new ObserverNotifiedEventArgs()
+                {
+                    Representation = repr,
+                    Result = (ResponseCode)result
+                };
+                ObserverNotified?.Invoke(null, e);
+            };
+
+            IntPtr queryHandle = IntPtr.Zero;
+            if (query != null)
+            {
+                queryHandle = query._resourceQueryHandle;
+            }
+
+            int errCode = Interop.IoTConnectivity.Client.RemoteResource.RegisterObserve(_remoteResourceHandle, (int)policy, queryHandle, _observeCallback, IntPtr.Zero);
+            if (errCode != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to register observe callbacks");
+                throw IoTConnectivityErrorFactory.GetException(errCode);
+            }
+        }
+
+        /// <summary>
+        /// Deregisters the observe callback on the resource
+        /// </summary>
+        public void StopObserving()
+        {
+            int ret = Interop.IoTConnectivity.Client.RemoteResource.DeregisterObserve(_remoteResourceHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to deregister observe callbacks");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Gets the attributes of a resource
+        /// </summary>
+        /// <param name="query">The ResourceQuery to send to server</param>
+        /// <returns></returns>
+        public async Task<RemoteResponse> GetAsync(ResourceQuery query = null)
+        {
+            TaskCompletionSource<RemoteResponse> tcsRemoteResponse = new TaskCompletionSource<RemoteResponse>();
+
+            IntPtr id = IntPtr.Zero;
+            lock (_responseCallbacksMap)
+            {
+                id = (IntPtr)_responseCallbackId++;
+            }
+            _responseCallbacksMap[id] = (IntPtr resource, int err, int requestType, IntPtr responseHandle, IntPtr userData) =>
+            {
+                IntPtr responseCallbackId = userData;
+                lock(_responseCallbacksMap)
+                {
+                    _responseCallbacksMap.Remove(responseCallbackId);
+                }
+
+                if (responseHandle != IntPtr.Zero)
+                {
+                    try
+                    {
+                        tcsRemoteResponse.TrySetResult(GetRemoteResponse(responseHandle));
+                    }
+                    catch(Exception exp)
+                    {
+                        Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get RemoteResponse: ", exp.Message);
+                        tcsRemoteResponse.TrySetException(exp);
+                    }
+                }
+                else
+                {
+                    tcsRemoteResponse.TrySetException(IoTConnectivityErrorFactory.GetException((int)IoTConnectivityError.System));
+                }
+            };
+
+            IntPtr queryHandle = (query == null) ? IntPtr.Zero : query._resourceQueryHandle;
+            int errCode = Interop.IoTConnectivity.Client.RemoteResource.Get(_remoteResourceHandle, queryHandle, _responseCallbacksMap[id], id);
+            if (errCode != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get resource attributes");
+                tcsRemoteResponse.TrySetException(IoTConnectivityErrorFactory.GetException(errCode));
+            }
+            return await tcsRemoteResponse.Task;
+        }
+
+        /// <summary>
+        /// Puts the representation of a resource, asynchronously.
+        /// </summary>
+        /// <param name="representation">Resource representation</param>
+        /// <param name="query">The ResourceQuery to send to server</param>
+        /// <returns></returns>
+        public async Task<RemoteResponse> PutAsync(Representation representation, ResourceQuery query = null)
+        {
+            TaskCompletionSource<RemoteResponse> tcsRemoteResponse = new TaskCompletionSource<RemoteResponse>();
+
+            IntPtr id = IntPtr.Zero;
+            lock (_responseCallbacksMap)
+            {
+                id = (IntPtr)_responseCallbackId++;
+            }
+            _responseCallbacksMap[id] = (IntPtr resource, int err, int requestType, IntPtr responseHandle, IntPtr userData) =>
+            {
+                IntPtr responseCallbackId = userData;
+                lock (_responseCallbacksMap)
+                {
+                    _responseCallbacksMap.Remove(responseCallbackId);
+                }
+
+                if (responseHandle != IntPtr.Zero)
+                {
+                    try
+                    {
+                        tcsRemoteResponse.TrySetResult(GetRemoteResponse(responseHandle));
+                    }
+                    catch (Exception exp)
+                    {
+                        Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get RemoteResponse: ", exp.Message);
+                        tcsRemoteResponse.TrySetException(exp);
+                    }
+                }
+                else
+                {
+                    tcsRemoteResponse.TrySetException(IoTConnectivityErrorFactory.GetException((int)IoTConnectivityError.System));
+                }
+            };
+
+            IntPtr queryHandle = (query == null) ? IntPtr.Zero : query._resourceQueryHandle;
+            int errCode = Interop.IoTConnectivity.Client.RemoteResource.Put(_remoteResourceHandle, representation._representationHandle, queryHandle, _responseCallbacksMap[id], id);
+            if (errCode != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to put resource representation");
+                tcsRemoteResponse.TrySetException(IoTConnectivityErrorFactory.GetException(errCode));
+            }
+            return await tcsRemoteResponse.Task;
+        }
+
+        /// <summary>
+        /// Post request on a resource
+        /// </summary>
+        /// <param name="representation">Resource representation</param>
+        /// <param name="query">The ResourceQuery to send to server</param>
+        /// <returns></returns>
+        public async Task<RemoteResponse> PostAsync(Representation representation, ResourceQuery query = null)
+        {
+            TaskCompletionSource<RemoteResponse> tcsRemoteResponse = new TaskCompletionSource<RemoteResponse>();
+
+            IntPtr id = IntPtr.Zero;
+            lock (_responseCallbacksMap)
+            {
+                id = (IntPtr)_responseCallbackId++;
+            }
+            _responseCallbacksMap[id] = (IntPtr resource, int err, int requestType, IntPtr responseHandle, IntPtr userData) =>
+            {
+                IntPtr responseCallbackId = userData;
+                lock (_responseCallbacksMap)
+                {
+                    _responseCallbacksMap.Remove(responseCallbackId);
+                }
+
+                if (responseHandle != IntPtr.Zero)
+                {
+                    try
+                    {
+                        tcsRemoteResponse.TrySetResult(GetRemoteResponse(responseHandle));
+                    }
+                    catch (Exception exp)
+                    {
+                        Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get RemoteResponse: ", exp.Message);
+                        tcsRemoteResponse.TrySetException(exp);
+                    }
+                }
+                else
+                {
+                    tcsRemoteResponse.TrySetException(IoTConnectivityErrorFactory.GetException((int)IoTConnectivityError.System));
+                }
+            };
+
+            IntPtr queryHandle = (query == null) ? IntPtr.Zero : query._resourceQueryHandle;
+            int errCode = Interop.IoTConnectivity.Client.RemoteResource.Post(_remoteResourceHandle, representation._representationHandle, queryHandle, _responseCallbacksMap[id], id);
+            if (errCode != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to post request");
+                tcsRemoteResponse.TrySetException(IoTConnectivityErrorFactory.GetException(errCode));
+            }
+            return await tcsRemoteResponse.Task;
+        }
+
+        /// <summary>
+        /// Delete the resource
+        /// </summary>
+        /// <returns></returns>
+        public async Task<RemoteResponse> DeleteAsync()
+        {
+            TaskCompletionSource<RemoteResponse> tcsRemoteResponse = new TaskCompletionSource<RemoteResponse>();
+
+            IntPtr id = IntPtr.Zero;
+            lock (_responseCallbacksMap)
+            {
+                id = (IntPtr)_responseCallbackId++;
+            }
+            _responseCallbacksMap[id] = (IntPtr resource, int err, int requestType, IntPtr responseHandle, IntPtr userData) =>
+            {
+                IntPtr responseCallbackId = userData;
+                lock (_responseCallbacksMap)
+                {
+                    _responseCallbacksMap.Remove(responseCallbackId);
+                }
+
+                if (responseHandle != IntPtr.Zero)
+                {
+                    try
+                    {
+                        tcsRemoteResponse.TrySetResult(GetRemoteResponse(responseHandle));
+                    }
+                    catch (Exception exp)
+                    {
+                        Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get RemoteResponse: ", exp.Message);
+                        tcsRemoteResponse.TrySetException(exp);
+                    }
+                }
+                else
+                {
+                    tcsRemoteResponse.TrySetException(IoTConnectivityErrorFactory.GetException((int)IoTConnectivityError.System));
+                }
+            };
+
+            int errCode = Interop.IoTConnectivity.Client.RemoteResource.Delete(_remoteResourceHandle, _responseCallbacksMap[id], id);
+            if (errCode != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to delete");
+                tcsRemoteResponse.TrySetException(IoTConnectivityErrorFactory.GetException(errCode));
+            }
+            return await tcsRemoteResponse.Task;
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        internal static Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType GetConnectivityType(string hostAddress)
+        {
+            Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType type = Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.None;
+
+            if (hostAddress == IoTConnectivityClientManager.MulticastAddress)
+            {
+                type = Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.Ipv4;
+            }
+            else
+            {
+                IPAddress address;
+                if (IPAddress.TryParse(hostAddress, out address))
+                {
+                    switch (address.AddressFamily)
+                    {
+                        case System.Net.Sockets.AddressFamily.InterNetwork:
+                            type = Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.Ipv4;
+                            break;
+                        case System.Net.Sockets.AddressFamily.InterNetworkV6:
+                            type = Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.Ipv6;
+                            break;
+                        default:
+                            Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to parse for Ipv4 or Ipv6");
+                            break;
+                    }
+                }
+            }
+            return type;
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects
+            }
+
+            Interop.IoTConnectivity.Client.RemoteResource.Destroy(_remoteResourceHandle);
+            _disposed = true;
+        }
+
+        private void HandleCachePolicyChanged()
+        {
+            if (_cacheEnabled)
+            {
+                _cacheUpdatedCallback = (IntPtr resource, IntPtr representation, IntPtr userData) =>
+                {
+                    if (CacheEnabled)
+                    {
+                        Representation repr = null;
+                        try
+                        {
+                            repr = new Representation(representation);
+                        }
+                        catch (Exception exp)
+                        {
+                            Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to new Representation: " + exp.Message);
+                            return;
+                        }
+
+                        CacheUpdatedEventArgs e = new CacheUpdatedEventArgs()
+                        {
+                            Representation = repr
+                        };
+                        CacheUpdated?.Invoke(null, e);
+                    }
+                };
+
+                int ret = Interop.IoTConnectivity.Client.RemoteResource.StartCaching(_remoteResourceHandle, _cacheUpdatedCallback, IntPtr.Zero);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add cache updated event handler");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+            else
+            {
+                int ret = Interop.IoTConnectivity.Client.RemoteResource.StopCaching(_remoteResourceHandle);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove cache updated event handler");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+        }
+
+        private void RegisterStateChangedEvent()
+        {
+            _stateChangedCallback = (IntPtr resource, int state, IntPtr userData) =>
+            {
+                StateChangedEventArgs e = new StateChangedEventArgs()
+                {
+                    State = (ResourceState)state
+                };
+                _stateChangedEventHandler?.Invoke(null, e);
+            };
+
+            int ret = Interop.IoTConnectivity.Client.RemoteResource.StartMonitoring(_remoteResourceHandle, _stateChangedCallback, IntPtr.Zero);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state changed event handler");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        private void UnregisterStateChangedEvent()
+        {
+            int ret = Interop.IoTConnectivity.Client.RemoteResource.StopMonitoring(_remoteResourceHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove state changed event handler");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        private void CreateRemoteResource(IntPtr resourceTypeHandle, IntPtr resourceInterfaceHandle)
+        {
+            Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType connectivityType = GetConnectivityType(HostAddress);
+            if (connectivityType == Interop.IoTConnectivity.Client.RemoteResource.ConnectivityType.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Unable to parse host address");
+                throw new ArgumentException("Unable to parse host address");
+            }
+            int ret = Interop.IoTConnectivity.Client.RemoteResource.Create(HostAddress, (int)connectivityType, UriPath, (int)Policy, resourceTypeHandle, resourceInterfaceHandle, out _remoteResourceHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get remote resource");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        private void SetRemoteResource()
+        {
+            string hostAddress, uriPath;
+            int ret = Interop.IoTConnectivity.Client.RemoteResource.GetHostAddress(_remoteResourceHandle, out hostAddress);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Faled to get host address");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            ret = Interop.IoTConnectivity.Client.RemoteResource.GetUriPath(_remoteResourceHandle, out uriPath);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Faled to get uri path");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            int policy = (int)ResourcePolicy.NoProperty;
+            ret = Interop.IoTConnectivity.Client.RemoteResource.GetProperties(_remoteResourceHandle, out policy);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Faled to get uri path");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            IntPtr typesHandle, interfacesHandle;
+            ret = Interop.IoTConnectivity.Client.RemoteResource.GetTypes(_remoteResourceHandle, out typesHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get resource types");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            ret = Interop.IoTConnectivity.Client.RemoteResource.GetInterfaces(_remoteResourceHandle, out interfacesHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get resource interfaces");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            string deviceId;
+            ret = Interop.IoTConnectivity.Client.RemoteResource.GetDeviceId(_remoteResourceHandle, out deviceId);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get device id");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            DeviceId = deviceId;
+            HostAddress = hostAddress;
+            UriPath = uriPath;
+            Types = new ResourceTypes(typesHandle);
+            Interfaces = new ResourceInterfaces(interfacesHandle);
+            Policy = (ResourcePolicy)policy;
+        }
+
+        private RemoteResponse GetRemoteResponse(IntPtr response)
+        {
+            int result;
+            IntPtr representationHandle, optionsHandle;
+            int ret = Interop.IoTConnectivity.Server.Response.GetResult(response, out result);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get result");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            ret = Interop.IoTConnectivity.Server.Response.GetRepresentation(response, out representationHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get representation");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            ret = Interop.IoTConnectivity.Server.Response.GetOptions(response, out optionsHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get options");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            return new RemoteResponse()
+            {
+                Result = (ResponseCode)result,
+                Representation = new Representation(representationHandle),
+                Options = new ResourceOptions(optionsHandle)
+            };
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResponse.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResponse.cs
new file mode 100755 (executable)
index 0000000..151ce0f
--- /dev/null
@@ -0,0 +1,31 @@
+/// 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.
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// RemoteResponse Class
+    /// </summary>
+    public class RemoteResponse
+    {
+        /// <summary>
+        /// Indicates the result of the response
+        /// </summary>
+        public ResponseCode Result { get; internal set; }
+
+        /// <summary>
+        /// Indicates representation of the response
+        /// </summary>
+        public Representation Representation { get; internal set; }
+
+        /// <summary>
+        /// Indicates header options of the response
+        /// </summary>
+        public ResourceOptions Options { get; internal set; }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Representation.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Representation.cs
new file mode 100755 (executable)
index 0000000..7297875
--- /dev/null
@@ -0,0 +1,226 @@
+/// 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.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// Class containing representation of a resource
+    /// </summary>
+    public class Representation : IDisposable
+    {
+        internal IntPtr _representationHandle = IntPtr.Zero;
+
+        private bool _disposed = false;
+        private ObservableCollection<Representation> _children = new ObservableCollection<Representation>();
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        public Representation()
+        {
+            int ret = Interop.IoTConnectivity.Common.Representation.Create(out _representationHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create representation");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            _children.CollectionChanged += ChildrenCollectionChanged;
+        }
+
+        // Constructor for cloning native representation object
+        internal Representation(IntPtr handleToClone)
+        {
+            int ret = (int)IoTConnectivityError.InvalidParameter;
+            if (handleToClone != IntPtr.Zero)
+            {
+                ret = Interop.IoTConnectivity.Common.Representation.Clone(handleToClone, out _representationHandle);
+            }
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create representation");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            _children.CollectionChanged += ChildrenCollectionChanged;
+        }
+
+        ~Representation()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// The URI of resource
+        /// </summary>
+        public string UriPath
+        {
+            get
+            {
+                string path;
+                int ret = Interop.IoTConnectivity.Common.Representation.GetUriPath(_representationHandle, out path);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to Get uri");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+                return path;
+            }
+            set
+            {
+                int ret = (int)IoTConnectivityError.InvalidParameter;
+                if (value != null)
+                    ret = Interop.IoTConnectivity.Common.Representation.SetUriPath(_representationHandle, value);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to set uri");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// The type of resource
+        /// </summary>
+        public ResourceTypes Type
+        {
+            get
+            {
+                IntPtr typeHandle;
+                int ret = Interop.IoTConnectivity.Common.Representation.GetResourceTypes(_representationHandle, out typeHandle);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get type");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+                return new ResourceTypes(typeHandle);
+            }
+            set
+            {
+                int ret = (int)IoTConnectivityError.InvalidParameter;
+                if (value != null)
+                    ret = Interop.IoTConnectivity.Common.Representation.SetResourceTypes(_representationHandle, value._resourceTypeHandle);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to set type");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// The interface of the resource
+        /// </summary>
+        public ResourceInterfaces Interface
+        {
+            get
+            {
+                IntPtr interfaceHandle;
+                int ret = Interop.IoTConnectivity.Common.Representation.GetResourceTypes(_representationHandle, out interfaceHandle);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get interface");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+                return new ResourceInterfaces(interfaceHandle);
+            }
+            set
+            {
+                int ret = (int)IoTConnectivityError.InvalidParameter;
+                if (value != null)
+                    ret = Interop.IoTConnectivity.Common.Representation.SetResourceTypes(_representationHandle, value.ResourceInterfacesHandle);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to set interface");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Current state of the resource
+        /// </summary>
+        public State State
+        {
+            get
+            {
+                return State;
+            }
+            set
+            {
+                State = value;
+                int ret = (int)IoTConnectivityError.InvalidParameter;
+                if (State != null)
+                    ret = Interop.IoTConnectivity.Common.Representation.SetState(_representationHandle, State._resourceStateHandle);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to set interface");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// List of Child resource representation
+        /// </summary>
+        public ICollection<Representation> Children
+        {
+            get
+            {
+                return _children;
+            }
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects
+                Type.Dispose();
+                Interface.Dispose();
+                State?.Dispose();
+            }
+
+            Interop.IoTConnectivity.Common.Representation.Destroy(_representationHandle);
+            _disposed = true;
+        }
+
+        private void ChildrenCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
+        {
+            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
+            {
+                foreach (Representation r in e.NewItems)
+                {
+                    int ret = Interop.IoTConnectivity.Common.Representation.AddChild(_representationHandle, r._representationHandle);
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+            else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
+            {
+                foreach (Representation r in e.NewItems)
+                {
+                    int ret = Interop.IoTConnectivity.Common.Representation.RemoveChild(_representationHandle, r._representationHandle);
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Request.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Request.cs
new file mode 100755 (executable)
index 0000000..fa46360
--- /dev/null
@@ -0,0 +1,66 @@
+/// 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;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// Class respresenting Request to a resource
+    /// </summary>
+    public class Request: IDisposable
+    {
+        private bool _disposed = false;
+
+        ~Request()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// The host address of the request
+        /// </summary>
+        public string HostAddress { get; internal set; }
+
+        /// <summary>
+        /// The representation of the request
+        /// </summary>
+        public Representation Representation { get; internal set; }
+
+        /// <summary>
+        /// The query of the request
+        /// </summary>
+        public ResourceQuery Query { get; internal set; }
+
+        /// <summary>
+        /// The options related to the request
+        /// </summary>
+        public ResourceOptions Options { get; internal set; }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+                return;
+
+            if (disposing)
+            {
+                Representation.Dispose();
+                Query.Dispose();
+                Options.Dispose();
+            }
+
+            _disposed = true;
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Resource.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Resource.cs
new file mode 100755 (executable)
index 0000000..6c1b12a
--- /dev/null
@@ -0,0 +1,392 @@
+/// 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.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    public abstract class Resource : IDisposable
+    {
+        private IntPtr _resourceHandle = IntPtr.Zero;
+        private bool _disposed = false;
+        private ObservableCollection<Resource> _children = new ObservableCollection<Resource>();
+        private IntPtr _observerHandle = IntPtr.Zero;
+
+        /// <summary>
+        /// The constructor
+        /// </summary>
+        /// <param name="uri">URI of the resource</param>
+        /// <param name="types">Resource types</param>
+        /// <param name="interfaces">Resource interfaces</param>
+        /// <param name="policy">Policy input of the resoruce</param>
+        public Resource(string uri, ResourceTypes types, ResourceInterfaces interfaces, ResourcePolicy policy)
+        {
+            UriPath = uri;
+            Types = types;
+            Interfaces = interfaces;
+            Policy = policy;
+
+            _children.CollectionChanged += ChildrenCollectionChanged;
+
+            int ret = Interop.IoTConnectivity.Server.Observers.Create(out _observerHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create obsever handle");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        ~Resource()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// Type details of the resource
+        /// </summary>
+        public ResourceTypes Types { get; internal set; }
+
+        /// <summary>
+        /// Interface details of the resource
+        /// </summary>
+        public ResourceInterfaces Interfaces { get; internal set; }
+
+        /// <summary>
+        /// The policy
+        /// </summary>
+        public ResourcePolicy Policy { get; internal set; }
+
+        /// <summary>
+        /// URI of the resource
+        /// </summary>
+        public string UriPath { get; internal set; }
+
+        /// <summary>
+        /// List of Child resources
+        /// </summary>
+        public ICollection<Resource> Children
+        {
+            get
+            {
+                return _children;
+            }
+        }
+
+        internal IntPtr ResourceHandle
+        {
+            get
+            {
+                return _resourceHandle;
+            }
+            set
+            {
+                _resourceHandle = value;
+            }
+        }
+
+        /// <summary>
+        /// Notify the specified representation and qos.
+        /// </summary>
+        /// <param name="representation">Representation.</param>
+        /// <param name="qos">Qos.</param>
+        public void Notify(Representation representation, QualityOfService qos)
+        {
+            int ret = (int)IoTConnectivityError.None;
+            ret = Interop.IoTConnectivity.Server.Resource.Notify(_resourceHandle, representation._representationHandle, _observerHandle, (int)qos);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to send notification");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Called on the get event.
+        /// </summary>
+        /// <param name="request">Request.</param>
+        public abstract Response OnGet(Request request);
+
+        /// <summary>
+        /// Called on the put event.
+        /// </summary>
+        /// <param name="request">Request.</param>
+        public abstract Response OnPut(Request request);
+
+        /// <summary>
+        /// Called on the post event.
+        /// </summary>
+        /// <param name="request">Request.</param>
+        public abstract Response OnPost(Request request);
+
+        /// <summary>
+        /// Called on the delete event.
+        /// </summary>
+        /// <param name="request">Request.</param>
+        public abstract Response OnDelete(Request request);
+
+        /// <summary>
+        /// Called on the observing event.
+        /// </summary>
+        /// <param name="request">Request.</param>
+        /// <param name="policy">Policy.</param>
+        /// <param name="observeId">Observe identifier.</param>
+        public abstract bool OnObserving(Request request, ObserveType type, int observeId);
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+                return;
+
+            if (disposing)
+            {
+                Types.Dispose();
+                Interfaces.Dispose();
+            }
+
+            Interop.IoTConnectivity.Server.Resource.Destroy(_resourceHandle);
+            Interop.IoTConnectivity.Server.Observers.Destroy(_observerHandle);
+            _disposed = true;
+        }
+
+        // This method is used as callback for Resource
+        internal void OnRequest(IntPtr resourceHandle, IntPtr requestHandle, IntPtr userData)
+        {
+            Request request = GetRequest(requestHandle);
+            Response response = null;
+
+            if (request == null)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get Request");
+                return;
+            }
+
+            try
+            {
+                int observeType;
+                int ret = Interop.IoTConnectivity.Server.Request.GetObserveType(requestHandle, out observeType);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to Get observe type");
+                    return;
+                }
+
+                if ((ObserveType)observeType != ObserveType.NoType)
+                {
+                    int observeId;
+                    ret = Interop.IoTConnectivity.Server.Request.GetObserveId(requestHandle, out observeId);
+                    if (ret != (int)IoTConnectivityError.None)
+                    {
+                        Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to Get observe id");
+                        return;
+                    }
+                    switch ((ObserveType)observeType)
+                    {
+                        case ObserveType.Register:
+                        {
+                            if (OnObserving(request, ObserveType.Register, observeId))
+                            {
+                                ret = Interop.IoTConnectivity.Server.Observers.Add(_observerHandle, observeId);
+                                if (ret != (int)IoTConnectivityError.None)
+                                {
+                                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add observer id");
+                                    return;
+                                }
+                                break;
+                            }
+                            else
+                            {
+                                // If OnObserving for ObserveType.Register returns false, do not operate for Get operation after Observe operation.
+                                return;
+                            }
+                        }
+                        case ObserveType.Deregister:
+                        {
+                            if (OnObserving(request, ObserveType.Deregister, observeId))
+                            {
+                                ret = Interop.IoTConnectivity.Server.Observers.Remove(_observerHandle, observeId);
+                                if (ret != (int)IoTConnectivityError.None)
+                                {
+                                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove observer id");
+                                    return;
+                                }
+                                break;
+                            }
+                            else
+                            {
+                                // If OnObserving for ObserveType.Deregister returns false, do not operate for Get operation after Observe operation.
+                                return;
+                            }
+                        }
+                    }
+                }
+
+                int requestType;
+                ret = Interop.IoTConnectivity.Server.Request.GetRequestType(requestHandle, out requestType);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to Get request type");
+                    return;
+                }
+
+                switch ((Interop.IoTConnectivity.Server.RequestType)requestType)
+                {
+                    case Interop.IoTConnectivity.Server.RequestType.Put:
+                    {
+                        response = OnPut(request);
+                        break;
+                    }
+                    case Interop.IoTConnectivity.Server.RequestType.Get:
+                    {
+                        response = OnGet(request);
+                        break;
+                    }
+                    case Interop.IoTConnectivity.Server.RequestType.Post:
+                    {
+                        response = OnPost(request);
+                        break;
+                    }
+                    case Interop.IoTConnectivity.Server.RequestType.Delete:
+                    {
+                        response = OnDelete(request);
+                        break;
+                    }
+                    default:
+                    break;
+                }
+                if (response == null)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to send Response");
+                    return;
+                }
+
+                if (!response.Send(requestHandle))
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to send Response");
+                    return;
+                }
+            }
+            finally
+            {
+                request.Dispose();
+                response?.Dispose();
+            }
+        }
+
+        private Request GetRequest(IntPtr requestHandle)
+        {
+            string hostAddress;
+            int ret = Interop.IoTConnectivity.Server.Request.GetHostAddress(requestHandle, out hostAddress);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to Get host address");
+                return null;
+            }
+
+            IntPtr optionsHandle = IntPtr.Zero;
+            ret = Interop.IoTConnectivity.Server.Request.GetOptions(requestHandle, out optionsHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to Get options");
+                return null;
+            }
+
+            IntPtr queryHandle = IntPtr.Zero;
+            ret = Interop.IoTConnectivity.Server.Request.GetQuery(requestHandle, out queryHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to Get Query");
+                return null;
+            }
+
+            IntPtr representationHandle = IntPtr.Zero;
+            ret = Interop.IoTConnectivity.Server.Request.GetRepresentation(requestHandle, out representationHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to Get representation");
+                return null;
+            }
+
+            ResourceOptions opts = null;
+            ResourceQuery query = null;
+            Representation representation = null;
+            try
+            {
+                opts = (optionsHandle == IntPtr.Zero) ? null : new ResourceOptions(optionsHandle);
+            }
+            catch (Exception exp)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to new ResourceOptions: " + exp.Message);
+                return null;
+            }
+
+            try
+            {
+                query = (queryHandle == IntPtr.Zero) ? null : new ResourceQuery(queryHandle);
+            }
+            catch (Exception exp)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to new ResourceQuery: " + exp.Message);
+                return null;
+            }
+
+            try
+            {
+                representation = (representationHandle == IntPtr.Zero) ? null : new Representation(representationHandle); ;
+            }
+            catch (Exception exp)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to new Representation: " + exp.Message);
+                return null;
+            }
+
+            return new Request()
+            {
+                HostAddress = hostAddress,
+                Options = opts,
+                Query = query,
+                Representation = representation
+            };
+        }
+
+        private void ChildrenCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs eventArgs)
+        {
+            if (eventArgs.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
+            {
+                foreach (Resource r in eventArgs.NewItems)
+                {
+                    int ret = Interop.IoTConnectivity.Server.Resource.BindChildResource(_resourceHandle, r._resourceHandle);
+                    if (ret != (int)IoTConnectivityError.None)
+                    {
+                        Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to bind resource ");
+                        throw IoTConnectivityErrorFactory.GetException(ret);
+                    }
+                }
+            }
+            else if (eventArgs.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
+            {
+                foreach (Resource r in eventArgs.NewItems)
+                {
+                    int ret = Interop.IoTConnectivity.Server.Resource.UnbindChildResource(_resourceHandle, r._resourceHandle);
+                    if (ret != (int)IoTConnectivityError.None)
+                    {
+                        Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to unbind resource");
+                        throw IoTConnectivityErrorFactory.GetException(ret);
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceFoundEventArgs.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceFoundEventArgs.cs
new file mode 100755 (executable)
index 0000000..3e204d8
--- /dev/null
@@ -0,0 +1,30 @@
+/// 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;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// ResourceFoundEventArgs class. This class is an event arguments of the ResourceFound event.
+    /// </summary>
+    public class ResourceFoundEventArgs : EventArgs
+    {
+        /// <summary>
+        /// RequestId property.
+        /// </summary>
+        /// <returns>int RequestId.</returns>
+        public int RequestId { get; internal set; }
+
+        /// <summary>
+        /// Resource property.
+        /// </summary>
+        /// <returns>RemoteResource Resource.</returns>
+        public RemoteResource Resource { get; internal set; }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceInterfaces.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceInterfaces.cs
new file mode 100755 (executable)
index 0000000..95227ff
--- /dev/null
@@ -0,0 +1,210 @@
+/// 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.Collections;
+using System.Collections.Generic;
+using System.Text.RegularExpressions;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// Class containing resource interfaces
+    /// </summary>
+    public class ResourceInterfaces : IEnumerable<string>, IDisposable
+    {
+        /// <summary>
+        /// Default Interface
+        /// </summary>
+        public const string DefaultInterface = "oic.if.baseline";
+
+        /// <summary>
+        /// List Links Interface which is used to list the references to other resources  contained in a resource.
+        /// </summary>
+        public const string LinkInterface = "oic.if.ll";
+
+        /// <summary>
+        /// Batch Interface which is used to manipulate (GET, PUT, POST, DELETE) on other resource contained in a resource.
+        /// </summary>
+        public const string BatchInterface = "oic.if.b";
+
+        /// <summary>
+        /// Group Interface which is used to manipulate (GET, PUT, POST) a group of remote resources.
+        /// </summary>
+        public const string GroupInterface = "oic.mi.grp";
+
+        /// <summary>
+        /// Read-Only Interface which is used to limit the methods that can be applied to a resource to GET only.
+        /// </summary>
+        public const string ReadonlyInterface = "oic.if.r";
+
+        private readonly IntPtr _resourceInterfacesHandle = IntPtr.Zero;
+        private const int MaxLength = 61;
+        private readonly HashSet<string> _resourceInterfaces = new HashSet<string>();
+        private bool _disposed = false;
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        public ResourceInterfaces()
+        {
+            int ret = Interop.IoTConnectivity.Common.ResourceInterfaces.Create(out _resourceInterfacesHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create interface");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="ifaces">List of resource interfaces</param>
+        public ResourceInterfaces(IEnumerable<string> ifaces)
+        {
+            int ret = Interop.IoTConnectivity.Common.ResourceInterfaces.Create(out _resourceInterfacesHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create interface");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+            foreach (string iface in ifaces)
+            {
+                Add(iface);
+            }
+        }
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        internal ResourceInterfaces(IntPtr ifacesHandleToClone)
+        {
+            int ret = Interop.IoTConnectivity.Common.ResourceInterfaces.Clone(ifacesHandleToClone, out _resourceInterfacesHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create interface");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            Interop.IoTConnectivity.Common.ResourceInterfaces.ForeachCallback cb = (string iface, IntPtr data) =>
+            {
+                _resourceInterfaces.Add(iface);
+                return true;
+            };
+
+            ret = Interop.IoTConnectivity.Common.ResourceInterfaces.Foreach(ifacesHandleToClone, cb, IntPtr.Zero);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create type");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        ~ResourceInterfaces()
+        {
+            Dispose(false);
+        }
+
+        internal IntPtr ResourceInterfacesHandle
+        {
+            get
+            {
+                return _resourceInterfacesHandle;
+            }
+        }
+
+        /// <summary>
+        /// Count of interfaces in the list
+        /// </summary>
+        public int Count
+        {
+            get
+            {
+                return _resourceInterfaces.Count;
+            }
+        }
+
+        /// <summary>
+        /// Adds a resource interface into the list.
+        /// </summary>
+        /// <param name="item"> Resource interface</param>
+        public void Add(string item)
+        {
+            if (IsValid(item))
+            {
+                int ret = Interop.IoTConnectivity.Common.ResourceInterfaces.Add(_resourceInterfacesHandle, item);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add interface");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+                _resourceInterfaces.Add(item);
+            }
+            else
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Invalid interface");
+                throw IoTConnectivityErrorFactory.GetException((int)IoTConnectivityError.InvalidParameter);
+            }
+        }
+
+        /// <summary>
+        /// Removes a resource interface from the list
+        /// </summary>
+        /// <param name="item">Resource interface</param>
+        public void Remove(string item)
+        {
+            int ret = Interop.IoTConnectivity.Common.ResourceInterfaces.Remove(_resourceInterfacesHandle, item);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add interface");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+            _resourceInterfaces.Remove(item);
+        }
+
+        /// <summary>
+        /// Return enumerator for the list of interfaces
+        /// </summary>
+        /// <returns>The enumerator</returns>
+        public IEnumerator<string> GetEnumerator()
+        {
+            return _resourceInterfaces.GetEnumerator();
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return _resourceInterfaces.GetEnumerator();
+        }
+
+        internal static bool IsValid(string type)
+        {
+            Regex r = new Regex("^[a-zA-Z0-9.-]+$");
+            return (type.Length <= MaxLength && char.IsLower(type[0]) && r.IsMatch(type));
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects
+            }
+
+            Interop.IoTConnectivity.Common.ResourceInterfaces.Destroy(_resourceInterfacesHandle);
+            _disposed = true;
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceOptions.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceOptions.cs
new file mode 100755 (executable)
index 0000000..fa481de
--- /dev/null
@@ -0,0 +1,289 @@
+/// 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.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using Tizen;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// Class representing Resource options
+    /// </summary>
+    public class ResourceOptions : IDictionary<ushort, string>, IDisposable
+    {
+        internal const int MaxSize = 2;
+        internal const int IdMin = 2048;
+        internal const int IdMax = 3000;
+        internal const int DataMax = 15;
+
+        internal IntPtr _resourceOptionsHandle = IntPtr.Zero;
+        private readonly IDictionary<ushort, string> _options = new Dictionary<ushort, string>();
+        private bool _disposed = false;
+
+        public ResourceOptions()
+        {
+            int ret = Interop.IoTConnectivity.Common.Options.Create(out _resourceOptionsHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create options");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        internal ResourceOptions(IntPtr handleToClone)
+        {
+            int ret = Interop.IoTConnectivity.Common.Options.Create(out _resourceOptionsHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create options");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            Interop.IoTConnectivity.Common.Options.OptionsCallback forEachCallback = (ushort id, string value, IntPtr userData) =>
+            {
+                Add(id, value);
+                return true;
+            };
+
+            ret = Interop.IoTConnectivity.Common.Options.ForEach(handleToClone, forEachCallback, IntPtr.Zero);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to iterate options");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        ~ResourceOptions()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// Contains all the Option keys
+        /// </summary>
+        public ICollection<ushort> Keys
+        {
+            get
+            {
+                return _options.Keys;
+            }
+        }
+
+        /// <summary>
+        /// Contains all the Option values
+        /// </summary>
+        public ICollection<string> Values
+        {
+            get
+            {
+                return _options.Values;
+            }
+        }
+
+        /// <summary>
+        /// Gets the number of options
+        /// </summary>
+        public int Count
+        {
+            get
+            {
+                return _options.Count;
+            }
+        }
+
+        /// <summary>
+        /// Represents whether the collection is readonly
+        /// </summary>
+        public bool IsReadOnly
+        {
+            get
+            {
+                return _options.IsReadOnly;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the option
+        /// </summary>
+        /// <param name="key">The option id to get or set.</param>
+        /// <returns>The option with the specified id.</returns>
+        public string this[ushort key]
+        {
+            get
+            {
+                return _options[key];
+            }
+
+            set
+            {
+                Add(key, value);
+            }
+        }
+
+        /// <summary>
+        /// Checks the given key exists in Options collection
+        /// </summary>
+        /// <param name="key">The key to look for</param>
+        /// <returns></returns>
+        public bool ContainsKey(ushort key)
+        {
+            return _options.ContainsKey(key);
+        }
+
+        /// <summary>
+        ///  Adds option key and value
+        /// </summary>
+        /// <param name="key">Option ID</param>
+        /// <param name="value">Value coresponding to option</param>
+        public void Add(ushort key, string value)
+        {
+            int ret = (int)IoTConnectivityError.InvalidParameter;
+            if (IsValid(key, value))
+            {
+                ret = Interop.IoTConnectivity.Common.Options.Add(_resourceOptionsHandle, key, value);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add option");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+                _options.Add(key, value);
+            }
+            else
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Invalid options");
+                throw IoTConnectivityErrorFactory.GetException((int)IoTConnectivityError.InvalidParameter);
+            }
+        }
+
+        /// <summary>
+        /// Removes an option
+        /// </summary>
+        /// <param name="key">The option to remvoe</param>
+        /// <returns></returns>
+        public bool Remove(ushort key)
+        {
+            int ret = Interop.IoTConnectivity.Common.Options.Remove(_resourceOptionsHandle, key);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove option");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            return _options.Remove(key);
+        }
+
+        /// <summary>
+        /// Gets the value associated with the specified key.
+        /// </summary>
+        /// <param name="key">The option id</param>
+        /// <param name="value">value corresponding to option id</param>
+        /// <returns>true if the key exists, false otherwise</returns>
+        public bool TryGetValue(ushort key, out string value)
+        {
+            return _options.TryGetValue(key, out value);
+        }
+
+        /// <summary>
+        ///  Adds options key and value as a key value pair
+        /// </summary>
+        /// <param name="item">The key value pair</param>
+        public void Add(KeyValuePair<ushort, string> item)
+        {
+            Add(item.Key, item.Value);
+        }
+
+        /// <summary>
+        /// Clears the Options collection
+        /// </summary>
+        public void Clear()
+        {
+            foreach (ushort key in Keys)
+            {
+                int ret = Interop.IoTConnectivity.Common.Options.Remove(_resourceOptionsHandle, key);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove option");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                };
+            }
+            _options.Clear();
+        }
+
+        /// <summary>
+        /// Checks if the given option pair exists
+        /// </summary>
+        /// <param name="item">The key value pair</param>
+        /// <returns></returns>
+        public bool Contains(KeyValuePair<ushort, string> item)
+        {
+            return _options.Contains(item);
+        }
+
+        /// <summary>
+        /// Copies the elements of the options collection to an Array, starting at a particular index.
+        /// </summary>
+        /// <param name="array">The destination array</param>
+        /// <param name="arrayIndex">Index parameter</param>
+        public void CopyTo(KeyValuePair<ushort, string>[] array, int arrayIndex)
+        {
+            _options.CopyTo(array, arrayIndex);
+        }
+
+        /// <summary>
+        /// Remove the gien option pair
+        /// </summary>
+        /// <param name="item">The option pair to remove</param>
+        /// <returns></returns>
+        public bool Remove(KeyValuePair<ushort, string> item)
+        {
+            return Remove(item.Key);
+        }
+
+        /// <summary>
+        /// Get the enumerator to options collection
+        /// </summary>
+        /// <returns> Enumerator to option pairs</returns>
+        public IEnumerator<KeyValuePair<ushort, string>> GetEnumerator()
+        {
+            return _options.GetEnumerator();
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return _options.GetEnumerator();
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects
+            }
+
+            Interop.IoTConnectivity.Common.Options.Destroy(_resourceOptionsHandle);
+            _disposed = true;
+        }
+
+        private bool IsValid(ushort key, string value)
+        {
+            return (key > IdMin && key < IdMax && value.Length <= DataMax && _options.Count() < MaxSize);
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourcePolicy.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourcePolicy.cs
new file mode 100755 (executable)
index 0000000..5285072
--- /dev/null
@@ -0,0 +1,48 @@
+/// 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;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// Enumeration for policy which can be held in a resource.
+    /// </summary>
+    [Flags]
+    public enum ResourcePolicy
+    {
+        /// <summary>
+        /// Indicates resource uninitialized
+        /// </summary>
+        NoProperty = 0,
+        /// <summary>
+        /// Indicates resource that is allowed to be discovered
+        /// </summary>
+        Discoverable = (1 << 0),
+        /// <summary>
+        /// Indicates resource that is allowed to be observed
+        /// </summary>
+        Observable = (1 << 1),
+        /// <summary>
+        /// Indicates resource initialized and activated
+        /// </summary>
+        Active = (1 << 2),
+        /// <summary>
+        /// Indicates resource which takes some delay to respond
+        /// </summary>
+        Slow = (1 << 3),
+        /// <summary>
+        /// Indicates secure resource
+        /// </summary>
+        Secure = (1 << 4),
+        /// <summary>
+        /// When this bit is set, the resource is allowed to be discovered only if discovery request contains an explicit querystring.
+        /// </summary>
+        ExplicitDiscoverable = (1 << 5),
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceQuery.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceQuery.cs
new file mode 100755 (executable)
index 0000000..3f0e2bf
--- /dev/null
@@ -0,0 +1,365 @@
+/// 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.Collections;
+using System.Collections.Generic;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// Class to manage query of request
+    /// </summary>
+    public class ResourceQuery : IDictionary<string, string>, IDisposable
+    {
+        internal const int QueryMaxLenth = 64;
+        internal IntPtr _resourceQueryHandle = IntPtr.Zero;
+        private readonly IDictionary<string, string> _query = new Dictionary<string, string>();
+        private bool _disposed = false;
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        public ResourceQuery()
+        {
+            int ret = Interop.IoTConnectivity.Common.Query.Create(out _resourceQueryHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create query");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        internal ResourceQuery(IntPtr resourceQueryHandleToClone)
+        {
+            int ret = Interop.IoTConnectivity.Common.Query.Create(out _resourceQueryHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create query");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            Interop.IoTConnectivity.Common.Query.QueryCallback forEachCallback = (string key, string value, IntPtr userData) =>
+            {
+                Add(key, value);
+                return true;
+            };
+
+            ret = Interop.IoTConnectivity.Common.Query.Foreach(resourceQueryHandleToClone, forEachCallback, IntPtr.Zero);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to iterate query");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        ~ResourceQuery()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// Resource type of the query
+        /// </summary>
+        public string Type
+        {
+            get
+            {
+                string type;
+                int ret = Interop.IoTConnectivity.Common.Query.GetResourceType(_resourceQueryHandle, out type);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get type");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+                return type;
+            }
+            set
+            {
+                int ret = (int)IoTConnectivityError.InvalidParameter;
+                if (ResourceTypes.IsValid(value))
+                    ret = Interop.IoTConnectivity.Common.Query.SetResourceType(_resourceQueryHandle, value);
+
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to set type");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Resource interface of the query
+        /// </summary>
+        public string Interface
+        {
+            get
+            {
+                string iface;
+                int ret = Interop.IoTConnectivity.Common.Query.GetInterface(_resourceQueryHandle, out iface);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get interface");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+                return iface;
+            }
+            set
+            {
+                int ret = (int)IoTConnectivityError.InvalidParameter;
+                if (ResourceInterfaces.IsValid(value))
+                    ret = Interop.IoTConnectivity.Common.Query.SetInterface(_resourceQueryHandle, value);
+
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to set interface");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Contains all keys of Query
+        /// </summary>
+        public ICollection<string> Keys
+        {
+            get
+            {
+                return _query.Keys;
+            }
+        }
+
+        /// <summary>
+        /// Contains all the values of Query
+        /// </summary>
+        public ICollection<string> Values
+        {
+            get
+            {
+                return _query.Values;
+            }
+        }
+
+        /// <summary>
+        /// Gets the number of query elements
+        /// </summary>
+        public int Count
+        {
+            get
+            {
+                return _query.Count;
+            }
+        }
+
+        /// <summary>
+        /// Represents whether Query is readonly
+        /// </summary>
+        public bool IsReadOnly
+        {
+            get
+            {
+                return _query.IsReadOnly;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the Query key..
+        /// </summary>
+        /// <param name="key">The key of the Query to get or set.</param>
+        /// <returns>The element with the specified key.</returns>
+        public string this[string key]
+        {
+            get
+            {
+                return _query[key];
+            }
+
+            set
+            {
+                Add(key, value);
+            }
+        }
+
+        /// <summary>
+        /// Checks the given key exists in Query
+        /// </summary>
+        /// <param name="key">The Query key</param>
+        /// <returns>true if exists. Otherwise, false</returns>
+        public bool ContainsKey(string key)
+        {
+            return _query.ContainsKey(key);
+        }
+
+        /// <summary>
+        /// Adds Query element
+        /// </summary>
+        /// <param name="key">The key representing the Query</param>
+        /// <param name="value">The value representing the Query</param>
+        public void Add(string key, string value)
+        {
+            if (CanAddQuery(key, value))
+            {
+                int ret = Interop.IoTConnectivity.Common.Query.Add(_resourceQueryHandle, key, value);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add query");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+                _query.Add(key, value);
+            }
+            else
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Query cannot be added");
+                throw IoTConnectivityErrorFactory.GetException((int)IoTConnectivityError.InvalidParameter);
+            }
+        }
+
+        /// <summary>
+        /// Removes a Query element from collection
+        /// </summary>
+        /// <param name="item">The Query element to remove</param>
+        /// <returns>true if operation is success. Otherwise, false</returns>
+        public bool Remove(string key)
+        {
+            int ret = Interop.IoTConnectivity.Common.Query.Remove(_resourceQueryHandle, key);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove query");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            return _query.Remove(key);
+        }
+
+        /// <summary>
+        /// Gets the value associated with the specified key.
+        /// </summary>
+        /// <param name="key">The key whose value to get.</param>
+        /// <param name="value"> The value associated with the specified key</param>
+        /// <returns> true if the Query contains an element with the specified key; otherwise, false.</returns>
+        public bool TryGetValue(string key, out string value)
+        {
+            return _query.TryGetValue(key, out value);
+        }
+
+        /// <summary>
+        /// Adds Query as a key value pair
+        /// </summary>
+        /// <param name="item">The key value pair</param>
+        public void Add(KeyValuePair<string, string> item)
+        {
+            Add(item.Key, item.Value);
+        }
+
+        /// <summary>
+        /// Clears Query
+        /// </summary>
+        public void Clear()
+        {
+            foreach (string key in _query.Keys)
+            {
+                int ret = Interop.IoTConnectivity.Common.Query.Remove(_resourceQueryHandle, key);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to clear query");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+            _query.Clear();
+        }
+
+        /// <summary>
+        /// Checks the given key value pair exists in Query
+        /// </summary>
+        /// <param name="item">The key value pair</param>
+        /// <returns>true if exists. Otherwise, false</returns>
+        public bool Contains(KeyValuePair<string, string> item)
+        {
+            return _query.Contains(item);
+        }
+
+        /// <summary>
+        /// Copies the elements of the Query to an Array, starting at a particular index.
+        /// </summary>
+        /// <param name="array">The destination array</param>
+        /// <param name="arrayIndex">The zero-based index in array at which copying begins.</param>
+        public void CopyTo(KeyValuePair<string, string>[] array, int arrayIndex)
+        {
+            _query.CopyTo(array, arrayIndex);
+        }
+
+        /// <summary>
+        /// Removes a Query element from collection
+        /// </summary>
+        /// <param name="item">The Query element to remove</param>
+        /// <returns>true if operation is success. Otherwise, false</returns>
+        public bool Remove(KeyValuePair<string, string> item)
+        {
+            int ret = Interop.IoTConnectivity.Common.Query.Remove(_resourceQueryHandle, item.Key);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove query");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            return _query.Remove(item);
+        }
+
+        /// <summary>
+        ///   Returns an enumerator that iterates through the collection.
+        /// </summary>
+        /// <returns> An enumerator that can be used to iterate through the collection.</returns>
+        public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
+        {
+            return _query.GetEnumerator();
+        }
+
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return _query.GetEnumerator();
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects
+            }
+
+            Interop.IoTConnectivity.Common.Query.Destroy(_resourceQueryHandle);
+            _disposed = true;
+        }
+
+        private bool CanAddQuery(string newKey, string newValue)
+        {
+            int queryLenth = 0;
+            foreach (string key in Keys)
+            {
+                queryLenth += key.Length;
+            }
+            foreach (string value in Values)
+            {
+                queryLenth += value.Length;
+            }
+
+            if ((newKey.Length + newValue.Length + queryLenth) < QueryMaxLenth)
+                return true;
+
+            return false;
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceState.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceState.cs
new file mode 100755 (executable)
index 0000000..9563e90
--- /dev/null
@@ -0,0 +1,25 @@
+/// 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.
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// Enumeration for states of remote resource.
+    /// </summary>
+    public enum ResourceState
+    {
+        /// <summary>
+        /// Indicates remote resource is alive
+        /// </summary>
+        Alive = 0,
+        /// <summary>
+        /// Indicates remote resource is lost
+        /// </summary>
+        LostSignal
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceTypes.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResourceTypes.cs
new file mode 100755 (executable)
index 0000000..83e9afa
--- /dev/null
@@ -0,0 +1,178 @@
+/// 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.Collections;
+using System.Collections.Generic;
+using System.Text.RegularExpressions;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// Class containing resource types
+    /// </summary>
+    public class ResourceTypes : IEnumerable<string>, IDisposable
+    {
+        internal const int MaxLength = 61;
+        internal IntPtr _resourceTypeHandle = IntPtr.Zero;
+        private readonly HashSet<string> _resourceTypes = new HashSet<string>();
+        private bool _disposed = false;
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        public ResourceTypes()
+        {
+            int ret = Interop.IoTConnectivity.Common.ResourceTypes.Create(out _resourceTypeHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create type");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        public ResourceTypes(IEnumerable<string> types)
+        {
+            int ret = Interop.IoTConnectivity.Common.ResourceTypes.Create(out _resourceTypeHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create type");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            foreach (string type in types)
+            {
+                Add(type);
+            }
+        }
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        internal ResourceTypes(IntPtr typesHandleToClone)
+        {
+            int ret = Interop.IoTConnectivity.Common.ResourceTypes.Clone(typesHandleToClone, out _resourceTypeHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create type");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            Interop.IoTConnectivity.Common.ResourceTypes.ForeachCallback cb = (string type, IntPtr data) =>
+            {
+                _resourceTypes.Add(type);
+                return true;
+            };
+
+            ret = Interop.IoTConnectivity.Common.ResourceTypes.Foreach(typesHandleToClone, cb, IntPtr.Zero);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create type");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        ~ResourceTypes()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// Count of resource types in the list
+        /// </summary>
+        public int Count
+        {
+            get
+            {
+                return _resourceTypes.Count;
+            }
+        }
+
+        /// <summary>
+        ///  Inserts a resource type into the list.
+        /// </summary>
+        /// <param name="item">The resource type to add</param>
+        public void Add(string item)
+        {
+            if (IsValid(item))
+            {
+                int ret = Interop.IoTConnectivity.Common.ResourceTypes.Add(_resourceTypeHandle, item);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add type");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+                _resourceTypes.Add(item);
+            }
+            else
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Invalid type");
+                throw IoTConnectivityErrorFactory.GetException((int)IoTConnectivityError.InvalidParameter);
+            }
+        }
+
+        /// <summary>
+        ///  Removes a resource type from the list
+        /// </summary>
+        /// <param name="item">The resource type to remove</param>
+        public void Remove(string item)
+        {
+            int ret = Interop.IoTConnectivity.Common.ResourceTypes.Remove(_resourceTypeHandle, item);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove type");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            _resourceTypes.Remove(item);
+        }
+
+        /// <summary>
+        ///  Return enumerator for the list of types
+        /// </summary>
+        /// <returns>Enumerator of the collection</returns>
+        public IEnumerator<string> GetEnumerator()
+        {
+            return _resourceTypes.GetEnumerator();
+        }
+
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return _resourceTypes.GetEnumerator();
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        internal static bool IsValid(string type)
+        {
+            Regex r = new Regex("^[a-zA-Z0-9.-]+$");
+            return (type.Length <= MaxLength && char.IsLower(type[0]) && r.IsMatch(type));
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects
+            }
+
+            Interop.IoTConnectivity.Common.ResourceTypes.Destroy(_resourceTypeHandle);
+            _disposed = true;
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Response.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Response.cs
new file mode 100755 (executable)
index 0000000..4120cc7
--- /dev/null
@@ -0,0 +1,94 @@
+/// 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;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// Class representing Response from a resource
+    /// </summary>
+    public class Response : IDisposable
+    {
+        private bool _disposed = false;
+
+        ~Response()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// Result corresponding to a request
+        /// </summary>
+        public ResponseCode Result { get; set; }
+
+        /// <summary>
+        /// Representation of the resource
+        /// </summary>
+        public Representation Representation { get; set; }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        internal bool Send(IntPtr requestHandle)
+        {
+            IntPtr responseHandle = IntPtr.Zero;
+            int ret = Interop.IoTConnectivity.Server.Response.Create(requestHandle, out responseHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to send response");
+                return false;
+            }
+
+            ret = Interop.IoTConnectivity.Server.Response.SetResult(responseHandle, (int)Result);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to send response");
+                Interop.IoTConnectivity.Server.Response.Destroy(responseHandle);
+                return false;
+            }
+
+            string iface = "oic.if.baseline";
+            // TODO: iface parameter will be removed after native API is changed
+            ret = Interop.IoTConnectivity.Server.Response.SetRepresentation(responseHandle, iface, Representation._representationHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to send response");
+                Interop.IoTConnectivity.Server.Response.Destroy(responseHandle);
+                return false;
+            }
+
+            ret = Interop.IoTConnectivity.Server.Response.Send(responseHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to send response");
+                Interop.IoTConnectivity.Server.Response.Destroy(responseHandle);
+                return false;
+            }
+
+            Interop.IoTConnectivity.Server.Response.Destroy(responseHandle);
+            return true;
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+                return;
+
+            if (disposing)
+            {
+                Representation?.Dispose();
+            }
+
+            _disposed = true;
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResponseCode.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/ResponseCode.cs
new file mode 100755 (executable)
index 0000000..3bddc37
--- /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.
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// Enumeration for result response
+    /// </summary>
+    public enum ResponseCode
+    {
+        /// <summary>
+        /// Indicates result of response for success
+        /// </summary>
+        Ok = 0,
+        /// <summary>
+        /// Indicates result of response for something error
+        /// </summary>
+        Error,
+        /// <summary>
+        /// Indicates result of response for resource has created
+        /// </summary>
+        Created,
+        /// <summary>
+        ///  Indicates result of response for resource has deleted
+        /// </summary>
+        Deleted,
+        /// <summary>
+        /// Indicates result of response for slow resource
+        /// </summary>
+        Slow,
+        /// <summary>
+        /// Indicates result of response for accessing unauthorized resource
+        /// </summary>
+        Forbidden
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/State.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/State.cs
new file mode 100755 (executable)
index 0000000..55c3cb2
--- /dev/null
@@ -0,0 +1,678 @@
+/// 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.Collections;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// State represents current state of a resource
+    /// </summary>
+    public class State : IDictionary<string, object>, IDisposable
+    {
+        internal IntPtr _resourceStateHandle = IntPtr.Zero;
+        private readonly IDictionary<string, object> _state = new Dictionary<string, object>();
+        private bool _disposed = false;
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        public State()
+        {
+            int ret = Interop.IoTConnectivity.Common.State.Create(out _resourceStateHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create state handle");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+        }
+
+        internal State(IntPtr stateHandleToClone)
+        {
+            int ret = Interop.IoTConnectivity.Common.State.Clone(stateHandleToClone, out _resourceStateHandle);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to create state handle");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            SetState(stateHandleToClone);
+        }
+
+        ~State()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// Gets the number of status elements
+        /// </summary>
+        public int Count
+        {
+            get
+            {
+                return _state.Count;
+            }
+        }
+
+        /// <summary>
+        /// Represents whether State is readonly
+        /// </summary>
+        public bool IsReadOnly
+        {
+            get
+            {
+                return _state.IsReadOnly;
+            }
+        }
+
+        /// <summary>
+        /// Contains all the status keys
+        /// </summary>
+        public ICollection<string> Keys
+        {
+            get
+            {
+                return _state.Keys;
+            }
+        }
+
+        /// <summary>
+        /// Contains all the status values
+        /// </summary>
+        public ICollection<object> Values
+        {
+            get
+            {
+                return _state.Values;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the status with the specified key.
+        /// </summary>
+        /// <param name="key">The key of the status to get or set.</param>
+        /// <returns>The element with the specified key.</returns>
+        public object this[string key]
+        {
+            get
+            {
+                return _state[key];
+            }
+
+            set
+            {
+                Add(key, value);
+            }
+        }
+
+        /// <summary>
+        /// Adds status key and value as a key value pair
+        /// </summary>
+        /// <param name="item">The item to add</param>
+        public void Add(KeyValuePair<string, object> item)
+        {
+            Add(item.Key, item.Value);
+        }
+
+        /// <summary>
+        /// Adds status element
+        /// </summary>
+        /// <param name="key">The key representing the state</param>
+        /// <param name="value">The value representing the state</param>
+        public void Add(string key, object value)
+        {
+            int ret = 0;
+            if (value is int)
+            {
+                ret = Interop.IoTConnectivity.Common.State.AddInt(_resourceStateHandle, key, (int)value);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add int");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+            else if (value is State)
+            {
+                State state = (State)value;
+                ret = Interop.IoTConnectivity.Common.State.AddState(_resourceStateHandle, key, state._resourceStateHandle);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+            else if (value is string)
+            {
+                ret = Interop.IoTConnectivity.Common.State.AddStr(_resourceStateHandle, key, (string)value);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add string");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+            else if (value is double)
+            {
+                ret = Interop.IoTConnectivity.Common.State.AddDouble(_resourceStateHandle, key, (double)value);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add double");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+            else if (value is bool)
+            {
+                ret = Interop.IoTConnectivity.Common.State.AddBool(_resourceStateHandle, key, (bool)value);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add bool");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+            else if (value is byte[])
+            {
+                byte[] val = value as byte[];
+                if (val == null)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get byte[] val");
+                    throw new ArgumentException("Invalid Parameter");
+                }
+                ret = Interop.IoTConnectivity.Common.State.AddByteStr(_resourceStateHandle, key, val, val.Length);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add bool");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+            else if (value is IEnumerable)
+            {
+                IntPtr listHandle = List.GetListHandle(value);
+                ret = Interop.IoTConnectivity.Common.State.AddList(_resourceStateHandle, key, listHandle);
+                Interop.IoTConnectivity.Common.State.Destroy(listHandle);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+            else
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to Add");
+                throw IoTConnectivityErrorFactory.GetException((int)IoTConnectivityError.InvalidParameter);
+            }
+            _state.Add(key, value);
+        }
+
+        /// <summary>
+        /// Clears state collection
+        /// </summary>
+        public void Clear()
+        {
+            foreach (string key in _state.Keys)
+            {
+                int ret = Interop.IoTConnectivity.Common.State.Remove(_resourceStateHandle, key);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to clear state");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+            }
+            _state.Clear();
+        }
+
+        /// <summary>
+        /// Checks the given key value pair exists in state collection
+        /// </summary>
+        /// <param name="item">The status key value pair</param>
+        /// <returns>true if exists. Otherwise, false</returns>
+        public bool Contains(KeyValuePair<string, object> item)
+        {
+            return _state.Contains(item);
+        }
+
+        /// <summary>
+        /// Checks the given key exists in state collection
+        /// </summary>
+        /// <param name="key">The status key</param>
+        /// <returns>true if exists. Otherwise, false</returns>
+        public bool ContainsKey(string key)
+        {
+            return _state.ContainsKey(key);
+        }
+
+        /// <summary>
+        /// Copies the elements of the state to an Array, starting at a particular index.
+        /// </summary>
+        /// <param name="array">The destination array</param>
+        /// <param name="arrayIndex">The zero-based index in array at which copying begins.</param>
+        public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
+        {
+            _state.CopyTo(array, arrayIndex);
+        }
+
+        /// <summary>
+        ///   Returns an enumerator that iterates through the collection.
+        /// </summary>
+        /// <returns> An enumerator that can be used to iterate through the collection.</returns>
+        public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
+        {
+            return _state.GetEnumerator();
+        }
+
+        /// <summary>
+        /// Removes a state element from collection
+        /// </summary>
+        /// <param name="item">The state element to remove</param>
+        /// <returns>true if operation is success. Otherwise, false</returns>
+        public bool Remove(KeyValuePair<string, object> item)
+        {
+            int ret = Interop.IoTConnectivity.Common.State.Remove(_resourceStateHandle, item.Key);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove state");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            return _state.Remove(item);
+        }
+
+        /// <summary>
+        ///  Removes a state element from collection using key
+        /// </summary>
+        /// <param name="key">The state element to remove</param>
+        /// <returns>true if operation is success. Otherwise, false</returns>
+        public bool Remove(string key)
+        {
+            int ret = Interop.IoTConnectivity.Common.State.Remove(_resourceStateHandle, key);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove state");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+
+            return _state.Remove(key);
+        }
+
+        /// <summary>
+        /// Gets the value associated with the specified key.
+        /// </summary>
+        /// <param name="key">The key whose value to get.</param>
+        /// <param name="value"> The value associated with the specified key</param>
+        /// <returns> true if the state collection contains an element with the specified key; otherwise, false.</returns>
+        public bool TryGetValue(string key, out object value)
+        {
+            return _state.TryGetValue(key, out value);
+        }
+
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return _state.GetEnumerator();
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects
+            }
+
+            Interop.IoTConnectivity.Common.State.Destroy(_resourceStateHandle);
+            _disposed = true;
+        }
+
+        private void SetState(IntPtr stateHandle)
+        {
+            Interop.IoTConnectivity.Common.State.StateCallback cb = (IntPtr state, string key, IntPtr userData) =>
+            {
+                Interop.IoTConnectivity.Common.DataType type = 0;
+                int ret = Interop.IoTConnectivity.Common.State.GetType(state, key, out type);
+                if (ret != (int)IoTConnectivityError.None)
+                {
+                    Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get type");
+                    throw IoTConnectivityErrorFactory.GetException(ret);
+                }
+                switch (type)
+                {
+                    case Interop.IoTConnectivity.Common.DataType.Int:
+                        {
+                            int value;
+                            ret = Interop.IoTConnectivity.Common.State.GetInt(state, key, out value);
+                            if (ret != (int)IoTConnectivityError.None)
+                            {
+                                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+                                throw IoTConnectivityErrorFactory.GetException(ret);
+                            }
+                            Add(key, value);
+                            break;
+                        }
+                    case Interop.IoTConnectivity.Common.DataType.Bool:
+                        {
+                            bool value;
+                            ret = Interop.IoTConnectivity.Common.State.GetBool(state, key, out value);
+                            if (ret != (int)IoTConnectivityError.None)
+                            {
+                                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+                                throw IoTConnectivityErrorFactory.GetException(ret);
+                            }
+                            Add(key, value);
+                            break;
+                        }
+                    case Interop.IoTConnectivity.Common.DataType.Double:
+                        {
+                            double value;
+                            ret = Interop.IoTConnectivity.Common.State.GetDouble(state, key, out value);
+                            if (ret != (int)IoTConnectivityError.None)
+                            {
+                                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+                                throw IoTConnectivityErrorFactory.GetException(ret);
+                            }
+                            Add(key, value);
+                            break;
+                        }
+                    case Interop.IoTConnectivity.Common.DataType.String:
+                        {
+                            string value;
+                            ret = Interop.IoTConnectivity.Common.State.GetStr(state, key, out value);
+                            if (ret != (int)IoTConnectivityError.None)
+                            {
+                                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+                                throw IoTConnectivityErrorFactory.GetException(ret);
+                            }
+                            Add(key, value);
+                            break;
+                        }
+                    case Interop.IoTConnectivity.Common.DataType.ByteStr:
+                        {
+                            IntPtr byteStrPtr;
+                            int byteStrSize;
+                            ret = Interop.IoTConnectivity.Common.State.GetByteStr(state, key, out byteStrPtr, out byteStrSize);
+                            if (ret != (int)IoTConnectivityError.None)
+                            {
+                                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+                                throw IoTConnectivityErrorFactory.GetException(ret);
+                            }
+                            byte[] byteStr = new byte[byteStrSize];
+                            Marshal.Copy(byteStrPtr, byteStr, 0, byteStrSize);
+                            Add(key, byteStr);
+                            break;
+                        }
+                    case Interop.IoTConnectivity.Common.DataType.Null:
+                        {
+                            Add(key, null);
+                            break;
+                        }
+                    case Interop.IoTConnectivity.Common.DataType.List:
+                        {
+                            IntPtr listHandle;
+                            ret = Interop.IoTConnectivity.Common.State.GetList(state, key, out listHandle);
+                            if (ret != (int)IoTConnectivityError.None)
+                            {
+                                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+                                throw IoTConnectivityErrorFactory.GetException(ret);
+                            }
+                            Add(key, List.GetList(listHandle));
+                            break;
+                        }
+                    case Interop.IoTConnectivity.Common.DataType.State:
+                        {
+                            IntPtr stateHndle;
+                            ret = Interop.IoTConnectivity.Common.State.GetState(state, key, out stateHndle);
+                            if (ret != (int)IoTConnectivityError.None)
+                            {
+                                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+                                throw IoTConnectivityErrorFactory.GetException(ret);
+                            }
+                            Add(key, new State(stateHndle));
+                            break;
+                        }
+                    default:
+                        break;
+                }
+
+                return true;
+            };
+
+            int res = Interop.IoTConnectivity.Common.State.Foreach(stateHandle, cb, IntPtr.Zero);
+            if (res != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove state");
+                throw IoTConnectivityErrorFactory.GetException(res);
+            }
+        }
+    }
+
+    internal static class List
+    {
+        internal static IntPtr GetListHandle(object list)
+        {
+            IntPtr listHandle = IntPtr.Zero;
+            int ret;
+            int pos = 0;
+
+            if (list is IEnumerable<IEnumerable>)
+            {
+                ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.List, out listHandle);
+                pos = 0;
+                foreach (IEnumerable val in (IEnumerable<IEnumerable>)list)
+                {
+                    IntPtr childList = GetListHandle(val);
+                    ret = Interop.IoTConnectivity.Common.List.AddList(listHandle, childList, pos++);
+                    if (ret != (int)IoTConnectivityError.None)
+                    {
+                        Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+                        Interop.IoTConnectivity.Common.List.Destroy(childList);
+                        throw IoTConnectivityErrorFactory.GetException(ret);
+                    }
+                }
+            }
+            else if (list is IEnumerable<int>)
+            {
+                ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.Int, out listHandle);
+                pos = 0;
+                foreach (int val in (IEnumerable<int>)list)
+                {
+                    ret = Interop.IoTConnectivity.Common.List.AddInt(listHandle, val, pos++);
+                    if (ret != (int)IoTConnectivityError.None)
+                    {
+                        Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+                        throw IoTConnectivityErrorFactory.GetException(ret);
+                    }
+                }
+            }
+            else if (list is IEnumerable<string>)
+            {
+                ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.String, out listHandle);
+                pos = 0;
+                foreach (string val in (IEnumerable<string>)list)
+                {
+                    ret = Interop.IoTConnectivity.Common.List.AddStr(listHandle, val, pos++);
+                    if (ret != (int)IoTConnectivityError.None)
+                    {
+                        Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+                        throw IoTConnectivityErrorFactory.GetException(ret);
+                    }
+                }
+            }
+            else if (list is IEnumerable<double>)
+            {
+                ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.Double, out listHandle);
+                pos = 0;
+                foreach (double val in (IEnumerable<double>)list)
+                {
+                    ret = Interop.IoTConnectivity.Common.List.AddDouble(listHandle, val, pos++);
+                    if (ret != (int)IoTConnectivityError.None)
+                    {
+                        Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+                        throw IoTConnectivityErrorFactory.GetException(ret);
+                    }
+                }
+            }
+            else if (list is IEnumerable<bool>)
+            {
+                ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.Bool, out listHandle);
+                pos = 0;
+                foreach (bool val in (IEnumerable<bool>)list)
+                {
+                    ret = Interop.IoTConnectivity.Common.List.AddBool(listHandle, val, pos++);
+                    if (ret != (int)IoTConnectivityError.None)
+                    {
+                        Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+                        throw IoTConnectivityErrorFactory.GetException(ret);
+                    }
+                }
+            }
+            else if (list is IEnumerable<State>)
+            {
+                ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.State, out listHandle);
+                pos = 0;
+                foreach (State val in (IEnumerable<State>)list)
+                {
+                    ret = Interop.IoTConnectivity.Common.List.AddState(listHandle, val._resourceStateHandle, pos++);
+                    if (ret != (int)IoTConnectivityError.None)
+                    {
+                        Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add state");
+                        throw IoTConnectivityErrorFactory.GetException(ret);
+                    }
+                }
+            }
+            else if (list is IEnumerable<byte[]>)
+            {
+                ret = Interop.IoTConnectivity.Common.List.Create(Interop.IoTConnectivity.Common.DataType.ByteStr, out listHandle);
+                pos = 0;
+                foreach (byte[] val in (IEnumerable<byte[]>)list)
+                {
+                    ret = Interop.IoTConnectivity.Common.List.AddByteStr(listHandle, val, val.Length, pos++);
+                    if (ret != (int)IoTConnectivityError.None)
+                    {
+                        Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to add byte[]");
+                        throw IoTConnectivityErrorFactory.GetException(ret);
+                    }
+                }
+            }
+            else
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to GetListHandle");
+                throw IoTConnectivityErrorFactory.GetException((int)IoTConnectivityError.InvalidParameter);
+            }
+            return listHandle;
+        }
+
+        internal static object GetList(IntPtr listHandle)
+        {
+            IList list = null;
+            int type;
+            int ret = Interop.IoTConnectivity.Common.List.GetType(listHandle, out type);
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get type");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+            switch ((Interop.IoTConnectivity.Common.DataType)type)
+            {
+                case Interop.IoTConnectivity.Common.DataType.Int:
+                    {
+                        list = new List<int>();
+                        Interop.IoTConnectivity.Common.List.IntCallback cb = (int pos, int value, IntPtr userData) =>
+                        {
+                            list.Add(value);
+                            return true;
+                        };
+                        ret = Interop.IoTConnectivity.Common.List.ForeachInt(listHandle, cb, IntPtr.Zero);
+                        break;
+                    }
+                case Interop.IoTConnectivity.Common.DataType.Bool:
+                    {
+                        list = new List<bool>();
+                        Interop.IoTConnectivity.Common.List.BoolCallback cb = (int pos, bool value, IntPtr userData) =>
+                        {
+                            list.Add(value);
+                            return true;
+                        };
+                        ret = Interop.IoTConnectivity.Common.List.ForeachBool(listHandle, cb, IntPtr.Zero);
+                        break;
+                    }
+                case Interop.IoTConnectivity.Common.DataType.Double:
+                    {
+                        list = new List<double>();
+                        Interop.IoTConnectivity.Common.List.DoubleCallback cb = (int pos, double value, IntPtr userData) =>
+                        {
+                            list.Add(value);
+                            return true;
+                        };
+                        ret = Interop.IoTConnectivity.Common.List.ForeachDouble(listHandle, cb, IntPtr.Zero);
+                        break;
+                    }
+                case Interop.IoTConnectivity.Common.DataType.String:
+                    {
+                        list = new List<string>();
+                        Interop.IoTConnectivity.Common.List.StrCallback cb = (int pos, string value, IntPtr userData) =>
+                        {
+                            list.Add(value);
+                            return true;
+                        };
+                        ret = Interop.IoTConnectivity.Common.List.ForeachStr(listHandle, cb, IntPtr.Zero);
+                        break;
+                    }
+                case Interop.IoTConnectivity.Common.DataType.State:
+                    {
+                        list = new List<State>();
+                        Interop.IoTConnectivity.Common.List.StateCallback cb = (int pos, IntPtr value, IntPtr userData) =>
+                        {
+                            list.Add(new State(value));
+                            return true;
+                        };
+                        ret = Interop.IoTConnectivity.Common.List.ForeachState(listHandle, cb, IntPtr.Zero);
+                        break;
+                    }
+                case Interop.IoTConnectivity.Common.DataType.ByteStr:
+                    {
+                        list = new List<byte[]>();
+                        Interop.IoTConnectivity.Common.List.ByteStrCallback cb = (int pos, byte[] value, int len, IntPtr userData) =>
+                        {
+                            list.Add(value);
+                            return true;
+                        };
+                        ret = Interop.IoTConnectivity.Common.List.ForeachByteStr(listHandle, cb, IntPtr.Zero);
+                        break;
+                    }
+                case Interop.IoTConnectivity.Common.DataType.List:
+                    {
+                        list = new List<List<object>>();
+                        Interop.IoTConnectivity.Common.List.ListCallback cb = (int pos, IntPtr value, IntPtr userData) =>
+                        {
+                            object childList = GetList(value);
+                            list.Add(childList);
+                            return true;
+                        };
+                        ret = Interop.IoTConnectivity.Common.List.ForeachList(listHandle, cb, IntPtr.Zero);
+                        break;
+                    }
+                default:
+                    break;
+            }
+            if (ret != (int)IoTConnectivityError.None)
+            {
+                Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get state");
+                throw IoTConnectivityErrorFactory.GetException(ret);
+            }
+            return list;
+        }
+    }
+}
diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/StateChangedEventArgs.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/StateChangedEventArgs.cs
new file mode 100755 (executable)
index 0000000..1801353
--- /dev/null
@@ -0,0 +1,24 @@
+/// 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;
+
+namespace Tizen.Network.IoTConnectivity
+{
+    /// <summary>
+    /// StateChangedEventArgs class. This class is an event arguments of the StateChanged event.
+    /// </summary>
+    public class StateChangedEventArgs : EventArgs
+    {
+        /// <summary>
+        /// State property.
+        /// </summary>
+        /// <returns>ResourceState State.</returns>
+        public ResourceState State { get; internal set; }
+    }
+}
diff --git a/packaging/csapi-network-iotconnectivity.manifest b/packaging/csapi-network-iotconnectivity.manifest
new file mode 100644 (file)
index 0000000..75b0fa5
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+    <request>
+        <domain name="_"/>
+    </request>
+</manifest>
diff --git a/packaging/csapi-network-iotconnectivity.pc.in b/packaging/csapi-network-iotconnectivity.pc.in
new file mode 100644 (file)
index 0000000..2849fd8
--- /dev/null
@@ -0,0 +1,5 @@
+Name: csapi-network-iotconnectivity
+Description: Tizen IoT Connectivity API for C#
+Version: @version@
+Libs: -r:@dllpath@/@dllname@
+Requires:
diff --git a/packaging/csapi-network-iotconnectivity.spec b/packaging/csapi-network-iotconnectivity.spec
new file mode 100755 (executable)
index 0000000..298ef09
--- /dev/null
@@ -0,0 +1,81 @@
+%define dllpath %{_libdir}/mono/tizen
+%define dllname Tizen.Network.IoTConnectivity.dll
+
+Name:       csapi-network-iotconnectivity
+Summary:    Tizen IoT Connectivity API for C#
+Version:    1.0.0
+Release:    1
+Group:      Development/Libraries
+License:    Apache-2.0
+URL:        https://www.tizen.org
+Source0:    %{name}-%{version}.tar.gz
+Source1:    %{name}.manifest
+Source2:    %{name}.pc.in
+
+# TODO: replace mono-compiler, mono-devel to mcs, mono-shlib-cop
+BuildRequires: mono-compiler
+BuildRequires: mono-devel
+# TODO: replace mono-core to gacutil.
+#       mono-core should provide the symbol 'gacutil'
+Requires(post): mono-core
+Requires(postun): mono-core
+
+# P/Invoke Dependencies
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(capi-appfw-application)
+
+# P/Invoke Runtime Dependencies
+# TODO: It should be removed after fix tizen-rpm-config
+Requires: glib-2.0
+BuildRequires: pkgconfig(iotcon)
+# DLL Dependencies
+BuildRequires: pkgconfig(csapi-tizen)
+#BuildRequires: ...
+
+%description
+Tizen API for C#
+
+%package devel
+Summary:    Development package for %{name}
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+Development package for %{name}
+
+%prep
+%setup -q
+
+cp %{SOURCE1} .
+
+%build
+# build dll
+make
+
+# check p/invoke
+if [ -x %{dllname} ]; then
+  RET=`mono-shlib-cop %{dllname}`; \
+  CNT=`echo $RET | grep -E "^error:" | wc -l`; \
+  if [ $CNT -gt 0 ]; then exit 1; fi
+fi
+
+%install
+# copy dll
+mkdir -p %{buildroot}%{dllpath}
+install -p -m 644 %{dllname} %{buildroot}%{dllpath}
+
+# generate pkgconfig
+mkdir -p %{buildroot}%{_libdir}/pkgconfig
+sed -e "s#@version@#%{version}#g" \
+    -e "s#@dllpath@#%{dllpath}#g" \
+    -e "s#@dllname@#%{dllname}#g" \
+    %{SOURCE2} > %{buildroot}%{_libdir}/pkgconfig/%{name}.pc
+
+%post
+gacutil -i %{dllpath}/%{dllname}
+
+%files
+%{dllpath}/%{dllname}
+
+%files devel
+%{_libdir}/pkgconfig/%{name}.pc