From 8b23930e2ff3286fffe8fb5c8aa9fabd84ad34af Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Thu, 2 Jul 2015 14:47:12 +0900 Subject: [PATCH] Code sync from tizen_2.4 Change-Id: Ib8ee5a9bacd93f8ed7ffd6a3ef3fc481a560a3a4 --- CMakeLists.txt | 2 +- doc/telephony_doc.h | 10 +-- include/telephony_call.h | 51 ++++++----- include/telephony_common.h | 59 ++++++------ include/telephony_modem.h | 2 +- include/telephony_network.h | 26 +++--- include/telephony_private.h | 25 +++++- include/telephony_sim.h | 30 ++++--- packaging/capi-telephony.spec | 8 +- src/telephony_call.c | 83 +++++++++++------ src/telephony_common.c | 117 ++++++++++++++---------- src/telephony_modem.c | 11 --- src/telephony_network.c | 31 +++---- src/telephony_sim.c | 82 +++++------------ test/test_all_api.c | 204 ++++++++++++++++++++++++------------------ 15 files changed, 404 insertions(+), 337 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f34dc8..45ea6b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ FOREACH(flag ${${fw_name}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(ADDITIONAL_CFLAGS "-Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wcast-qual") +SET(ADDITIONAL_CFLAGS "-Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ADDITIONAL_CFLAGS}") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") diff --git a/doc/telephony_doc.h b/doc/telephony_doc.h index 769aa96..10fc50c 100644 --- a/doc/telephony_doc.h +++ b/doc/telephony_doc.h @@ -37,7 +37,7 @@ * * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n * - * More details on featuring your application can be found from Feature Element. + * More details on featuring your application can be found from Feature List. */ /** @@ -61,7 +61,7 @@ * * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n * - * More details on featuring your application can be found from Feature Element. + * More details on featuring your application can be found from Feature List. */ /** @@ -85,7 +85,7 @@ * * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n * - * More details on featuring your application can be found from Feature Element. + * More details on featuring your application can be found from Feature List. */ /** @@ -108,7 +108,7 @@ * * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n * - * More details on featuring your application can be found from Feature Element. + * More details on featuring your application can be found from Feature List. */ /** @@ -131,7 +131,7 @@ * * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n * - * More details on featuring your application can be found from Feature Element. + * More details on featuring your application can be found from Feature List. */ #endif /* __TIZEN_TELEPHONY_INFORMATION_DOC_H__ */ diff --git a/include/telephony_call.h b/include/telephony_call.h index c99632b..1264c0d 100644 --- a/include/telephony_call.h +++ b/include/telephony_call.h @@ -34,34 +34,37 @@ extern "C" { */ /** - * @brief Definition for the max length of call number - * @since_tizen 2.4 - */ -#define TELEPHONY_CALL_NUMBER_LEN_MAX 82 - -/** - * @brief Definition for the max length of call count - * @since_tizen 2.4 - */ -#define TELEPHONY_CALL_COUNT_LEN_MAX 6 - -/** * @brief The call handle. * @since_tizen 2.4 */ typedef struct telephony_call_info_s *telephony_call_h; /** + * @deprecated Deprecated Since 2.4. Use #telephony_call_status_e instead. + * * @brief Enumeration for the call state. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - TELEPHONY_CALL_STATE_IDLE, /**< There exists no calls. */ - TELEPHONY_CALL_STATE_CONNECTING, /**< There exists at least one call that is dialing, alerting or incoming */ - TELEPHONY_CALL_STATE_CONNECTED, /**< There exist active or held calls, and no calls are dialing, alerting or incoming*/ + TELEPHONY_CALL_STATE_IDLE, /**< There exists no calls. */ + TELEPHONY_CALL_STATE_CONNECTING, /**< There exists at least one call that is dialing, alerting or incoming */ + TELEPHONY_CALL_STATE_CONNECTED, /**< There exist active or held calls, and no calls are dialing, alerting or incoming */ } telephony_call_state_e; /** + * @brief Enumeration for the call status. + * @since_tizen 2.4 + */ +typedef enum { + TELEPHONY_CALL_STATUS_IDLE, /**< Idle status */ + TELEPHONY_CALL_STATUS_ACTIVE, /**< Active status */ + TELEPHONY_CALL_STATUS_HELD, /**< Held status */ + TELEPHONY_CALL_STATUS_DIALING, /**< Dialing status */ + TELEPHONY_CALL_STATUS_ALERTING, /**< Alerting status */ + TELEPHONY_CALL_STATUS_INCOMING, /**< Incoming status */ +} telephony_call_status_e; + +/** * @brief Enumeration for the preferred voice call subscription. * @since_tizen 2.4 */ @@ -93,10 +96,12 @@ typedef enum { } telephony_call_direction_e; /** + * @deprecated Deprecated Since 2.4. Use #telephony_call_get_status instead. + * * @brief Gets the voice call state of the telephony service. * @details Determines if the voice call is connecting, connected, or idle. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -120,10 +125,12 @@ typedef enum { int telephony_call_get_voice_call_state(telephony_h handle, telephony_call_state_e *call_state); /** + * @deprecated Deprecated Since 2.4. Use #telephony_call_get_status instead. + * * @brief Gets the video call state of the telephony service. * @details Determines if the video call is connecting, connected, or idle. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -275,12 +282,12 @@ int telephony_call_get_number(telephony_call_h call_handle, char **number); int telephony_call_get_type(telephony_call_h call_handle, telephony_call_type_e *type); /** - * @brief Gets the call state. + * @brief Gets the call status. * * @since_tizen 2.4 * * @param[in] call_handle The handle from #telephony_call_get_call_list() - * @param[out] state The state of the call (#telephony_call_state_e) + * @param[out] status The status of the call (#telephony_call_status_e) * * @return @c 0 on success, * otherwise a negative error value @@ -292,7 +299,7 @@ int telephony_call_get_type(telephony_call_h call_handle, telephony_call_type_e * @pre The call handle should be obtained from #telephony_call_get_call_list() * @post The call list should be released by using #telephony_call_release_call_list() */ -int telephony_call_get_state(telephony_call_h call_handle, telephony_call_state_e *state); +int telephony_call_get_status(telephony_call_h call_handle, telephony_call_status_e *status); /** * @brief Gets whether the call is MO(Mobile Originated) call or MT(Mobile Terminated). @@ -318,7 +325,7 @@ int telephony_call_get_direction(telephony_call_h call_handle, telephony_call_di * @since_tizen 2.4 * * @param[in] call_handle The handle from #telephony_call_get_call_list() - * @param[out] conference_status The value whether this call is conference call or not. + * @param[out] conference_status The value whether the call is conference call or not. * (true: Conference call, false: Single call) * * @return @c 0 on success, diff --git a/include/telephony_common.h b/include/telephony_common.h index 862eec0..8c3f9c9 100644 --- a/include/telephony_common.h +++ b/include/telephony_common.h @@ -40,7 +40,7 @@ extern "C" { /** * @brief The Telephony API handle. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef struct telephony_data *telephony_h; @@ -48,7 +48,7 @@ typedef struct telephony_data *telephony_h; * @brief The structure type for the list of handles to use the Telephony API. * @remarks There are two handles in case of dual SIM device. \n * In this case, handle[0] is mean Primary SIM and handle[1] is mean Secondary SIM. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef struct { unsigned int count; /**< Number of available handle */ @@ -57,7 +57,7 @@ typedef struct { /** * @brief Enumeration for Telephony error. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { TELEPHONY_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ @@ -71,37 +71,46 @@ typedef enum { /** * @brief Enumeration for Telephony notification. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - TELEPHONY_NOTI_SIM_STATUS = 0x10, /**< Notification to be invoked when the SIM card state changes */ - - TELEPHONY_NOTI_NETWORK_SERVICE_STATE = 0x20, /**< Notification to be invoked when the network service state changes */ - TELEPHONY_NOTI_NETWORK_CELLID, /**< Notification to be invoked when the cell ID changes */ - TELEPHONY_NOTI_NETWORK_ROAMING_STATUS, /**< Notification to be invoked when the roaming status changes */ - TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL, /**< Notification to be invoked when the signal strength changes */ - TELEPHONY_NOTI_NETWORK_SPN_NAME, /**< Notification to be invoked when the spn changes */ - TELEPHONY_NOTI_NETWORK_NETWORK_NAME, /**< Notification to be invoked when the network name changes */ - TELEPHONY_NOTI_NETWORK_NAME_OPTION, /**< Notification to be invoked when the network name option changes */ - TELEPHONY_NOTI_NETWORK_PS_TYPE, /**< Notification to be invoked when the ps type changes */ - TELEPHONY_NOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION, /**< Notification to be invoked when the default data subscription changes */ - TELEPHONY_NOTI_NETWORK_DEFAULT_SUBSCRIPTION, /**< Notification to be invoked when the default subscription changes */ - - TELEPHONY_NOTI_VOICE_CALL_STATE = 0x30, /**< Notification to be invoked when the voice call state changes */ - TELEPHONY_NOTI_VIDEO_CALL_STATE, /**< Notification to be invoked when the video call state changes */ - TELEPHONY_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION /**< Notification to be invoked when the preferred voice subscription changes */ + 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_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 */ + TELEPHONY_NOTI_NETWORK_ROAMING_STATUS, /**< Notification to be invoked when the roaming status changes, 'roaming_status(bool)' will be delivered in notification data */ + TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL, /**< Notification to be invoked when the signal strength changes, '#telephony_network_rssi_e' will be delivered in notification data */ + TELEPHONY_NOTI_NETWORK_NETWORK_NAME, /**< Notification to be invoked when the network name changes, 'network_name(char *)' wil be delivered in notification data (@b Since: 2.4) */ + TELEPHONY_NOTI_NETWORK_PS_TYPE, /**< Notification to be invoked when the ps type changes, '#telephony_network_ps_type_e' will be delivered in notification data (@b Since: 2.4) */ + TELEPHONY_NOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION, /**< Notification to be invoked when the default data subscription changes, '#telephony_network_default_data_subs_e' wil be delivered in notification data (@b Since: 2.4) */ + TELEPHONY_NOTI_NETWORK_DEFAULT_SUBSCRIPTION, /**< Notification to be invoked when the default subscription changes, '#telephony_network_default_subs_e' will be delivered in notification data (@b Since: 2.4) */ + + TELEPHONY_NOTI_VOICE_CALL_STATE = 0x30, /**< Notification to be invoked when the voice call state changes, '#telephony_call_state_e' will be delivered in notification data (Deprecated Since 2.4. Use #TELEPHONY_NOTI_VOICE_CALL_STATUS_XXX instead.) */ + TELEPHONY_NOTI_VIDEO_CALL_STATE, /**< Notification to be invoked when the video call state changes, '#telephony_call_state_e' will be delivered in notification data (Deprecated Since 2.4. Use #TELEPHONY_NOTI_VIDEO_CALL_STATUS_XXX instead.) */ + TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE, /**< Notification to be invoked when a voice call is in idle status, 'handle_id(unsigned int)' will be delivered in notification data (@b Since: 2.4) */ + TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE, /**< Notification to be invoked when a voice call is in active status, 'handle_id(unsigned int)' will be delivered in notification data (@b Since: 2.4) */ + TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD, /**< Notification to be invoked when a voice call is in held status, 'handle_id(unsigned int)' will be delivered in notification data (@b Since: 2.4) */ + TELEPHONY_NOTI_VOICE_CALL_STATUS_DIALING, /**< Notification to be invoked when a voice call is in dialing status, 'handle_id(unsigned int)' will be delivered in notification data (@b Since: 2.4) */ + TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING, /**< Notification to be invoked when a voice call is in alerting status, 'handle_id(unsigned int)' will be delivered in notification data (@b Since: 2.4) */ + TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING, /**< Notification to be invoked when a voice call is in incoming status, 'handle_id(unsigned int)' will be delivered in notification data (@b Since: 2.4) */ + TELEPHONY_NOTI_VIDEO_CALL_STATUS_IDLE, /**< Notification to be invoked when a video call is in idle status, 'handle_id(unsigned int)' will be delivered in notification data (@b Since: 2.4) */ + TELEPHONY_NOTI_VIDEO_CALL_STATUS_ACTIVE, /**< Notification to be invoked when a video call is in active status, 'handle_id(unsigned int)' will be delivered in notification data (@b Since: 2.4) */ + TELEPHONY_NOTI_VIDEO_CALL_STATUS_DIALING, /**< Notification to be invoked when a video call is in dialing status, 'handle_id(unsigned int)' will be delivered in notification data (@b Since: 2.4) */ + TELEPHONY_NOTI_VIDEO_CALL_STATUS_ALERTING, /**< Notification to be invoked when a video call is in alerting status, 'handle_id(unsigned int)' will be delivered in notification data (@b Since: 2.4) */ + TELEPHONY_NOTI_VIDEO_CALL_STATUS_INCOMING, /**< Notification to be invoked when a video call is in incoming status, 'handle_id(unsigned int)' will be delivered in notification data (@b Since: 2.4) */ + TELEPHONY_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION /**< Notification to be invoked when the preferred voice subscription changes, '#telephony_call_preferred_voice_subs_e' will be delivered in notification data (@b Since: 2.4) */ } telephony_noti_e; /** * @brief Called when the telephony state changes. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef void (*telephony_noti_cb)(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data); /** * @brief Sets a callback function to be invoked when the telephony state changes. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -129,7 +138,7 @@ int telephony_set_noti_cb(telephony_h handle, /** * @brief Unsets a callback function. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -152,7 +161,7 @@ int telephony_unset_noti_cb(telephony_h handle, telephony_noti_e noti_id); /** * @brief Acquires the list of available handles to use the telephony API. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @remarks You will get two handles in case of dual SIM device. \n * In this case, handle[0] is mean Primary SIM and handle[1] is mean Secondary SIM. @@ -175,7 +184,7 @@ int telephony_init(telephony_handle_list_s *list); /** * @brief Deinitializes the telephony handle list. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] list The handle list to be deinitialized * diff --git a/include/telephony_modem.h b/include/telephony_modem.h index ae2816c..b8f77e1 100644 --- a/include/telephony_modem.h +++ b/include/telephony_modem.h @@ -51,7 +51,7 @@ typedef enum * @details The IMEI number is used by a GSM network to identify valid devices * and therefore can be used for stopping a stolen phone from accessing that network. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * diff --git a/include/telephony_network.h b/include/telephony_network.h index db53d38..dfff3c4 100644 --- a/include/telephony_network.h +++ b/include/telephony_network.h @@ -37,7 +37,7 @@ extern "C" /** * @brief Enumeration for RSSI (Receive Signal Strength Indicator). * @details #TELEPHONY_NETWORK_RSSI_6 indicates the highest strength. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -53,7 +53,7 @@ typedef enum /** * @brief Enumeration for Network Type. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -81,7 +81,7 @@ typedef enum /** * @brief Enumeration for Network Service State. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -125,7 +125,7 @@ typedef enum { /** * @brief Gets the LAC (Location Area Code) of the current network. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -150,7 +150,7 @@ int telephony_network_get_lac(telephony_h handle, int *lac); /** * @brief Gets the cell ID. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -175,9 +175,9 @@ int telephony_network_get_cell_id(telephony_h handle, int *cell_id); /** * @brief Gets the RSSI (Received Signal Strength Indicator). * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public - * @privilege %%%%%http://tizen.org/privilege/telephony + * @privilege %http://tizen.org/privilege/telephony * * @param[in] handle The handle from telephony_init() * @param[out] rssi The Received Signal Strength Indicator \n @@ -201,7 +201,7 @@ int telephony_network_get_rssi(telephony_h handle, telephony_network_rssi_e *rss /** * @brief Gets the roaming state. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -227,7 +227,7 @@ int telephony_network_get_roaming_status(telephony_h handle, bool *status); /** * @brief Gets the MCC (Mobile Country Code) of the current registered network. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -255,7 +255,7 @@ int telephony_network_get_mcc(telephony_h handle, char **mcc); /** * @brief Gets the MNC (Mobile Network Code) of the current registered network. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -283,7 +283,7 @@ int telephony_network_get_mnc(telephony_h handle, char **mnc); /** * @brief Gets the name of the current registered network. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -310,7 +310,7 @@ int telephony_network_get_network_name(telephony_h handle, char **network_name); /** * @brief Gets the network service type of the current registered network. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -387,7 +387,7 @@ int telephony_network_get_network_name_option(telephony_h handle, /** * @brief Gets the current network state of the telephony service. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * diff --git a/include/telephony_private.h b/include/telephony_private.h index e2ba8f2..63df3eb 100644 --- a/include/telephony_private.h +++ b/include/telephony_private.h @@ -25,6 +25,17 @@ #define TELEPHONY_FEATURE "http://tizen.org/feature/network.telephony" +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "CAPI_TELEPHONY" + +#define CHECK_INPUT_PARAMETER(arg) \ + if (arg == NULL) { \ + LOGE("INVALID_PARAMETER"); \ + return TELEPHONY_ERROR_INVALID_PARAMETER; \ + } + #define CHECK_TELEPHONY_SUPPORTED(feature_name) { \ bool telephony_supported = FALSE; \ if (!system_info_get_platform_bool(feature_name, &telephony_supported)) { \ @@ -38,6 +49,12 @@ } \ } +/** + * @brief Definition for the max length of call number + * @since_tizen 2.4 + */ +#define TELEPHONY_CALL_NUMBER_LEN_MAX 82 + typedef struct { GSList *evt_list; struct tapi_handle *tapi_h; @@ -65,10 +82,10 @@ struct tapi_handle { */ typedef struct { unsigned int id; /**< The handle of the call */ - char number[TELEPHONY_CALL_NUMBER_LEN_MAX + 1]; /**< Current Calling number */ - telephony_call_type_e type; /**< Type of call (voice, data, emergency) */ - telephony_call_state_e state; /**< Current Call state */ - telephony_call_direction_e direction; /**< Current Call direction (MO, MT) */ + char number[TELEPHONY_CALL_NUMBER_LEN_MAX + 1]; /**< Calling number */ + telephony_call_type_e type; /**< Type of call (voice, video, emergency) */ + telephony_call_status_e status; /**< Call Status */ + telephony_call_direction_e direction; /**< Call direction (MO, MT) */ bool conference_status; /**< true: Conference call, false: Single call */ } telephony_call_info_s; diff --git a/include/telephony_sim.h b/include/telephony_sim.h index 53275c5..f9481fe 100644 --- a/include/telephony_sim.h +++ b/include/telephony_sim.h @@ -35,7 +35,7 @@ /** * @brief Enumeration for the state of SIM card. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -51,9 +51,10 @@ typedef enum * @since_tizen 2.4 */ typedef enum { - TELEPHONY_SIM_APP_TYPE_SIM = 0x01, /**< SIM(GSM) card */ - TELEPHONY_SIM_APP_TYPE_USIM = 0x02, /**< USIM card */ - TELEPHONY_SIM_APP_TYPE_CSIM = 0x04, /**< CDMA card */ + TELEPHONY_SIM_APP_TYPE_SIM = 0x01, /**< SIM(GSM) Application */ + TELEPHONY_SIM_APP_TYPE_USIM = 0x02, /**< USIM Application */ + TELEPHONY_SIM_APP_TYPE_CSIM = 0x04, /**< CDMA Application */ + TELEPHONY_SIM_APP_TYPE_ISIM = 0x08, /**< ISIM Application */ } telephony_sim_application_type_e; @@ -61,7 +62,7 @@ typedef enum { * @brief Gets the Integrated Circuit Card IDentification (ICC-ID). * @details The Integrated Circuit Card Identification number internationally identifies SIM cards. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -90,7 +91,7 @@ int telephony_sim_get_icc_id(telephony_h handle, char **icc_id); * @brief Gets the SIM Operator (MCC [3 digits] + MNC [2~3 digits]). * @details The Operator is embedded in the SIM card. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -119,7 +120,7 @@ int telephony_sim_get_operator(telephony_h handle, char **sim_operator); * @brief Gets the Mobile Subscription Identification Number (MSIN [9~10 digits]) of the SIM provider. * @details This function gets Mobile Subscription Identification Number embedded in the SIM card. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -149,7 +150,7 @@ int telephony_sim_get_msin(telephony_h handle, char **msin); * @details This function gets Service Provider Name embedded in the SIM card. * If this value is not stored in SIM card, @c NULL will be returned. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -177,7 +178,7 @@ int telephony_sim_get_spn(telephony_h handle, char **spn); /** * @brief Checks whether the current SIM card is different from the previous SIM card. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -204,7 +205,7 @@ int telephony_sim_is_changed(telephony_h handle, bool *is_changed); /** * @brief Gets the state of the SIM. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * @@ -231,9 +232,10 @@ int telephony_sim_get_state(telephony_h handle, telephony_sim_state_e *sim_state * * @param[in] handle The handle from telephony_init() * @param[out] app_list The masking value for below values - * #TAPI_SIM_APP_TYPE_SIM 0x01 GSM Application - * #TAPI_SIM_APP_TYPE_USIM 0x02 USIM Application - * #TAPI_SIM_APP_TYPE_CSIM 0x04 CSIM Application + * #TELEPHONY_SIM_APP_TYPE_SIM 0x01 GSM Application + * #TELEPHONY_SIM_APP_TYPE_USIM 0x02 USIM Application + * #TELEPHONY_SIM_APP_TYPE_CSIM 0x04 CSIM Application + * #TELEPHONY_SIM_APP_TYPE_ISIM 0x08 ISIM Application * * @return @c 0 on success, * otherwise a negative error value @@ -252,7 +254,7 @@ int telephony_sim_get_application_list(telephony_h handle, unsigned int *app_lis * This value contains MSISDN related to the subscriber. * If this value is not stored in SIM card, @c NULL will be returned. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/telephony * diff --git a/packaging/capi-telephony.spec b/packaging/capi-telephony.spec index 26c55e6..79a89dc 100644 --- a/packaging/capi-telephony.spec +++ b/packaging/capi-telephony.spec @@ -1,9 +1,9 @@ Name: capi-telephony Summary: Telephony Core API -Version: 0.1.32 +Version: 0.1.47 Release: 1 -Group: Telephony/Libraries -License: Apache +Group: System/Libraries +License: Apache-2.0 Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: pkgconfig(dlog) @@ -59,5 +59,3 @@ mkdir -p %{buildroot}/usr/share/license %{_includedir}/telephony/telephony_modem.h %{_libdir}/pkgconfig/*.pc %{_libdir}/libcapi-telephony.so - - diff --git a/src/telephony_call.c b/src/telephony_call.c index b5b64b9..143aa09 100644 --- a/src/telephony_call.c +++ b/src/telephony_call.c @@ -27,17 +27,6 @@ #include "telephony_call.h" #include "telephony_private.h" -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "CAPI_TELEPHONY" - -#define CHECK_INPUT_PARAMETER(arg) \ - if (arg == NULL) { \ - LOGE("INVALID_PARAMETER"); \ - return TELEPHONY_ERROR_INVALID_PARAMETER; \ - } - static void _mapping_call_state(TelCallStates_t tapi_call_state, telephony_call_state_e *call_state) { switch (tapi_call_state) { @@ -59,6 +48,35 @@ static void _mapping_call_state(TelCallStates_t tapi_call_state, telephony_call_ } } +static void _mapping_call_status(TelCallStates_t tapi_call_state, + telephony_call_status_e *status) +{ + switch (tapi_call_state) { + case TAPI_CALL_STATE_IDLE: + *status = TELEPHONY_CALL_STATUS_IDLE; + break; + case TAPI_CALL_STATE_ACTIVE: + *status = TELEPHONY_CALL_STATUS_ACTIVE; + break; + case TAPI_CALL_STATE_HELD: + *status = TELEPHONY_CALL_STATUS_HELD; + break; + case TAPI_CALL_STATE_DIALING: + *status = TELEPHONY_CALL_STATUS_DIALING; + break; + case TAPI_CALL_STATE_ALERT: + *status = TELEPHONY_CALL_STATUS_ALERTING; + break; + case TAPI_CALL_STATE_INCOMING: + case TAPI_CALL_STATE_WAITING: + *status = TELEPHONY_CALL_STATUS_INCOMING; + break; + default: + LOGE("Not handled call state: [%d]", tapi_call_state); + break; + } +} + static void _voice_call_get_state_cb(TelCallStatus_t *tapi_status, void *user_data) { telephony_call_state_e *call_state = user_data; @@ -86,16 +104,27 @@ static void _get_call_status_cb(TelCallStatus_t *status, void *user_data) telephony_call_info_s *call_info; call_info = g_malloc0(sizeof(telephony_call_info_s)); + if (!call_info) + return; call_info->id = status->CallHandle; call_info->type = status->CallType; call_info->direction = status->bMoCall ? TELEPHONY_CALL_DIRECTION_MO : TELEPHONY_CALL_DIRECTION_MT; call_info->conference_status = status->bConferenceState; - _mapping_call_state(status->CallState, &call_info->state); + _mapping_call_status(status->CallState, &call_info->status); strncpy(call_info->number, status->pNumber, TELEPHONY_CALL_NUMBER_LEN_MAX); - LOGI("id[%d] number[%s] type[%d] state[%d] direction[%d] conference_status[%d]", - call_info->id, call_info->number, call_info->type, - call_info->state, call_info->direction, call_info->conference_status); + LOGI("id[%d] number[%s] type[%s] status[%s] direction[%s] conference_status[%s]", + call_info->id, call_info->number, + call_info->type == TELEPHONY_CALL_TYPE_VOICE ? "VOICE" : + call_info->type == TELEPHONY_CALL_TYPE_VIDEO ? "VIDEO" : "E911", + call_info->status == TELEPHONY_CALL_STATUS_IDLE ? "IDLE" : + call_info->status == TELEPHONY_CALL_STATUS_ACTIVE ? "ACTVIE" : + call_info->status == TELEPHONY_CALL_STATUS_HELD ? "HELD" : + call_info->status == TELEPHONY_CALL_STATUS_DIALING ? "DIALING" : + call_info->status == TELEPHONY_CALL_STATUS_ALERTING ? "ALERTING" : + call_info->status == TELEPHONY_CALL_STATUS_INCOMING ? "INCOMING" : "UNKNOWN", + call_info->direction == TELEPHONY_CALL_DIRECTION_MO ? "MO" : "MT", + call_info->conference_status ? "TRUE" : "FALSE"); *list = g_slist_append(*list, call_info); } @@ -221,12 +250,13 @@ int telephony_call_get_call_list(telephony_h handle, if (g_slist_length(list)) { *count = g_slist_length(list); - *call_list = g_malloc0(*count * sizeof(telephony_call_info_s)); + *call_list = g_malloc0(*count * sizeof(telephony_call_h)); + tmp = list; while (tmp) { telephony_call_info_s *call_info = tmp->data; - *call_list[call_index] = g_malloc0(sizeof(telephony_call_info_s)); - memcpy(*call_list[call_index], call_info, sizeof(telephony_call_info_s)); + (*call_list)[call_index] = g_malloc0(sizeof(telephony_call_info_s)); + memcpy((*call_list)[call_index], call_info, sizeof(telephony_call_info_s)); tmp = g_slist_next(tmp); call_index++; } @@ -235,6 +265,7 @@ int telephony_call_get_call_list(telephony_h handle, *count = 0; *call_list = NULL; } + return TELEPHONY_ERROR_NONE; } @@ -244,10 +275,12 @@ int telephony_call_release_call_list(unsigned int count, telephony_call_h **call CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE); CHECK_INPUT_PARAMETER(call_list); - for (i = 0; i < count; i++) { - g_free((telephony_call_info_s *)*call_list[i]); + if (count > 0) { + for (i = 0; i < count; i++) + g_free((telephony_call_info_s *)(*call_list)[i]); + g_free(*call_list); } - g_free(*call_list); + return TELEPHONY_ERROR_NONE; } @@ -282,14 +315,14 @@ int telephony_call_get_type(telephony_call_h call_handle, return TELEPHONY_ERROR_NONE; } -int telephony_call_get_state(telephony_call_h call_handle, - telephony_call_state_e *state) +int telephony_call_get_status(telephony_call_h call_handle, + telephony_call_status_e *status) { CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE); CHECK_INPUT_PARAMETER(call_handle); - CHECK_INPUT_PARAMETER(state); + CHECK_INPUT_PARAMETER(status); - *state = ((telephony_call_info_s *)call_handle)->state; + *status = ((telephony_call_info_s *)call_handle)->status; return TELEPHONY_ERROR_NONE; } diff --git a/src/telephony_common.c b/src/telephony_common.c index 5dcb574..2b0a4a3 100644 --- a/src/telephony_common.c +++ b/src/telephony_common.c @@ -23,25 +23,29 @@ #include #include +#include #include #include #include -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "CAPI_TELEPHONY" - #define CALLBACK_CALL(data) \ if (evt_cb_data->cb) { \ evt_cb_data->cb(evt_cb_data->handle, \ evt_cb_data->noti_id, data, evt_cb_data->user_data); \ } -#define CHECK_INPUT_PARAMETER(arg) \ - if (arg == NULL) { \ - LOGE("INVALID_PARAMETER"); \ - return TELEPHONY_ERROR_INVALID_PARAMETER; \ +/* Handle deprecated noti_id for backward compatibility */ +#define CALLBACK_CALL_FOR_DEPRECATED_NOTI(evt_cb_data) \ + if (evt_cb_data->noti_id == TELEPHONY_NOTI_VOICE_CALL_STATE) { \ + telephony_call_state_e call_state; \ + telephony_call_get_voice_call_state(evt_cb_data->handle, &call_state); \ + CALLBACK_CALL(&call_state); \ + return; \ + } else if (evt_cb_data->noti_id == TELEPHONY_NOTI_VIDEO_CALL_STATE) { \ + telephony_call_state_e call_state; \ + telephony_call_get_video_call_state(evt_cb_data->handle, &call_state); \ + CALLBACK_CALL(&call_state); \ + return; \ } typedef struct { @@ -81,12 +85,8 @@ static const char *_mapping_noti_id(telephony_noti_e noti_id) return TAPI_PROP_NETWORK_ROAMING_STATUS; case TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL: return TAPI_PROP_NETWORK_SIGNALSTRENGTH_LEVEL; - case TELEPHONY_NOTI_NETWORK_SPN_NAME: - return TAPI_PROP_NETWORK_SPN_NAME; case TELEPHONY_NOTI_NETWORK_NETWORK_NAME: return TAPI_PROP_NETWORK_NETWORK_NAME; - case TELEPHONY_NOTI_NETWORK_NAME_OPTION: - return TAPI_PROP_NETWORK_NAME_OPTION; case TELEPHONY_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION: return TAPI_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION; case TELEPHONY_NOTI_NETWORK_PS_TYPE: @@ -95,6 +95,28 @@ static const char *_mapping_noti_id(telephony_noti_e noti_id) return TAPI_NOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION; case TELEPHONY_NOTI_NETWORK_DEFAULT_SUBSCRIPTION: return TAPI_NOTI_NETWORK_DEFAULT_SUBSCRIPTION; + case TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE: + return TAPI_NOTI_VOICE_CALL_STATUS_IDLE; + case TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE: + return TAPI_NOTI_VOICE_CALL_STATUS_ACTIVE; + case TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD: + return TAPI_NOTI_VOICE_CALL_STATUS_HELD; + case TELEPHONY_NOTI_VOICE_CALL_STATUS_DIALING: + return TAPI_NOTI_VOICE_CALL_STATUS_DIALING; + case TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING: + return TAPI_NOTI_VOICE_CALL_STATUS_ALERT; + case TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING: + return TAPI_NOTI_VOICE_CALL_STATUS_INCOMING; + case TELEPHONY_NOTI_VIDEO_CALL_STATUS_IDLE: + return TAPI_NOTI_VIDEO_CALL_STATUS_IDLE; + case TELEPHONY_NOTI_VIDEO_CALL_STATUS_ACTIVE: + return TAPI_NOTI_VIDEO_CALL_STATUS_ACTIVE; + case TELEPHONY_NOTI_VIDEO_CALL_STATUS_DIALING: + return TAPI_NOTI_VIDEO_CALL_STATUS_DIALING; + case TELEPHONY_NOTI_VIDEO_CALL_STATUS_ALERTING: + return TAPI_NOTI_VIDEO_CALL_STATUS_ALERT; + case TELEPHONY_NOTI_VIDEO_CALL_STATUS_INCOMING: + return TAPI_NOTI_VIDEO_CALL_STATUS_INCOMING; default: return NULL; } @@ -176,24 +198,21 @@ static telephony_error_e __deregister_all_noti(telephony_h handle, telephony_not int count = sizeof(voice_call_state_tbl) / sizeof(char *); for (i = 0; i < count; i++) { ret = tel_deregister_noti_event(tapi_h, voice_call_state_tbl[i]); - if (ret != TAPI_API_SUCCESS) { + if (ret != TAPI_API_SUCCESS) LOGE("Noti [%s] deregistration failed", voice_call_state_tbl[i]); - } } } else if (noti_id == TELEPHONY_NOTI_VIDEO_CALL_STATE) { int count = sizeof(video_call_state_tbl) / sizeof(char *); for (i = 0; i < count; i++) { ret = tel_deregister_noti_event(tapi_h, video_call_state_tbl[i]); - if (ret != TAPI_API_SUCCESS) { + if (ret != TAPI_API_SUCCESS) LOGE("Noti [%s] deregistration failed", video_call_state_tbl[i]); - } } } else { /* Deregister other notifications */ ret = tel_deregister_noti_event(tapi_h, tapi_noti); - if (ret != TAPI_API_SUCCESS) { + if (ret != TAPI_API_SUCCESS) LOGE("Noti [%s] deregistration failed", tapi_noti); - } } return TELEPHONY_ERROR_NONE; @@ -228,9 +247,6 @@ static void on_signal_callback(TapiHandle *tapi_h, const char *evt_id, 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)) { - int call_forwading_state = *(int *)data; - CALLBACK_CALL(&call_forwading_state); } else if (!g_strcmp0(evt_id, TAPI_PROP_NETWORK_SERVICE_TYPE)) { int service_state = _mapping_service_state(*(int *)data); CALLBACK_CALL(&service_state); @@ -243,15 +259,9 @@ static void on_signal_callback(TapiHandle *tapi_h, const char *evt_id, } else if (!g_strcmp0(evt_id, TAPI_PROP_NETWORK_SIGNALSTRENGTH_LEVEL)) { int rssi = *(int *)data; CALLBACK_CALL(&rssi); - } else if (!g_strcmp0(evt_id, TAPI_PROP_NETWORK_SPN_NAME)) { - char *spn = data; - CALLBACK_CALL(spn); } else if (!g_strcmp0(evt_id, TAPI_PROP_NETWORK_NETWORK_NAME)) { char *network_name = data; CALLBACK_CALL(network_name); - } else if (!g_strcmp0(evt_id, TAPI_PROP_NETWORK_NAME_OPTION)) { - int network_name_option = *(int *)data; - CALLBACK_CALL(&network_name_option); } else if (!g_strcmp0(evt_id, TAPI_PROP_NETWORK_PS_TYPE)) { int ps_type = *(int *)data; CALLBACK_CALL(&ps_type); @@ -262,22 +272,40 @@ static void on_signal_callback(TapiHandle *tapi_h, const char *evt_id, int default_sub = *(int *)data; CALLBACK_CALL(&default_sub); } else if (!g_strcmp0(evt_id, TAPI_NOTI_VOICE_CALL_STATUS_IDLE) - || !g_strcmp0(evt_id, TAPI_NOTI_VIDEO_CALL_STATUS_IDLE)) { - /* Do not check IDLE state to prevent overriding in case of multi-party call */ - LOGI("Not handled IDLE call state"); + || !g_strcmp0(evt_id, TAPI_NOTI_VIDEO_CALL_STATUS_IDLE)) { + TelCallStatusIdleNoti_t *noti = data; + unsigned int handle_id = noti->id; + CALLBACK_CALL_FOR_DEPRECATED_NOTI(evt_cb_data); + CALLBACK_CALL(&handle_id); } else if (!g_strcmp0(evt_id, TAPI_NOTI_VOICE_CALL_STATUS_ACTIVE) - || !g_strcmp0(evt_id, TAPI_NOTI_VIDEO_CALL_STATUS_ACTIVE) - || !g_strcmp0(evt_id, TAPI_NOTI_VOICE_CALL_STATUS_HELD)) { - telephony_call_state_e call_state = TELEPHONY_CALL_STATE_CONNECTED; - CALLBACK_CALL(&call_state); + || !g_strcmp0(evt_id, TAPI_NOTI_VIDEO_CALL_STATUS_ACTIVE)) { + TelCallStatusActiveNoti_t *noti = data; + unsigned int handle_id = noti->id; + CALLBACK_CALL_FOR_DEPRECATED_NOTI(evt_cb_data); + CALLBACK_CALL(&handle_id); + } else if (!g_strcmp0(evt_id, TAPI_NOTI_VOICE_CALL_STATUS_HELD)) { + TelCallStatusHeldNoti_t *noti = data; + unsigned int handle_id = noti->id; + CALLBACK_CALL_FOR_DEPRECATED_NOTI(evt_cb_data); + CALLBACK_CALL(&handle_id); } else if (!g_strcmp0(evt_id, TAPI_NOTI_VOICE_CALL_STATUS_DIALING) - || !g_strcmp0(evt_id, TAPI_NOTI_VIDEO_CALL_STATUS_DIALING) - || !g_strcmp0(evt_id, TAPI_NOTI_VOICE_CALL_STATUS_ALERT) - || !g_strcmp0(evt_id, TAPI_NOTI_VIDEO_CALL_STATUS_ALERT) - || !g_strcmp0(evt_id, TAPI_NOTI_VOICE_CALL_STATUS_INCOMING) - || !g_strcmp0(evt_id, TAPI_NOTI_VIDEO_CALL_STATUS_INCOMING)) { - telephony_call_state_e call_state = TELEPHONY_CALL_STATE_CONNECTING; - CALLBACK_CALL(&call_state); + || !g_strcmp0(evt_id, TAPI_NOTI_VIDEO_CALL_STATUS_DIALING)) { + TelCallStatusDialingNoti_t *noti = data; + unsigned int handle_id = noti->id; + CALLBACK_CALL_FOR_DEPRECATED_NOTI(evt_cb_data); + CALLBACK_CALL(&handle_id); + } else if (!g_strcmp0(evt_id, TAPI_NOTI_VOICE_CALL_STATUS_ALERT) + || !g_strcmp0(evt_id, TAPI_NOTI_VIDEO_CALL_STATUS_ALERT)) { + TelCallStatusAlertNoti_t *noti = data; + unsigned int handle_id = noti->id; + CALLBACK_CALL_FOR_DEPRECATED_NOTI(evt_cb_data); + CALLBACK_CALL(&handle_id); + } else if (!g_strcmp0(evt_id, TAPI_NOTI_VOICE_CALL_STATUS_INCOMING) + || !g_strcmp0(evt_id, TAPI_NOTI_VIDEO_CALL_STATUS_INCOMING)) { + TelCallIncomingCallInfo_t *noti = data; + unsigned int handle_id = noti->CallHandle; + CALLBACK_CALL_FOR_DEPRECATED_NOTI(evt_cb_data); + CALLBACK_CALL(&handle_id); } else if (!g_strcmp0(evt_id, TAPI_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION)) { int call_pref_voice_sub = *(int *)data; CALLBACK_CALL(&call_pref_voice_sub); @@ -396,7 +424,7 @@ int telephony_init(telephony_handle_list_s *list) CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE); CHECK_INPUT_PARAMETER(list); -#if !GLIB_CHECK_VERSION(2,35,0) +#if !GLIB_CHECK_VERSION(2, 35, 0) /* Need g_type_init() to use tel_get_cp_name_list() */ g_type_init(); #endif @@ -407,9 +435,8 @@ int telephony_init(telephony_handle_list_s *list) return TELEPHONY_ERROR_OPERATION_FAILED; } - while (cp_list[cp_count]) { + while (cp_list[cp_count]) cp_count++; - } list->count = cp_count; list->handle = g_malloc(cp_count * sizeof(telephony_h)); diff --git a/src/telephony_modem.c b/src/telephony_modem.c index 79ca0e6..975eebc 100644 --- a/src/telephony_modem.c +++ b/src/telephony_modem.c @@ -27,17 +27,6 @@ #include "telephony_modem.h" #include "telephony_private.h" -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "CAPI_TELEPHONY" - -#define CHECK_INPUT_PARAMETER(arg) \ - if (arg == NULL) { \ - LOGE("INVALID_PARAMETER"); \ - return TELEPHONY_ERROR_INVALID_PARAMETER; \ - } - int telephony_modem_get_imei(telephony_h handle, char **imei) { GVariant *gv = NULL; diff --git a/src/telephony_network.c b/src/telephony_network.c index f1000d0..9517417 100644 --- a/src/telephony_network.c +++ b/src/telephony_network.c @@ -30,17 +30,6 @@ #include #include -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "CAPI_TELEPHONY" - -#define CHECK_INPUT_PARAMETER(arg) \ - if (arg == NULL) { \ - LOGE("INVALID_PARAMETER"); \ - return TELEPHONY_ERROR_INVALID_PARAMETER; \ - } - int telephony_network_get_lac(telephony_h handle, int *lac) { int ret; @@ -165,14 +154,14 @@ int telephony_network_get_mcc(telephony_h handle, char **mcc) ret = tel_get_property_string(tapi_h, TAPI_PROP_NETWORK_PLMN, &plmn_str); if (ret == TAPI_API_SUCCESS) { - *mcc = malloc (sizeof(char) * (mcc_length + 1)); + *mcc = malloc(sizeof(char) * (mcc_length + 1)); if (*mcc == NULL) { LOGE("OUT_OF_MEMORY"); ret = TELEPHONY_ERROR_OUT_OF_MEMORY; } else { - memset (*mcc, 0x00, mcc_length + 1); - strncpy (*mcc, plmn_str, mcc_length); - free (plmn_str); + memset(*mcc, 0x00, mcc_length + 1); + strncpy(*mcc, plmn_str, mcc_length); + free(plmn_str); LOGI("mcc:[%s]", *mcc); ret = TELEPHONY_ERROR_NONE; @@ -206,14 +195,14 @@ int telephony_network_get_mnc(telephony_h handle, char **mnc) plmn_length = strlen(plmn_str); LOGI("plmn:[%s], length:[%d]", plmn_str, plmn_length); - *mnc = malloc (sizeof(char) * (plmn_length -3 + 1)); + *mnc = malloc(sizeof(char) * (plmn_length -3 + 1)); if (*mnc == NULL) { LOGE("OUT_OF_MEMORY"); ret = TELEPHONY_ERROR_OUT_OF_MEMORY; } else { - memset (*mnc, 0x00, (plmn_length -3 + 1)); - strncpy (*mnc, plmn_str + 3, (plmn_length -3 + 1)); - free (plmn_str); + memset(*mnc, 0x00, (plmn_length -3 + 1)); + strncpy(*mnc, plmn_str + 3, (plmn_length -3 + 1)); + free(plmn_str); LOGI("mnc:[%s]", *mnc); ret = TELEPHONY_ERROR_NONE; @@ -448,7 +437,7 @@ int telephony_network_get_default_data_subscription(telephony_h handle, ret = tel_get_network_default_data_subscription(tapi_h, &default_data_subscription); if (ret == TAPI_API_SUCCESS) { - switch(default_data_subscription) { + switch (default_data_subscription) { case TAPI_NETWORK_DEFAULT_DATA_SUBS_SIM1: *default_data_sub = TELEPHONY_NETWORK_DEFAULT_DATA_SUBS_SIM1; break; @@ -488,7 +477,7 @@ int telephony_network_get_default_subscription(telephony_h handle, ret = tel_get_network_default_subscription(tapi_h, &default_subscription); if (ret == TAPI_API_SUCCESS) { - switch(default_subscription) { + switch (default_subscription) { case TAPI_NETWORK_DEFAULT_SUBS_SIM1: *default_sub = TELEPHONY_NETWORK_DEFAULT_SUBS_SIM1; break; diff --git a/src/telephony_sim.c b/src/telephony_sim.c index 53690c9..ce2e5f0 100644 --- a/src/telephony_sim.c +++ b/src/telephony_sim.c @@ -28,11 +28,6 @@ #include "telephony_sim.h" #include "telephony_private.h" -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "CAPI_TELEPHONY" - #define DBUS_SIM_STATUS_ERROR "SIM STATUS ERROR" #define DBUS_SIM_NOT_FOUND "SIM NOT FOUND" #define DBUS_SIM_PERM_BLOCKED "SIM PERM BLOCKED" @@ -44,12 +39,6 @@ #define DBUS_SIM_RESPONSE_DATA_ERROR "SIM RESPONSE DATA ERROR" #define DBUS_SIM_ACCESS_DENIED "No access rights" -#define CHECK_INPUT_PARAMETER(arg) \ - if (arg == NULL) { \ - LOGE("INVALID_PARAMETER"); \ - return TELEPHONY_ERROR_INVALID_PARAMETER; \ - } - #define GET_SIM_STATUS(tapi_h, sim_card_state) { \ int card_changed = 0; \ int ret = tel_get_sim_init_info(tapi_h, &sim_card_state, &card_changed); \ @@ -107,12 +96,12 @@ int telephony_sim_get_icc_id(telephony_h handle, char **icc_id) CHECK_INPUT_PARAMETER(icc_id); GET_SIM_STATUS(tapi_h, sim_card_state); + *icc_id = NULL; if (sim_card_state == TAPI_SIM_STATUS_CARD_ERROR || sim_card_state == TAPI_SIM_STATUS_CARD_BLOCKED || sim_card_state == TAPI_SIM_STATUS_CARD_NOT_PRESENT || sim_card_state == TAPI_SIM_STATUS_CARD_REMOVED || sim_card_state == TAPI_SIM_STATUS_UNKNOWN) { - *icc_id = NULL; error_code = TELEPHONY_ERROR_SIM_NOT_AVAILABLE; } else { GError *gerr = NULL; @@ -127,19 +116,18 @@ int telephony_sim_get_icc_id(telephony_h handle, char **icc_id) if (sync_gv) { g_variant_get(sync_gv, "(is)", &result, &iccid); if (result == TAPI_SIM_ACCESS_SUCCESS) { - if (iccid != NULL && strlen(iccid) != 0) { + if (iccid != NULL && strlen(iccid) != 0) *icc_id = g_strdup_printf("%s", iccid); - } + else + *icc_id = g_strdup_printf("%s", ""); } else { error_code = TELEPHONY_ERROR_OPERATION_FAILED; - *icc_id = NULL; } g_free(iccid); } else { LOGE("g_dbus_conn failed. error (%s)", gerr->message); error_code = _convert_dbus_errmsg_to_sim_error(gerr->message); g_error_free(gerr); - *icc_id = NULL; } } @@ -159,8 +147,8 @@ int telephony_sim_get_operator(telephony_h handle, char **sim_operator) CHECK_INPUT_PARAMETER(sim_operator); GET_SIM_STATUS(tapi_h, sim_card_state); + *sim_operator = NULL; if (sim_card_state != TAPI_SIM_STATUS_SIM_INIT_COMPLETED) { - *sim_operator = NULL; error_code = TELEPHONY_ERROR_SIM_NOT_AVAILABLE; } else { TelSimImsiInfo_t sim_imsi_info; @@ -170,11 +158,9 @@ int telephony_sim_get_operator(telephony_h handle, char **sim_operator) LOGI("SIM operator: [%s]", *sim_operator); } else if (ret == TAPI_API_ACCESS_DENIED) { LOGE("PERMISSION_DENIED"); - *sim_operator = NULL; error_code = TELEPHONY_ERROR_PERMISSION_DENIED; } else { LOGE("OPERATION_FAILED"); - *sim_operator = NULL; error_code = TELEPHONY_ERROR_OPERATION_FAILED; } } @@ -195,8 +181,8 @@ int telephony_sim_get_msin(telephony_h handle, char **msin) CHECK_INPUT_PARAMETER(msin); GET_SIM_STATUS(tapi_h, sim_card_state); + *msin = NULL; if (sim_card_state != TAPI_SIM_STATUS_SIM_INIT_COMPLETED) { - *msin = NULL; error_code = TELEPHONY_ERROR_SIM_NOT_AVAILABLE; } else { TelSimImsiInfo_t sim_imsi_info; @@ -205,11 +191,9 @@ int telephony_sim_get_msin(telephony_h handle, char **msin) *msin = g_strdup_printf("%s", sim_imsi_info.szMsin); } else if (ret == TAPI_API_ACCESS_DENIED) { LOGE("PERMISSION_DENIED"); - *msin = NULL; error_code = TELEPHONY_ERROR_PERMISSION_DENIED; } else { LOGE("OPERATION_FAILED"); - *msin = NULL; error_code = TELEPHONY_ERROR_OPERATION_FAILED; } } @@ -230,12 +214,12 @@ int telephony_sim_get_spn(telephony_h handle, char **spn) CHECK_INPUT_PARAMETER(spn); GET_SIM_STATUS(tapi_h, sim_card_state); + *spn = NULL; if (sim_card_state == TAPI_SIM_STATUS_CARD_ERROR || sim_card_state == TAPI_SIM_STATUS_CARD_BLOCKED || sim_card_state == TAPI_SIM_STATUS_CARD_NOT_PRESENT || sim_card_state == TAPI_SIM_STATUS_CARD_REMOVED || sim_card_state == TAPI_SIM_STATUS_UNKNOWN) { - *spn = NULL; error_code = TELEPHONY_ERROR_SIM_NOT_AVAILABLE; } else { GError *gerr = NULL; @@ -255,18 +239,17 @@ int telephony_sim_get_spn(telephony_h handle, char **spn) *spn = g_strdup_printf("%s", spn_str); LOGI("SPN: [%s]", *spn); } else { - *spn = NULL; + *spn = g_strdup_printf("%s", ""); + LOGI("SPN: [%s]", *spn); } - g_free(spn_str); } else { error_code = TELEPHONY_ERROR_OPERATION_FAILED; - *spn = NULL; } + g_free(spn_str); } else { LOGE("g_dbus_conn failed. error (%s)", gerr->message); error_code = _convert_dbus_errmsg_to_sim_error(gerr->message); g_error_free(gerr); - *spn = NULL; } } @@ -349,10 +332,10 @@ int telephony_sim_get_state(telephony_h handle, telephony_sim_state_e *sim_state return error_code; } -int telephony_sim_get_application_list (telephony_h handle, unsigned int *app_list) +int telephony_sim_get_application_list(telephony_h handle, unsigned int *app_list) { - TelSimCardType_t sim_card_type = TAPI_SIM_CARD_TYPE_UNKNOWN; TapiHandle *tapi_h; + unsigned char tapi_app_list; int ret; CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE); @@ -361,7 +344,7 @@ int telephony_sim_get_application_list (telephony_h handle, unsigned int *app_li CHECK_INPUT_PARAMETER(tapi_h); CHECK_INPUT_PARAMETER(app_list); - ret = tel_get_sim_type(tapi_h, &sim_card_type); + ret = tel_get_sim_application_list(tapi_h, &tapi_app_list); if (ret == TAPI_API_ACCESS_DENIED) { LOGE("PERMISSION_DENIED"); return TELEPHONY_ERROR_PERMISSION_DENIED; @@ -370,25 +353,8 @@ int telephony_sim_get_application_list (telephony_h handle, unsigned int *app_li return TELEPHONY_ERROR_OPERATION_FAILED; } - *app_list = 0; - - switch(sim_card_type) { - case TAPI_SIM_CARD_TYPE_GSM: - *app_list |= TELEPHONY_SIM_APP_TYPE_SIM; - break; - case TAPI_SIM_CARD_TYPE_USIM: - *app_list |= TELEPHONY_SIM_APP_TYPE_USIM; - break; - case TAPI_SIM_CARD_TYPE_RUIM: - *app_list |= TELEPHONY_SIM_APP_TYPE_CSIM; - break; - default: - LOGI("Not supporting sim application type"); - break; - } - - LOGI("Sim application list: [0x%x]", *app_list); - + *app_list = (unsigned int)tapi_app_list; + LOGI("SIM Application List: [0x%x]", *app_list); return TELEPHONY_ERROR_NONE; } @@ -406,10 +372,10 @@ int telephony_sim_get_subscriber_number(telephony_h handle, char **subscriber_nu CHECK_INPUT_PARAMETER(tapi_h); CHECK_INPUT_PARAMETER(subscriber_number); + *subscriber_number = NULL; sync_gv = g_dbus_connection_call_sync(tapi_h->dbus_connection, DBUS_TELEPHONY_SERVICE, tapi_h->path, DBUS_TELEPHONY_SIM_INTERFACE, "GetMSISDN", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &gerr); - if (sync_gv) { GVariantIter *iter = NULL; g_variant_get(sync_gv, "(iaa{sv})", &result, &iter); @@ -418,31 +384,29 @@ int telephony_sim_get_subscriber_number(telephony_h handle, char **subscriber_nu GVariant *value = NULL; const gchar *str_value = NULL; GVariantIter *iter_row = NULL; + while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { while (g_variant_iter_loop(iter_row, "{sv}", &key, &value)) { if (!g_strcmp0(key, "number")) { str_value = g_variant_get_string(value, NULL); - if (strlen(str_value) != 0) { + if (str_value != NULL && strlen(str_value) != 0) *subscriber_number = g_strdup_printf("%s", str_value); - } else { - *subscriber_number = NULL; - } } } g_variant_iter_free(iter_row); /* Acquire only 1 subscriber number */ break; } + if (!*subscriber_number) + *subscriber_number = g_strdup_printf("%s", ""); g_variant_iter_free(iter); } else { error_code = TELEPHONY_ERROR_OPERATION_FAILED; - *subscriber_number = NULL; } } else { LOGE("g_dbus_conn failed. error (%s)", gerr->message); error_code = _convert_dbus_errmsg_to_sim_error(gerr->message); g_error_free(gerr); - *subscriber_number = NULL; } return error_code; @@ -461,8 +425,8 @@ int telephony_sim_get_subscriber_id(telephony_h handle, char **subscriber_id) CHECK_INPUT_PARAMETER(subscriber_id); GET_SIM_STATUS(tapi_h, sim_card_state); + *subscriber_id = NULL; if (sim_card_state != TAPI_SIM_STATUS_SIM_INIT_COMPLETED) { - *subscriber_id = NULL; error_code = TELEPHONY_ERROR_SIM_NOT_AVAILABLE; } else { TelSimImsiInfo_t imsi_info; @@ -482,16 +446,14 @@ int telephony_sim_get_subscriber_id(telephony_h handle, char **subscriber_id) *subscriber_id = g_malloc0(SHA256_DIGEST_LENGTH * 2 + 1); for (i = 0; i < SHA256_DIGEST_LENGTH; i++) - sprintf(*subscriber_id + (i * 2), "%02x", md[i]); + snprintf(*subscriber_id + (i * 2), 3, "%02x", md[i]); LOGI("Subscriber ID: [%s]", *subscriber_id); g_free(imsi); } else if (error_code == TAPI_API_ACCESS_DENIED) { LOGE("get_subscriber_id: PERMISSION_DENIED"); - *subscriber_id = NULL; error_code = TELEPHONY_ERROR_PERMISSION_DENIED; } else { LOGE("get_subscriber_id: OPERATION_FAILED"); - *subscriber_id = NULL; error_code = TELEPHONY_ERROR_OPERATION_FAILED; } } diff --git a/test/test_all_api.c b/test/test_all_api.c index 5e58750..6ca4375 100644 --- a/test/test_all_api.c +++ b/test/test_all_api.c @@ -27,23 +27,26 @@ #define LOG_TAG "CAPI_TELEPHONY_TEST" static GMainLoop *event_loop; +static telephony_handle_list_s handle_list; static int network_noti_tbl[] = { TELEPHONY_NOTI_NETWORK_SERVICE_STATE, TELEPHONY_NOTI_NETWORK_CELLID, TELEPHONY_NOTI_NETWORK_ROAMING_STATUS, TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL, - TELEPHONY_NOTI_NETWORK_SPN_NAME, TELEPHONY_NOTI_NETWORK_NETWORK_NAME, - TELEPHONY_NOTI_NETWORK_NAME_OPTION, TELEPHONY_NOTI_NETWORK_PS_TYPE, TELEPHONY_NOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION, TELEPHONY_NOTI_NETWORK_DEFAULT_SUBSCRIPTION }; static int call_noti_tbl[] = { - TELEPHONY_NOTI_VOICE_CALL_STATE, - TELEPHONY_NOTI_VIDEO_CALL_STATE, + TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE, + TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE, + TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD, + TELEPHONY_NOTI_VOICE_CALL_STATUS_DIALING, + TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING, + TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING, TELEPHONY_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION }; @@ -64,8 +67,6 @@ static const char *_mapping_sim_state(telephony_sim_state_e sim_state) static void sim_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data) { LOGI("Noti!! SIM status: [%d]", *(int *)data); - -// g_main_loop_quit(event_loop); } static const char *_mapping_service_state(telephony_network_service_state_e service_state) @@ -175,15 +176,9 @@ static void network_noti_cb(telephony_h handle, telephony_noti_e noti_id, void * case TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL: LOGI("Noti!!! Signal strength: [%d]", *(int *)data); break; - case TELEPHONY_NOTI_NETWORK_SPN_NAME: - LOGI("Noti!!! SPN Name: [%s]", *(int *)data); - break; case TELEPHONY_NOTI_NETWORK_NETWORK_NAME: LOGI("Noti!!! Network Name: [%s]", *(int *)data); break; - case TELEPHONY_NOTI_NETWORK_NAME_OPTION: - LOGI("Noti!!! Name Option: [%s]", _mapping_name_option(*(int *)data)); - break; case TELEPHONY_NOTI_NETWORK_PS_TYPE: LOGI("Noti!!! PS Type: [%s]", _mapping_ps_type(*(int *)data)); break; @@ -198,7 +193,6 @@ static void network_noti_cb(telephony_h handle, telephony_noti_e noti_id, void * break; } -// g_main_loop_quit(event_loop); } static const char *_mapping_call_state(telephony_call_state_e call_state) @@ -234,27 +228,79 @@ static const char *_mapping_preferred_voice_sub(telephony_call_preferred_voice_s static void call_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data) { + int ret_value; + telephony_call_h *call_list; + unsigned int count = 0; + + if (noti_id == TELEPHONY_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION) { + LOGI("Noti!!! Preferred Voice Subscription: [%d]", *(int *)data); + return; + } + switch (noti_id) { - case TELEPHONY_NOTI_VOICE_CALL_STATE: - LOGI("Noti!!! Voice Call state: [%s]", _mapping_call_state(*(int *)data)); + case TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE: + LOGI("Noti!!! Voice Call Status Idle!!! [%d]", *(int *)data); break; - case TELEPHONY_NOTI_VIDEO_CALL_STATE: - LOGI("Noti!!! Video Call state: [%s]", _mapping_call_state(*(int *)data)); + case TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE: + LOGI("Noti!!! Voice Call Status Active!!! [%d]", *(int *)data); break; - case TELEPHONY_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION: - LOGI("Noti!!! Preferred Voice Subscription: [%d]", *(int *)data); + case TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD: + LOGI("Noti!!! Voice Call Status Held!!! [%d]", *(int *)data); + break; + case TELEPHONY_NOTI_VOICE_CALL_STATUS_DIALING: + LOGI("Noti!!! Voice Call Status Dialing!!! [%d]", *(int *)data); + break; + case TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING: + LOGI("Noti!!! Voice Call Status Alerting!!! [%d]", *(int *)data); + break; + case TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING: + LOGI("Noti!!! Voice Call Status Incoming!!! [%d]", *(int *)data); break; default: LOGE("Unknown noti"); break; } -// g_main_loop_quit(event_loop); + ret_value = telephony_call_get_call_list(handle_list.handle[0], &count, &call_list); + if (ret_value != TELEPHONY_ERROR_NONE) { + LOGE("telephony_call_get_call_list() failed!!!zz [0x%x]", ret_value); + } else { + int i; + unsigned int handle_id = 0; + char *number = NULL; + telephony_call_type_e type = 0; + telephony_call_status_e status = 0; + telephony_call_direction_e direction = 0; + bool conf_status = 0; + + for (i = 0; i < count; i++) { + telephony_call_get_handle_id(call_list[i], &handle_id); + telephony_call_get_number(call_list[i], &number); + telephony_call_get_type(call_list[i], &type); + telephony_call_get_status(call_list[i], &status); + telephony_call_get_direction(call_list[i], &direction); + telephony_call_get_conference_status(call_list[i], &conf_status); + LOGI("id[%d] number[%s] type[%s] status[%s] direction[%s] conference_status[%s]", + handle_id, number, + type == TELEPHONY_CALL_TYPE_VOICE ? "VOICE" : + type == TELEPHONY_CALL_TYPE_VIDEO ? "VIDEO" : "E911", + status == TELEPHONY_CALL_STATUS_IDLE ? "IDLE" : + status == TELEPHONY_CALL_STATUS_ACTIVE ? "ACTVIE" : + status == TELEPHONY_CALL_STATUS_HELD ? "HELD" : + status == TELEPHONY_CALL_STATUS_DIALING ? "DIALING" : + status == TELEPHONY_CALL_STATUS_ALERTING ? "ALERTING" : + status == TELEPHONY_CALL_STATUS_INCOMING ? "INCOMING" : "UNKNOWN", + direction == TELEPHONY_CALL_DIRECTION_MO ? "MO" : "MT", + conf_status ? "TRUE" : "FALSE"); + free(number); + } + telephony_call_release_call_list(count, &call_list); + } + } int main() { - telephony_handle_list_s handle_list; int ret_value, i; /* SIM value */ @@ -266,6 +312,7 @@ int main() unsigned int app_list = 0; char *subscriber_number = NULL; char *subscriber_id = NULL; + bool is_changed = FALSE; /* Network value */ int cell_id = 0; @@ -290,7 +337,7 @@ int main() /* Modem value */ char *imei = NULL; - telephony_modem_power_status_e status = 0; + telephony_modem_power_status_e power_status = 0; /* Initialize handle */ ret_value = telephony_init(&handle_list); @@ -302,6 +349,12 @@ int main() LOGI("handle count: [%d]", handle_list.count); /* SIM API */ + ret_value = telephony_sim_is_changed(handle_list.handle[0], &is_changed); + if (ret_value != TELEPHONY_ERROR_NONE) + LOGE("telephony_sim_is_changed() failed!!! [%d]", ret_value); + else + LOGI("SIM is [%s]", is_changed ? "Changed" : "Not changed"); + ret_value = telephony_sim_get_operator(handle_list.handle[0], &operator); if (ret_value != TELEPHONY_ERROR_NONE) { LOGE("telephony_sim_get_operator() failed!!! [%d]", ret_value); @@ -335,25 +388,21 @@ int main() } ret_value = telephony_sim_get_state(handle_list.handle[0], &sim_state); - if (ret_value != TELEPHONY_ERROR_NONE) { + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("telephony_sim_get_state() failed!!! [%d]", ret_value); - } else { + else LOGI("SIM state is [%s]", _mapping_sim_state(sim_state)); - } ret_value = telephony_sim_get_application_list(handle_list.handle[0], &app_list); if (ret_value != TELEPHONY_ERROR_NONE) { LOGE("telephony_sim_get_type() failed!!! [%d]", ret_value); } else { - if (app_list & TELEPHONY_SIM_APP_TYPE_SIM) { + if (app_list & TELEPHONY_SIM_APP_TYPE_SIM) LOGI("Sim type [SIM]"); - } - if (app_list & TELEPHONY_SIM_APP_TYPE_USIM) { + if (app_list & TELEPHONY_SIM_APP_TYPE_USIM) LOGI("Sim type [USIM]"); - } - if (app_list & TELEPHONY_SIM_APP_TYPE_CSIM) { + if (app_list & TELEPHONY_SIM_APP_TYPE_CSIM) LOGI("Sim type [CSIM]"); - } } ret_value = telephony_sim_get_subscriber_number(handle_list.handle[0], &subscriber_number); @@ -374,18 +423,16 @@ int main() /* Network API */ ret_value = telephony_network_get_cell_id(handle_list.handle[0], &cell_id); - if (ret_value != TELEPHONY_ERROR_NONE) { + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("telephony_network_get_cell_id() failed!!! [%d]", ret_value); - } else { + else LOGI("Cell ID is [%d]", cell_id); - } ret_value = telephony_network_get_lac(handle_list.handle[0], &lac); - if (ret_value != TELEPHONY_ERROR_NONE) { + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("telephony_network_get_lac() failed!!! [%d]", ret_value); - } else { + else LOGI("Location Area Code is [%d]", lac); - } ret_value = telephony_network_get_mcc(handle_list.handle[0], &mcc); if (ret_value != TELEPHONY_ERROR_NONE) { @@ -412,82 +459,71 @@ int main() } ret_value = telephony_network_get_network_name_option(handle_list.handle[0], &network_name_option); - if (ret_value != TELEPHONY_ERROR_NONE) { + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("telephony_network_get_network_name_option() failed!!! [%d]", ret_value); - } else { + else LOGI("Network_name_option name is [%s]", _mapping_name_option(network_name_option)); - } ret_value = telephony_network_get_roaming_status(handle_list.handle[0], &roaming_status); - if (ret_value != TELEPHONY_ERROR_NONE) { + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("telephony_network_get_roaming_status() failed!!! [%d]", ret_value); - } else { + else LOGI("Network Roaming: [%s]", roaming_status ? "ON" : "OFF"); - } ret_value = telephony_network_get_rssi(handle_list.handle[0], &rssi); - if (ret_value != TELEPHONY_ERROR_NONE) { + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("telephony_network_get_rssi() failed!!! [%d]", ret_value); - } else { + else LOGI("Received Signal Strength Indicator is [%d]", rssi); - } ret_value = telephony_network_get_service_state(handle_list.handle[0], &service_state); - if (ret_value != TELEPHONY_ERROR_NONE) { + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("telephony_network_get_service_state() failed!!! [%d]", ret_value); - } else { + else LOGI("Network service state is [%s]", _mapping_service_state(service_state)); - } ret_value = telephony_network_get_type(handle_list.handle[0], &network_type); - if (ret_value != TELEPHONY_ERROR_NONE) { + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("telephony_network_get_type() failed!!! [%d]", ret_value); - } else { + else LOGI("Network type is [%s]", _mapping_network_type(network_type)); - } ret_value = telephony_network_get_ps_type(handle_list.handle[0], &ps_type); - if (ret_value != TELEPHONY_ERROR_NONE) { + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("telephony_network_get_ps_type() failed!!! [%d]", ret_value); - } else { + else LOGI("PS type is [%s]", _mapping_ps_type(ps_type)); - } ret_value = telephony_network_get_default_data_subscription(handle_list.handle[0], &default_data_sub); - if (ret_value != TELEPHONY_ERROR_NONE) { + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("telephony_network_get_default_data_subscription() failed!!! [%d]", ret_value); - } else { + else LOGI("Default data subscription is [%s]", _mapping_default_data_sub(default_data_sub)); - } ret_value = telephony_network_get_default_subscription(handle_list.handle[0], &default_sub); - if (ret_value != TELEPHONY_ERROR_NONE) { + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("telephony_network_get_default_subscription() failed!!! [%d]", ret_value); - } else { + else LOGI("Default subscription is [%s]", _mapping_default_sub(default_sub)); - } /* Call API */ ret_value = telephony_call_get_voice_call_state(handle_list.handle[0], &call_state); - if (ret_value != TELEPHONY_ERROR_NONE) { + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("telephony_call_get_voice_call_state() failed!!! [%d]", ret_value); - } else { + else LOGI("Voice Call state is [%s]", _mapping_call_state(call_state)); - } ret_value = telephony_call_get_video_call_state(handle_list.handle[0], &call_state); - if (ret_value != TELEPHONY_ERROR_NONE) { + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("telephony_call_get_video_call_state() failed!!! [%d]", ret_value); - } else { + else LOGI("Video Call state is [%s]", _mapping_call_state(call_state)); - } ret_value = telephony_call_get_preferred_voice_subscription(handle_list.handle[0], &call_sub); - if (ret_value != TELEPHONY_ERROR_NONE) { + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("telephony_call_get_preferred_voice_subscription() failed!!! [%d]", ret_value); - } else { + else LOGI("Preferred voice subscription is [%s]", _mapping_preferred_voice_sub(call_sub)); - } ret_value = telephony_call_get_call_list(handle_list.handle[0], &count, &call_list); if (ret_value != TELEPHONY_ERROR_NONE) { @@ -496,7 +532,7 @@ int main() unsigned int handle_id = 0; char *number = NULL; telephony_call_type_e type = 0; - telephony_call_state_e state = 0; + telephony_call_status_e status = 0; telephony_call_direction_e direction = 0; bool conf_status = 0; @@ -504,11 +540,11 @@ int main() telephony_call_get_handle_id(call_list[i], &handle_id); telephony_call_get_number(call_list[i], &number); telephony_call_get_type(call_list[i], &type); - telephony_call_get_state(call_list[i], &state); + telephony_call_get_status(call_list[i], &status); telephony_call_get_direction(call_list[i], &direction); telephony_call_get_conference_status(call_list[i], &conf_status); - LOGI("handle_id[%d] number[%s] type[%d] state[%d] direction[%d] conf_status[%d]", - handle_id, number, type, state, direction, conf_status); + LOGI("handle_id[%d] number[%s] type[%d] status[%d] direction[%d] conf_status[%d]", + handle_id, number, type, status, direction, conf_status); free(number); } telephony_call_release_call_list(count, &call_list); @@ -523,25 +559,24 @@ int main() free(imei); } - ret_value = telephony_modem_get_power_status(handle_list.handle[0], &status); - if (ret_value != TELEPHONY_ERROR_NONE) { + ret_value = telephony_modem_get_power_status(handle_list.handle[0], &power_status); + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("telephony_modem_get_power_status() failed!!! [%d]", ret_value); - } else { - LOGI("Modem power status is [%d] (0=on,1=off,2=rst,3=low)", status); - } + else + 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 < 4; i++) { + 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); if (ret_value != TELEPHONY_ERROR_NONE) LOGE("Set noti failed!!!"); } - for (i = 0; i < 3; i++) { + for (i = 0; i < (sizeof(call_noti_tbl) / sizeof(int)); i++) { ret_value = telephony_set_noti_cb(handle_list.handle[0], call_noti_tbl[i], call_noti_cb, NULL); if (ret_value != TELEPHONY_ERROR_NONE) LOGE("Set noti failed!!!"); @@ -555,22 +590,21 @@ int main() if (ret_value != TELEPHONY_ERROR_NONE) LOGE("Unset noti failed!!!"); - for (i = 0; i < 4; i++) { + 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]); if (ret_value != TELEPHONY_ERROR_NONE) LOGE("Unset noti failed!!!"); } - for (i = 0; i < 3; i++) { + for (i = 0; i < (sizeof(call_noti_tbl) / sizeof(int)); i++) { ret_value = telephony_unset_noti_cb(handle_list.handle[0], call_noti_tbl[i]); if (ret_value != TELEPHONY_ERROR_NONE) LOGE("Unset noti failed!!!"); } ret_value = telephony_deinit(&handle_list); - if (ret_value != TELEPHONY_ERROR_NONE) { + if (ret_value != TELEPHONY_ERROR_NONE) LOGE("Deinitialize failed!!!"); - } return 0; } -- 2.7.4