Initialize Tizen 2.3
[framework/telephony/libslp-tapi.git] / src / tapi_ss.c
1 /*
2  * libslp-tapi
3  *
4  * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Ja-young Gu <jygu@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21
22 #include <stdio.h>
23 #include <string.h>
24 #include <stdlib.h>
25
26 #include "tapi_common.h"
27 #include "TapiUtility.h"
28 #include "TelSs.h"
29
30 #include "common.h"
31 #include "tapi_log.h"
32 #include "ITapiSs.h"
33
34 static void on_response_get_ss_barring_status(GObject *source_object, GAsyncResult *res, gpointer user_data)
35 {
36         GError *error = 0;
37         GDBusConnection *conn = 0;
38         struct tapi_resp_data *evt_cb_data = user_data;
39         int result = -1, i = 0;
40         TelSsBarringResp_t resp;
41
42         GVariant *dbus_result = 0, *value = 0;
43         GVariantIter *iter = 0;
44         GVariantIter *iter_row = 0;
45         const gchar *key = 0;
46
47         memset(&resp, '\0', sizeof(TelSsBarringResp_t));
48
49         conn = G_DBUS_CONNECTION (source_object);
50         dbus_result = g_dbus_connection_call_finish(conn, res, &error);
51         CHECK_ERROR(error);
52
53         g_variant_get (dbus_result, "(aa{sv}i)", &iter, &result);
54
55         resp.record_num = g_variant_iter_n_children(iter);
56
57         if (TAPI_SS_RECORD_NUM_MAX < resp.record_num) {
58                 resp.record_num = TAPI_SS_RECORD_NUM_MAX;
59         }
60
61         while ( g_variant_iter_next(iter, "a{sv}", &iter_row ) && (i < resp.record_num)) {
62                 while ( g_variant_iter_loop( iter_row, "{sv}", &key, &value ) ) {
63
64                         if ( !g_strcmp0(key, "ss_class") ) {
65                                 resp.record[i].Class = g_variant_get_int32(value);
66                         }
67
68                         if ( !g_strcmp0(key, "ss_status") ) {
69                                 resp.record[i].Status = g_variant_get_int32(value);
70                         }
71
72                         if ( !g_strcmp0(key, "barring_mode") ) {
73                                 resp.record[i].Flavour = g_variant_get_int32(value);
74                         }
75
76                 }
77                 i++;
78                 g_variant_iter_free(iter_row);
79         }
80         g_variant_iter_free(iter);
81
82         if (evt_cb_data->cb_fn) {
83                 evt_cb_data->cb_fn(evt_cb_data->handle, result, &resp, evt_cb_data->user_data);
84         }
85
86         g_free(evt_cb_data);
87         g_variant_unref(dbus_result);
88 }
89
90 static void on_response_change_ss_barring_password(GObject *source_object, GAsyncResult *res, gpointer user_data)
91 {
92         GError *error = 0;
93         GDBusConnection *conn = 0;
94         struct tapi_resp_data *evt_cb_data = user_data;
95         int result = -1;
96
97         GVariant *dbus_result = 0;
98
99         conn = G_DBUS_CONNECTION (source_object);
100         dbus_result = g_dbus_connection_call_finish(conn, res, &error);
101         CHECK_ERROR(error);
102
103         g_variant_get (dbus_result, "(i)",  &result);
104
105         if (evt_cb_data->cb_fn) {
106                 evt_cb_data->cb_fn(evt_cb_data->handle, result, NULL, evt_cb_data->user_data);
107         }
108
109         g_free(evt_cb_data);
110         g_variant_unref(dbus_result);
111 }
112
113 static void on_response_get_ss_forward_status(GObject *source_object, GAsyncResult *res, gpointer user_data)
114 {
115         GError *error = 0;
116         GDBusConnection *conn = 0;
117         struct tapi_resp_data *evt_cb_data = user_data;
118         int result = -1, i = 0;
119         TelSsForwardResp_t resp;
120
121         GVariant *dbus_result = 0, *value = 0;
122         GVariantIter *iter = 0;
123         GVariantIter *iter_row = 0;
124         const gchar *key = 0;
125
126
127         memset(&resp, '\0', sizeof(TelSsForwardResp_t));
128
129         conn = G_DBUS_CONNECTION (source_object);
130         dbus_result = g_dbus_connection_call_finish(conn, res, &error);
131         CHECK_ERROR(error);
132
133         g_variant_get (dbus_result, "(aa{sv}i)", &iter, &result);
134
135         resp.record_num = g_variant_iter_n_children(iter);
136
137         if (TAPI_SS_RECORD_NUM_MAX < resp.record_num) {
138                 resp.record_num = TAPI_SS_RECORD_NUM_MAX;
139         }
140
141         while ( g_variant_iter_next(iter, "a{sv}", &iter_row ) && (i < resp.record_num)) {
142                 while ( g_variant_iter_loop( iter_row, "{sv}", &key, &value ) ) {
143
144                         if ( !g_strcmp0(key, "ss_class") ) {
145                                 resp.record[i].Class = g_variant_get_int32(value);
146                         }
147
148                         if ( !g_strcmp0(key, "ss_status") ) {
149                                 resp.record[i].Status = g_variant_get_int32(value);
150                         }
151
152                         if ( !g_strcmp0(key, "forwarding_mode") ) {
153                                 resp.record[i].ForwardCondition = g_variant_get_int32(value);
154                         }
155
156                         if ( !g_strcmp0(key, "number_present") ) {
157                                 resp.record[i].bCallForwardingNumberPresent = g_variant_get_int32(value);
158                         }
159
160                         if ( !g_strcmp0(key, "no_reply_time") ) {
161                                 resp.record[i].NoReplyWaitTime = g_variant_get_int32(value);
162                         }
163
164                         if ( !g_strcmp0(key, "type_of_number") ) {
165                                 resp.record[i].Ton = g_variant_get_int32(value);
166                         }
167
168                         if ( !g_strcmp0(key, "number_plan_identity") ) {
169                                 resp.record[i].Npi = g_variant_get_int32(value);
170                         }
171
172                         if ( !g_strcmp0(key, "forwarding_number") ) {
173                                 strncpy((char *)resp.record[i].szCallForwardingNumber, g_variant_get_string(value, 0), TAPI_CALL_DIALDIGIT_LEN_MAX );
174                         }
175
176                 }
177                 i++;
178                 g_variant_iter_free(iter_row);
179         }
180         g_variant_iter_free(iter);
181
182         if (evt_cb_data->cb_fn) {
183                 evt_cb_data->cb_fn(evt_cb_data->handle, result, &resp, evt_cb_data->user_data);
184         }
185
186         g_free(evt_cb_data);
187         g_variant_unref(dbus_result);
188 }
189
190 static void on_response_get_ss_waiting_status(GObject *source_object, GAsyncResult *res, gpointer user_data)
191 {
192         GError *error = 0;
193         GDBusConnection *conn = 0;
194         struct tapi_resp_data *evt_cb_data = user_data;
195         int result = -1, i = 0;
196         TelSsWaitingResp_t resp;
197
198         GVariant *dbus_result = 0, *value = 0;
199         GVariantIter *iter = 0;
200         GVariantIter *iter_row = 0;
201         const gchar *key = 0;
202
203
204         memset(&resp, '\0', sizeof(TelSsWaitingResp_t));
205
206         conn = G_DBUS_CONNECTION (source_object);
207         dbus_result = g_dbus_connection_call_finish(conn, res, &error);
208         CHECK_ERROR(error);
209
210         g_variant_get (dbus_result, "(aa{sv}i)", &iter, &result);
211
212         resp.record_num = g_variant_iter_n_children(iter);
213
214         if (TAPI_SS_RECORD_NUM_MAX < resp.record_num) {
215                 resp.record_num = TAPI_SS_RECORD_NUM_MAX;
216         }
217
218         while ( g_variant_iter_next(iter, "a{sv}", &iter_row ) && (i < resp.record_num) ) {
219                 while ( g_variant_iter_loop( iter_row, "{sv}", &key, &value ) ) {
220
221                         if ( !g_strcmp0(key, "ss_class") ) {
222                                 resp.record[i].Class = g_variant_get_int32(value);
223                         }
224
225                         if ( !g_strcmp0(key, "ss_status") ) {
226                                 resp.record[i].Status = g_variant_get_int32(value);
227                         }
228                 }
229                 i++;
230                 g_variant_iter_free(iter_row);
231         }
232         g_variant_iter_free(iter);
233
234         if (evt_cb_data->cb_fn) {
235                 evt_cb_data->cb_fn(evt_cb_data->handle, result, &resp, evt_cb_data->user_data);
236         }
237
238         g_free(evt_cb_data);
239         g_variant_unref(dbus_result);
240 }
241
242 static void on_response_set_ss_cli_status(GObject *source_object, GAsyncResult *res, gpointer user_data)
243 {
244         GError *error = 0;
245         GDBusConnection *conn = 0;
246         struct tapi_resp_data *evt_cb_data = user_data;
247         int result = -1;
248         int data = 0;
249
250         GVariant *dbus_result = 0;
251
252         conn = G_DBUS_CONNECTION (source_object);
253         dbus_result = g_dbus_connection_call_finish(conn, res, &error);
254         CHECK_ERROR(error);
255
256         g_variant_get (dbus_result, "(i)",  &result);
257
258         if (evt_cb_data->cb_fn) {
259                 evt_cb_data->cb_fn(evt_cb_data->handle, result, &data, evt_cb_data->user_data);
260         }
261
262         g_free(evt_cb_data);
263         g_variant_unref(dbus_result);
264 }
265
266 static void on_response_get_ss_cli_status(GObject *source_object, GAsyncResult *res, gpointer user_data)
267 {
268         GError *error = 0;
269         GDBusConnection *conn = 0;
270         struct tapi_resp_data *evt_cb_data = user_data;
271         int result = -1;
272         TelSsCliResp_t resp;
273
274         GVariant *dbus_result = 0;
275
276         memset(&resp, '\0', sizeof(TelSsCliResp_t));
277
278         conn = G_DBUS_CONNECTION (source_object);
279         dbus_result = g_dbus_connection_call_finish(conn, res, &error);
280         CHECK_ERROR(error);
281
282         g_variant_get (dbus_result, "(iii)",  &result, &resp.Type, &resp.Status);
283
284         msg("Type(%d), Status(%d)", resp.Type, resp.Status);
285         if (evt_cb_data->cb_fn) {
286                 evt_cb_data->cb_fn(evt_cb_data->handle, result, &resp, evt_cb_data->user_data);
287         }
288
289         g_free(evt_cb_data);
290         g_variant_unref(dbus_result);
291 }
292
293 static void on_response_send_ss_ussd_request(GObject *source_object, GAsyncResult *res, gpointer user_data)
294 {
295         GError *error = 0;
296         GDBusConnection *conn = 0;
297         struct tapi_resp_data *evt_cb_data = user_data;
298         int result = -1;
299         char *tmp_str = 0;
300         TelSsUssdResp_t resp;
301
302         GVariant *dbus_result = 0;
303
304         memset(&resp, '\0', sizeof(TelSsUssdResp_t));
305
306         conn = G_DBUS_CONNECTION (source_object);
307         dbus_result = g_dbus_connection_call_finish(conn, res, &error);
308         CHECK_ERROR(error);
309
310         g_variant_get (dbus_result, "(iiiiis)",  &result, &resp.Type, &resp.Status, &resp.Dcs, &resp.Length, &tmp_str);
311
312         if (!result) {
313                 memcpy( resp.szString, tmp_str, resp.Length );
314                 g_free(tmp_str);
315         }
316
317         if (evt_cb_data->cb_fn) {
318                 evt_cb_data->cb_fn(evt_cb_data->handle, result, &resp, evt_cb_data->user_data);
319         }
320
321         g_free(evt_cb_data);
322         g_variant_unref(dbus_result);
323 }
324
325 EXPORT_API int tel_set_ss_barring(TapiHandle *handle, TelSsBarringInfo_t *info, tapi_response_cb callback, void *user_data)
326 {
327         struct tapi_resp_data *evt_cb_data = 0;
328         GVariant *param = 0;
329         const gchar *method = NULL;
330
331         dbg("Func Entrance ");
332
333         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
334         TAPI_RET_ERR_NUM_IF_FAIL(info, TAPI_API_INVALID_PTR);
335
336         MAKE_RESP_CB_DATA(evt_cb_data, handle, callback, user_data);
337
338         param = g_variant_new("(iis)", info->Class, info->Type, info->szPassword);
339
340         if ( info->Mode == TAPI_SS_CB_MODE_ACTIVATE ) {
341                 msg("[ check ] barring activate");
342                 method = "ActivateBarring";
343
344         } else {
345                 msg("[ check ] barring deactivate");
346                 method = "DeactivateBarring";
347
348         }
349
350         g_dbus_connection_call(handle->dbus_connection,
351                         DBUS_TELEPHONY_SERVICE, handle->path, DBUS_TELEPHONY_SS_INTERFACE,
352                         method, param, 0,
353                         G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca,
354                         on_response_get_ss_barring_status, evt_cb_data );
355
356         return TAPI_API_SUCCESS;
357 }
358
359 EXPORT_API int tel_get_ss_barring_status(TapiHandle *handle, TelSsClass_t class, TelSsBarringType_t type, tapi_response_cb callback, void *user_data)
360 {
361         struct tapi_resp_data *evt_cb_data = 0;
362         GVariant *param = 0;
363
364         dbg("Func Entrance ");
365
366         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
367         TAPI_RET_ERR_NUM_IF_FAIL(callback, TAPI_API_INVALID_PTR);
368
369         MAKE_RESP_CB_DATA(evt_cb_data, handle, callback, user_data);
370
371         param = g_variant_new("(ii)", class, type);
372
373         g_dbus_connection_call(handle->dbus_connection,
374                         DBUS_TELEPHONY_SERVICE, handle->path, DBUS_TELEPHONY_SS_INTERFACE,
375                         "GetBarringStatus", param, 0,
376                         G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca,
377                         on_response_get_ss_barring_status, evt_cb_data );
378
379         return TAPI_API_SUCCESS;
380 }
381
382 /**********************************************************************************************
383  *
384  * This function is used to change call barring password.
385  *
386  * @param       pOldPassword[IN] of type char* Specifies the Old Call Barring Password.
387  * @param       pNewPassword[IN] of type char* Specifies the New Call Barring Password.
388  * @param       pNewPasswordAgain[IN] of type char* Specifies the New Call Barring Password for Confirm.
389  * @return      enum type TapiResult_t Specifies the API's Return result.
390  * @remark
391  *
392  ***********************************************************************************************/
393 EXPORT_API int tel_change_ss_barring_password(TapiHandle *handle,
394                 const char *old_password,
395                 const char *new_password,
396                 const char *new_password_again,
397                 tapi_response_cb callback, void *user_data)
398 {
399         struct tapi_resp_data *evt_cb_data = 0;
400         GVariant *param = 0;
401
402         msg("barring_password change request");
403
404         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
405         TAPI_RET_ERR_NUM_IF_FAIL(old_password, TAPI_API_INVALID_PTR);
406         TAPI_RET_ERR_NUM_IF_FAIL(new_password, TAPI_API_INVALID_PTR);
407         TAPI_RET_ERR_NUM_IF_FAIL(new_password_again, TAPI_API_INVALID_PTR);
408
409         MAKE_RESP_CB_DATA(evt_cb_data, handle, callback, user_data);
410
411         param = g_variant_new("(sss)", old_password, new_password, new_password_again);
412
413         g_dbus_connection_call(handle->dbus_connection,
414                         DBUS_TELEPHONY_SERVICE, handle->path, DBUS_TELEPHONY_SS_INTERFACE,
415                         "ChangeBarringPassword", param, 0,
416                         G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca,
417                         on_response_change_ss_barring_password, evt_cb_data );
418
419         return TAPI_API_SUCCESS;
420 }
421
422 /**********************************************************************************************
423  *
424  * This function is used to Activate or Deactivate the call forwarding feature.
425  *
426  * @param       forwardInfo[IN] of type TelSsForwardInfo_t which specifies the Teleservice and CF flavour, Forwarded to number.
427  * @return      enum type TapiResult_t Specifies the API's Return result.
428  * @remark
429  *
430  ***********************************************************************************************/
431 EXPORT_API int tel_set_ss_forward(TapiHandle *handle, const TelSsForwardInfo_t *info, tapi_response_cb callback, void *user_data)
432 {
433         struct tapi_resp_data *evt_cb_data = 0;
434         GVariant *param = 0;
435         const gchar *method = 0;
436
437         dbg("Func Entrance ");
438
439         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
440         TAPI_RET_ERR_NUM_IF_FAIL(info, TAPI_API_INVALID_PTR);
441
442         MAKE_RESP_CB_DATA(evt_cb_data, handle, callback, user_data);
443
444         param = g_variant_new("(iiiiis)", info->Class, info->Condition,
445                         info->NoReplyConditionTimer, info->Ton, info->Npi, info->szPhoneNumber);
446
447         switch ( info->Mode ) {
448                 case TAPI_SS_CF_MODE_DISABLE_EV: {
449                         msg("[ check ] forwarding deactivate");
450                         method = "DeactivateForwarding";
451                 } break;
452
453                 case TAPI_SS_CF_MODE_ENABLE_EV: {
454                         msg("[ check ] forwarding activate");
455                         method = "ActivateForwarding";
456                 } break;
457
458                 case TAPI_SS_CF_MODE_REGISTRATION_EV: {
459                         msg("[ check ] forwarding registration");
460                         method = "RegisterForwarding";
461                 } break;
462
463                 case TAPI_SS_CF_MODE_ERASURE_EV: {
464                         msg("[ check ] forwarding deregistration");
465                         method = "DeregisterForwarding";
466                 } break;
467
468                 default:
469                         err("[ error ] invalid input : (0x%x)", info->Mode);
470                         return TAPI_API_INVALID_INPUT;
471         }
472
473         g_dbus_connection_call(handle->dbus_connection,
474                         DBUS_TELEPHONY_SERVICE, handle->path, DBUS_TELEPHONY_SS_INTERFACE,
475                         method, param, 0,
476                         G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca,
477                         on_response_get_ss_forward_status, evt_cb_data );
478
479         return TAPI_API_SUCCESS;
480 }
481
482 /**********************************************************************************************
483  *
484  * This function is used to interrogate the status of call forwarding feature.
485  *
486  * @param       forwardType[IN] of type TelSsForwardType_t which specifies the telecommunication service.
487  * @param       condition[IN]   is of type TelSsForwardWhen_t specified the CF flavour
488  * @return      enum type TapiResult_t Specifies the API's Return result.
489  * @remark
490  *
491  ***********************************************************************************************/
492 EXPORT_API int tel_get_ss_forward_status(TapiHandle *handle, TelSsClass_t class, TelSsForwardWhen_t condition, tapi_response_cb callback, void *user_data)
493 {
494         struct tapi_resp_data *evt_cb_data = 0;
495         GVariant *param = 0;
496
497         dbg("Func Entrance ");
498
499         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
500         TAPI_RET_ERR_NUM_IF_FAIL(callback, TAPI_API_INVALID_PTR);
501
502         MAKE_RESP_CB_DATA(evt_cb_data, handle, callback, user_data);
503
504         param = g_variant_new("(ii)", class, condition);
505
506         g_dbus_connection_call(handle->dbus_connection,
507                         DBUS_TELEPHONY_SERVICE, handle->path, DBUS_TELEPHONY_SS_INTERFACE,
508                         "GetForwardingStatus", param, 0,
509                         G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca,
510                         on_response_get_ss_forward_status, evt_cb_data );
511
512         return TAPI_API_SUCCESS;
513 }
514
515 /**********************************************************************************************
516  *
517  * This function is used to Activate or dectivate call waiting feature.
518  *
519  * @param       waitInfo[IN] of type TelSsWaitingInfo_t which specifies the telecommunication service and mode.
520  * @return      enum type TapiResult_t Specifies the API's Return result.
521  * @remark
522  *
523  ***********************************************************************************************/
524 EXPORT_API int tel_set_ss_waiting(TapiHandle *handle, const TelSsWaitingInfo_t *info, tapi_response_cb callback, void *user_data)
525 {
526         struct tapi_resp_data *evt_cb_data = 0;
527         GVariant *param = 0;
528         const gchar *method = 0;
529
530         dbg("Func Entrance ");
531
532         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
533         TAPI_RET_ERR_NUM_IF_FAIL(info, TAPI_API_INVALID_PTR);
534
535         MAKE_RESP_CB_DATA(evt_cb_data, handle, callback, user_data);
536
537         param = g_variant_new("(i)", info->Class);
538
539         if ( info->Mode == TAPI_SS_CW_MODE_ACTIVATE ) {
540                 msg("[ check ] waiting activate");
541                 method = "ActivateWaiting";
542         } else {
543                 msg("[ check ] waiting deactivate");
544                 method = "DeactivateWaiting";
545         }
546
547         g_dbus_connection_call(handle->dbus_connection,
548                         DBUS_TELEPHONY_SERVICE, handle->path, DBUS_TELEPHONY_SS_INTERFACE,
549                         method, param, 0,
550                         G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca,
551                         on_response_get_ss_waiting_status, evt_cb_data );
552
553         return TAPI_API_SUCCESS;
554 }
555
556 /**********************************************************************************************
557  *
558  * This function is used to interrogate the status of call waiting feature.
559  *
560  * @param       CallType[IN] of type TelSsCallType_t which specifies the telecommunication service .
561  * @return      enum type TapiResult_t Specifies the API's Return result.
562  * @remark
563  *
564  ***********************************************************************************************/
565
566 EXPORT_API int tel_get_ss_waiting_status(TapiHandle *handle, const TelSsClass_t class, tapi_response_cb callback, void *user_data)
567 {
568         struct tapi_resp_data *evt_cb_data = 0;
569         GVariant *param = 0;
570
571         dbg("Func Entrance ");
572
573         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
574         TAPI_RET_ERR_NUM_IF_FAIL(callback, TAPI_API_INVALID_PTR);
575
576         MAKE_RESP_CB_DATA(evt_cb_data, handle, callback, user_data);
577
578         param = g_variant_new("(i)", class);
579
580         g_dbus_connection_call(handle->dbus_connection,
581                         DBUS_TELEPHONY_SERVICE, handle->path, DBUS_TELEPHONY_SS_INTERFACE,
582                         "GetWaitingStatus", param, 0,
583                         G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca,
584                         on_response_get_ss_waiting_status, evt_cb_data );
585
586         return TAPI_API_SUCCESS;
587 }
588
589 /**********************************************************************************************
590  *
591  * This function is used to set the status of CLI services feature.
592  *
593  * @param       CliType[IN] of type TelSsCliType_t which specifies the CLI service .
594  * @return      enum type TapiResult_t Specifies the API's Return result.
595  * @remark
596  *
597  ***********************************************************************************************/
598 EXPORT_API int tel_set_ss_cli_status(TapiHandle *handle, TelSsCliType_t type, TelSsCliStatus_t status, tapi_response_cb callback, void *user_data)
599 {
600         struct tapi_resp_data *evt_cb_data = 0;
601         GVariant *param = 0;
602
603         msg("set cli type:[%d] status:[%d]", type, status);
604
605         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
606         TAPI_RET_ERR_NUM_IF_FAIL(callback, TAPI_API_INVALID_PTR);
607
608         MAKE_RESP_CB_DATA(evt_cb_data, handle, callback, user_data);
609
610         param = g_variant_new("(ii)", type, status);
611
612         g_dbus_connection_call(handle->dbus_connection,
613                         DBUS_TELEPHONY_SERVICE, handle->path, DBUS_TELEPHONY_SS_INTERFACE,
614                         "SetCLIStatus", param, 0,
615                         G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca,
616                         on_response_set_ss_cli_status, evt_cb_data );
617
618         return TAPI_API_SUCCESS;
619 }
620
621 /**********************************************************************************************
622  *
623  * This function is used to interrogate the status of CLI services feature.
624  *
625  * @param       CliType[IN] of type TelSsCliType_t which specifies the CLI service .
626  * @return      enum type TapiResult_t Specifies the API's Return result.
627  * @remark
628  *
629  ***********************************************************************************************/
630 EXPORT_API int tel_get_ss_cli_status(TapiHandle *handle, TelSsCliType_t type, tapi_response_cb callback, void *user_data)
631 {
632         struct tapi_resp_data *evt_cb_data = 0;
633         GVariant *param = 0;
634
635         dbg("Func Entrance ");
636
637         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
638         TAPI_RET_ERR_NUM_IF_FAIL(callback, TAPI_API_INVALID_PTR);
639
640         MAKE_RESP_CB_DATA(evt_cb_data, handle, callback, user_data);
641
642         param = g_variant_new("(i)", type);
643
644         g_dbus_connection_call(handle->dbus_connection,
645                         DBUS_TELEPHONY_SERVICE, handle->path, DBUS_TELEPHONY_SS_INTERFACE,
646                         "GetCLIStatus", param, 0,
647                         G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca,
648                         on_response_get_ss_cli_status, evt_cb_data );
649
650         return TAPI_API_SUCCESS;
651 }
652
653 /**********************************************************************************************
654  *
655  * This function is used to send a USSD string and also the User response for a NW intiated USSD.
656  *
657  * @param       pAppMsg[IN] of type TelSsUssdMsgInfo_t which specifies the USSD String,length of the string, format of the string.
658  * @return      enum type TapiResult_t Specifies the API's Return result.
659  * @remark      TelSsUssdMsgInfo_t ->IndType is not used while calling this function, This is used for sending the response.
660  *                      Limo standard defines only one structure for Request and response.
661  *
662  ***********************************************************************************************/
663 EXPORT_API int tel_send_ss_ussd_request(TapiHandle *handle, const TelSsUssdMsgInfo_t *info, tapi_response_cb callback, void *user_data)
664 {
665         struct tapi_resp_data *evt_cb_data = 0;
666         GVariant *param = 0;
667
668         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
669         TAPI_RET_ERR_NUM_IF_FAIL(info, TAPI_API_INVALID_PTR);
670
671         MAKE_RESP_CB_DATA(evt_cb_data, handle, callback, user_data);
672
673         param = g_variant_new("(iiis)", info->Type, info->Dcs, info->Length, info->szString);
674         msg("ussd type:[%d] length:[%d]", info->Type, info->Length);
675         g_dbus_connection_call(handle->dbus_connection,
676                         DBUS_TELEPHONY_SERVICE, handle->path, DBUS_TELEPHONY_SS_INTERFACE,
677                         "SendUSSD", param, 0,
678                         G_DBUS_CALL_FLAGS_NONE, G_MAXINT, handle->ca,
679                         on_response_send_ss_ussd_request, evt_cb_data );
680
681         return TAPI_API_SUCCESS;
682 }