_MessageConditionHandler::_MessageConditionHandler(void)
: __messageHandle(null)
,__pSmsCondition(null)
+ ,__pWapPushCondition(null)
{
int elapsedTime = 0; // 10 sec
while (true)
return r;
}
}
+
+ if(!__pWapPushCondition)
+ {
+ __pWapPushCondition = new (std::nothrow) Tizen::Base::Collection::ArrayList();
+ SysTryReturnResult(NID_MSG, __pWapPushCondition != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] memory allocation failed.");
+ r = __pWapPushCondition->Construct();
+ if (r != E_SUCCESS)
+ {
+ delete __pWapPushCondition;
+ SysLogException(NID_MSG, r,"[%s] Contruct of ArrayList Failed.", GetErrorMessage(r));
+ return r;
+ }
+ }
// get condition string
condition = appLaunchCondition.GetConditionString();
SysLog(NID_APP, "Content-Type: [%s]", pWapContentType.get());
SysLog(NID_APP, "X-WAP-Application-ID: [%s]", pWapApplicationId.get());
+\r
+ __pWapPushCondition->Add(appLaunchCondition);
// add incoming callback with wap application id
err = messages_push_add_incoming_cb(__messageHandle, pWapApplicationId.get(),
- &_MessageConditionHandler::IncomingWapPushMessageCallback, &appLaunchCondition);
+ &_MessageConditionHandler::IncomingWapPushMessageCallback,__pWapPushCondition);
SysTryReturnResult(NID_APP, err == MESSAGES_ERROR_NONE, E_OPERATION_FAILED,
"Failed to add incoming wap push callback. (%d)", err);
err = messages_push_remove_incoming_cb(__messageHandle, pWapApplicationId.get());
SysTryReturnResult(NID_APP, err == MESSAGES_ERROR_NONE, E_OPERATION_FAILED,
"Failed to remove incoming push callback. (%d)", err);
+ //Unregister is not working.
+ //SysLog(NID_APP, "Unregister SMS [%d] num[%d]", port, __pWapPushCondition->GetCount());
+ //__pWapPushCondition->Remove(appLaunchCondition);
+ //SysLog(NID_APP, "Unregisternum[%d]", __pWapPushCondition->GetCount());
__wapApplicationId.Clear();
__wapContentType.Clear();
int port = 0;
int count = 0;
Tizen::Base::Collection::ArrayList *pCondition = null;
- bool hit = false;
int hitCount = 0;
_AppLaunchCondition* pAppLaunchCondition = null;
_MessageConditionHandler* pHandler = null;
messages_get_address(incomingMsg, 0, &pTempAddress, &recipientType); // sender address
messages_get_message_port(incomingMsg, &port); // port number
- 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));
-
+
+ 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++)
{
if ( port == pHandler->GetPortNumber(pAppLaunchCondition->GetConditionString()))
{
+ hitCount++;
SysLog(NID_APP, "launch hit count[%d]", hitCount);
pHandler->Fire(*pAppLaunchCondition, &map);
-
}
}
-
+ SysTryReturnVoidResult(NID_APP, hitCount > 0, E_SYSTEM, "An SMS message[%d] received. But not matched with launch condition.", port);
}
void
{
SysTryReturnVoidResult(NID_APP, pHeader != null, E_INVALID_ARG, "the header is null.");
SysTryReturnVoidResult(NID_APP, pBody != null, E_INVALID_ARG, "the body is null.");
+
- _AppLaunchCondition* pAppLaunchCondition = static_cast<_AppLaunchCondition*>(pUserParam);
- SysTryReturnVoidResult(NID_APP, pAppLaunchCondition != null, E_INVALID_STATE, "pUserParam should NOT be null.");
-
- _MessageConditionHandler* pHandler = dynamic_cast<_MessageConditionHandler*>(pAppLaunchCondition->GetUserData());
- SysTryReturnVoidResult(NID_APP, pHandler != null, E_INVALID_STATE, "user data is null");
+ int count = 0;
+ Tizen::Base::Collection::ArrayList *pCondition = null;
+ int hitCount = 0;
+ _AppLaunchCondition* pAppLaunchCondition = null;
+ _MessageConditionHandler* pHandler = null;
+ String header;
ByteBuffer *msgBody = new ByteBuffer();
SysTryReturnVoidResult(NID_APP, msgBody != null, E_OUT_OF_MEMORY, "Failed to add a BODY to the hash map.");
r = map.Add(new String(L"BODY"), msgBody);
SysTryReturnVoidResult(NID_APP, r == E_SUCCESS, r, "Failed to add a BODY to the hash map.");
- pHandler->Fire(*pAppLaunchCondition, &map);
+ header = pHeader;
+
+ 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++)
+ {
+ String condition, id, type;
+
+ 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");
+
+ condition = pAppLaunchCondition->GetConditionString();
+ pHandler->GetWapConditions(condition, id, type);
+
+ if (header.Contains(id))
+ {
+ hitCount++;
+ SysLog(NID_APP, "launch hit count[%d]", hitCount);
+ pHandler->Fire(*pAppLaunchCondition, &map);
+ }
+
+ }
+ SysTryReturnVoidResult(NID_APP, hitCount > 0, E_SYSTEM, "An WapPush[%s] received. But not matched with launch condition.", pHeader);
+
}
Tizen::Base::DateTime