From 85eb2d8d811fdb1680632ea3a67b66772f9572cc Mon Sep 17 00:00:00 2001 From: WonYoung Choi Date: Tue, 26 Apr 2016 20:40:55 +0900 Subject: [PATCH] Clean up Tizen.Applications.Messages Change-Id: I7f732388d58053523b7901da816f5c2357479743 --- .../Tizen.Applications.Messages/MessagePort.cs | 54 +++++++--------------- .../MessagePortErrorFactory.cs | 5 +- .../MessageReceivedEventArgs.cs | 16 +------ .../Tizen.Applications.Messages/RemoteValues.cs | 25 ++-------- 4 files changed, 24 insertions(+), 76 deletions(-) diff --git a/Tizen.Applications/Tizen.Applications.Messages/MessagePort.cs b/Tizen.Applications/Tizen.Applications.Messages/MessagePort.cs index 48b6cf1..2cd1d8d 100755 --- a/Tizen.Applications/Tizen.Applications.Messages/MessagePort.cs +++ b/Tizen.Applications/Tizen.Applications.Messages/MessagePort.cs @@ -1,11 +1,5 @@ using System; using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using Tizen.Internals; namespace Tizen.Applications.Messages { @@ -22,6 +16,20 @@ namespace Tizen.Applications.Messages private static readonly object s_lock = new object(); private static readonly HashSet s_portMap = new HashSet(); + // The name of the local message port + private readonly string _portName = null; + + // If true the message port is a trusted port, otherwise false it is not + private readonly bool _trusted = false; + + // The local message port ID + private int _portId = 0; + + // If true the message port is listening, otherwise false it is not + private bool _listening = false; + + private Interop.MessagePort.message_port_message_cb _messageCallBack; + /// /// Initializes the instance of the MessagePort class. /// @@ -83,28 +91,6 @@ namespace Tizen.Applications.Messages } /// - /// The local message port ID - /// - private int _portId = 0; - - /// - /// The name of the local message port - /// - private readonly string _portName = null; - - /// - /// If true the message port is a trusted port, otherwise false it is not - /// - private readonly bool _trusted = false; - - /// - /// If true the message port is listening, otherwise false it is not - /// - private bool _listening = false; - - private Interop.MessagePort.message_port_message_cb _messageCallBack; - - /// /// Register the local message port. /// public void Listen() @@ -131,7 +117,7 @@ namespace Tizen.Applications.Messages Trusted = trusted }; } - RaiseMessageReceivedEvent(MessageReceived, args); + MessageReceived?.Invoke(this, args); }; _portId = _trusted ? @@ -215,14 +201,6 @@ namespace Tizen.Applications.Messages } } - private void RaiseMessageReceivedEvent(EventHandler evt, MessageReceivedEventArgs args) - { - if (evt != null) - { - evt(this, args); - } - } - /// /// Releases the unmanaged resourced used by the MessagePort class specifying whether to perform a normal dispose operation. /// @@ -237,7 +215,7 @@ namespace Tizen.Applications.Messages } catch (Exception e) { - Tizen.Log.Warn(GetType().Namespace, "Exception in Dispose :" + e.Message); + Log.Warn(GetType().Namespace, "Exception in Dispose :" + e.Message); } } } diff --git a/Tizen.Applications/Tizen.Applications.Messages/MessagePortErrorFactory.cs b/Tizen.Applications/Tizen.Applications.Messages/MessagePortErrorFactory.cs index ac8bf68..ed74f34 100755 --- a/Tizen.Applications/Tizen.Applications.Messages/MessagePortErrorFactory.cs +++ b/Tizen.Applications/Tizen.Applications.Messages/MessagePortErrorFactory.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Tizen.Internals.Errors; namespace Tizen.Applications.Messages @@ -19,6 +15,7 @@ namespace Tizen.Applications.Messages MaxExceeded = -0x01130000 | 0x03, ResourceUnavailable = -0x01130000 | 0x04 } + internal static class MessagePortErrorFactory { internal static void ThrowException(int errorCode, string errorMessage = null, string paramName = null) diff --git a/Tizen.Applications/Tizen.Applications.Messages/MessageReceivedEventArgs.cs b/Tizen.Applications/Tizen.Applications.Messages/MessageReceivedEventArgs.cs index d3f9121..626886a 100755 --- a/Tizen.Applications/Tizen.Applications.Messages/MessageReceivedEventArgs.cs +++ b/Tizen.Applications/Tizen.Applications.Messages/MessageReceivedEventArgs.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Tizen.Applications.Messages { @@ -14,19 +10,11 @@ namespace Tizen.Applications.Messages /// /// Contains AppId, Port Name, Trusted /// - public RemoteValues Remote - { - get; - internal set; - } + public RemoteValues Remote { get; internal set; } /// /// The message passed from the remote application /// - public Bundle Message - { - get; - internal set; - } + public Bundle Message { get; internal set; } } } diff --git a/Tizen.Applications/Tizen.Applications.Messages/RemoteValues.cs b/Tizen.Applications/Tizen.Applications.Messages/RemoteValues.cs index f11cfff..a2890a9 100755 --- a/Tizen.Applications/Tizen.Applications.Messages/RemoteValues.cs +++ b/Tizen.Applications/Tizen.Applications.Messages/RemoteValues.cs @@ -1,9 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace Tizen.Applications.Messages { /// @@ -14,25 +8,16 @@ namespace Tizen.Applications.Messages /// /// The ID of the remote application that sent this message /// - public string AppId - { - get; set; - } + public string AppId { get; set; } + /// /// The name of the remote message port /// - public string PortName - { - get; - set; - } + public string PortName { get; set; } + /// /// If true the remote port is a trusted port, otherwise if false it is not /// - public bool Trusted - { - get; - set; - } + public bool Trusted { get; set; } } } -- 2.7.4