Release 4.0.0-preview1-00165
authorDotnetBuild <dotnetbuild.tizen@gmail.com>
Thu, 7 Sep 2017 05:09:39 +0000 (14:09 +0900)
committerDotnetBuild <dotnetbuild.tizen@gmail.com>
Thu, 7 Sep 2017 05:09:39 +0000 (14:09 +0900)
19 files changed:
Artifacts/Tizen.NET.4.0.0-preview1-00165.nupkg [moved from Artifacts/Tizen.NET.4.0.0-preview1-00162.nupkg with 97% similarity]
Artifacts/Tizen.NET.4.0.0-preview1-00165.symbols.nupkg [moved from Artifacts/Tizen.NET.4.0.0-preview1-00162.symbols.nupkg with 97% similarity]
Artifacts/Tizen.NET.Private.4.0.0-preview1-00165.nupkg [moved from Artifacts/Tizen.NET.Private.4.0.0-preview1-00162.nupkg with 97% similarity]
Artifacts/Tizen.NET.Private.4.0.0-preview1-00165.symbols.nupkg [moved from Artifacts/Tizen.NET.Private.4.0.0-preview1-00162.symbols.nupkg with 97% similarity]
Artifacts/Version.txt
Artifacts/bin/dummy/Tizen.Applications.MessagePort.dll
Artifacts/bin/public/Tizen.Applications.MessagePort.dll
Artifacts/bin/public/Tizen.Applications.MessagePort.pdb
Artifacts/bin/public/Tizen.Applications.MessagePort.xml
Artifacts/bin/public/Tizen.Content.MediaContent.dll
Artifacts/bin/public/Tizen.Multimedia.dll
build/build.dummy.csproj
build/build.proj
packaging/csapi-tizenfx.spec
src/Tizen.Applications.MessagePort/Interop/Interop.MessagePort.cs
src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/MessagePort.cs
src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/MessagePortErrorFactory.cs
src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/RemotePort.cs [new file with mode: 0755]
src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/RemotePortStateChangedEventArgs.cs [new file with mode: 0755]

similarity index 97%
rename from Artifacts/Tizen.NET.4.0.0-preview1-00162.nupkg
rename to Artifacts/Tizen.NET.4.0.0-preview1-00165.nupkg
index 0d8f46d..f55e214 100644 (file)
Binary files a/Artifacts/Tizen.NET.4.0.0-preview1-00162.nupkg and b/Artifacts/Tizen.NET.4.0.0-preview1-00165.nupkg differ
similarity index 97%
rename from Artifacts/Tizen.NET.4.0.0-preview1-00162.symbols.nupkg
rename to Artifacts/Tizen.NET.4.0.0-preview1-00165.symbols.nupkg
index 0d36d3b..952a8e7 100644 (file)
Binary files a/Artifacts/Tizen.NET.4.0.0-preview1-00162.symbols.nupkg and b/Artifacts/Tizen.NET.4.0.0-preview1-00165.symbols.nupkg differ
similarity index 97%
rename from Artifacts/Tizen.NET.Private.4.0.0-preview1-00162.nupkg
rename to Artifacts/Tizen.NET.Private.4.0.0-preview1-00165.nupkg
index 40f1f3f..4c8a29c 100644 (file)
Binary files a/Artifacts/Tizen.NET.Private.4.0.0-preview1-00162.nupkg and b/Artifacts/Tizen.NET.Private.4.0.0-preview1-00165.nupkg differ
similarity index 97%
rename from Artifacts/Tizen.NET.Private.4.0.0-preview1-00162.symbols.nupkg
rename to Artifacts/Tizen.NET.Private.4.0.0-preview1-00165.symbols.nupkg
index d04ed89..294b4ff 100644 (file)
Binary files a/Artifacts/Tizen.NET.Private.4.0.0-preview1-00162.symbols.nupkg and b/Artifacts/Tizen.NET.Private.4.0.0-preview1-00165.symbols.nupkg differ
index b771960..049cb87 100644 (file)
@@ -1,4 +1,4 @@
 Prefix:4.0.0\r
-Suffix:preview1-00162\r
-Number:162\r
-VCS:3af5310e0d6a5cfd114e20a7e0d4c2976db796ae\r
+Suffix:preview1-00165\r
+Number:165\r
+VCS:cac44c48e4d3f296cb0d822d95fd0378c0d36131\r
index b3dcc4f..b28153f 100644 (file)
Binary files a/Artifacts/bin/dummy/Tizen.Applications.MessagePort.dll and b/Artifacts/bin/dummy/Tizen.Applications.MessagePort.dll differ
index ef0c2f2..d65aa6f 100644 (file)
Binary files a/Artifacts/bin/public/Tizen.Applications.MessagePort.dll and b/Artifacts/bin/public/Tizen.Applications.MessagePort.dll differ
index 55efffb..4944edf 100644 (file)
Binary files a/Artifacts/bin/public/Tizen.Applications.MessagePort.pdb and b/Artifacts/bin/public/Tizen.Applications.MessagePort.pdb differ
index b55ef18..beaaf7c 100644 (file)
@@ -20,7 +20,7 @@
             </summary>\r
             <param name="portName">The name of the local message port.</param>\r
             <param name="trusted">If true, it is the trusted message port of application, otherwise false.</param>\r
