From 478c7f4a1672ea957d2652b4b309eec2a2fea995 Mon Sep 17 00:00:00 2001 From: Kyeonghun Lee Date: Mon, 20 Feb 2017 19:02:42 +0900 Subject: [PATCH] fix event register/unregister issue Change-Id: I13a5dd9e8bfff667f96cd9393fefa509b9ee3473 Signed-off-by: Kyeonghun Lee --- src/Tizen.Messaging/Interop/Interop.Messages.cs | 3 --- .../Tizen.Messaging.Messages/MessagesEvent.cs | 17 ++++------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/Tizen.Messaging/Interop/Interop.Messages.cs b/src/Tizen.Messaging/Interop/Interop.Messages.cs index 7697262..c68e3f1 100755 --- a/src/Tizen.Messaging/Interop/Interop.Messages.cs +++ b/src/Tizen.Messaging/Interop/Interop.Messages.cs @@ -108,9 +108,6 @@ internal static partial class Interop [DllImport(Libraries.Messages, EntryPoint = "messages_set_message_incoming_cb")] internal static extern int SetMessageIncomingCb(IntPtr serviceHandle, MessageIncomingCallback cb, IntPtr userData); - [DllImport(Libraries.Messages, EntryPoint = "messages_unset_message_incoming_cb")] - internal static extern int UnsetMessageIncomingCb(IntPtr serviceHandle); - [DllImport(Libraries.Messages, EntryPoint = "messages_send_message")] internal static extern int SendMessage(IntPtr serviceHandle, IntPtr messageHandle, bool saveToSentbox, MessageSentCallback cb, IntPtr userData); diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesEvent.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesEvent.cs index dd0d616..bae6475 100755 --- a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesEvent.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesEvent.cs @@ -24,11 +24,13 @@ namespace Tizen.Messaging.Messages private Interop.Messages.MessageIncomingCallback _messageReceivedCallback; + private bool _registered = false; + internal event EventHandler _MessageReceived { add { - if (_messageReceived == null) + if (_registered == false && _messageReceived == null) { RegisterMessageReceivedEvent(); } @@ -37,10 +39,6 @@ namespace Tizen.Messaging.Messages remove { _messageReceived -= value; - if (_messageReceived == null) - { - UnregisterMessageReceivedEvent(); - } } } @@ -111,15 +109,8 @@ namespace Tizen.Messaging.Messages { Log.Error(Globals.LogTag, "Failed to set message incoming callback, Error - " + (MessagesError)ret); } - } - private void UnregisterMessageReceivedEvent() - { - int ret = Interop.Messages.UnsetMessageIncomingCb(_MessageServiceHandle); - if (ret != (int)MessagesError.None) - { - Log.Error(Globals.LogTag, "Failed to unset message incoming callback, Error - " + (MessagesError)ret); - } + _registered = true; } } } -- 2.7.4