[Feature][R306BR][task-view-1592][voice] add call time dial time call hold call lock hotline

Change-Id: Iface4e5341d6a6496d42187ba7dc77e311e9575e
diff --git a/lynq/R306BR/ap/app/ccapp/cc_proc.c b/lynq/R306BR/ap/app/ccapp/cc_proc.c
index 1bb29a3..4418a7b 100755
--- a/lynq/R306BR/ap/app/ccapp/cc_proc.c
+++ b/lynq/R306BR/ap/app/ccapp/cc_proc.c
@@ -572,7 +572,11 @@
 {

     UINT8   callCnt = 0, slave = 0;

     SINT32  chldret = -1;

+    char voice_dial_time[4] = {0};

+    unsigned int dtmf_interval;

 

+    cfg_get_item("voice_dial_time", voice_dial_time, sizeof(voice_dial_time));

+    dtmf_interval = atoi(voice_dial_time) * 1000;

     ccapp_log("ret=%d", ret);

 

     slave = zCc_GetSpecSlave(ZCC_S_DACCM_S);

@@ -581,7 +585,7 @@
         case ZCC_NO_RESULT:

             CreateSoftTimer(ZCCAPP_TIMER_DTMF_DETECT,

                         0,

-                        ZCCAPP_TIMER_DTMF_INTERVAL,

+                        dtmf_interval,

                         zCcApp_DtmfTimer,

                         NULL);                    

             zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s  zCc_DigitsMatchRltProc CreateSoftTimer zCcApp_DtmfTimer\n",__FUNCTION__);

@@ -2186,6 +2190,7 @@
     SINT32  chldret = -1;

     UINT8 tmpslave = 0;

     CHAR voip_status[ZDIAL_NUM_MAX] = {0};

+    char hotline_time[4] = {0};

 

     printf("[ccapp_debug]: Seize State Recv MsgCmd: %d,localtest=%d\n",ptMsgBuf->usMsgCmd,local_test_call_st);

 

@@ -2591,14 +2596,15 @@
         {

             if(g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_DT_S)

             {

+                cfg_get_item("hotline_time", hotline_time, sizeof(hotline_time));

             	g_Cc_CallDetail.slaveObj[slave].idle_second++;            	

-				if(g_Cc_CallDetail.slaveObj[slave].idle_second >= 5000/ZCCAPP_TIMER_HOOKOFF_IDLE_INTERVAL)

+				if(g_Cc_CallDetail.slaveObj[slave].idle_second >= atoi(hotline_time) * 2)

 				{

 					int rt;

 					char hotline[ZDIAL_NUM_MAX-1];

 					

 					memset(hotline, 0, sizeof(hotline));

-					rt = cfg_get_item("dialog_hotline_str", hotline, sizeof(hotline)-1);

+					rt = cfg_get_item("hotline_number", hotline, sizeof(hotline)-1);

 					if(rt!=0 || strlen(hotline)<=0)

 					{

 						DeleteSoftTimer(ZCCAPP_TIMER_HOOKOFF_IDLE);

diff --git a/lynq/R306BR/ap/app/goahead/interface5.0/zte_web_voice.c b/lynq/R306BR/ap/app/goahead/interface5.0/zte_web_voice.c
index 272ad2b..90da7f3 100755
--- a/lynq/R306BR/ap/app/goahead/interface5.0/zte_web_voice.c
+++ b/lynq/R306BR/ap/app/goahead/interface5.0/zte_web_voice.c
@@ -28,20 +28,12 @@
     {

         cfg_set("calling_time_duration", calling_limit_times);

     }

-    else

-    {

-

-    }

     

     cfg_set("called_time_enable", called_limit_enable);

     if (0 == strcmp(called_limit_enable, "1"))

     {

         cfg_set("called_time_duration", called_limit_times);

     }

-    else

-    {

-

-    }

 

     zte_write_result_to_web(wp, SUCCESS);

     return;

@@ -57,11 +49,11 @@
 

     if(0 == strcmp(call_hold_enable, "1"))

     {

-

+        system("at AT+CHLD=2");

     }

     else

     {

-

+        system("at AT+CHLD=0");

     }

 

     zte_write_result_to_web(wp, SUCCESS);

@@ -89,7 +81,7 @@
     }

     else

     {

-

+        cfg_set("hotline_number", "");

     }

 

     zte_write_result_to_web(wp, SUCCESS);

diff --git a/lynq/R306BR/ap/app/zte_comm/at_ctl/src/atctrl/at_rcvmsg.c b/lynq/R306BR/ap/app/zte_comm/at_ctl/src/atctrl/at_rcvmsg.c
index ca777cf..be66ef3 100755
--- a/lynq/R306BR/ap/app/zte_comm/at_ctl/src/atctrl/at_rcvmsg.c
+++ b/lynq/R306BR/ap/app/zte_comm/at_ctl/src/atctrl/at_rcvmsg.c
@@ -899,6 +899,146 @@
 

 }

 

+void* calling_timeout_proc(VOID *arg)

+{

+	ipc_send_message(MODULE_ID_CALL_CTRL_LOCAL, MODULE_ID_AT_CTL, MSG_CMD_CHUP_REQ, 0, NULL, 0);

+	return NULL;

+}

+

+void* called_timeout_proc(VOID *arg)

+{

+	ipc_send_message(MODULE_ID_CALL_CTRL_LOCAL, MODULE_ID_AT_CTL, MSG_CMD_CHUP_REQ, 0, NULL, 0);

+	return NULL;

+}

+

+static void at_dsci_call_time_proc(char *at_str)

+{

+	char calling_time_enable[4] = {0};

+	char called_time_enable[4] = {0};

+	char calling_time_duration[4] = {0};

+	char called_time_duration[4] = {0};

+	int calling_duration = 0;

+	int called_duration = 0;

+	

+	cfg_get_item("calling_time_enable", calling_time_enable, sizeof(calling_time_enable));

+	cfg_get_item("called_time_enable", called_time_enable, sizeof(called_time_enable));

+

+	if(strstr(at_str, ",0,0,0,0,") && 0 == strncmp(calling_time_enable, "1", 1))

+	{

+		DeleteSoftTimer(AtWaitRspTimeID);

+		cfg_get_item("calling_time_duration", calling_time_duration, sizeof(calling_time_duration));

+		calling_duration = atoi(calling_time_duration) * 1000 * 60;

+

+		CreateSoftTimer(AtWaitRspTimeID,

+					TIMER_FLAG_ONCE,

+					calling_duration,

+					calling_timeout_proc,

+					NULL);

+	}

+	

+	if(strstr(at_str, ",1,0,0,0,") && 0 == strncmp(called_time_enable, "1", 1))

+	{

+		DeleteSoftTimer(AtWaitRspTimeID);

+		cfg_get_item("called_time_duration", called_time_duration, sizeof(called_time_duration));

+		called_duration = atoi(called_time_duration) * 1000 * 60;

+

+		CreateSoftTimer(AtWaitRspTimeID,

+					TIMER_FLAG_ONCE,

+					called_duration,

+					called_timeout_proc,

+					NULL);

+	}

+

+	return;

+}

+

+static void extract_phone_number(const char *at_str, char *phoneNumArray, int arraySize) {

+    const char *start = strchr(at_str, '"');

+    if (start == NULL) {

+        phoneNumArray[0] = '\0';

+        return;

+    }

+    start++;

+

+    const char *end = strchr(start, '"');

+    if (end == NULL) {

+        phoneNumArray[0] = '\0';

+        return;

+    }

+

+    int phoneLength = end - start;

+    if (phoneLength >= arraySize) {

+        phoneNumArray[0] = '\0';

+        return;

+    }

+

+    strncpy(phoneNumArray, start, phoneLength);

+    phoneNumArray[phoneLength] = '\0';

+}

+

+static void at_dsci_call_block_proc(char *at_str)

+{

+	char local_call_block_enable[4] = {0};

+	char ddd_call_block_enable[4] = {0};

+	char ddi_call_block_enable[4] = {0};

+	char received_call_block_enable[4] = {0};

+	char phone_number[20] = {0};

+

+	cfg_get_item("local_call_block_enable", local_call_block_enable, sizeof(local_call_block_enable));

+	cfg_get_item("ddd_call_block_enable", ddd_call_block_enable, sizeof(ddd_call_block_enable));

+	cfg_get_item("ddi_call_block_enable", ddi_call_block_enable, sizeof(ddi_call_block_enable));

+	cfg_get_item("received_call_block_enable", received_call_block_enable, sizeof(received_call_block_enable));

+	extract_phone_number(at_str, phone_number, sizeof(phone_number));

+	at_print(AT_ERR, "phone_number = %s\n", phone_number);

+

+	if(strstr(at_str, ",0,2,0,0,") && 0 == strncmp(local_call_block_enable, "1", 1))

+	{

+		if(phone_number[0] >= '1' && phone_number[0] <= '9')

+		{

+			ipc_send_message(MODULE_ID_CALL_CTRL_LOCAL, MODULE_ID_AT_CTL, MSG_CMD_CHUP_REQ, 0, NULL, 0);

+		}

+	}

+

+	if(strstr(at_str, ",0,2,0,0,") && 0 == strncmp(ddd_call_block_enable, "1", 1))

+	{

+		if(phone_number[0] == '0')

+		{

+			ipc_send_message(MODULE_ID_CALL_CTRL_LOCAL, MODULE_ID_AT_CTL, MSG_CMD_CHUP_REQ, 0, NULL, 0);

+		}

+	}

+

+	if(strstr(at_str, ",0,2,0,0,") && 0 == strncmp(ddi_call_block_enable, "1", 1))

+	{

+		if(phone_number[0] == '0' && phone_number[1] == '0')

+		{

+			ipc_send_message(MODULE_ID_CALL_CTRL_LOCAL, MODULE_ID_AT_CTL, MSG_CMD_CHUP_REQ, 0, NULL, 0);

+		}

+	}

+

+	if(strstr(at_str, ",1,4,0,0,") && 0 == strncmp(received_call_block_enable, "1", 1))

+	{

+		ipc_send_message(MODULE_ID_CALL_CTRL_LOCAL, MODULE_ID_AT_CTL, MSG_CMD_CHUP_REQ, 0, NULL, 0);

+	}

+

+	return;

+}

+

+static void at_dsci_inform_proc(char* at_str)

+{

+	at_print(AT_ERR,"at_dsci_inform_proc at_str = %s\n", at_str);

+

+	if(strstr(at_str, ",0,0,0,0,") || strstr(at_str, ",1,0,0,0,"))

+	{

+		at_dsci_call_time_proc(at_str);

+	}

+	

+	if(strstr(at_str, ",0,2,0,0,") || strstr(at_str, ",1,4,0,0,"))

+	{

+		at_dsci_call_block_proc(at_str);

+	}

+

+	return;

+}

 

 /* ֪ͨÀàATÃüÁî´¦Àí*/

 static int rcv_at_inform_handle(int at_fd, char *at_str, void *at_cmd_prefix, int prefix_len, void * at_cmd_paras, int paras_len)

@@ -963,6 +1103,11 @@
     {

     	at_print(AT_ERR,"receive auto report str = %s, fd = %d, g_auto_fd = %d, position = %d\n", at_str, at_fd, g_auto_fd, position);

 

+		if(strstr(at_str, "^DSCI:"))

+		{

+			at_dsci_inform_proc(at_str);

+		}

+

 		list_for_each_entry(entry,&g_inform_list,list)

 		{

 		   if((0 == at_strncmp(entry->at_cmd_prefix,(char*)at_cmd_prefix, MAXSTR(entry->at_cmd_prefix,prefix_len))) && entry->inform_act)

diff --git a/lynq/R306BR/ap/app/zte_webui/js/voice.js b/lynq/R306BR/ap/app/zte_webui/js/voice.js
index a59cc65..42012d0 100755
--- a/lynq/R306BR/ap/app/zte_webui/js/voice.js
+++ b/lynq/R306BR/ap/app/zte_webui/js/voice.js
@@ -148,7 +148,7 @@
 			}

 		}

 

-        sf_produceArray(1, 10, sc_startpSeconds);

+        sf_produceArray(4, 10, sc_startpSeconds);

         sf_produceArray(1, 10, sc_startpTimes);

 

         function HotlineVM() {

diff --git a/lynq/R306BR/ap/app/zte_webui/subpg/voice_hotline.html b/lynq/R306BR/ap/app/zte_webui/subpg/voice_hotline.html
index e68e8de..e0e0fd4 100755
--- a/lynq/R306BR/ap/app/zte_webui/subpg/voice_hotline.html
+++ b/lynq/R306BR/ap/app/zte_webui/subpg/voice_hotline.html
@@ -59,12 +59,12 @@
                         </div>

                     </div>

 

-                    <div data-bind='visible: hotlineSetting() == "1"' class="row form-group">

+                    <!-- <div data-bind='visible: hotlineSetting() == "1"' class="row form-group">

                         <label data-trans='attempts_number' for="hotline_attempts_select" class="col-xs-4 side-right"></label>

                         <div class="col-xs-4">

                             <select id="hotline_attempts_select" data-bind="options: scr_times, value: hotlineAttemptsNumber, optionsText: 'text', optionsValue: 'value'" class="form-control"></select>

                         </div>

-                    </div>

+                    </div> -->

 

                     <div data-bind='visible: hotlineSetting() == "1"' class="row form-group">

                         <label data-trans='phone_number' for="hotline_number_input" class="col-xs-4 side-right"></label>