#include "legato.h"
#include "interfaces.h"
static le_sim_SimToolkitEventHandlerRef_t HandlerRef = NULL;
static const char* AcceptCmdArg = NULL;
static void TestSimToolkitHandler
(
le_sim_Id_t simId,
le_sim_StkEvent_t stkEvent,
void* contextPtr
)
{
le_sim_StkRefreshMode_t refreshMode;
le_sim_StkRefreshStage_t refreshStage;
switch(stkEvent)
{
case LE_SIM_OPEN_CHANNEL:
LE_INFO(
"-TEST- OPEN_CHANNEL SIM Toolkit event for SIM card.%d", simId);
break;
case LE_SIM_REFRESH:
LE_INFO(
"-TEST- REFRESH SIM Toolkit event for SIM card.%d", simId);
LE_INFO(
"REFRESH SIM MODE: %d, STAGE: %d", refreshMode, refreshStage);
if (LE_SIM_STAGE_WAITING_FOR_OK != refreshStage)
{
return;
}
break;
case LE_SIM_STK_EVENT_MAX:
default:
LE_INFO(
"-TEST- Unknown SIM Toolkit event %d for SIM card.%d", stkEvent, simId);
break;
}
if( strncmp(AcceptCmdArg, "accept", strlen("accept")) == 0 )
{
LE_INFO(
"-TEST- Accept SIM Toolkit command");
"Accept SIM Toolkit failure!");
}
else if( strncmp(AcceptCmdArg, "reject", strlen("reject")) == 0 )
{
LE_INFO(
"-TEST- Reject SIM Toolkit command");
"Reject SIM Toolkit failure!");
}
else if( strncmp(AcceptCmdArg, "none", strlen("none")) == 0 )
{
LE_INFO(
"-TEST- Don't answer to SIM Toolkit command");
}
}
static void SigHandler
(
int sigNum
)
{
exit(EXIT_SUCCESS);
}
static void PrintUsage
(
void
)
{
int idx;
bool sandboxed = (getuid() != 0);
const char * usagePtr[] =
{
"Usage of the simToolkit app is:",
" app runProc simToolkit --exe=simToolkit -- <accept/reject/none> [<APN> <UserName> <Password>]",
};
{
if(sandboxed)
{
}
else
{
fprintf(stderr, "%s\n", usagePtr[idx]);
}
}
}
{
{
signal(SIGINT, SigHandler);
LE_INFO(
"======== Start SIM Toolkit Test ========");
{
if (NULL == apnArg)
{
exit(EXIT_FAILURE);
}
if (NULL == userNameArg)
{
exit(EXIT_FAILURE);
}
le_mdc_ProfileRef_t profileRef;
uint32_t defaultIndex;
LE_MDC_AUTH_PAP,
userNameArg,
LE_INFO(
"BIP default profile uses index.%d", defaultIndex);
}
else
{
LE_INFO(
"NO profile defined for OPEN_CHANNEL command.");
}
if (NULL == AcceptCmdArg)
{
exit(EXIT_FAILURE);
}
if( strncmp(AcceptCmdArg, "accept", strlen("accept")) == 0 )
{
LE_INFO(
"SIM Toolkit Test will accept all SIM Toolkit commands.");
}
else if( strncmp(AcceptCmdArg, "reject", strlen("reject")) == 0 )
{
LE_INFO(
"SIM Toolkit Test will reject all SIM Toolkit commands.");
}
else if( strncmp(AcceptCmdArg, "none", strlen("none")) == 0 )
{
LE_INFO(
"SIM Toolkit Test will not answer to SIM Toolkit commands.");
}
else
{
PrintUsage();
exit(EXIT_FAILURE);
}
LE_INFO(
"======== Test SIM Toolkit SUCCESS ========");
}
else
{
PrintUsage();
exit(EXIT_FAILURE);
}
}