*
* @since_tizen 2.4
*
- * @remarks You must release @c number using free().
+ * @remarks You must release @c number using free() on success case.
*
* @param[in] call_handle The handle from #telephony_call_get_call_list()
* @param[out] number The number of the call
*/
typedef enum {
TELEPHONY_NOTI_SIM_STATUS = 0x10, /**< Notification to be invoked when the SIM card state changes, '#telephony_sim_state_e' will be delivered in notification data */
+ TELEPHONY_NOTI_SIM_CALL_FORWARDING_STATE, /**< Notification to be invoked when the SIM call forwarding state changes, 'call_forwarding_state(bool)' will be delivered in notification data (@b Since: 3.0) */
TELEPHONY_NOTI_NETWORK_SERVICE_STATE = 0x20, /**< Notification to be invoked when the network service state changes, '#telephony_network_service_state_e' will be delivered in notification data */
TELEPHONY_NOTI_NETWORK_CELLID, /**< Notification to be invoked when the cell ID changes, 'cell_id(int)' will be delivered in notification data */
* @privlevel public
* @privilege %http://tizen.org/privilege/telephony
*
- * @remarks You must release @c imei using free().
+ * @remarks You must release @c imei using free() on success case.
*
* @param[in] handle The handle from telephony_init()
* @param[out] imei The International Mobile Station Equipment Identity
* @privlevel public
* @privilege %http://tizen.org/privilege/telephony
*
- * @remarks You must release @c mcc using free().
+ * @remarks You must release @c mcc using free() on success case.
*
* @param[in] handle The handle from telephony_init()
* @param[out] mcc The Mobile Country Code (three digits)
* @privlevel public
* @privilege %http://tizen.org/privilege/telephony
*
- * @remarks You must release @c mnc using free().
+ * @remarks You must release @c mnc using free() on success case.
*
* @param[in] handle The handle from telephony_init()
* @param[out] mnc The Mobile Network Code (three digits)
* @privlevel public
* @privilege %http://tizen.org/privilege/telephony
*
- * @remarks You must release @c network_name using free().
+ * @remarks You must release @c network_name using free() on success case.
*
* @param[in] handle The handle from telephony_init()
* @param[out] network_name The name of the current registered network
* @brief Enumeration for the state of SIM card.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
-typedef enum
-{
- TELEPHONY_SIM_STATE_UNAVAILABLE, /**< SIM is not available on this device */
- TELEPHONY_SIM_STATE_LOCKED, /**< SIM is locked */
- TELEPHONY_SIM_STATE_AVAILABLE, /**< SIM is available on this device */
- TELEPHONY_SIM_STATE_UNKNOWN, /**< SIM is in transition between states */
+typedef enum {
+ TELEPHONY_SIM_STATE_UNAVAILABLE, /**< SIM is not available on this device */
+ TELEPHONY_SIM_STATE_LOCKED, /**< SIM is locked */
+ TELEPHONY_SIM_STATE_AVAILABLE, /**< SIM is available on this device */
+ TELEPHONY_SIM_STATE_UNKNOWN, /**< SIM is in transition between states */
} telephony_sim_state_e;
+/**
+ * @brief Enumeration for the lock state of SIM card.
+ * @since_tizen 3.0
+ */
+typedef enum {
+ TELEPHONY_SIM_LOCK_STATE_UNKNOWN, /**< SIM is not in lock */
+ TELEPHONY_SIM_LOCK_STATE_PIN_REQUIRED, /**< SIM is PIN(Personal Identification Number) locked */
+ TELEPHONY_SIM_LOCK_STATE_PUK_REQUIRED, /**< SIM is PUK(Personal Unblocking Code) locked */
+ TELEPHONY_SIM_LOCK_STATE_PERM_LOCKED, /**< SIM is permanently blocked(All the attempts for PIN/PUK failed) */
+ TELEPHONY_SIM_LOCK_STATE_NCK_REQUIRED, /**< SIM is NCK(Network Control Key) locked */
+ TELEPHONY_SIM_LOCK_STATE_NSCK_REQUIRED, /**< SIM is NSCK(Network Subset Control Key) locked */
+ TELEPHONY_SIM_LOCK_STATE_SPCK_REQUIRED, /**< SIM is SPCK(Service Provider Control Key) locked */
+ TELEPHONY_SIM_LOCK_STATE_CCK_REQUIRED, /**< SIM is CCK(Corporate Control Key) locked */
+ TELEPHONY_SIM_LOCK_STATE_PHONE_REQUIRED /**< SIM is PH-SIM(Phone-SIM) locked */
+} telephony_sim_lock_state_e;
/**
* @brief Enumeration for the type of SIM card .
* @privlevel public
* @privilege %http://tizen.org/privilege/telephony
*
- * @remarks You must release @c icc_id using free().
+ * @remarks You must release @c icc_id using free() on success case.
*
* @param[in] handle The handle from telephony_init()
* @param[out] icc_id The Integrated Circuit Card Identification
* @privlevel public
* @privilege %http://tizen.org/privilege/telephony
*
- * @remarks You must release @c sim_operator using free().
+ * @remarks You must release @c sim_operator using free() on success case.
*
* @param[in] handle The handle from telephony_init()
* @param[out] sim_operator The SIM Operator
* @privlevel public
* @privilege %http://tizen.org/privilege/telephony
*
- * @remarks You must release @c msin using free().
+ * @remarks You must release @c msin using free() on success case.
*
* @param[in] handle The handle from telephony_init()
* @param[out] msin The Mobile Subscription Identification Number
* @privlevel public
* @privilege %http://tizen.org/privilege/telephony
*
- * @remarks You must release @c spn using free().
+ * @remarks You must release @c spn using free() on success case.
*
* @param[in] handle The handle from telephony_init()
* @param[out] spn The Service Provider Name
* @privlevel public
* @privilege %http://tizen.org/privilege/telephony
*
- * @remarks You must release @c subscriber_number using free().
+ * @remarks You must release @c subscriber_number using free() on success case.
*
* @param[in] handle The handle from telephony_init()
* @param[out] subscriber_number The subscriber number in the SIM
* @privlevel public
* @privilege %http://tizen.org/privilege/telephony
*
- * @remarks You must release @c subscriber_id using free().
+ * @remarks You must release @c subscriber_id using free() on success case.
*
* @param[in] handle The handle from telephony_init()
* @param[out] subscriber_id The subscriber ID
*/
int telephony_sim_get_subscriber_id(telephony_h handle, char **subscriber_id);
+/**
+ * @brief Gets the lock state of the SIM.
+ * @details This function gets SIM card lock state.
+ * If SIM state is #TELEPHONY_SIM_STATE_LOCKED, you can use this function to retrieve lock state.
+ *
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] lock_state The current lock state of the SIM
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Out of memory
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED Invalid parameter
+ *
+ * @pre The SIM state must be #TELEPHONY_SIM_STATE_LOCKED.
+ *
+ * @see telephony_sim_get_state()
+ */
+int telephony_sim_get_lock_state(telephony_h handle, telephony_sim_lock_state_e *lock_state);
+
+/**
+ * @brief Gets the Group Identifier Level 1(GID1).
+ * @details This function gets Group Identifier Level 1(GID1) embedded in the SIM card.
+ * If this value is not stored in SIM card, @c NULL will be returned.
+ *
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @remarks You must release @c gid1 using free() on success case.
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] gid1 The GID1
+ *
+ * @retval #TELEPHONY_ERROR_NONE Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Out of memory
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED Invalid parameter
+ * @retval #TELEPHONY_ERROR_SIM_NOT_AVAILABLE SIM is not available
+ *
+ * @pre The SIM state must be #TELEPHONY_SIM_STATE_AVAILABLE.
+ *
+ * @see telephony_sim_get_state()
+ */
+int telephony_sim_get_gid1(telephony_h handle, char **gid1);
+
+/**
+ * @brief Gets the call fowarding state of the SIM.
+ * @details If the state is true, incoming call will be forwareded to selected number.
+ *
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] call_forwarding_state The value whether incoming call will be forwarded or not.
+ * (true: forwared, false: not forwared)
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Out of memory
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED Invalid parameter
+ *
+ * @pre The SIM state must be #TELEPHONY_SIM_STATE_LOCKED.
+ *
+ * @see telephony_sim_get_state()
+ */
+int telephony_sim_get_call_forwarding_state(telephony_h handle, bool *call_forwarding_state);
+
/**
* @}
*/
#ifdef __cplusplus
- }
+}
#endif
-#endif // __CAPI_TELEPHONY_SIM_H__
+#endif /* __CAPI_TELEPHONY_SIM_H__ */
Name: capi-telephony
Summary: Telephony Core API
-Version: 0.1.49
+Version: 0.1.50
Release: 1
Group: System/Libraries
License: Apache-2.0
switch (noti_id) {
case TELEPHONY_NOTI_SIM_STATUS:
return TAPI_NOTI_SIM_STATUS;
+ case TELEPHONY_NOTI_SIM_CALL_FORWARDING_STATE:
+ return TAPI_PROP_SIM_CALL_FORWARD_STATE;
case TELEPHONY_NOTI_NETWORK_SERVICE_STATE:
return TAPI_PROP_NETWORK_SERVICE_TYPE;
case TELEPHONY_NOTI_NETWORK_CELLID:
if (!g_strcmp0(evt_id, TAPI_NOTI_SIM_STATUS)) {
int sim_status = _mapping_sim_status(*(TelSimCardStatus_t *)data);
CALLBACK_CALL(&sim_status);
+ } else if (!g_strcmp0(evt_id, TAPI_PROP_SIM_CALL_FORWARD_STATE)) {
+ bool call_forwarding_state = *(bool *)data;
+ CALLBACK_CALL(&call_forwarding_state);
} else if (!g_strcmp0(evt_id, TAPI_PROP_NETWORK_SERVICE_TYPE)) {
int service_state = _mapping_service_state(*(int *)data);
CALLBACK_CALL(&service_state);
switch (sim_card_state) {
case TAPI_SIM_STATUS_CARD_ERROR:
case TAPI_SIM_STATUS_CARD_NOT_PRESENT:
- case TAPI_SIM_STATUS_CARD_BLOCKED:
case TAPI_SIM_STATUS_CARD_REMOVED:
case TAPI_SIM_STATUS_CARD_CRASHED:
*sim_state = TELEPHONY_SIM_STATE_UNAVAILABLE;
break;
case TAPI_SIM_STATUS_SIM_PIN_REQUIRED:
case TAPI_SIM_STATUS_SIM_PUK_REQUIRED:
+ case TAPI_SIM_STATUS_CARD_BLOCKED:
case TAPI_SIM_STATUS_SIM_NCK_REQUIRED:
case TAPI_SIM_STATUS_SIM_NSCK_REQUIRED:
case TAPI_SIM_STATUS_SIM_SPCK_REQUIRED:
return error_code;
}
+
+int telephony_sim_get_lock_state(telephony_h handle, telephony_sim_lock_state_e *lock_state)
+{
+ TelSimCardStatus_t sim_card_state;
+ int error_code = TELEPHONY_ERROR_NONE;
+ TapiHandle *tapi_h;
+
+ CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+ CHECK_INPUT_PARAMETER(handle);
+ tapi_h = ((telephony_data *)handle)->tapi_h;
+ CHECK_INPUT_PARAMETER(tapi_h);
+ CHECK_INPUT_PARAMETER(lock_state);
+ GET_SIM_STATUS(tapi_h, sim_card_state);
+
+ switch (sim_card_state) {
+ case TAPI_SIM_STATUS_SIM_PIN_REQUIRED:
+ *lock_state = TELEPHONY_SIM_LOCK_STATE_PIN_REQUIRED;
+ break;
+ case TAPI_SIM_STATUS_SIM_PUK_REQUIRED:
+ *lock_state = TELEPHONY_SIM_LOCK_STATE_PUK_REQUIRED;
+ break;
+ case TAPI_SIM_STATUS_CARD_BLOCKED:
+ *lock_state = TELEPHONY_SIM_LOCK_STATE_PERM_LOCKED;
+ break;
+ case TAPI_SIM_STATUS_SIM_NCK_REQUIRED:
+ *lock_state = TELEPHONY_SIM_LOCK_STATE_NCK_REQUIRED;
+ break;
+ case TAPI_SIM_STATUS_SIM_NSCK_REQUIRED:
+ *lock_state = TELEPHONY_SIM_LOCK_STATE_NSCK_REQUIRED;
+ break;
+ case TAPI_SIM_STATUS_SIM_SPCK_REQUIRED:
+ *lock_state = TELEPHONY_SIM_LOCK_STATE_SPCK_REQUIRED;
+ break;
+ case TAPI_SIM_STATUS_SIM_CCK_REQUIRED:
+ *lock_state = TELEPHONY_SIM_LOCK_STATE_CCK_REQUIRED;
+ break;
+ case TAPI_SIM_STATUS_SIM_LOCK_REQUIRED:
+ *lock_state = TELEPHONY_SIM_LOCK_STATE_PHONE_REQUIRED;
+ break;
+ default:
+ *lock_state = TELEPHONY_SIM_LOCK_STATE_UNKNOWN;
+ break;
+ }
+
+ return error_code;
+}
+
+int telephony_sim_get_gid1(telephony_h handle, char **gid1)
+{
+ int error_code = TELEPHONY_ERROR_NONE;
+ TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN;
+ TapiHandle *tapi_h;
+
+ CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+ CHECK_INPUT_PARAMETER(handle);
+ tapi_h = ((telephony_data *)handle)->tapi_h;
+ CHECK_INPUT_PARAMETER(tapi_h);
+ CHECK_INPUT_PARAMETER(gid1);
+ GET_SIM_STATUS(tapi_h, sim_card_state);
+
+ *gid1 = NULL;
+ if (sim_card_state != TAPI_SIM_STATUS_SIM_INIT_COMPLETED) {
+ error_code = TELEPHONY_ERROR_SIM_NOT_AVAILABLE;
+ } else {
+ GError *gerr = NULL;
+ TelSimAccessResult_t result = TAPI_SIM_ACCESS_SUCCESS;
+ GVariant *sync_gv = NULL;
+ GVariant *gid_gv = NULL;
+ GVariant *inner_gv = NULL;
+ GVariantIter *iter = NULL;
+ TelSimGid_t tel_gid;
+ int i = 0;
+ guchar value = 0;
+
+ sync_gv = g_dbus_connection_call_sync(tapi_h->dbus_connection,
+ DBUS_TELEPHONY_SERVICE, tapi_h->path, DBUS_TELEPHONY_SIM_INTERFACE,
+ "GetGID", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &gerr);
+
+ if (sync_gv) {
+ g_variant_get(sync_gv, "(ii@v)", &result, &tel_gid.GroupIdentifierLen, &gid_gv);
+ if (result == TAPI_SIM_ACCESS_SUCCESS) {
+ inner_gv = g_variant_get_variant(gid_gv);
+ g_variant_get(inner_gv, "ay", &iter);
+ while (g_variant_iter_loop(iter, "y", &value) && i < TAPI_SIM_GROUP_IDENTIFIER_LEN_MAX) {
+ tel_gid.szGroupIdentifier[i] = value;
+ i++;
+ }
+ *gid1 = malloc(tel_gid.GroupIdentifierLen * 2 + 1);
+ for (i = 0; i < tel_gid.GroupIdentifierLen; i++) {
+ snprintf(*gid1 + (i * 2), 3, "%02x", tel_gid.szGroupIdentifier[i]);
+ }
+ g_variant_iter_free(iter);
+ g_variant_unref(inner_gv);
+ g_variant_unref(gid_gv);
+ } else {
+ error_code = TELEPHONY_ERROR_OPERATION_FAILED;
+ }
+ } else {
+ LOGE("g_dbus_conn failed. error (%s)", gerr->message);
+ error_code = _convert_dbus_errmsg_to_sim_error(gerr->message);
+ g_error_free(gerr);
+ }
+ }
+
+ return error_code;
+}
+
+int telephony_sim_get_call_forwarding_state(telephony_h handle, bool *call_forwarding_state)
+{
+ int error_code;
+ TapiHandle *tapi_h;
+ int tel_state;
+
+ CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+ CHECK_INPUT_PARAMETER(handle);
+ tapi_h = ((telephony_data *)handle)->tapi_h;
+ CHECK_INPUT_PARAMETER(tapi_h);
+ CHECK_INPUT_PARAMETER(call_forwarding_state);
+
+ error_code = tel_get_property_int(tapi_h, TAPI_PROP_SIM_CALL_FORWARD_STATE, &tel_state);
+ if (error_code == TAPI_API_SUCCESS) {
+ *call_forwarding_state = (bool)tel_state;
+ LOGI("call_forwarding_state: [%s]", *call_forwarding_state ? "ON" : "OFF");
+ error_code = TELEPHONY_ERROR_NONE;
+ } else if (error_code == TAPI_API_ACCESS_DENIED) {
+ LOGE("PERMISSION_DENIED");
+ error_code = TELEPHONY_ERROR_PERMISSION_DENIED;
+ } else {
+ LOGE("OPERATION_FAILED");
+ error_code = TELEPHONY_ERROR_OPERATION_FAILED;
+ }
+
+ return error_code;
+}
static GMainLoop *event_loop;
static telephony_handle_list_s handle_list;
+static int sim_noti_tbl[] = {
+ TELEPHONY_NOTI_SIM_STATUS,
+ TELEPHONY_NOTI_SIM_CALL_FORWARDING_STATE
+};
+
static int network_noti_tbl[] = {
TELEPHONY_NOTI_NETWORK_SERVICE_STATE,
TELEPHONY_NOTI_NETWORK_CELLID,
char *subscriber_number = NULL;
char *subscriber_id = NULL;
bool is_changed = FALSE;
+ telephony_sim_lock_state_e lock_state = 0;
+ char *gid1 = NULL;
+ bool call_forwarding_state = FALSE;
/* Network value */
int cell_id = 0;
free(subscriber_id);
}
+ ret_value = telephony_sim_get_lock_state(handle_list.handle[0], &lock_state);
+ if (ret_value != TELEPHONY_ERROR_NONE) {
+ LOGE("telephony_sim_get_lock_state() failed!!! [%d]", ret_value);
+ } else {
+ LOGI("Lock state is [%d]", lock_state);
+ }
+
+ ret_value = telephony_sim_get_gid1(handle_list.handle[0], &gid1);
+ if (ret_value != TELEPHONY_ERROR_NONE) {
+ LOGE("telephony_sim_get_gid1() failed!!! [%d]", ret_value);
+ } else {
+ LOGI("GID1 is [%s]", gid1);
+ free(gid1);
+ }
+
+ ret_value = telephony_sim_get_call_forwarding_state(handle_list.handle[0], &call_forwarding_state);
+ if (ret_value != TELEPHONY_ERROR_NONE) {
+ LOGE("telephony_sim_get_call_forwarding_state() failed!!! [%d]", ret_value);
+ } else {
+ LOGI("Call forwarding state is [%s]", call_forwarding_state ? "ON" : "OFF");
+ }
+
/* Network API */
ret_value = telephony_network_get_cell_id(handle_list.handle[0], &cell_id);
if (ret_value != TELEPHONY_ERROR_NONE)
LOGI("Modem power status is [%d] (0=on,1=off,2=rst,3=low)", power_status);
/* set_noti_cb */
- ret_value = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_SIM_STATUS, sim_noti_cb, NULL);
- if (ret_value != TELEPHONY_ERROR_NONE)
- LOGE("Set noti failed!!!");
+ for (i = 0; i < (sizeof(sim_noti_tbl) / sizeof(int)); i++) {
+ ret_value = telephony_set_noti_cb(handle_list.handle[0], sim_noti_tbl[i], sim_noti_cb, NULL);
+ if (ret_value != TELEPHONY_ERROR_NONE)
+ LOGE("Set noti failed!!!");
+ }
for (i = 0; i < (sizeof(network_noti_tbl) / sizeof(int)); i++) {
ret_value = telephony_set_noti_cb(handle_list.handle[0], network_noti_tbl[i], network_noti_cb, NULL);
event_loop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(event_loop);
- ret_value = telephony_unset_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_SIM_STATUS);
- if (ret_value != TELEPHONY_ERROR_NONE)
- LOGE("Unset noti failed!!!");
+ for (i = 0; i < (sizeof(sim_noti_tbl) / sizeof(int)); i++) {
+ ret_value = telephony_unset_noti_cb(handle_list.handle[0], sim_noti_tbl[i]);
+ if (ret_value != TELEPHONY_ERROR_NONE)
+ LOGE("Unset noti failed!!!");
+ }
for (i = 0; i < (sizeof(network_noti_tbl) / sizeof(int)); i++) {
ret_value = telephony_unset_noti_cb(handle_list.handle[0], network_noti_tbl[i]);