<p>The Call API (in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__TELEPHONY__INFORMATION__CALL.html">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__TELEPHONY__INFORMATION__CALL.html">wearable</a> applications) provides the following functions:</p>
-<ul><li><span style="font-family: Courier New,Courier,monospace">telephony_call_get_voice_call_state()</span>
-<p>Determines whether the voice call is connecting, connected, or idle. It returns one of the <span style="font-family: Courier New,Courier,monospace">telephony_call_state_e</span> values.</p></li>
-<li><span style="font-family: Courier New,Courier,monospace">telephony_call_get_video_call_state()</span>
-<p>Determines whether the video call is connecting, connected, or idle. It returns one of the <span style="font-family: Courier New,Courier,monospace">telephony_call_state_e</span> values.</p></li>
+<ul>
<li><span style="font-family: Courier New,Courier,monospace">telephony_call_get_preferred_voice_subscription()</span>
<p>Gets the current value for the preferred voice call subscription. It returns one of the <span style="font-family: Courier New,Courier,monospace">telephony_call_preferred_voice_subs_e</span> values.</p></li>
<li><span style="font-family: Courier New,Courier,monospace">telephony_call_get_call_list()</span>
<p>Gets the call number.</p></li>
<li><span style="font-family: Courier New,Courier,monospace">telephony_call_get_type()</span>
<p>Gets the call type. It returns one of the <span style="font-family: Courier New,Courier,monospace">telephony_call_type_e</span> values.</p></li>
-<li><span style="font-family: Courier New,Courier,monospace">telephony_call_get_state()</span>
-<p>Gets the call state. It returns one of the <span style="font-family: Courier New,Courier,monospace">telephony_call_state_e</span> values.</p></li>
+<li><span style="font-family: Courier New,Courier,monospace">telephony_call_get_status()</span>
+<p>Gets the call status. It returns one of the <span style="font-family: Courier New,Courier,monospace">telephony_call_status_e</span> values.</p></li>
<li><span style="font-family: Courier New,Courier,monospace">telephony_call_get_direction()</span>
<p>Gets the call direction: MO (Mobile Originated) or MT (Mobile Terminated). It returns one of the <span style="font-family: Courier New,Courier,monospace">telephony_call_direction_e</span> values.</p></li>
<li><span style="font-family: Courier New,Courier,monospace">telephony_call_get_conference_status()</span>
<th>Notification ID</th>
</tr>
<tr>
- <td>Voice call</td>
- <td><span style="font-family: Courier New,Courier,monospace">TELEPHONY_NOTI_VOICE_CALL_STATE</span></td>
- </tr>
- <tr>
- <td>Video call</td>
- <td><span style="font-family: Courier New,Courier,monospace">TELEPHONY_NOTI_VIDEO_CALL_STATE</span></td>
+ <td>Voice Status Idle</td>
+ <td><span style="font-family: Courier New,Courier,monospace">TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE</span></td>
+ </tr>
+ <tr>
+ <td>Voice Status Active</td>
+ <td><span style="font-family: Courier New,Courier,monospace">TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE</span></td>
+ </tr>
+ <tr>
+ <td>Voice Status Held</td>
+ <td><span style="font-family: Courier New,Courier,monospace">TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD</span></td>
+ </tr>
+ <tr>
+ <td>Voice Status Dialing</td>
+ <td><span style="font-family: Courier New,Courier,monospace">TELEPHONY_NOTI_VOICE_CALL_STATUS_DIALING</span></td>
+ </tr>
+ <tr>
+ <td>Voice Status Alerting</td>
+ <td><span style="font-family: Courier New,Courier,monospace">TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING</span></td>
+ </tr>
+ <tr>
+ <td>Voice Status Incoming</td>
+ <td><span style="font-family: Courier New,Courier,monospace">TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING</span></td>
+ </tr>
+ <tr>
+ <td>Video Status Idle</td>
+ <td><span style="font-family: Courier New,Courier,monospace">TELEPHONY_NOTI_VIDEO_CALL_STATUS_IDLE</span></td>
+ </tr>
+ <tr>
+ <td>Video Status Active</td>
+ <td><span style="font-family: Courier New,Courier,monospace">TELEPHONY_NOTI_VIDEO_CALL_STATUS_ACTIVE</span></td>
+ </tr>
+ <tr>
+ <td>Video Status Dialing</td>
+ <td><span style="font-family: Courier New,Courier,monospace">TELEPHONY_NOTI_VIDEO_CALL_STATUS_DIALING</span></td>
+ </tr>
+ <tr>
+ <td>Video Status Alerting</td>
+ <td><span style="font-family: Courier New,Courier,monospace">TELEPHONY_NOTI_VIDEO_CALL_STATUS_ALERTING</span></td>
+ </tr>
+ <tr>
+ <td>Video Status Incoming</td>
+ <td><span style="font-family: Courier New,Courier,monospace">TELEPHONY_NOTI_VIDEO_CALL_STATUS_INCOMING</span></td>
</tr>
<tr>
<td>Preferred voice subscription</td>
</script>
</body>
-</html>
\ No newline at end of file
+</html>
<h1>Telephony: Handling Phone Call, SIM Card, and Network Information</h1>
-<p>This tutorial demonstrates how you can get the state of both voice and video calls, get notified when the user makes a voice or video call or hangs up the phone, extract information stored on a SIM card, and get IMEI information.</p>
+<p>This tutorial demonstrates how you can get the status of both voice and video calls, get notified when the user makes a voice or video call or hangs up the phone, extract information stored on a SIM card, and get IMEI information.</p>
<h2>Warm-up</h2>
<h2 id="call" name="call">Getting Call Information</h2>
-<p>To get the voice and video call states and be notified when the user makes a voice or video call or hangs up the phone, use the Telephony Call API (in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__TELEPHONY__INFORMATION__CALL.html">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__TELEPHONY__INFORMATION__CALL.html">wearable</a> applications) in call-related actions:</p>
-
-<h3>Getting the Call State</h3>
-
-<ol><li><p>You can get the state of the current voice call by using the <span style="font-family: Courier New,Courier,monospace">telephony_call_get_voice_call_state()</span> function. It returns one of the <span style="font-family: Courier New,Courier,monospace">telephony_call_state_e</span> values (in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__TELEPHONY__INFORMATION__CALL.html#gafef963e029b4d1d48bece63245f692f2">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__TELEPHONY__INFORMATION__CALL.html#gafef963e029b4d1d48bece63245f692f2">wearable</a> applications).</p>
-
-
-<pre class="prettyprint">
-void tutorial_telephony_call_get_voice_call_state()
-{
- telephony_error_e ret;
- telephony_call_state_e voice_call_state;
- ret = telephony_call_get_voice_call_state(handle_list.handle[0], &voice_call_state);
- if (ret != TELEPHONY_ERROR_NONE)
- {
- // Error handling
- }
- dlog_print(DLOG_INFO, LOG_TAG, "Voice call state: [%d]", voice_call_state);
-}
-</pre></li>
-
-<li><p>You can use the previous process to get to the video call state by replacing voice with video in the function: <span style="font-family: Courier New,Courier,monospace">telephony_call_get_video_call_state()</span>.</p>
-
-<pre class="prettyprint">
-void tutorial_telephony_call_get_video_call_state()
-{
- telephony_error_e ret;
- telephony_call_state_e video_call_state;
- ret = telephony_call_get_video_call_state(handle_list.handle[0], &video_call_state);
- if (ret != TELEPHONY_ERROR_NONE)
- {
- // Error handling
- }
- dlog_print(DLOG_INFO, LOG_TAG, "Video call state: [%d]", video_call_state);
-}
-</pre></li></ol>
-
-<h3>Receiving Change Notifications for the Call States</h3>
-<p>The callback function can be used to obtain change notifications for the call state asynchronously. The call state is returned through a callback function, given to the function as one of its parameters.</p>
-
-<ol><li><p>To be notified when the voice call state changes, implement a callback function compatible with the <span style="font-family: Courier New,Courier,monospace">telephony_noti_cb()</span> function typedef and register this function.</p>
-
-<pre class="prettyprint">
-void voice_call_state_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void* user_data)
-{
- telephony_call_state_e voice_call_state = *(int *)data;
- dlog_print(DLOG_INFO, LOG_TAG, "Voice call state: [%d]", voice_call_state);
-}
-
-void tutorial_telephony_set_noti_cb_voice()
-{
- telephony_error_e ret;
- ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_VOICE_CALL_STATE,
- voice_call_state_noti_cb, NULL);
- if (ret != TELEPHONY_ERROR_NONE)
- {
- // Error handling
- }
-}
-</pre>
-
-<p>After registering, you are notified of the voice call state until you cancel the registration of the callback function. To unregister the callback, invoke the <span style="font-family: Courier New,Courier,monospace">telephony_unset_noti_cb()</span> function with <span style="font-family: Courier New,Courier,monospace">TELEPHONY_NOTI_VOICE_CALL_STATE</span>.</p></li>
-
-<li><p>To be notified when the video call state changes, use the same callback function typedef as for the voice calls.</p>
-
-<pre class="prettyprint">
-void video_call_state_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void* user_data)
-{
- telephony_call_state_e video_call_state = *(int *)data;
- dlog_print(DLOG_INFO, LOG_TAG, "Video call state: [%d]", video_call_state);
-}
-
-void tutorial_telephony_set_noti_cb_video()
-{
- telephony_error_e ret;
- ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_VIDEO_CALL_STATE,
- video_call_state_noti_cb, NULL);
- if (ret != TELEPHONY_ERROR_NONE)
- {
- // Error handling
- }
-}
-</pre>
-
-<p>After registering, you are notified of the video call state information until you cancel the registration of the callback function. To unregister the callback, invoke the <span style="font-family: Courier New,Courier,monospace">telephony_unset_noti_cb()</span> function with <span style="font-family: Courier New,Courier,monospace">TELEPHONY_NOTI_VIDEO_CALL_STATE</span>.</p></li></ol>
+<p>To get the voice and video call status and be notified when the user makes a voice or video call or hangs up the phone, use the Telephony Call API (in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__TELEPHONY__INFORMATION__CALL.html">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__TELEPHONY__INFORMATION__CALL.html">wearable</a> applications) in call-related actions:</p>
<h3>Getting the Current Call List</h3>
else
{
int i;
- unsigned int handle_id;
- char *number;
- telephony_call_type_e type;
- telephony_call_state_e state;
- telephony_call_direction_e direction;
- bool conf_status;
+ 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;
if (count == 0)
{
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);
- dlog_print(DLOG_INFO, LOG_TAG,
- "handle_id[%d] number[%s] type[%d] state[%d] direction[%d] conf_status[%d]",
- handle_id, number, type, state, direction, conf_status);
+ dlog_print(DLOG_INFO, LOG_TAG, "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);
}
}
</pre>
-<p>After getting the handle, you can use it to retrieve various call information (such as handle ID, number, type, state, direction, conference status).</p></li>
+<p>After getting the handle, you can use it to retrieve various call information (such as handle ID, number, type, status, direction, conference status).</p></li>
<li><p>When the call handle is no longer needed, call the <span style="font-family: Courier New,Courier,monospace">telephony_call_release_call_list()</span> function to free the handle:</p>
<pre class="prettyprint">
}
</pre></li></ol>
+<h3>Receiving Change Notifications for the Call Status</h3>
+<p>The callback function can be used to obtain change notifications for the call status asynchronously. The call id is returned through a callback function, given to the function as one of its parameters.</p>
+
+<li><p>To be notified when the voice call status changes, implement a callback function compatible with the <span style="font-family: Courier New,Courier,monospace">telephony_noti_cb()</span> function typedef and register this function.</p>
+
+<pre class="prettyprint">
+static int voice_call_noti_tbl[] = {
+ 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,
+};
+
+void voice_call_status_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void* user_data)
+{
+ int ret;
+ telephony_call_h *call_list;
+ unsigned int count = 0;
+
+ switch (noti_id) {
+ case TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE:
+ dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Idle!!! [%d]", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE:
+ dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Active!!! [%d]", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD:
+ dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Held!!! [%d]", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_VOICE_CALL_STATUS_DIALING:
+ dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Dialing!!! [%d]", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING:
+ dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Alerting!!! [%d]", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING:
+ dlog_print(DLOG_INFO, LOG_TAG, "Noti!!! Voice Call Status Incoming!!! [%d]", *(int *)data);
+ break;
+ default:
+ dlog_print(DLOG_INFO, LOG_TAG, "Unknown noti");
+ break;
+ }
+
+ 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);
+
+ dlog_print(DLOG_INFO, LOG_TAG, "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);
+ }
+}
+
+void tutorial_telephony_set_noti_cb_voice()
+{
+ telephony_error_e ret;
+ int i;
+
+ for (i = 0; i < (sizeof(voice_call_noti_tbl) / sizeof(int)); i++) {
+ ret = telephony_set_noti_cb(handle_list.handle[0], voice_call_noti_tbl[i], voice_call_status_noti_cb, NULL);
+  if (ret != TELEPHONY_ERROR_NONE)
+  {
+  // Error handling
+  }
+ }
+}
+</pre>
+
+<p>After registering, you are notified of the voice call status until you cancel the registration of the callback function. To unregister the callback, invoke the <span style="font-family: Courier New,Courier,monospace">telephony_unset_noti_cb()</span> function with each notification.</p></li>
<h2 id="sim" name="sim">Getting SIM Information</h2>