-            <exception cref="T:System.InvalidOperationException">Thrown when portName is null or empty.</exception>\r
+            <exception cref="T:System.ArgumentException">Thrown when portName is null or empty.</exception>\r
             <code>\r
             MessagePort messagePort = new MessagePort("SenderPort", true);\r
             </code>\r
@@ -65,7 +65,9 @@
             <summary>\r
             Register the local message port.\r
             </summary>\r
-            <exception cref="T:System.InvalidOperationException">Thrown when portName is already used, when there is an invalid parameter, when out of memory, when there is an I/O error.</exception>\r
+            <exception cref="T:System.InvalidOperationException">Thrown when portName is already used, when there is an I/O error.</exception>\r
+            <exception cref="T:System.ArgumentException">Thrown when there is an invalid parameter.</exception>\r
+            <exception cref="T:System.OutOfMemoryException">Thrown when out of memory.</exception>\r
             <code>\r
             MessagePort messagePort = new MessagePort("SenderPort", true);\r
             messagePort.MessageReceived += MessageReceivedCallback;\r
@@ -76,7 +78,9 @@
             <summary>\r
             Unregisters the local message port.\r
             </summary>\r
-            <exception cref="T:System.InvalidOperationException">Thrown when messageport is already stopped, when there is an invalid parameter, when the port is not found, when out of memory, when there is an I/O error.</exception>\r
+            <exception cref="T:System.InvalidOperationException">Thrown when messageport is already stopped, when there is an I/O error, when the port is not found.</exception>\r
+            <exception cref="T:System.ArgumentException">Thrown when there is an invalid parameter.</exception>\r
+            <exception cref="T:System.OutOfMemoryException">Thrown when out of memory.</exception>\r
             <code>\r
             MessagePort messagePort = new MessagePort("SenderPort", true);\r
             messagePort.MessageReceived += MessageReceivedCallback;\r
@@ -86,7 +90,7 @@
                 message.AddItem("message", "a_string");\r
                 messagePort.Send(message, "ReceiverAppID", "ReceiverPort");\r
             }\r
-            messageProt.StopListening();\r
+            messagePort.StopListening();\r
             </code>\r
         </member>\r
         <member name="M:Tizen.Applications.Messages.MessagePort.Send(Tizen.Applications.Bundle,System.String,System.String)">\r
             <param name="message">The message to be passed to the remote application, the recommended message size is under 4KB.</param>\r
             <param name="remoteAppId">The ID of the remote application.</param>\r
             <param name="remotePortName">The name of the remote message port.</param>\r
-            <exception cref="T:System.InvalidOperationException">Thrown when there is an invalid parameter, when the port is not found, when out of memory, when there is an I/O error.</exception>\r
+            <exception cref="T:System.InvalidOperationException">Thrown when there is an I/O error, when the port is not found.</exception>\r
+            <exception cref="T:System.ArgumentException">Thrown when there is an invalid parameter.</exception>\r
+            <exception cref="T:System.OutOfMemoryException">Thrown when out of memory.</exception>\r
             <exception cref="T:System.ArgumentOutOfRangeException">Thrown when message has exceeded the maximum limit(4KB).</exception>\r
             <code>\r
             MessagePort messagePort = new MessagePort("SenderPort", true);\r
             <param name="remoteAppId">The ID of the remote application.</param>\r
             <param name="remotePortName">The name of the remote message port.</param>\r
             <param name="trusted">If true, it is the trusted message port of remote application, otherwise false.</param>\r
-            <exception cref="T:System.InvalidOperationException">Thrown when there is an invalid parameter, when the port is not found, when out of memory, when there is an I/O error.</exception>\r
+            <exception cref="T:System.InvalidOperationException">Thrown when there is an I/O error, when the port is not found.</exception>\r
+            <exception cref="T:System.ArgumentException">Thrown when there is an invalid parameter.</exception>\r
+            <exception cref="T:System.OutOfMemoryException">Thrown when out of memory.</exception>\r
             <exception cref="T:System.ArgumentOutOfRangeException">Thrown when message has exceeded the maximum limit(4KB).</exception>\r
+            <exception cref="T:System.UnauthorizedAccessException">Thrown when the remote application is not signed with the same certificate.</exception>\r
             <code>\r
             MessagePort messagePort = new MessagePort("SenderPort", true);\r
             messagePort.MessageReceived += MessageReceivedCallback;\r
         </member>\r
         <member name="M:Tizen.Applications.Messages.MessagePort.Dispose(System.Boolean)">\r
             <summary>\r
