//////////////////////////////////////////////////////////////
_MessageConditionHandler::_MessageConditionHandler(void)
: __messageHandle(null)
+ ,__pSmsCondition(null)
{
int elapsedTime = 0; // 10 sec
while (true)
{
SysLog(NID_APP, "Start to register appLaunchConditions.");
SysTryReturnResult(NID_APP, __messageHandle != NULL, E_INVALID_STATE, "The message handle is NULL.");
-
+
result r = E_SUCCESS;
int err = MESSAGES_ERROR_NONE;
_MessageType messageType = _MESSAGE_TYPE_NONE;
String condition;
+ if(!__pSmsCondition)
+ {
+ __pSmsCondition = new (std::nothrow) Tizen::Base::Collection::ArrayList();
+ SysTryReturnResult(NID_MSG, __pSmsCondition != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] memory allocation failed.");
+ r = __pSmsCondition->Construct();
+ if (r != E_SUCCESS)
+ {
+ delete __pSmsCondition;
+ SysLogException(NID_MSG, r,"[%s] Contruct of ArrayList Failed.", GetErrorMessage(r));
+ return r;
+ }
+ }
+
// get condition string
condition = appLaunchCondition.GetConditionString();
SysLog(NID_APP, "condition string: [%ls]", condition.GetPointer());
SysTryReturnResult(NID_APP, r == E_SUCCESS, E_OPERATION_FAILED,
"Failed to set incoming sms callback. (%d)", err);
SysLog(NID_APP, "Port Number: [%d]", port);
- __portList.Add(*new Integer(port));
+ __pSmsCondition->Add(appLaunchCondition);
// register sms incoming callback
err = messages_set_message_incoming_cb(__messageHandle,
- &_MessageConditionHandler::IncomingSmsMessageCallback, &appLaunchCondition);
+ &_MessageConditionHandler::IncomingSmsMessageCallback, __pSmsCondition);
SysTryReturnResult(NID_APP, err == MESSAGES_ERROR_NONE, E_OPERATION_FAILED,
"Failed to set incoming sms callback. (%d)", err);
_MessageConditionHandler::Unregister(_AppLaunchCondition& appLaunchCondition)
{
SysTryReturnResult(NID_APP, __messageHandle != NULL, E_INVALID_STATE, "The message handle is NULL.");
+ SysLog(NID_APP, "Unregister");
result r = E_SUCCESS;
int err = MESSAGES_ERROR_NONE;
// SmsPort case
if (messageType == _MESSAGE_TYPE_SMS_PORT)
{
+ int port = 0;
+ int count = 0;
// unset the SMS incoming callback
err = messages_cb_unset_incoming_cb(__messageHandle);
SysTryReturnResult(NID_APP, err == MESSAGES_ERROR_NONE, E_OPERATION_FAILED,
"Failed to unset incoming sms callback. (%d)", err);
- __portList.RemoveAll();
+ port = GetPortNumber(appLaunchCondition.GetConditionString());
+
+ //Unregister is not working.
+ //SysLog(NID_APP, "Unregister SMS [%d] num[%d]", port, __pSmsCondition->GetCount());
+ //__pSmsCondition->Remove(appLaunchCondition);
+ //SysLog(NID_APP, "Unregisternum[%d]", __pSmsCondition->GetCount());
+
}
// WapPush case
else if (messageType == _MESSAGE_TYPE_WAP_PUSH)
{
SysTryReturnVoidResult(NID_APP, incomingMsg != null, E_INVALID_ARG, "the incoming message is null.");
- _AppLaunchCondition* pAppLaunchCondition = static_cast<_AppLaunchCondition*>(pUserParam);
- SysTryReturnVoidResult(NID_APP, pAppLaunchCondition != null, E_INVALID_STATE, "pUserData should NOT be null.");
-
- _MessageConditionHandler* pHandler = dynamic_cast<_MessageConditionHandler*>(pAppLaunchCondition->GetUserData());
- SysTryReturnVoidResult(NID_APP, pHandler != null, E_INVALID_STATE, "user data is null");
-
result r = E_SUCCESS;
char* pTempBody = null;
char* pTempAddress = null;
time_t tempTime = 0;
messages_recipient_type_e recipientType = MESSAGES_RECIPIENT_TO;
int port = 0;
+ int count = 0;
+ Tizen::Base::Collection::ArrayList *pCondition = null;
+ bool hit = false;
+ int hitCount = 0;
+ _AppLaunchCondition* pAppLaunchCondition = null;
+ _MessageConditionHandler* pHandler = null;
// get each element
messages_get_text(incomingMsg, &pTempBody); // body
messages_get_address(incomingMsg, 0, &pTempAddress, &recipientType); // sender address
messages_get_message_port(incomingMsg, &port); // port number
- // check the condition
- if (!pHandler->__portList.Contains(*new Integer(port)))
+ pCondition = static_cast<Tizen::Base::Collection::ArrayList*>(pUserParam);
+ SysTryReturnVoidResult(NID_APP, pCondition != null, E_INVALID_STATE, "pUserData should NOT be null.");
+ count = pCondition->GetCount();
+ SysLog(NID_APP, "Condition List Count[%d]", count);
+
+ for ( int i = 0; i < count ; i++)
+ {
+
+ pAppLaunchCondition = static_cast<_AppLaunchCondition*>(pCondition->GetAt(i));
+ SysTryReturnVoidResult(NID_APP, pAppLaunchCondition != null, E_INVALID_STATE, "pUserData should NOT be null.");
+
+ pHandler = dynamic_cast<_MessageConditionHandler*>(pAppLaunchCondition->GetUserData());
+ SysTryReturnVoidResult(NID_APP, pHandler != null, E_INVALID_STATE, "user data is null");
+
+ if ( port == pHandler->GetPortNumber(pAppLaunchCondition->GetConditionString()))
+ {
+
+ hit = true;
+ pAppLaunchCondition = null;
+ break;
+ }
+
+
+ }
+
+ // check the condition
+ if (!hit)
{
SysLog(NID_APP, "An SMS message received. But not matched with launch condition.");
SysLog(NID_APP, "Port Number Received: [%d]", port);
return;
}
-
unique_ptr<char[], _CharDeleter> pBody(pTempBody);
unique_ptr<char[], _CharDeleter> pAddress(pTempAddress);
SysTryReturnVoidResult(NID_APP, r == E_SUCCESS, r, "[%s] Failed to add a TIME to the hash map.", GetErrorMessage(r));
r = map.Add(new String(L"PORT"), new String(strPort));
SysTryReturnVoidResult(NID_APP, r == E_SUCCESS, r, "[%s] Failed to add a PORT to the hash map.", GetErrorMessage(r));
+
+ for ( int i = 0; i < count ; i++)
+ {
+
+ pAppLaunchCondition = static_cast<_AppLaunchCondition*>(pCondition->GetAt(i));
+ SysTryReturnVoidResult(NID_APP, pAppLaunchCondition != null, E_INVALID_STATE, "pUserData should NOT be null.");
+
+ pHandler = dynamic_cast<_MessageConditionHandler*>(pAppLaunchCondition->GetUserData());
+ SysTryReturnVoidResult(NID_APP, pHandler != null, E_INVALID_STATE, "user data is null");
+
+ if ( port == pHandler->GetPortNumber(pAppLaunchCondition->GetConditionString()))
+ {
+ SysLog(NID_APP, "launch hit count[%d]", hitCount);
+ pHandler->Fire(*pAppLaunchCondition, &map);
+
+ }
+
+ }
- pHandler->Fire(*pAppLaunchCondition, &map);
}
void