r = __pSmsReceiveEvent->AddListener(eventListener, true);
SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "Failed to add a listener");
- err = msg_reg_sms_message_callback(__msgHandle, &_SmsMmsCallbackHandler::IncomingSmsMessageCallback, 0, (void*)
- __pSmsReceiveEvent);
+ err = _SmsMmsCallbackHandler::GetInstance()->RegisterIncomingMessageCallback(__pSmsReceiveEvent);
r = ConvertException(err);
SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to register for incoming sms callback.", GetErrorMessage(r));
: __msgHandle(0)
, __callbackRegistered(false)
, __incomingSmsCallbackRegistered(true)
+ , __incomingCallbackRegistered(false)
+ , __pSmsIncomingEvent(null)
{
}
}
int
+_SmsMmsCallbackHandler::RegisterIncomingMessageCallback(Tizen::Base::Object* pSmsIncomingEvent)
+{
+ int err = MSG_SUCCESS;
+
+ __pSmsIncomingEvent = pSmsIncomingEvent;
+
+ if (__msgHandle && !__incomingCallbackRegistered)
+ {
+ err = msg_reg_sms_message_callback(__msgHandle, &_SmsMmsCallbackHandler::IncomingSmsMessageCallback, 0, null);
+ __incomingCallbackRegistered = true;
+ }
+
+ return err;
+}
+
+int
_SmsMmsCallbackHandler::CloseMessageHandle()
{
int err = MSG_SUCCESS;
void
_SmsMmsCallbackHandler::IncomingSmsMessageCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam)
{
- _SmsEvent* pSmsEvent = static_cast <_SmsEvent*>(pUserParam);
+ _SmsEvent* pSmsEvent = static_cast <_SmsEvent*>(_SmsMmsCallbackHandler::GetInstance()->__pSmsIncomingEvent);
_SmsEventArg* pSmsEventArg = null;
int msgSize = 0;
*/
result GetAndRemoveFromMessageMap(int reqId, _MessageType& msgType, Tizen::Base::Object** pEvent);
+ /**
+ * Registers the Message call back for incoming SMS operation.
+ *
+ * @since 3.0
+ * @return An error codea
+ * @param[in] pSmsIncomingEvent message Event
+ * @exception MSG_SUCCESS The method was successful.
+ * @exception MSG_ERR_NULL_POINTER Input parameter is NULL.
+ * @exception MSG_ERR_MEMORY_ERROR Memory error.
+ */
+ int RegisterIncomingMessageCallback(Tizen::Base::Object* pSmsIncomingEvent);
+
// for SMS and MMS sent status
static void SentMessageStatusCallback(msg_handle_t hMsgHandle, msg_struct_t msgStatus, void* pUserParam);
msg_handle_t __msgHandle;
bool __callbackRegistered;
bool __incomingSmsCallbackRegistered;
+ bool __incomingCallbackRegistered;
+ Tizen::Base::Object* __pSmsIncomingEvent;
Tizen::Base::Collection::MultiHashMap __messageMap;
Tizen::Base::Runtime::Mutex __msgMutex;
static bool __destroyed;