-            Releases the unmanaged resource used by the MessagePort class specifying whether to perform a normal dispose operation.\r
+            Releases the unmanaged resources used by the MessagePort class specifying whether to perform a normal dispose operation.\r
             </summary>\r
             <param name="disposing">true for a normal dispose operation; false to finalize the handle.</param>\r
         </member>\r
             The message passed from the remote application.\r
             </summary>\r
         </member>\r
+        <member name="T:Tizen.Applications.Messages.RemotePort">\r
+            <summary>\r
+            The RemotePort Class provides functions to get if the remote port is running and to get whether the remote port is registered or unregistered.\r
+            </summary>\r
+            <since_tizen> 4 </since_tizen>\r
+        </member>\r
+        <member name="M:Tizen.Applications.Messages.RemotePort.#ctor(System.String,System.String,System.Boolean)">\r
+            <summary>\r
+            Constructor of the RemotePort class.\r
+            </summary>\r
+            <since_tizen> 4 </since_tizen>\r
+            <param name="appId">The Id of the remote application</param>\r
+            <param name="portName">The name of the remote message port</param>\r
+            <param name="trusted">If true is the trusted message port of application, otherwise false</param>\r
+            <exception cref="T:System.ArgumentException">Thrown when appId is null or empty, when portName is null or empty</exception>\r
+            <code>\r
+            RemotePort remotePort = new RemotePort("org.tizen.example.messageport", "SenderPort", false);\r
+            </code>\r
+        </member>\r
+        <member name="M:Tizen.Applications.Messages.RemotePort.Finalize">\r
+            <summary>\r
+            Destructor of the RemotePort class.\r
+            </summary>\r
+            <since_tizen> 4 </since_tizen>\r
+        </member>\r
+        <member name="P:Tizen.Applications.Messages.RemotePort.AppId">\r
+            <summary>\r
+            The AppId of the remote port\r
+            </summary>\r
+            <since_tizen> 4 </since_tizen>\r
+            <returns> Return appid of RemotePort </returns>\r
+        </member>\r
+        <member name="P:Tizen.Applications.Messages.RemotePort.PortName">\r
+            <summary>\r
+            The name of the remote message port\r
+            </summary>\r
+            <since_tizen> 4 </since_tizen>\r
+            <returns> Return name of RemotePort </returns>\r
+        </member>\r
+        <member name="P:Tizen.Applications.Messages.RemotePort.Trusted">\r
+            <summary>\r
+            If true the remote port is a trusted port, otherwise if false it is not\r
+            </summary>\r
+            <since_tizen> 4 </since_tizen>\r
+             <returns> Return true if RemotePort is trusted </returns>\r
+        </member>\r
+        <member name="M:Tizen.Applications.Messages.RemotePort.IsRunning">\r
+            <summary>\r
+            Check if the remote message port is running.\r
+            </summary>\r
+            <since_tizen> 4 </since_tizen>\r
+            <exception cref="T:System.InvalidOperationException">Thrown when there is an I/O error</exception>\r
+            <exception cref="T:System.OutOfMemoryException">Thrown when out of memory.</exception>\r
+            <code>\r
+            Remote remotePort = new RemotePort("org.tizen.example", "SenderPort", true);\r
+            bool isRunning = remotePort.isRunning();\r
+            </code>\r
+            <returns> Return true if Remote Port is running </returns>\r
+        </member>\r
+        <member name="E:Tizen.Applications.Messages.RemotePort.RemotePortStateChanged">\r
+            <summary>\r
+            Called when the remote port is registered or unregistered.\r
+            </summary>\r
+            <since_tizen> 4 </since_tizen>\r
+            <exception cref="T:System.InvalidOperationException">Thrown when there is an I/O error</exception>\r
+            <exception cref="T:System.OutOfMemoryException">Thrown when out of memory.</exception>\r
+            <code>\r
+            Remote remotePort = new RemotePort("org.tizen.example", "SenderPort", true);\r
+            remotePort.RemotePortStateChanged += RemotePortStateChangedCallback;\r
+            static void RemotePortStateChangedCallback(object sender, MessageReceivedEventArgs e)\r
+            {\r
+                switch (e.Status)\r
+                {\r
+                case State.Registered :\r
+                    Console.WriteLine("Remote Port Registered ");\r
+                    break;\r
+                case State.Unregistered :\r
+                    Console.WriteLine("Remote Port Unregistered ");\r
+                    break;\r
+                default :\r
+                    break;\r
+                }\r
+            }\r
+            </code>\r
+        </member>\r
+        <member name="M:Tizen.Applications.Messages.RemotePort.Dispose(System.Boolean)">\r
+            <summary>\r
+            Releases the unmanaged resources used by the RemotePort class specifying whether to perform a normal dispose operation.\r
+            </summary>\r
+            <param name="disposing">true for a normal dispose operation; false to finalize the handle.</param>\r
+        </member>\r
+        <member name="M:Tizen.Applications.Messages.RemotePort.Dispose">\r
+            <summary>\r
+            Releases all resources used by the RemotePort class.\r
+            </summary>\r
+            <since_tizen> 4 </since_tizen>\r
+        </member>\r
+        <member name="T:Tizen.Applications.Messages.State">\r
+            <summary>\r
+            Enumeration for Remote Message Port state type\r
+            </summary>\r
+            <since_tizen> 4 </since_tizen>\r
+        </member>\r
+        <member name="F:Tizen.Applications.Messages.State.Unregistered">\r
+            <summary>\r
+            Value representing Remote Port state is unregistered\r
+            </summary>\r
+        </member>\r
+        <member name="F:Tizen.Applications.Messages.State.Registered">\r
+            <summary>\r
+            Value representing Remote Port state is registered\r
+            </summary>\r
+        </member>\r
+        <member name="T:Tizen.Applications.Messages.RemotePortStateChangedEventArgs">\r
+            <summary>\r
+            An extended EventArgs class which contains state of remote message port\r
+            </summary>\r
+            <since_tizen> 4 </since_tizen>\r
+        </member>\r
+        <member name="P:Tizen.Applications.Messages.RemotePortStateChangedEventArgs.Status">\r
+            <summary>\r
+            The State of remote port\r
+            </summary>\r
+            <since_tizen> 4 </since_tizen>\r
+        </member>\r
         <member name="T:Tizen.Applications.Messages.RemoteValues">\r
             <summary>\r
             Contains AppId, port name, and trusted.\r
