upload tizen1.0 source
[framework/telephony/tel-plugin-socket_communicator.git] / test / gprs.c
1 /*
2  * tel-plugin-socket-communicator
3  *
4  * Copyright (c) 2012 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 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <sys/time.h>
25 #include <unistd.h>
26 #include <glib.h>
27 #include <glib-object.h>
28
29 #include <tapi_sipc.h>
30
31 #include "menu.h"
32 #include "noti.h"
33
34 static char data_gprs_dun_signal[MENU_DATA_SIZE + 1] = "dtr";
35 static char data_gprs_dun_status[MENU_DATA_SIZE + 1] = "off";
36
37
38
39 gboolean on_noti_ps_dun_pin_control(tapi_service_object_t *data, void *user_data)
40 {
41         gchar *str_signal;
42         gboolean status;
43
44         msg("TAPI_NOTI_PS_DUN_PIN_CONTROL receive !!");
45
46         str_signal = tapi_service_object_get_string(data, "signal");
47         status = tapi_service_object_get_boolean(data, "status");
48
49         msg("signal = %s", str_signal);
50         msg("status = %d", status);
51         return TRUE;
52 }
53
54
55 gboolean on_noti_ps_external_call(tapi_service_object_t *data, void *user_data)
56 {
57         msg("TAPI_NOTI_PS_EXTERNAL_CALL receive !!");
58
59         /* no data */
60
61         return TRUE;
62 }
63
64 static gboolean on_gprs_dun_callback(tapi_service_object_t *data, void *cb_data)
65 {
66         int result;
67
68         msg("TAPI_SERVICE_PS_SET_DUN_PIN_CONTROL response receive");
69         result = tapi_service_object_get_int(data, "result");
70
71         msg("result = %d (0 = success)", result);
72
73         return TRUE;
74 }
75
76 static int run_gprs_dun(MManager *mm, struct menu_data *menu)
77 {
78         tapi_handle_t *handle = menu_manager_ref_user_data(mm);
79         tapi_service_object_t *in = NULL;
80         gboolean in_status = FALSE;
81
82         if (!g_strcmp0(data_gprs_dun_status, "on")) {
83                 in_status = TRUE;
84         }
85         else if (!g_strcmp0(data_gprs_dun_status, "off")) {
86                 in_status = FALSE;
87         }
88         else {
89                 msg("wrong value in STATUS");
90                 return -1;
91         }
92
93         msg("SIGNAL = %s", data_gprs_dun_signal);
94         msg("STATUS = %s (convert to boolean = %d)", data_gprs_dun_status, in_status);
95         msg("call [%s] tapi service !!!", menu->title);
96
97         in = tapi_create_service_object(TAPI_SERVICE_PS_SET_DUN_PIN_CONTROL);
98         tapi_service_object_add_data(in, "signal", data_gprs_dun_signal, TAPI_OBJECT_DATA_TYPE_STRING);
99         tapi_service_object_add_data(in, "status", &in_status, TAPI_OBJECT_DATA_TYPE_BOOLEAN);
100
101         tel_processing_command_async(handle, in, on_gprs_dun_callback, NULL);
102
103         return 0;
104 }
105
106 struct menu_data menu_gprs_dun[] = {
107         { "1", "SIGNAL (dcd / dtr / dsr / rts / cts / ri)", NULL, NULL, data_gprs_dun_signal},
108         { "2", "STATUS (on / off)", NULL, NULL, data_gprs_dun_status},
109         { "3", "run", NULL, run_gprs_dun, NULL},
110         { NULL, NULL, },
111 };
112
113 struct menu_data menu_gprs[] = {
114         { "1", "DUN Pin Control", menu_gprs_dun, NULL, NULL},
115         { NULL, NULL, },
116 };
117