+ ret = _call_request_message(pending, o, ur, on_response_call_list_get, event_flag);
+ if (!ret) {
+ err("AT request (%s) sending failed", req->cmd);
+ // free only UserRequest.
+ if (ur) {
+ tcore_user_request_free(ur);
+ ur = NULL;
+ }
+ return TCORE_RETURN_FAILURE;
+ }
+
+ dbg("AT request sent success");
+ return TCORE_RETURN_SUCCESS;
+}
+
+// CONFIRMATION
+static void on_confirmation_call_message_send(TcorePending *p, gboolean result, void *user_data)
+{
+ dbg("Entry");
+
+ if (result == FALSE) { // Fail
+ dbg("SEND FAIL");
+ } else {
+ dbg("SEND OK");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+static void call_prepare_and_send_pending_request(CoreObject *co, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, TcorePendingResponseCallback callback)
+{
+ TcoreATRequest *req = NULL;
+ TcoreHal *hal = NULL;
+ TcorePending *pending = NULL;
+ TReturn ret;
+
+ hal = tcore_object_get_hal(co);
+ dbg("hal: %p", hal);
+
+ pending = tcore_pending_new(co, 0);
+ if (!pending)
+ dbg("Pending is NULL");
+ req = tcore_at_request_new(at_cmd, prefix, at_cmd_type);
+
+ dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+
+ tcore_pending_set_request_data(pending, 0, req);
+ tcore_pending_set_response_callback(pending, callback, NULL);
+ tcore_pending_set_send_callback(pending, on_confirmation_call_message_send, NULL);
+ ret = tcore_hal_send_request(hal, pending);
+ if (ret != TCORE_RETURN_SUCCESS)
+ err("Failed to process request");
+}
+
+static void on_confirmation_call_outgoing(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ UserRequest *ur = NULL;
+ GSList *tokens = NULL;
+ const char *line = NULL;
+ const TcoreATResponse *response = data;
+ struct tresp_call_dial resp;
+ enum telephony_call_error error;
+ dbg("Entry");
+
+ ur = tcore_pending_ref_user_request(p);
+ if (ur) {
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = CALL_ERROR_NONE;
+ } else {
+ dbg("RESPONSE NOT OK");
+
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ err("Unspecified error cause OR string corrupted");
+ resp.err = CALL_ERROR_SERVICE_UNAVAIL;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+ err("Error: [%d]", error);
+ // TODO: CMEE error mapping is required.
+ resp.err = CALL_ERROR_SERVICE_UNAVAIL;
+ }
+
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ }
+
+ // Send Response to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_DIAL, sizeof(struct tresp_call_dial), &resp);
+ } else {
+ err("User Request is NULL");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+static void on_confirmation_call_accept(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ UserRequest *ur = NULL;
+ GSList *tokens = NULL;
+ const char *line = NULL;
+ const TcoreATResponse *response = data;
+ struct tresp_call_answer resp;
+ enum telephony_call_error error;
+ dbg("Entry");
+
+ ur = tcore_pending_ref_user_request(p);
+ if (ur) {
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = CALL_ERROR_NONE;
+ } else {
+ dbg("RESPONSE NOT OK");
+
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ err("Unspecified error cause OR string corrupted");
+ resp.err = CALL_ERROR_SERVICE_UNAVAIL;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+ err("Error: [%d]", error);
+ // TODO: CMEE error mapping is required.
+ resp.err = CALL_ERROR_SERVICE_UNAVAIL;
+ }
+
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ }
+
+ resp.id = tcore_call_object_get_id((CallObject *) user_data);
+
+ // Send Response to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_ANSWER, sizeof(struct tresp_call_answer), &resp);
+ } else {
+ err("User Request is NULL");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+
+static void on_confirmation_call_reject(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ UserRequest *ur = NULL;
+ GSList *tokens = NULL;
+ const char *line = NULL;
+ const TcoreATResponse *response = data;
+ struct tresp_call_answer resp;
+ enum telephony_call_error error;
+
+ dbg("Entry");
+
+ ur = tcore_pending_ref_user_request(p);
+ if (ur) {
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = CALL_ERROR_NONE;
+ } else {
+ dbg("RESPONSE NOT OK");
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ err("Unspecified error cause OR string corrupted");
+ resp.err = CALL_ERROR_SERVICE_UNAVAIL;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+ err("Error: [%d]", error);
+ // TODO: CMEE error mapping is required.
+ resp.err = CALL_ERROR_SERVICE_UNAVAIL;
+ }
+
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ }
+
+ resp.id = tcore_call_object_get_id((CallObject *) user_data);
+
+ // Send Response to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_ANSWER, sizeof(struct tresp_call_answer), &resp);
+ } else {
+ err("User Request is NULL");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+static void on_confirmation_call_replace(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ UserRequest *ur = NULL;
+ GSList *tokens = NULL;
+ const char *line = NULL;
+ const TcoreATResponse *response = data;
+ struct tresp_call_answer resp;
+ enum telephony_call_error error;
+
+ dbg("Entry");
+ ur = tcore_pending_ref_user_request(p);
+ if (ur) {
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = CALL_ERROR_NONE;
+ } else {
+ dbg("RESPONSE NOT OK");
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ err("Unspecified error cause OR string corrupted");
+ resp.err = CALL_ERROR_SERVICE_UNAVAIL;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+ err("Error: [%d]", error);
+ // TODO: CMEE error mapping is required.
+ resp.err = CALL_ERROR_SERVICE_UNAVAIL;
+ }
+
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ }
+ resp.id = tcore_call_object_get_id((CallObject *) user_data);
+
+ // Send Response to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_ANSWER, sizeof(struct tresp_call_answer), &resp);
+ } else {
+ dbg("User Request is NULL");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+static void on_confirmation_call_hold_and_accept(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ CoreObject *o = NULL;
+ UserRequest *ur = NULL;
+ GSList *tokens = NULL;
+ const char *line = NULL;
+ const TcoreATResponse *response = data;
+ struct tresp_call_answer resp;
+ enum telephony_call_error error;
+
+ dbg("Entry");
+
+ o = tcore_pending_ref_core_object(p);
+ ur = tcore_pending_ref_user_request(p);
+ resp.id = tcore_call_object_get_id((CallObject *) user_data);
+
+ if (ur) {
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = CALL_ERROR_NONE;
+ } else {
+ err("RESPONSE NOT OK");
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ err("Unspecified error cause OR string corrupted");
+ resp.err = CALL_ERROR_SERVICE_UNAVAIL;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+ err("Error: [%d]", error);
+ // TODO: CMEE error mapping is required.
+ resp.err = CALL_ERROR_SERVICE_UNAVAIL;
+ }
+
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ }
+
+ // Send response to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_ANSWER, sizeof(struct tresp_call_answer), &resp);
+ if (!resp.err) {
+ GSList *list = 0;
+ CallObject *co = NULL;
+
+ // Active Call
+ list = tcore_call_object_find_by_status(o, TCORE_CALL_STATUS_ACTIVE);
+ if (!list) {
+ err("Can't find active Call");
+ return;
+ }
+
+ co = (CallObject *) list->data;
+ if (!co) {
+ err("Can't get active Call object");
+ return;
+ }
+
+ // Set Call Status
+ tcore_call_object_set_status(co, TCORE_CALL_STATUS_HELD);
+ dbg("Call status is set to HELD");
+ }
+ } else {
+ err("User Request is NULL");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+static void _on_confirmation_call_release(TcorePending *p, int data_len, const void *data, void *user_data, int type)
+{
+ UserRequest *ur = NULL;
+ struct tresp_call_end resp;
+ GSList *tokens = NULL;
+ const char *line = NULL;
+ enum telephony_call_error error;
+ const TcoreATResponse *response = data;
+
+ dbg("Entry");
+ ur = tcore_pending_ref_user_request(p);
+ if (ur) {
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = CALL_ERROR_NONE;
+ } else {
+ err("RESPONSE NOT OK");
+
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ err("Unspecified error cause OR string corrupted");
+ resp.err = CALL_ERROR_SERVICE_UNAVAIL;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+ err("Error: [%d]", error);
+ // TODO: CMEE error mapping is required.
+ resp.err = CALL_ERROR_SERVICE_UNAVAIL;
+ }
+ tcore_at_tok_free(tokens);
+ }
+
+ resp.type = type;
+ resp.id = tcore_call_object_get_id((CallObject *) user_data);
+ dbg("resp.type = %d resp.id= %d", resp.type, resp.id);
+
+ // Send reponse to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_END, sizeof(struct tresp_call_end), &resp);
+ } else {
+ err("User Request is NULL");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+// RESPONSE
+static void on_confirmation_call_endall(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ // skip response handling - actual result will be handled in on_confirmation_call_release_all
+ const TcoreATResponse *response = data;
+
+ dbg("Entry");
+
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ } else {
+ err("RESPONSE NOT OK");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+
+static void on_confirmation_call_release_all(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ dbg("Entry");
+ _on_confirmation_call_release(p, data_len, data, user_data, CALL_END_TYPE_ALL);
+
+ return;
+}
+
+
+static void on_confirmation_call_release_specific(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ dbg("Entry");
+ _on_confirmation_call_release(p, data_len, data, user_data, CALL_END_TYPE_DEFAULT);
+
+ return;
+}
+
+static void on_confirmation_call_release_all_active(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ dbg("Entry");
+ _on_confirmation_call_release(p, data_len, data, user_data, CALL_END_TYPE_ACTIVE_ALL);
+
+ return;
+}
+
+static void on_confirmation_call_release_all_held(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ dbg("Entry");
+ _on_confirmation_call_release(p, data_len, data, user_data, CALL_END_TYPE_HOLD_ALL);
+
+ return;
+}
+
+static void _on_confirmation_call(TcorePending *p, int data_len, const void *data, void *user_data, int type)
+{
+ UserRequest *ur = NULL;
+ GSList *tokens = NULL;
+ const char *line = NULL;
+ const TcoreATResponse *response = NULL;
+ enum telephony_call_error error;
+
+ dbg("Entry");
+ ur = tcore_pending_ref_user_request(p);
+ response = (TcoreATResponse *) data;
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ error = CALL_ERROR_NONE;
+ } else {
+ err("RESPONSE NOT OK");
+
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ err("Unspecified error cause OR string corrupted");
+ error = CALL_ERROR_SERVICE_UNAVAIL;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+
+ // TODO: CMEE error mapping is required.
+ error = CALL_ERROR_SERVICE_UNAVAIL;
+ }
+
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ }
+
+ dbg("Response Call type -%d", type);
+ switch (type) {
+ case TRESP_CALL_HOLD:
+ {
+ struct tresp_call_hold resp;
+
+ resp.err = error;
+ resp.id = tcore_call_object_get_id((CallObject *) user_data);
+ dbg("call hold response");
+ // Send reponse to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_HOLD, sizeof(struct tresp_call_hold), &resp);
+ }
+ break;
+
+ case TRESP_CALL_ACTIVE:
+ {
+ struct tresp_call_active resp;
+
+ resp.err = error;
+ resp.id = tcore_call_object_get_id((CallObject *) user_data);
+ dbg("call active response");
+ // Send reponse to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_ACTIVE, sizeof(struct tresp_call_active), &resp);
+ }
+ break;
+
+ case TRESP_CALL_JOIN:
+ {
+ struct tresp_call_join resp;
+
+ resp.err = error;
+ resp.id = tcore_call_object_get_id((CallObject *) user_data);
+ dbg("call join response");
+
+ // Send reponse to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_JOIN, sizeof(struct tresp_call_join), &resp);
+ }
+ break;
+
+ case TRESP_CALL_SPLIT:
+ {
+ struct tresp_call_split resp;
+
+ resp.err = error;
+ resp.id = tcore_call_object_get_id((CallObject *) user_data);
+ dbg("call split response");
+ // Send reponse to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_SPLIT, sizeof(struct tresp_call_split), &resp);
+ }
+ break;
+
+ case TRESP_CALL_DEFLECT:
+ {
+ struct tresp_call_deflect resp;
+
+ resp.err = error;
+ resp.id = tcore_call_object_get_id((CallObject *) user_data);
+ dbg("call deflect response");
+ // Send reponse to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_DEFLECT, sizeof(struct tresp_call_deflect), &resp);
+ }
+
+ break;
+
+ case TRESP_CALL_TRANSFER:
+ {
+ struct tresp_call_transfer resp;
+
+ resp.err = error;
+ resp.id = tcore_call_object_get_id((CallObject *) user_data);
+ dbg("call transfer response");
+ // Send reponse to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_TRANSFER, sizeof(struct tresp_call_transfer), &resp);
+ }
+ break;
+
+ case TRESP_CALL_START_CONT_DTMF:
+ {
+ struct tresp_call_dtmf resp;
+
+ resp.err = error;
+ dbg("call dtmf response");
+ // Send reponse to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_START_CONT_DTMF, sizeof(struct tresp_call_dtmf), &resp);
+ }
+ break;
+
+ default:
+ {
+ dbg("type not supported");
+ return;
+ }
+ }
+
+ if ((type == TRESP_CALL_HOLD) || (type == TRESP_CALL_ACTIVE) || (type == TRESP_CALL_JOIN)
+ || (type == TRESP_CALL_SPLIT)) {
+ if (!error) {
+ CoreObject *core_obj = NULL;
+ gboolean *eflag = g_new0(gboolean, 1);
+
+ core_obj = tcore_pending_ref_core_object(p);
+ *eflag = FALSE;
+
+ dbg("Calling _call_list_get");
+ _call_list_get(core_obj, eflag);
+ }
+ }
+
+ dbg("Exit");
+ return;
+}
+
+static void on_confirmation_call_hold(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ dbg("Entry");
+ _on_confirmation_call(p, data_len, data, user_data, TRESP_CALL_HOLD);
+
+ return;
+}
+
+static void on_confirmation_call_active(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ dbg("Entry");
+ _on_confirmation_call(p, data_len, data, user_data, TRESP_CALL_ACTIVE);
+
+ return;
+}
+
+static void on_confirmation_call_join(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ dbg("Entry");
+ _on_confirmation_call(p, data_len, data, user_data, TRESP_CALL_JOIN);
+
+ return;
+}
+
+static void on_confirmation_call_split(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ dbg("Entry");
+ _on_confirmation_call(p, data_len, data, user_data, TRESP_CALL_SPLIT);
+
+ return;
+}
+
+static void on_confirmation_call_deflect(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ dbg("Entry");
+ _on_confirmation_call(p, data_len, data, user_data, TRESP_CALL_DEFLECT);
+
+ return;
+}
+
+static void on_confirmation_call_transfer(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ dbg("Entry");
+ _on_confirmation_call(p, data_len, data, user_data, TRESP_CALL_TRANSFER);
+
+ return;
+}
+
+static void on_confirmation_call_dtmf(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ dbg("Entry");
+ _on_confirmation_call(p, data_len, data, user_data, TRESP_CALL_START_CONT_DTMF);
+
+ return;
+}
+
+#if 0
+static void _on_confirmation_dtmf_tone_duration(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ GSList *tokens = NULL;
+ const char *line = NULL;
+ const TcoreATResponse *response = data;
+ enum telephony_call_error error;
+
+ dbg("Entry");
+
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ error = CALL_ERROR_NONE;
+ } else {
+ err("RESPONSE NOT OK");
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+ if (g_slist_length(tokens) < 1) {
+ err("err cause not specified or string corrupted");
+ error = CALL_ERROR_SERVICE_UNAVAIL;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+ // TODO: CMEE error mapping is required.
+ }
+
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ }
+
+ dbg("Set dtmf tone duration response - %d", error);
+ return;
+}
+#endif
+
+static void on_confirmation_call_swap(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ CoreObject *core_obj = NULL;
+ UserRequest *ur = NULL;
+ const TcoreATResponse *response = data;
+ struct tresp_call_swap resp;
+ GSList *tokens = NULL;
+ const char *line = NULL;
+
+ dbg("Entry");
+ core_obj = tcore_pending_ref_core_object(p);
+ ur = tcore_pending_ref_user_request(p);
+
+ if (ur) {
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = CALL_ERROR_NONE;
+ } else {
+ err("RESPONSE NOT OK");
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+ if (g_slist_length(tokens) < 1) {
+ err("err cause not specified or string corrupted");
+ resp.err = CALL_ERROR_SERVICE_UNAVAIL;
+ } else {
+ resp.err = atoi(g_slist_nth_data(tokens, 0));
+
+ // TODO: CMEE error mapping is required.
+ resp.err = CALL_ERROR_SERVICE_UNAVAIL;
+ }
+
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ }
+
+ resp.id = tcore_call_object_get_id((CallObject *) user_data);
+ dbg("resp.id = %d", resp.id);
+
+ // Send response to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_SWAP, sizeof(struct tresp_call_swap), &resp);
+
+ if (!resp.err) {
+ GSList *active = NULL;
+ GSList *held = NULL;
+ CallObject *co = NULL;
+ gboolean *eflag = NULL;
+
+ held = tcore_call_object_find_by_status(core_obj, TCORE_CALL_STATUS_HELD);
+ if (!held) {
+ err("Can't find held Call");
+ return;
+ }
+
+ active = tcore_call_object_find_by_status(core_obj, TCORE_CALL_STATUS_ACTIVE);
+ if (!active) {
+ dbg("Can't find active Call");
+ return;
+ }
+
+ while (held) {
+ co = (CallObject *) held->data;
+ if (!co) {
+ err("Can't get held Call object");
+ return;
+ }
+
+ resp.id = tcore_call_object_get_id(co);
+
+ // Send response to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_ACTIVE, sizeof(struct tresp_call_active), &resp);
+
+ held = g_slist_next(held);
+ }
+
+ while (active) {
+ co = (CallObject *) active->data;
+ if (!co) {
+ err("[ error ] can't get active call object");
+ return;
+ }
+
+ resp.id = tcore_call_object_get_id(co);
+
+ // Send response to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_HOLD, sizeof(struct tresp_call_hold), &resp);
+ active = g_slist_next(active);
+ }
+
+ eflag = g_new0(gboolean, 1);
+ *eflag = FALSE;
+
+ dbg("calling _call_list_get");
+ _call_list_get(core_obj, eflag);
+ }
+ } else {
+ err("User Request is NULL");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+static void on_confirmation_set_sound_path(TcorePending *p, int data_len,
+ const void *data,
+ void *user_data)
+{
+ const TcoreATResponse *resp = data;
+ struct tnoti_call_sound_path *snd_path = user_data;
+ struct tresp_call_set_sound_path resp_set_sound_path;
+ UserRequest *ur = tcore_pending_ref_user_request(p);
+ TcorePlugin *plugin = tcore_pending_ref_plugin(p);
+ CoreObject *co_call;
+
+ if (ur == NULL) {
+ err("User Request is NULL");
+ g_free(user_data);
+ return;
+ }
+
+ if (resp->success <= 0) {
+
+ dbg("RESPONSE NOT OK");
+ resp_set_sound_path.err = TRUE;
+
+ goto out;
+ }
+
+ dbg("RESPONSE OK");
+ resp_set_sound_path.err = FALSE;
+
+ co_call = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_CALL);
+
+ /* Notify control plugin about sound path */
+ tcore_server_send_notification(tcore_plugin_ref_server(plugin),
+ co_call, TNOTI_CALL_SOUND_PATH,
+ sizeof(struct tnoti_call_sound_path),
+ snd_path);
+
+out:
+ /* Answer TAPI request */
+ tcore_user_request_send_response(ur, TRESP_CALL_SET_SOUND_PATH,
+ sizeof(resp_set_sound_path),
+ &resp_set_sound_path);
+
+ g_free(user_data);
+}
+
+static void on_confirmation_call_set_source_sound_path(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ UserRequest *ur = NULL;
+ GSList *tokens = NULL;
+ const char *line = NULL;
+ const TcoreATResponse *response = data;
+ char *resp_str = NULL;
+ struct tresp_call_set_sound_path resp;
+ gboolean error;
+
+ dbg("Entry");
+ ur = tcore_pending_ref_user_request(p);
+
+ // +XDRV: <group_id>,<function_id>,<xdrv_result>[,<response_n>]\ 3
+ if (!response) {
+ err("Input data is NULL");
+ return;
+ }
+
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+
+ line = (const char *) (((GSList *) response->lines)->data);
+ tokens = tcore_at_tok_new(line);
+
+ resp_str = g_slist_nth_data(tokens, 0);
+ if (!g_slist_nth_data(tokens, 0)) {
+ err("group_id is missing");
+ resp.err = TRUE;
+ goto OUT;
+ }
+
+ if (!g_slist_nth_data(tokens, 1)) {
+ err(" function_id is missing");
+ resp.err = TRUE;
+ goto OUT;
+ }
+
+ resp_str = g_slist_nth_data(tokens, 2);
+
+ if (resp_str) {
+ error = atoi(resp_str);
+ if (0 == error) {
+ dbg("Response is Success");
+ resp.err = FALSE;
+ } else {
+ resp.err = TRUE;
+ }
+ }
+OUT:
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ } else {
+ dbg("RESPONSE NOT OK");
+
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ err("err cause not specified or string corrupted");
+ resp.err = TRUE;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+
+ // TODO: CMEE error mapping is required.
+ resp.err = TRUE;
+ }
+
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ }
+
+ if (ur) {
+ if ( resp.err ) { // Send only failed notification . success notification send when destination device is set.
+ // Send notification to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_SET_SOUND_PATH, sizeof(struct tresp_call_set_sound_path), &resp);
+ setsoundpath = TRUE;
+ }
+ } else {
+ err("User Request is NULL");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+static void on_confirmation_call_set_destination_sound_path(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ UserRequest *ur = NULL;
+ GSList *tokens = NULL;
+ const char *line = NULL;
+ char *resp_str = NULL;
+ struct tresp_call_set_sound_path resp;
+ const TcoreATResponse *response = data;
+ gboolean error;
+
+ dbg("Entry");
+
+ ur = tcore_pending_ref_user_request(p);
+ // +XDRV: <group_id>,<function_id>,<xdrv_result>[,<response_n>]\ 3
+
+ if (!response) {
+ err("Input data is NULL");
+ return;
+ }
+
+ if (ur) {
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+
+ line = (const char *) (((GSList *) response->lines)->data);
+ tokens = tcore_at_tok_new(line);
+
+ resp_str = g_slist_nth_data(tokens, 0);
+ if (!g_slist_nth_data(tokens, 0)) {
+ dbg("group_id is missing");
+ resp.err = TRUE;
+ goto OUT;
+ }
+
+ if (!g_slist_nth_data(tokens, 1)) {
+ dbg("function_id is missing");
+ resp.err = TRUE;
+ goto OUT;
+ }
+
+ resp_str = g_slist_nth_data(tokens, 2);
+ if (resp_str) {
+ error = atoi(resp_str);
+ if (0 == error) {
+ dbg("Response is Success");
+ resp.err = FALSE;
+ } else {
+ resp.err = TRUE;
+ }
+ }
+
+OUT:
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ } else {
+ dbg("RESPONSE NOT OK");
+
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ err("err cause not specified or string corrupted");
+ resp.err = TRUE;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+ // TODO: CMEE error mapping is required.
+ resp.err = TRUE;
+ }
+
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ }
+
+ if (setsoundpath == TRUE) {
+ setsoundpath = FALSE;
+ } else {
+ // Send response to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_SET_SOUND_PATH, sizeof(struct tresp_call_set_sound_path), &resp);
+ }
+ } else {
+ dbg("User Request is NULL");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+static void on_confirmation_call_set_source_sound_volume_level(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ UserRequest *ur = NULL;
+ GSList *tokens = NULL;
+ const char *line = NULL;
+ const TcoreATResponse *response = data;
+ char *resp_str = NULL;
+ struct tresp_call_set_sound_volume_level resp;
+ gboolean error;
+
+ ur = tcore_pending_ref_user_request(p);
+ dbg("Entry");
+ // +XDRV: <group_id>,<function_id>,<xdrv_result>[,<response_n>]\ 3
+ if (!response) {
+ err("Input data is NULL");
+ return;
+ }
+
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+
+ line = (const char *) (((GSList *) response->lines)->data);
+ tokens = tcore_at_tok_new(line);
+
+ resp_str = g_slist_nth_data(tokens, 0);
+ if (!g_slist_nth_data(tokens, 0)) {
+ err("group_id is missing");
+ resp.err = TRUE;
+ goto OUT;
+ }
+
+ if (!g_slist_nth_data(tokens, 1)) {
+ err("function_id is missing");
+ resp.err = TRUE;
+ goto OUT;
+ }
+
+ resp_str = g_slist_nth_data(tokens, 2);
+ if (resp_str) {
+ error = atoi(resp_str);
+
+ if (0 == error) {
+ dbg("Response is Success ");
+ resp.err = FALSE;
+ } else {
+ resp.err = TRUE;
+ }
+ }
+
+OUT:
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ } else {
+ dbg("RESPONSE NOT OK");
+
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ err("err cause not specified or string corrupted");
+ resp.err = TRUE;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+
+ // TODO: CMEE error mapping is required.
+ resp.err = TRUE;
+ }
+
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ }
+
+ if (ur) {
+ if (resp.err && soundvolume == FALSE) { // Send only failed notification . success notification send when destination device is set.
+ // Send reposne to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_SET_SOUND_VOLUME_LEVEL, sizeof(struct tresp_call_set_sound_volume_level), &resp);
+ soundvolume = TRUE;
+ }
+ } else {
+ err("User Request is NULL");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+
+static void on_confirmation_call_set_destination_sound_volume_level(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ UserRequest *ur = NULL;
+ GSList *tokens = NULL;
+ const char *line = NULL;
+ char *resp_str = NULL;
+ const TcoreATResponse *response = data;
+ struct tresp_call_set_sound_volume_level resp;
+ gboolean error;
+
+ dbg("Entry");
+
+ ur = tcore_pending_ref_user_request(p);
+
+ // +XDRV: <group_id>,<function_id>,<xdrv_result>[,<response_n>]\ 3
+ if (!response) {
+ err("Input data is NULL");
+ return;
+ }
+
+ if (ur) {
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ line = (const char *) (((GSList *) response->lines)->data);
+ tokens = tcore_at_tok_new(line);
+ resp_str = g_slist_nth_data(tokens, 0);
+
+ if (!g_slist_nth_data(tokens, 0)) {
+ err("group_id is missing");
+ resp.err = TRUE;
+ goto OUT;
+ }
+
+ if (!g_slist_nth_data(tokens, 1)) {
+ err("function_id is missing");
+ resp.err = TRUE;
+ goto OUT;
+ }
+
+ resp_str = g_slist_nth_data(tokens, 2);
+
+ if (resp_str) {
+ error = atoi(resp_str);
+
+ if (0 == error) {
+ dbg("Response is Success");
+ resp.err = FALSE;
+ } else {
+ resp.err = TRUE;
+ }
+ }
+
+OUT:
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ } else {
+ dbg("RESPONSE NOT OK");
+
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ err("err cause not specified or string corrupted");
+ resp.err = TRUE;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+
+ // TODO: CMEE error mapping is required.
+ resp.err = TRUE;
+ }
+
+ tcore_at_tok_free(tokens);
+ }
+
+ if (soundvolume == TRUE) {
+ soundvolume = FALSE;
+ } else {
+ // Send reposne to TAPI
+ tcore_user_request_send_response(ur, TRESP_CALL_SET_SOUND_VOLUME_LEVEL, sizeof(struct tresp_call_set_sound_volume_level), &resp);
+ }
+ } else {
+ err("User Request is NULL");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+
+static void on_confirmation_call_set_sound_mute_status(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ UserRequest *ur = NULL;
+ GSList *tokens = NULL;
+ const char *line = NULL;
+ char *resp_str = NULL;
+ struct tresp_call_set_sound_mute_status resp;
+ const TcoreATResponse *response = data;
+ gboolean error;
+
+ dbg("Entry");
+
+ ur = tcore_pending_ref_user_request(p);
+
+ if (!response) {
+ err("Input data is NULL");
+ return;
+ }
+
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+
+ line = (const char *) (((GSList *) response->lines)->data);
+ tokens = tcore_at_tok_new(line);
+ resp_str = g_slist_nth_data(tokens, 0);
+
+ if (!g_slist_nth_data(tokens, 0)) {
+ err("group_id is missing");
+ resp.err = TRUE;
+ goto OUT;
+ }
+
+ if (!g_slist_nth_data(tokens, 1)) {
+ err(" function_id is missing");
+ resp.err = TRUE;
+ goto OUT;
+ }
+
+ resp_str = g_slist_nth_data(tokens, 2);
+
+ if (resp_str) {
+ error = atoi(resp_str);
+ if (0 == error) {
+ dbg("Response is Success");
+ resp.err = FALSE;
+ } else {
+ resp.err = TRUE;
+ }
+ }
+OUT:
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ } else {
+ dbg("RESPONSE NOT OK");
+
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ err("err cause not specified or string corrupted");
+ resp.err = TRUE;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+
+ // TODO: CMEE error mapping is required.
+ resp.err = TRUE;
+ }
+
+ // Free tokens
+ tcore_at_tok_free(tokens);
+ }
+
+ if (ur) {
+ tcore_user_request_send_response(ur, TRESP_CALL_SET_SOUND_MUTE_STATUS, sizeof(struct tresp_call_set_sound_mute_status), &resp);
+ } else {
+ err("User Request is NULL");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+// RESPONSE
+static void on_response_call_list_get(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ TcorePlugin *plugin = NULL;
+ CoreObject *core_obj = NULL;
+ CallObject *co = NULL;
+ struct clcc_call_t *call_list = NULL;
+ gboolean *event_flag = (gboolean *) user_data;
+ const TcoreATResponse *response = data;
+ GSList *resp_data = NULL;
+ char *line = NULL;
+
+ int cllc_info = 0, countCalls = 0, countValidCalls = 0;
+ int error = 0;
+
+ dbg("Entry");
+
+ plugin = tcore_pending_ref_plugin(p);
+ core_obj = tcore_pending_ref_core_object(p);
+
+ if (response->success > 0) {
+ dbg("RESPONCE OK");
+ if (response->lines) {
+ resp_data = (GSList *) response->lines;
+ countCalls = g_slist_length(resp_data);
+ dbg("Total records : %d", countCalls);
+ }
+
+ if (0 == countCalls) {
+ err("Call count is zero");
+ if (event_flag) {
+ g_free(event_flag);
+ event_flag = NULL;
+ }
+ return;
+ }