index b9e6455..77df6ff 100644 (file)
Binary files a/Artifacts/bin/public/Tizen.Content.MediaContent.dll and b/Artifacts/bin/public/Tizen.Content.MediaContent.dll differ
index db513b0..9b44868 100644 (file)
Binary files a/Artifacts/bin/public/Tizen.Multimedia.dll and b/Artifacts/bin/public/Tizen.Multimedia.dll differ
index 2100ad3..264b527 100644 (file)
@@ -10,6 +10,7 @@
     <GenerateDependencyFile>false</GenerateDependencyFile>
     <DummyAssemblyVersion>$(VersionPrefix)</DummyAssemblyVersion>
     <BaseIntermediateOutputPath>$(OutputBaseDir)obj\</BaseIntermediateOutputPath>
+    <OutDir>$(OutputDummyDir)</OutDir>
   </PropertyGroup>
 
   <!-- Properties for directories -->
index ccb85da..dc1f4bf 100644 (file)
@@ -5,6 +5,7 @@
   <!-- Common Properties -->
   <PropertyGroup>
     <PublicModuleListFile>$(PackageSrcDir)PublicModuleList.txt</PublicModuleListFile>
+    <DummyBuildProject>$(MSBuildThisFileDirectory)build.dummy.csproj</DummyBuildProject>
   </PropertyGroup>
 
   <!-- Build Properties -->
   <Target Name="Build" DependsOnTargets="Clean">
 
     <MSBuild Projects="@(ProjectToBuild)"
-             Properties="Configuration=$(Configuration);OutDir=$(OutputPlatformDir);RestoreSources=$(RestoreSources)"
+             Properties="Configuration=$(Configuration);RestoreSources=$(RestoreSources)"
+             Targets="Restore" />
+
+    <MSBuild Projects="@(ProjectToBuild)"
+             Properties="Configuration=$(Configuration);OutDir=$(OutputPlatformDir)"
              BuildInParallel="true"
              UseResultsCache="true"
-             Targets="Restore;Rebuild" />
+             Targets="Build" />
 
     <ReadLinesFromFile File="$(PublicModuleListFile)">
       <Output TaskParameter="Lines" ItemName="PublicProject" />
   -->
   <Target Name="BuildDummy">
 
-    <MSBuild Projects="$(MSBuildThisFileDirectory)build.dummy.csproj"
-             Properties="Configuration=$(Configuration);OutDir=$(OutputBaseDir)\obj\bin;RestoreSources=$(RestoreSources)"
-             BuildInParallel="true"
-             UseResultsCache="true"
+    <MSBuild Projects="$(DummyBuildProject)"
+             Properties="Configuration=$(Configuration);RestoreSources=$(RestoreSources)"
              Targets="Restore;Rebuild" />
 
   </Target>
index 3ead7da..34860d7 100644 (file)
@@ -10,7 +10,7 @@
 
 Name:       csapi-tizenfx
 Summary:    Assemblies of Tizen .NET
-Version:    4.0.0.162
+Version:    4.0.0.165
 Release:    1
 Group:      Development/Libraries
 License:    Apache-2.0
