From 262c4cacccb9e57a8a58c1f771099b1b726e12eb Mon Sep 17 00:00:00 2001 From: Byounghui Date: Thu, 1 Aug 2013 23:30:54 +0900 Subject: [PATCH] IPC Modified. Change-Id: I1396288f352f42672cd5dc0896885e9f21a46b31 Signed-off-by: Byounghui --- src/messaging/FMsg_IpcCallbackHandler.cpp | 83 +++++++++++++++++++++---------- src/messaging/FMsg_IpcCallbackHandler.h | 8 +-- src/messaging/FMsg_SmsService.cpp | 2 +- src/messaging/FMsg_WapPushService.cpp | 3 +- 4 files changed, 63 insertions(+), 33 deletions(-) diff --git a/src/messaging/FMsg_IpcCallbackHandler.cpp b/src/messaging/FMsg_IpcCallbackHandler.cpp index 97adc56..6d6d8d7 100644 --- a/src/messaging/FMsg_IpcCallbackHandler.cpp +++ b/src/messaging/FMsg_IpcCallbackHandler.cpp @@ -213,9 +213,6 @@ _IpcCallbackHandler::AddCbsChannel(int from, int to, const Tizen::Base::String& } - - - r = SaveCbsSettings(); return r; } @@ -544,13 +541,33 @@ _IpcCallbackHandler::IncomingSmsCallback(msg_handle_t hMsgHandle, msg_struct_t n //SysLog(NID_MSG, "received time: [%s]", ctime(pReceivedTime)); SysTryReturnVoidResult(NID_MSG, GetInstance()->__pSmsClientId != null, E_OUT_OF_MEMORY,"failed to get client id."); - for ( int i = 0; i < GetInstance()->__pSmsClientId->GetCount(); i++) + IMapEnumerator* pMapEnum = GetInstance()->__pSmsClientId->GetMapEnumeratorN(); + SysTryReturnVoidResult(NID_MSG, pMapEnum != null, E_OUT_OF_MEMORY,"MapEnum failed."); + + while (pMapEnum->MoveNext() == E_SUCCESS) + { + Integer* pKey = null; + String* pValue = null; + String portNum; + + pKey = static_cast< Integer* > (pMapEnum->GetKey()); + pValue = static_cast< String* > (pMapEnum->GetValue()); + SysLog(NID_MSG, "pKey %d, value %ls", pKey->ToInt(), pValue->GetPointer()); + portNum.Append(port); + if (pValue->Contains(portNum)) { - Integer * pId = static_cast (GetInstance()->__pSmsClientId->GetAt(i)); - _SmsService::GetStubInstance()->IncomingSmsCallback(port, displayTime, message, senderAddress,pId->ToInt()); + SysLog(NID_MSG, "pKey %d, value %ls", pKey->ToInt(), pValue->GetPointer()); + _SmsService::GetStubInstance()->IncomingSmsCallback(port, displayTime, message, senderAddress,pKey->ToInt()); + } } + delete pMapEnum; + SysLog(NID_MSG, "End"); + + +} + void _IpcCallbackHandler::IncomingCbsMessageCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam) { @@ -689,13 +706,28 @@ _IpcCallbackHandler::IncomingWapPushMessageCallback(msg_handle_t hMsgHandle, con SysLog(NID_MSG, "push body length: [%d]", bodyLength); SysTryReturnVoidResult(NID_MSG, _IpcCallbackHandler::GetInstance()->__pWapPushClientId != null, E_OUT_OF_MEMORY, "failed to get client id."); - for ( int i = 0; i < _IpcCallbackHandler::GetInstance()->__pWapPushClientId->GetCount(); i++) + IMapEnumerator* pMapEnum = _IpcCallbackHandler::GetInstance()->__pWapPushClientId->GetMapEnumeratorN(); + SysTryReturnVoidResult(NID_MSG, pMapEnum != null, E_OUT_OF_MEMORY,"MapEnum failed."); + + while (pMapEnum->MoveNext() == E_SUCCESS) { + Integer* pKey = null; + String* pValue = null; - Integer * pId = static_cast (_IpcCallbackHandler::GetInstance()->__pWapPushClientId->GetAt(i)); - _WapPushService::GetStubInstance()->IncomingWapPushMessageCallback(msgHeader, msgBody, bodyLength, pId->ToInt()); + pKey = static_cast< Integer* > (pMapEnum->GetKey()); + pValue = static_cast< String* > (pMapEnum->GetValue()); + + + if (msgHeader.Contains(*pValue)) + { + SysLog(NID_MSG, "pKey %d, value %ls", pKey->ToInt(), pValue->GetPointer()); + _WapPushService::GetStubInstance()->IncomingWapPushMessageCallback(msgHeader, msgBody, bodyLength, pKey->ToInt()); + } } + delete pMapEnum; + SysLog(NID_MSG, "End"); + } Tizen::Base::String @@ -762,48 +794,53 @@ _IpcCallbackHandler::GetCbsLanguageType(byte codingScheme) } result -_IpcCallbackHandler::SetWapPushClientId( int id) +_IpcCallbackHandler::SetWapPushClientId(const Tizen::Base::String& AppId, int id) { result r = E_SUCCESS; Integer *pId = new Integer(id); + String *pApp = new String(AppId); if(!__pWapPushClientId) { - __pWapPushClientId = new (std::nothrow) Tizen::Base::Collection::ArrayList(); + __pWapPushClientId = new (std::nothrow) Tizen::Base::Collection::MultiHashMap(); SysTryReturnResult(NID_MSG, __pWapPushClientId != null, E_OUT_OF_MEMORY, "memory allocation failed."); __pWapPushClientId->Construct(); } - if(!__pWapPushClientId->Contains(*pId)) + if(!__pWapPushClientId->Contains(*pId, *pApp)) { - r = __pWapPushClientId->Add(*pId); - SysLog(NID_MSG, "Client %d",id); + r = __pWapPushClientId->Add(*pId, *pApp); + SysLog(NID_MSG, "AppId %ls, Client %d",AppId.GetPointer(), id); return r; } delete pId; + delete pApp; return r; } result -_IpcCallbackHandler::SetSmsClientId ( int id) +_IpcCallbackHandler::SetSmsClientId (int port, int id) { result r = E_SUCCESS; Integer *pId = new Integer(id); + String *pPort = new String; + pPort->Append(port); if(!__pSmsClientId) { - __pSmsClientId = new (std::nothrow) Tizen::Base::Collection::ArrayList(); + __pSmsClientId = new (std::nothrow) Tizen::Base::Collection::MultiHashMap(); SysTryReturnResult(NID_MSG, __pSmsClientId != null, E_OUT_OF_MEMORY, "memory allocation failed."); __pSmsClientId->Construct(); } - if(!__pSmsClientId->Contains(*pId)) + if(!__pSmsClientId->Contains(*pId, *pPort)) { - r = __pSmsClientId->Add(*pId); - SysLog(NID_MSG, "Client %d",id); + r = __pSmsClientId->Add(*pId, *pPort); + SysLog(NID_MSG, "Port %ls, Client %d",pPort->GetPointer(), id); return r; } delete pId; + delete pPort; return r; } @@ -839,22 +876,14 @@ _IpcCallbackHandler::RemoveClientId ( int id) if(__pWapPushClientId) { - - if(__pWapPushClientId->Contains(*pId)) - { r = __pWapPushClientId->Remove(*pId); SysLog(NID_MSG, "WapPush Removed :Client %d",id); - } } if(__pSmsClientId) { - - if(__pSmsClientId->Contains(*pId)) - { r = __pSmsClientId->Remove(*pId); SysLog(NID_MSG, "SMS Removed :Client %d",id); - } } if(__pCbsEtwsClientId) diff --git a/src/messaging/FMsg_IpcCallbackHandler.h b/src/messaging/FMsg_IpcCallbackHandler.h index a58ef53..04da7d2 100644 --- a/src/messaging/FMsg_IpcCallbackHandler.h +++ b/src/messaging/FMsg_IpcCallbackHandler.h @@ -188,8 +188,8 @@ public: //get cb message language type static Tizen::Base::String GetCbsLanguageType(byte codingScheme); - result SetWapPushClientId( int id); - result SetSmsClientId ( int id); + result SetWapPushClientId(const Tizen::Base::String& AppId, int id); + result SetSmsClientId (int port, int id); result SetCbsEtwsClientId ( int id); result RemoveClientId ( int id); Tizen::Base::DateTime ConvertTime(time_t* pTime); @@ -215,8 +215,8 @@ private: bool __incomingSmsCallbackRegistered; Tizen::Base::Collection::MultiHashMap __messageMap; Tizen::Base::Runtime::Mutex __msgMutex; - Tizen::Base::Collection::ArrayList* __pWapPushClientId; - Tizen::Base::Collection::ArrayList* __pSmsClientId; + Tizen::Base::Collection::MultiHashMap* __pWapPushClientId; + Tizen::Base::Collection::MultiHashMap* __pSmsClientId; Tizen::Base::Collection::ArrayList* __pCbsEtwsClientId; static bool __destroyed; diff --git a/src/messaging/FMsg_SmsService.cpp b/src/messaging/FMsg_SmsService.cpp index 7c3915a..b33ef38 100644 --- a/src/messaging/FMsg_SmsService.cpp +++ b/src/messaging/FMsg_SmsService.cpp @@ -179,7 +179,7 @@ _SmsService::AddSmsEventListener(int port, int clientId) result r = E_SUCCESS; int err = MSG_SUCCESS; - SysTryCatch(NID_MSG, _IpcCallbackHandler::GetInstance()->SetSmsClientId(clientId)== E_SUCCESS, r = E_SYSTEM, r, "failed to save client id."); + SysTryCatch(NID_MSG, _IpcCallbackHandler::GetInstance()->SetSmsClientId(port, clientId)== E_SUCCESS, r = E_SYSTEM, r, "failed to save client id."); // Register SMS Trigger err = msg_reg_sms_message_callback(__msgHandle, &_IpcCallbackHandler::IncomingSmsCallback, port, null); diff --git a/src/messaging/FMsg_WapPushService.cpp b/src/messaging/FMsg_WapPushService.cpp index fb50c41..081b6a7 100644 --- a/src/messaging/FMsg_WapPushService.cpp +++ b/src/messaging/FMsg_WapPushService.cpp @@ -121,10 +121,11 @@ _WapPushService::AddWapPushEventListener(const Tizen::Base::String& wapApplicati char* pWapAppId = null; ClearLastResult(); + SysLog(NID_MSG, "wapApp: %ls", wapApplicationId.GetPointer()); pWapAppId = _StringConverter::CopyToCharArrayN(wapApplicationId); SysTryCatch(NID_MSG, pWapAppId != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); - SysTryCatch(NID_MSG, _IpcCallbackHandler::GetInstance()->SetWapPushClientId(clientId)== E_SUCCESS, r = E_SYSTEM, r, "failed to save client id."); + SysTryCatch(NID_MSG, _IpcCallbackHandler::GetInstance()->SetWapPushClientId(wapApplicationId, clientId)== E_SUCCESS, r = E_SYSTEM, r, "failed to save client id."); SysTryCatch(NID_MSG, _IpcCallbackHandler::GetInstance() != null, r = E_OUT_OF_MEMORY, r, "failed to get msg handle."); // open message handle -- 2.7.4