//
#include <memory>
-#include <dpl/log/log.h>
#include <JSTizenExceptionFactory.h>
#include <JSTizenException.h>
#include <SecurityExceptions.h>
#include <sim.h>
#include "JSSIMInfo.h"
#include "plugin_config.h"
+#include <Logger.h>
namespace DeviceAPI {
namespace Systeminfo {
using namespace DeviceAPI::Common;
namespace {
+const char* SIM_STATE_PROPERTY = "state";
const char* SIM_OPERATORNAME_PROPERTY = "operatorName";
const char* SIM_MSISDN_PROPERTY = "msisdn";
const char* SIM_ICCID_PROPERTY = "iccid";
};
JSStaticValue JSSIMInfo::m_properties[] = {
+ { SIM_STATE_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
{ SIM_OPERATORNAME_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
{ SIM_MSISDN_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
{ SIM_ICCID_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
void JSSIMInfo::Finalize(JSObjectRef object)
{
- LogDebug("Entered");
+ LoggerD("Entered");
JSSIMPriv* priv = static_cast<JSSIMPriv*>(JSObjectGetPrivate(object));
JSObjectSetPrivate(object, NULL);
- LogDebug("Deleting SIM Info object");
+ LoggerD("Deleting SIM Info object");
delete priv;
}
JSObjectRef JSSIMInfo::createJSObject(JSContextRef context, const SIMPropertiesPtr SIMInfo)
{
- LogDebug("Enter");
+ LoggerD("Enter");
JSSIMPriv *priv = new JSSIMPriv(context, SIMInfo);
return JSObjectMake(context, getClassRef(), priv);
}
JSValueRef JSSIMInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
{
- LogDebug("Enter");
+ LoggerD("Enter");
JSSIMPriv *priv = static_cast<JSSIMPriv*>(JSObjectGetPrivate(object));
int ret = SIM_ERROR_NONE;
if (NULL == priv) {
- LogError("Private object not set.");
+ LoggerE("Private object not set.");
return JSValueMakeUndefined(context);
}
{
SIMPropertiesPtr SIMInfo = priv->getObject();
Converter convert(context);
-
- if (JSStringIsEqualToUTF8CString(propertyName, SIM_OPERATORNAME_PROPERTY)) {
+ if (JSStringIsEqualToUTF8CString(propertyName, SIM_STATE_PROPERTY)) {
+ AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_PROPERTY_SIM_VALUE);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ sim_state_e state;
+ ret = sim_get_state(&state);
+ if (ret == SIM_ERROR_NONE) {
+ if (state == SIM_STATE_UNAVAILABLE) {
+ SIMInfo->state = "ABSENT";
+ } else if (state == SIM_STATE_LOCKED) {
+ SIMInfo->state = "PIN_REQUIRED";
+ } else if (state == SIM_STATE_AVAILABLE) {
+ SIMInfo->state = "READY";
+ } else if (state == SIM_STATE_UNKNOWN) {
+ SIMInfo->state = "INITIALIZING";
+ }
+ }
+ return convert.toJSValueRef(SIMInfo->state);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, SIM_OPERATORNAME_PROPERTY)) {
AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_PROPERTY_SIM_VALUE);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
char* fullName = NULL;
if (ret == SIM_ERROR_NONE) {
if (fullName) {
SIMInfo->operatorName = fullName;
- LogDebug("operatorName : " << SIMInfo->operatorName);
+ LoggerD("operatorName : " << SIMInfo->operatorName);
free(fullName);
} else if (shortName) {
SIMInfo->operatorName = shortName;
- LogDebug("operatorName : " << SIMInfo->operatorName);
+ LoggerD("operatorName : " << SIMInfo->operatorName);
free(shortName);
}
}
if (ret == SIM_ERROR_NONE) {
if (msisdn) {
SIMInfo->msisdn = msisdn;
- LogDebug("msisdn : " << SIMInfo->msisdn);
+ LoggerD("msisdn : " << SIMInfo->msisdn);
free(msisdn);
}
}
if (ret == SIM_ERROR_NONE) {
if (iccId) {
SIMInfo->iccid = iccId;
- LogDebug("iccid : " << SIMInfo->iccid);
+ LoggerD("iccid : " << SIMInfo->iccid);
free(iccId);
}
}
if (ret == SIM_ERROR_NONE) {
if (mcc) {
SIMInfo->mcc = atoi(mcc);
- LogDebug("mcc : " << SIMInfo->mcc);
+ LoggerD("mcc : " << SIMInfo->mcc);
free(mcc);
}
}
if (ret == SIM_ERROR_NONE) {
if (mnc) {
SIMInfo->mnc = atoi(mnc);
- LogDebug("mnc : " << SIMInfo->mnc);
+ LoggerD("mnc : " << SIMInfo->mnc);
free(mnc);
}
}
if (ret == SIM_ERROR_NONE) {
if (msin) {
SIMInfo->msin = msin;
- LogDebug("msin : " << SIMInfo->msin);
+ LoggerD("msin : " << SIMInfo->msin);
free(msin);
}
}
if (ret == SIM_ERROR_NONE) {
if (spn) {
SIMInfo->spn = spn;
- LogDebug("spn : " << SIMInfo->spn);
+ LoggerD("spn : " << SIMInfo->spn);
free(spn);
}
}
}
Catch(Exception)
{
- LogError("Exception: " << _rethrown_exception.GetMessage());
+ LoggerE("Exception: " << _rethrown_exception.GetMessage());
}
return JSValueMakeUndefined(context);
}