index bcbbc63..564e7ba 100755 (executable)
@@ -41,7 +41,25 @@ internal static partial class Interop
         [DllImport(Libraries.MessagePort, EntryPoint = "message_port_send_trusted_message_with_local_port", CallingConvention = CallingConvention.Cdecl)]
         internal static extern int SendTrustedMessageWithLocalPort(string remote_app_id, string remote_port, SafeBundleHandle message, int local_port_id);
 
+        [DllImport(Libraries.MessagePort, EntryPoint = "message_port_check_remote_port", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int CheckRemotePort(string remote_app_id, string remote_port, out bool exist);
+
+        [DllImport(Libraries.MessagePort, EntryPoint = "message_port_check_trusted_remote_port", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int CheckTrustedRemotePort(string remote_app_id, string remote_port, out bool exist);
+
+        [DllImport(Libraries.MessagePort, EntryPoint = "message_port_add_registered_cb", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int AddRegisteredCallback(string remote_app_id, string remote_port, bool trusted_remote_port, message_port_registration_event_cb callback, IntPtr userData, out int watcher_id);
+
+        [DllImport(Libraries.MessagePort, EntryPoint = "message_port_add_unregistered_cb", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int AddUnregisteredCallback(string remote_app_id, string remote_port, bool trusted_remote_port, message_port_registration_event_cb callback, IntPtr userData, out int watcher_id);
+
+        [DllImport(Libraries.MessagePort, EntryPoint = "message_port_remove_registration_event_cb", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int RemoveRegistrationCallback(int watcher_id);
+
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         internal delegate void message_port_message_cb(int local_port_id, string remote_app_id, string remote_port, bool trusted_remote_port, IntPtr message, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void message_port_registration_event_cb(string remote_app_id, string remote_port, bool trusted_remote_port, IntPtr userData);
     }
 }
index c92362a..dc44e9d 100755 (executable)
@@ -52,7 +52,7 @@ namespace Tizen.Applications.Messages
         /// </summary>
         /// <param name="portName">The name of the local message port.</param>
         /// <param name="trusted">If true, it is the trusted message port of application, otherwise false.</param>
-        /// <exception cref="System.InvalidOperationException">Thrown when portName is null or empty.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when portName is null or empty.</exception>
         /// <code>
         /// MessagePort messagePort = new MessagePort("SenderPort", true);
         /// </code>
@@ -125,7 +125,9 @@ namespace Tizen.Applications.Messages
         /// <summary>
         /// Register the local message port.
         /// </summary>
-        /// <exception cref="System.InvalidOperationException">Thrown when portName is already used, when there is an invalid parameter, when out of memory, when there is an I/O error.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when portName is already used, when there is an I/O error.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when there is an invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when out of memory.</exception>
         /// <code>
         /// MessagePort messagePort = new MessagePort("SenderPort", true);
         /// messagePort.MessageReceived += MessageReceivedCallback;
@@ -137,7 +139,7 @@ namespace Tizen.Applications.Messages
             {
                 if (s_portMap.Contains(_portName))
                 {
-                    throw new InvalidOperationException(_portName + " is already used");
+                    MessagePortErrorFactory.ThrowException((int)MessagePortError.InvalidOperation, _portName + "is already used");
                 }
                 _messageCallBack = (int localPortId, string remoteAppId, string remotePortName, bool trusted, IntPtr message, IntPtr userData) =>
                 {
@@ -163,7 +165,7 @@ namespace Tizen.Applications.Messages
                             Interop.MessagePort.RegisterPort(_portName, _messageCallBack, IntPtr.Zero);
 
                 if (_portId <= 0)
-                    throw new InvalidOperationException("Can't Listening with " + _portName);
+                    MessagePortErrorFactory.ThrowException(_portId, "RegisterPort", _portName);
 
                 s_portMap.Add(_portName);
                 _listening = true;
@@ -173,7 +175,9 @@ namespace Tizen.Applications.Messages
         /// <summary>
         /// Unregisters the local message port.
         /// </summary>
-        /// <exception cref="System.InvalidOperationException">Thrown when messageport is already stopped, when there is an invalid parameter, when the port is not found, when out of memory, when there is an I/O error.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when messageport is already stopped, when there is an I/O error, when the port is not found.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when there is an invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when out of memory.</exception>
         /// <code>
         /// MessagePort messagePort = new MessagePort("SenderPort", true);
         /// messagePort.MessageReceived += MessageReceivedCallback;
@@ -183,13 +187,13 @@ namespace Tizen.Applications.Messages
         ///     message.AddItem("message", "a_string");
         ///     messagePort.Send(message, "ReceiverAppID", "ReceiverPort");
         /// }
-        /// messageProt.StopListening();
+        /// messagePort.StopListening();
         /// </code>
         public void StopListening()
         {
             if (!_listening)
             {
-                throw new InvalidOperationException("Already stopped");
+                MessagePortErrorFactory.ThrowException((int)MessagePortError.InvalidOperation, "Already stopped");
             }
 
             int ret = _trusted ?
@@ -198,7 +202,7 @@ namespace Tizen.Applications.Messages
 
             if (ret != (int)MessagePortError.None)
             {
-                MessagePortErrorFactory.ThrowException(ret);
+                MessagePortErrorFactory.ThrowException(ret, "Error Unregister port");
             }
 
             lock (s_lock)
@@ -215,7 +219,9 @@ namespace Tizen.Applications.Messages
         /// <param name="message">The message to be passed to the remote application, the recommended message size is under 4KB.</param>
         /// <param name="remoteAppId">The ID of the remote application.</param>
         /// <param name="remotePortName">The name of the remote message port.</param>
-        /// <exception cref="System.InvalidOperationException">Thrown when there is an invalid parameter, when the port is not found, when out of memory, when there is an I/O error.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when there is an I/O error, when the port is not found.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when there is an invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when out of memory.</exception>
         /// <exception cref="System.ArgumentOutOfRangeException">Thrown when message has exceeded the maximum limit(4KB).</exception>
         /// <code>
         /// MessagePort messagePort = new MessagePort("SenderPort", true);
@@ -239,8 +245,11 @@ namespace Tizen.Applications.Messages
         /// <param name="remoteAppId">The ID of the remote application.</param>
         /// <param name="remotePortName">The name of the remote message port.</param>
         /// <param name="trusted">If true, it is the trusted message port of remote application, otherwise false.</param>
-        /// <exception cref="System.InvalidOperationException">Thrown when there is an invalid parameter, when the port is not found, when out of memory, when there is an I/O error.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when there is an I/O error, when the port is not found.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when there is an invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when out of memory.</exception>
         /// <exception cref="System.ArgumentOutOfRangeException">Thrown when message has exceeded the maximum limit(4KB).</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when the remote application is not signed with the same certificate.</exception>
         /// <code>
         /// MessagePort messagePort = new MessagePort("SenderPort", true);
         /// messagePort.MessageReceived += MessageReceivedCallback;
@@ -255,11 +264,11 @@ namespace Tizen.Applications.Messages
         {
             if (!_listening)
             {
-                throw new InvalidOperationException("Should start listen before send");
+                MessagePortErrorFactory.ThrowException((int)MessagePortError.InvalidOperation, "Should start listen before send");
             }
             if (message == null)
             {
-                throw new ArgumentNullException("message");
+                MessagePortErrorFactory.ThrowException((int)MessagePortError.InvalidParameter, "message is null", "Message");
             }
             int ret = trusted ?
                         Interop.MessagePort.SendTrustedMessageWithLocalPort(remoteAppId, remotePortName, message.SafeBundleHandle, _portId) :
@@ -276,7 +285,7 @@ namespace Tizen.Applications.Messages
         }
 
         /// <summary>
-        /// Releases the unmanaged resource used by the MessagePort class specifying whether to perform a normal dispose operation.
+        /// Releases the unmanaged resources used by the MessagePort class specifying whether to perform a normal dispose operation.
         /// </summary>
         /// <param name="disposing">true for a normal dispose operation; false to finalize the handle.</param>
         protected virtual void Dispose(bool disposing)
index 949d067..5215ac1 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 using System;
+using System.Runtime.CompilerServices;
 using Tizen.Internals.Errors;
 
 namespace Tizen.Applications.Messages
@@ -34,22 +35,28 @@ namespace Tizen.Applications.Messages
 
     internal static class MessagePortErrorFactory
     {
-        internal static void ThrowException(int errorCode, string errorMessage = null, string paramName = null)
+        private const string LogTag = "Tizen.Applications.MessagePort";
+        internal static void ThrowException(int errorCode, string errorMessage = null, string paramName = null,
+            [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0)
         {
             MessagePortError err = (MessagePortError)errorCode;
             if (String.IsNullOrEmpty(errorMessage))
             {
                 errorMessage = err.ToString();
             }
+
+            Log.Error(LogTag, $"{memberName}({lineNumber.ToString()}) : {filePath}");
+            Log.Error(LogTag, "Error : " + errorMessage);
+
             switch ((MessagePortError)errorCode)
             {
                 case MessagePortError.IOError:
-                case MessagePortError.OutOfMemory:
                 case MessagePortError.InvalidOperation:
                 case MessagePortError.PortNotFound:
                 case MessagePortError.ResourceUnavailable: throw new InvalidOperationException(errorMessage);
-                case MessagePortError.InvalidParameter:
-                case MessagePortError.CertificateNotMatch: throw new ArgumentException(errorMessage, paramName);
+                case MessagePortError.InvalidParameter: throw new ArgumentException(errorMessage, paramName);
+                case MessagePortError.CertificateNotMatch: throw new UnauthorizedAccessException(errorMessage);
+                case MessagePortError.OutOfMemory: throw new OutOfMemoryException(errorMessage);
                 case MessagePortError.MaxExceeded: throw new ArgumentOutOfRangeException(paramName, errorMessage);
             }
         }
diff --git a/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/RemotePort.cs b/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/RemotePort.cs
new file mode 100755 (executable)
index 0000000..5e9f541
--- /dev/null
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.\
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Messages
+{
+    using System;
+
+    /// <summary>
+    /// The RemotePort Class provides functions to get if the remote port is running and to get whether the remote port is registered or unregistered.
+    /// </summary>
+    /// <since_tizen> 4 </since_tizen>
+    public class RemotePort : IDisposable
+    {
+        private int _watcherIdForRegistered = -1;
+        private int _watcherIdForUnRegistered = -1;
+        private bool _disposed = false;
+
+        private Interop.MessagePort.message_port_registration_event_cb _registeredCallBack;
+        private Interop.MessagePort.message_port_registration_event_cb _unregisteredCallBack;
+
+        private EventHandler<RemotePortStateChangedEventArgs> _remotePortRegistered;
+        private EventHandler<RemotePortStateChangedEventArgs> _remotePortUnregistered;
+
+        private readonly string _portName = null;
+        private readonly string _appId = null;
+        private readonly bool _trusted = false;
+
+        private bool _isRunning = false;
+
+        /// <summary>
+        /// Constructor of the RemotePort class.
+        /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <param name="appId">The Id of the remote application</param>
+        /// <param name="portName">The name of the remote message port</param>
+        /// <param name="trusted">If true is the trusted message port of application, otherwise false</param>
+        /// <exception cref="System.ArgumentException">Thrown when appId is null or empty, when portName is null or empty</exception>
+        /// <code>
+        /// RemotePort remotePort = new RemotePort("org.tizen.example.messageport", "SenderPort", false);
+        /// </code>
+        public RemotePort(String appId, string portName, bool trusted)
+        {
+            if (String.IsNullOrEmpty(appId) || String.IsNullOrEmpty(portName))
+            {
+                MessagePortErrorFactory.ThrowException((int)MessagePortError.InvalidParameter, "Remote Port", "AppId or PortName");
+            }
+
+            _appId = appId;
+            _portName = portName;
+            _trusted = trusted;
+
+            _registeredCallBack = (string remoteAppId, string remotePortName, bool remoteTrusted, IntPtr userData) =>
+            {
+                RemotePortStateChangedEventArgs args = new RemotePortStateChangedEventArgs()
+                {
+                    Status = State.Registered
+                };
+
+                _remotePortRegistered?.Invoke(this, args);
+            };
+
+            _unregisteredCallBack = (string remoteAppId, string remotePortName, bool remoteTrusted, IntPtr userData) =>
+            {
+                RemotePortStateChangedEventArgs args = new RemotePortStateChangedEventArgs()
+                {
+                    Status = State.Unregistered
+                };
+
+                _remotePortUnregistered?.Invoke(this, args);
+            };
+        }
+
+        /// <summary>
+        /// Destructor of the RemotePort class.
+        /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        ~RemotePort()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
+        /// The AppId of the remote port
+        /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <returns> Return appid of RemotePort </returns>
+        public string AppId
+        {
+            get
+            {
+                return _appId;
+            }
+        }
+
+        /// <summary>
+        /// The name of the remote message port
+        /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <returns> Return name of RemotePort </returns>
+        public string PortName
+        {
+            get
+            {
+                return _portName;
+            }
+        }
+
+        /// <summary>
+        /// If true the remote port is a trusted port, otherwise if false it is not
+        /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        ///  <returns> Return true if RemotePort is trusted </returns>
+        public bool Trusted
+        {
+            get
+            {
+                return _trusted;
+            }
+        }
+
+        /// <summary>
+        /// Check if the remote message port is running.
+        /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <exception cref="System.InvalidOperationException">Thrown when there is an I/O error</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when out of memory.</exception>
+        /// <code>
+        /// Remote remotePort = new RemotePort("org.tizen.example", "SenderPort", true);
+        /// bool isRunning = remotePort.isRunning();
+        /// </code>
+        /// <returns> Return true if Remote Port is running </returns>
+        public bool IsRunning()
+        {
+            int ret;
+
+            ret = _trusted ?
+                Interop.MessagePort.CheckTrustedRemotePort(_appId, _portName, out _isRunning) :
+                Interop.MessagePort.CheckRemotePort(_appId, _portName, out _isRunning);
+
+            if (ret != (int)MessagePortError.None)
+            {
+                MessagePortErrorFactory.ThrowException(ret);
+            }
+
+            return _isRunning;
+        }
+
+        /// <summary>
+        /// Called when the remote port is registered or unregistered.
+        /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <exception cref="System.InvalidOperationException">Thrown when there is an I/O error</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when out of memory.</exception>
+        /// <code>
+        /// Remote remotePort = new RemotePort("org.tizen.example", "SenderPort", true);
+        /// remotePort.RemotePortStateChanged += RemotePortStateChangedCallback;
+        /// static void RemotePortStateChangedCallback(object sender, MessageReceivedEventArgs e)
+        /// {
+        ///     switch (e.Status)
+        ///     {
+        ///     case State.Registered :
+        ///         Console.WriteLine("Remote Port Registered ");
+        ///         break;
+        ///     case State.Unregistered :
+        ///         Console.WriteLine("Remote Port Unregistered ");
+        ///         break;
+        ///     default :
+        ///         break;
+        ///     }
+        /// }
+        /// </code>
+        public event EventHandler<RemotePortStateChangedEventArgs> RemotePortStateChanged
+        {
+            add
+            {
+                if (_remotePortRegistered == null)
+                {
+                    int ret = AddRegistrationCallback();
+
+                    if (ret != (int)MessagePortError.None)
+                    {
+                        MessagePortErrorFactory.ThrowException(ret);
+                    }
+                }
+
+                _remotePortRegistered += value;
+                _remotePortUnregistered += value;
+            }
+
+            remove
+            {
+                if (_remotePortRegistered?.GetInvocationList()?.Length > 0)
+                {
+                    _remotePortRegistered -= value;
+                    _remotePortUnregistered -= value;
+
+                    if (_remotePortRegistered == null)
+                    {
+                        RemoveRegistrationCallback();
+                    }
+                }
+            }
+        }
+
+        private int AddRegistrationCallback()
+        {
+            if (_watcherIdForRegistered != -1)
+            {
+                Interop.MessagePort.RemoveRegistrationCallback(_watcherIdForRegistered);
+                _watcherIdForRegistered = -1;
+            }
+
+            int ret = Interop.MessagePort.AddRegisteredCallback(_appId, _portName, _trusted, _registeredCallBack, IntPtr.Zero, out _watcherIdForRegistered);
+
+            if (ret != (int)MessagePortError.None)
+            {
+                return ret;
+            }
+
+            if (_watcherIdForUnRegistered != -1)
+            {
+                Interop.MessagePort.RemoveRegistrationCallback(_watcherIdForUnRegistered);
+                _watcherIdForUnRegistered = -1;
+            }
+
+            ret = Interop.MessagePort.AddUnregisteredCallback(_appId, _portName, _trusted, _unregisteredCallBack, IntPtr.Zero, out _watcherIdForUnRegistered);
+
+            if (ret != (int)MessagePortError.None)
+            {
+                return ret;
+            }
+
+            return ret;
+        }
+
+        private void RemoveRegistrationCallback()
+        {
+            if (_watcherIdForRegistered != -1 && _watcherIdForUnRegistered != -1)
+            {
+                int ret = Interop.MessagePort.RemoveRegistrationCallback(_watcherIdForRegistered);
+
+                if (ret != (int)MessagePortError.None)
+                {
+                    MessagePortErrorFactory.ThrowException(ret);
+                }
+
+                _watcherIdForRegistered = -1;
+
+                ret = Interop.MessagePort.RemoveRegistrationCallback(_watcherIdForUnRegistered);
+
+                if (ret != (int)MessagePortError.None)
+                {
+                    MessagePortErrorFactory.ThrowException(ret);
+                }
+
+                _watcherIdForUnRegistered = -1;
+            }
+        }
+
+        /// <summary>
+        /// Releases the unmanaged resources used by the RemotePort class specifying whether to perform a normal dispose operation.
+        /// </summary>
+        /// <param name="disposing">true for a normal dispose operation; false to finalize the handle.</param>
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+            {
+                return;
+            }
+
+            RemoveRegistrationCallback();
+
+            _disposed = true;
+        }
+
+        /// <summary>
+        /// Releases all resources used by the RemotePort class.
+        /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+    }
+
+    /// <summary>
+    /// Enumeration for Remote Message Port state type
+    /// </summary>
+    /// <since_tizen> 4 </since_tizen>
+    public enum State : Byte
+    {
+        /// <summary>
+        /// Value representing Remote Port state is unregistered
+        /// </summary>
+        Unregistered = 0,
+        /// <summary>
+        /// Value representing Remote Port state is registered
+        /// </summary>
+        Registered = 1
+    }
+}
diff --git a/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/RemotePortStateChangedEventArgs.cs b/src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/RemotePortStateChangedEventArgs.cs
new file mode 100755 (executable)
index 0000000..b679eb8
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.\
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.Messages
+{
+    using System;
+
+    /// <summary>
+    /// An extended EventArgs class which contains state of remote message port
+    /// </summary>
+    /// <since_tizen> 4 </since_tizen>
+    public class RemotePortStateChangedEventArgs : EventArgs
+    {
+        /// <summary>
+        /// The State of remote port
+        /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        public State Status { get; internal set; }
+    }
+}