block the incoming calls when the incoming call barring set.
[platform/adaptation/emulator/vmodem-daemon-emulator.git] / vmodem / at / at_tx_call.c
1 /*
2  *  telephony-emulator
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: 
7  * Sooyoung Ha <yoosah.ha@samsung.com>
8  * Sungmin Ha <sungmin82.ha@samsung.com>
9  * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
10  * 
11  * This library is free software; you can redistribute it and/or modify it under
12  * the terms of the GNU Lesser General Public License as published by the
13  * Free Software Foundation; either version 2.1 of the License, or (at your option)
14  * any later version.
15  * 
16  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
17  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19  * License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with this library; if not, write to the Free Software Foundation, Inc., 51
23  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24  *
25  * Contributors:
26  * - S-Core Co., Ltd
27  * 
28  */
29
30 /*  at_tx_call.c */
31
32 #include "at_send.h"
33 #include "at_gen_resp.h"
34 #include "at_tx_call.h"
35 #include "at_func.h"
36 #include "server_tx_call.h"
37 #include "db_ss.h"
38 #include "flight.h"
39 #include <vconf/vconf.h>
40 #include <vconf/vconf-keys.h>
41
42 int at_tx_call_incoming_noti(void *data, int len)
43 {
44         TRACE(MSGL_VGSM_INFO, "RING noti\n");
45
46         /* add block 130321 : flight mode on, rssi zero, call barring set */
47         bool flightMode = false;
48         bool icb = false; // incomming call barring
49         int i = 0;
50         int rssi = 5;
51         call_barring_entry_t * resp_entry  = get_call_barring_entry();
52         
53         flightMode = is_flight_mode();
54
55         if(!resp_entry)
56                 TRACE(MSGL_VGSM_INFO, "entry is NULL!!!\n");
57         else {
58                 for(i=0; i<resp_entry[0].count; i++) {
59                         TRACE(MSGL_VGSM_INFO,"i : %d,  type : %d\n", i, resp_entry[i].type);
60                         if(resp_entry[i].type == 4 && resp_entry[i].ss_mode == 3) { // 'All incoming calls' has set
61                                 icb = true;
62                         }
63                 }
64         }
65
66         if(vconf_get_int(VCONFKEY_TELEPHONY_RSSI, &rssi)) {
67                 TRACE(MSGL_WARN, "vconf_get_int(%s) fail\n", VCONFKEY_TELEPHONY_RSSI);
68         }
69
70         if(rssi != 0 && icb == false && flightMode == false) {
71                 TRACE(MSGL_VGSM_INFO, "call OK, %d, %d, %d \n", rssi, icb, flightMode);
72                 char sndbuf[SEND_BUF_SIZE];
73                 memset(sndbuf, '\0', sizeof(sndbuf));
74
75                 sprintf(sndbuf, "%s%s", RING, CRLF);    
76                 at_msg_send(ACK_SEQ_NOTIFICATION, sndbuf, strlen(sndbuf));
77                 return at_tx_call_status_noti(data, strlen((char*)data));
78         } else {
79                 TRACE(MSGL_VGSM_INFO, "cannot RING a call, %d, %d, %d \n", rssi, icb, flightMode); 
80                 return -1;
81         }
82
83 }
84
85 int at_tx_call_connect_noti(void *data, int len)
86 {
87         TRACE(MSGL_VGSM_INFO, "CONNECT noti\n");
88         return server_tx_call_list_noti();
89 }
90
91 int at_tx_call_waiting_noti(void *data, int len)
92 {
93         TRACE(MSGL_VGSM_INFO, "+CCWA noti\n");
94         char sndbuf[SEND_BUF_SIZE];
95         memset(sndbuf, '\0', sizeof(sndbuf));
96
97         sprintf(sndbuf, "%s%s%s", CCWA, (char*)data, CRLF);
98         return at_msg_send(ACK_SEQ_NOTIFICATION, sndbuf, strlen(sndbuf));
99 }
100
101 int at_tx_call_list_noti(void *data, int len)
102 {
103         TRACE(MSGL_VGSM_INFO, "+CLCC noti\n");
104         return at_msg_send(ACK_SEQ_NOTIFICATION, data, len);
105 }
106
107 int at_tx_call_list_resp(void *data, int len)
108 {
109         TRACE(MSGL_VGSM_INFO, "+CLCC resp\n");
110         return at_msg_send(ACK_SEQ_RESPONSE, data, len);
111 }
112
113 int at_tx_call_status_noti(void *data, int len)
114 {
115         TRACE(MSGL_VGSM_INFO, "%%SCLCC noti\n");
116         char sndbuf[SEND_BUF_SIZE];
117         memset(sndbuf, '\0', sizeof(sndbuf));
118
119         sprintf(sndbuf, "%s%s%s", SCLCC, (char*)data, CRLF);
120         TRACE(MSGL_VGSM_INFO, "%s", sndbuf);
121         return at_msg_send(ACK_SEQ_NOTIFICATION, sndbuf, strlen(sndbuf));
122 }
123
124 int at_tx_call_burst_dtmf_noti(void *data, int len)
125 {
126         TRACE(MSGL_VGSM_INFO, "noti\n");
127         return 0;
128 //      return at_msg_send(ACK_SEQ_NOTIFICATION, data, len);
129 }
130
131 int at_tx_call_line_id_resp(void *data, int len)
132 {
133         TRACE(MSGL_VGSM_INFO, "resp\n");
134         return 0;
135 //      return at_msg_send(ACK_SEQ_RESPONSE, data, len);
136 }
137
138 int at_tx_call_gen_resp(char* resp)
139 {
140         TRACE(MSGL_VGSM_INFO, "call gen resp\n");
141         return at_gen_resp_send(resp);
142 }
143